--- /dev/null
+#!/bin/sh
+
+NAME="jshop-core"
+LIST=`find ../*/lib/${NAME}.jar`
+LIST="${LIST} `find ../*/*-ejb/lib/${NAME}.jar`"
+
+for entry in ${LIST};
+do
+ cp -v dist/${NAME}.jar ${entry}
+done
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop;
-
-import org.mxchange.jcore.BaseFrameworkSystem;
-import org.mxchange.jshop.model.product.Product;
-
-/**
- * A general shop class
- *
- * @author Roland Haeder
- */
-public class BaseShopCore extends BaseFrameworkSystem implements ShopInterface {
- /**
- * Item instance
- */
- private Product product;
-
- /**
- * @return the product
- */
- @Override
- public Product getProduct () {
- return this.product;
- }
-
- /**
- * @param product the product to set
- */
- @Override
- public void setProduct (final Product product) {
- this.product = product;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop;
-
-import org.mxchange.jcore.FrameworkInterface;
-import org.mxchange.jshop.model.product.Product;
-
-/**
- * A general shop interface
- *
- * @author Roland Haeder
- */
-public interface ShopInterface extends FrameworkInterface {
- /**
- * @return the product
- */
- public Product getProduct ();
-
- /**
- * @param product the product to set
- */
- public void setProduct (final Product product);
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jshop.model.category.Category;
-
-/**
- * An exception thrown when the given title is already used
- *
- * @author Roland Haeder
- */
-public class CategoryTitleAlreadyUsedException extends Exception {
- /**
- * Serial number
- */
- private static final long serialVersionUID = 53751434673262L;
-
- /**
- * Constructor with HttpServletRequest instance
- *
- * @param category Category instance
- */
- public CategoryTitleAlreadyUsedException (final Category category) {
- // Call super constructor
- super(MessageFormat.format("Title {0} is already used.", category.getTitle())); //NOI18N
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jshop.model.product.Product;
-
-/**
- * An exception thrown when the given title is already used
- *
- * @author Roland Haeder
- */
-public class ProductTitleAlreadyUsedException extends Exception {
- /**
- * Serial number
- */
- private static final long serialVersionUID = 4252734834174L;
-
- /**
- * Constructor with HttpServletRequest instance
- *
- * @param product Product instance
- */
- public ProductTitleAlreadyUsedException (final Product product) {
- // Call super constructor
- super(MessageFormat.format("Title {0} is already used.", product.getTitle())); //NOI18N
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.basket;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-import java.text.MessageFormat;
-import java.util.Map;
-import org.mxchange.jshop.BaseShopCore;
-import org.mxchange.jshop.model.item.AddableBasketItem;
-
-/**
- * A general basket class
- *
- * @author Roland Haeder
- * @param <T> Any instance that implements AddableBasketItem
- */
-public class BaseBasket<T extends AddableBasketItem> extends BaseShopCore implements Basket<T>, Serializable {
- /**
- * Serial number
- */
- private static final long serialVersionUID = 784396762230845717L;
-
- /**
- * Protected constructor with session instance
- *
- * @throws java.sql.SQLException If an SQL error occurs
- */
- protected BaseBasket () throws SQLException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
- }
-
- @Override
- public void init () throws SQLException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Is the bundle initialized?
- if (!BaseShopCore.isBundledInitialized()) {
- // Temporary initialize default bundle
- // TODO The enum Gender uses this
- this.initBundle();
- }
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- // Trace call
- this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
-
- // item must not be null
- if (null == item) {
- // Then abort here
- throw new NullPointerException("item is null"); //NOI18N
- } else if (this.isAdded(item)) {
- // Already been added
- throw new IllegalArgumentException("item has already been added. Did you miss to call isAdded()?"); //NOI18N
- }
-
- // Add item to database
- // TODO: ((BasketFrontend) this.getFrontend()).addItem(item, this.getSessionId());
-
- // Trace call
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- @Override
- public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- // Deligate call to frontend
- // TODO: return ((BasketFrontend) this.getFrontend()).isEmpty();
- throw new UnsupportedOperationException("Not yet implmeneted.");
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Init map
- // TODO: Map<Long, T> map = ((BasketFrontend) this.getFrontend()).getAll();
- Map<Long, T> map = null;
-
- // Trace message
- this.getLogger().trace("map=" + map); //NOI18N
-
- // Return it
- return map;
- }
-
- @Override
- public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- // Deligate to frontend
- // TODO: return ((BasketFrontend) this.getFrontend()).getLast();
- throw new UnsupportedOperationException("Not yet implmeneted.");
- }
-
- @Override
- public int getLastNumRows () {
- // Deligate to frontend
- // TODO: return this.getFrontend().getLastNumRows();
- throw new UnsupportedOperationException("Not yet implmeneted.");
- }
-
- @Override
- public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- // Trace call
- this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
-
- // item must not be null
- if (null == item) {
- // Then abort here
- throw new NullPointerException("item is null"); //NOI18N
- }
-
- // Call map's method
- // TODO: boolean isAdded = ((BasketFrontend) this.getFrontend()).isAdded(item, this.getSessionId());
- boolean isAdded = true;
-
- // Trace message
- this.getLogger().trace(MessageFormat.format("isAdded={0} - EXIT!", isAdded)); //NOI18N
-
- // Return it
- return isAdded;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.basket;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.sql.SQLException;
-import java.util.Map;
-import org.mxchange.jshop.ShopInterface;
-import org.mxchange.jshop.model.item.AddableBasketItem;
-
-/**
- * An interface for baskets
- *
- * @author Roland Haeder
- * @param <T> Any addable basket items
- */
-public interface Basket<T extends AddableBasketItem> extends Serializable, ShopInterface {
-
- /**
- * Adds given item instance to this basket
- * @param item Item instance to add
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Checks whether the given item as already been added. If the product's
- * item id number was found in basket, the corresponding item instance will be set
- *
- * @param item Item instance to check
- * @return Whether the given item has been found
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Checks if the basket is empty
- *
- * @return Whether the basket is empty
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Initializes this instance with given ServletContext
- *
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
- */
- public void init () throws SQLException, IOException;
-
- /**
- * Some "getter" for all entries in this basket
- *
- * @return Map on all basket items
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Getter for last entry
- *
- * @return Last added item in basket
- * @throws java.io.IOException If an IO error occurs
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.lang.NoSuchMethodException If a method was not found
- * @throws java.lang.IllegalAccessException If the invoked method is not public
- * @throws java.lang.reflect.InvocationTargetException If anything else happened?
- */
- public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
-
- /**
- * Getter for last num rows
- *
- * @return Last num rows
- */
- public int getLastNumRows ();
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.basket.item;
-
-import java.sql.SQLException;
-import org.mxchange.jshop.model.basket.BaseBasket;
-import org.mxchange.jshop.model.basket.Basket;
-import org.mxchange.jshop.model.item.AddableBasketItem;
-
-/**
- * A basket for orderable items
- *
- * @author Roland Haeder
- */
-public class ItemBasket extends BaseBasket<AddableBasketItem> implements Basket<AddableBasketItem> {
- /**
- * Serial number
- */
- private static final long serialVersionUID = 4384123923163957L;
-
- /**
- * Default constructor to be able to throw exceptions from super constructor
- * @throws java.sql.SQLException If an SQL error occurs
- */
- public ItemBasket () throws SQLException {
- // Call super constructor
- super();
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.category;
-
-import java.io.UnsupportedEncodingException;
-import java.text.MessageFormat;
-import java.util.Objects;
-import org.mxchange.jshop.BaseShopCore;
-
-/**
- * A general product category class
- *
- * @author Roland Haeder
- */
-public class BaseCategory extends BaseShopCore implements Category {
-
- /**
- * Id number of category
- */
- private Long categoryId;
-
- /**
- * Parent category categoryId
- */
- private Long parentId;
-
- /**
- * Title of category
- */
- private String title;
-
- /**
- * Constructor which accepts all database fields
- *
- * @param categoryId Id number of database record
- * @param title Category title
- * @param parentId Parent categoryId
- */
- protected BaseCategory (final Long categoryId, final String title, final Long parentId) {
- // Set all here
- this.setCategoryId(categoryId);
- this.setTitle(title);
- this.setParentId(parentId);
- }
-
- /**
- * Default constructor
- */
- protected BaseCategory () {
- }
-
- /**
- * Compares two categories with each other
- *
- * @param category Category comparator
- * @return Comparison value
- */
- @Override
- public int compareTo (final Category category) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N
-
- // category should not be null
- if (null == category) {
- throw new NullPointerException("category is null"); //NOI18N
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getCategoryId(), category.getCategoryId())); //NOI18N
-
- // Is the categoryId the same?
- if (Objects.equals(this.getCategoryId(), category.getCategoryId())) {
- // Same categoryId, means same category
- return 0;
- } else if (this.getCategoryId() > category.getCategoryId()) {
- // This categoryId is larger than compared to
- return -1;
- }
-
- // The other categoryId is larger
- return 1;
- }
-
- /**
- * Decodes the UTF8-encoded title
- *
- * @return Decoded title
- */
- @Override
- public final String getDecodedTitle () throws UnsupportedEncodingException {
- // Get title
- byte[] t = this.getTitle().getBytes();
-
- // Decode it
- return new String(t, "UTF-8"); //NOI18N
- }
-
- /**
- * Id number of category
- *
- * @return the categoryId
- */
- @Override
- public final Long getCategoryId () {
- return this.categoryId;
- }
-
- /**
- * Id number of category
- *
- * @param categoryId the categoryId to set
- */
- @Override
- public final void setCategoryId (final Long categoryId) {
- this.categoryId = categoryId;
- }
-
- /**
- * Parent category categoryId
- *
- * @return the parentId
- */
- @Override
- public final Long getParentId () {
- return this.parentId;
- }
-
- /**
- * Parent category categoryId
- *
- * @param parentId the parentId to set
- */
- @Override
- public final void setParentId (final Long parentId) {
- this.parentId = parentId;
- }
-
- /**
- * Title of category
- *
- * @return the title
- */
- @Override
- public final String getTitle () {
- return this.title;
- }
-
- /**
- * Title of category
- *
- * @param title the title to set
- */
- @Override
- public final void setTitle (final String title) {
- this.title = title;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.category;
-
-import java.io.UnsupportedEncodingException;
-import org.mxchange.jshop.ShopInterface;
-
-/**
- * An interface for categories
- *
- * @author Roland Haeder
- */
-public interface Category extends ShopInterface, Comparable<Category> {
-
- /**
- * Id number of category
- * @return the id
- */
- public Long getCategoryId ();
-
- /**
- * Id number of category
- * @param id the id to set
- */
- public void setCategoryId (final Long id);
-
- /**
- * Parent category id
- * @return the parent
- */
- public Long getParentId ();
-
- /**
- * Parent category id
- * @param parent the parent to set
- */
- public void setParentId (final Long parent);
-
- /**
- * Title of category
- * @return the title
- */
- public String getTitle ();
-
- /**
- * Title of category
- * @param title the title to set
- */
- public void setTitle (final String title);
-
- /**
- * Compare method
- * @param category Category to compare to
- * @return Comparison value
- */
- @Override
- public int compareTo (final Category category);
-
- /**
- * Decodes the UTF8-encoded title
- *
- * @return Decoded title
- * @throws java.io.UnsupportedEncodingException If the encoding UTF-8 is not supported
- */
- public String getDecodedTitle () throws UnsupportedEncodingException ;
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.category.product;
-
-import org.mxchange.jshop.model.category.BaseCategory;
-
-/**
- * A product category
- * @author Roland Haeder
- */
-public class ProductCategory extends BaseCategory {
- /**
- * Constructor which accepts all database fields
- * @param id Id number of database record
- * @param title Category title
- * @param parent Parent id
- */
- public ProductCategory (final Long id, final String title, final Long parent) {
- // Call parent constructor
- super(id, title, parent);
- }
-
- /**
- * Default constructor
- */
- public ProductCategory () {
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.customer;
-
-import org.mxchange.jcore.model.contact.Contact;
-
-/**
- * A customer interface
- *
- * @author Roland Haeder
- */
-public interface Customer extends Contact {
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.customer;
-
-import org.mxchange.jcore.model.contact.BaseContact;
-
-/**
- * A shop customer class.
- *
- * @author Roland Haeder
- */
-public class ShopCustomer extends BaseContact implements Customer {
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.item;
-
-import org.mxchange.jshop.ShopInterface;
-
-/**
- * An interface for addable basket items
- *
- * @author Roland Haeder
- */
-public interface AddableBasketItem extends ShopInterface, Comparable<AddableBasketItem> {
-
- /**
- * Item amount
- * @return the amount
- */
- public Long getAmount ();
-
- /**
- * Item amount
- * @param amount the amount to set
- */
- public void setAmount (final Long amount);
-
- /**
- * Entry id (from database backend)
- * @return the id
- */
- public Long getId ();
-
- /**
- * Entry id (from database backend)
- * @param id the id to set
- */
- public void setId (final Long id);
-
- /**
- * @return the id
- */
- public Long getItemId ();
-
- /**
- * @param id the id to set
- */
- public void setItemId (final Long id);
-
- /**
- * @return the type
- */
- public String getItemType ();
-
- /**
- * @param type the type to set
- */
- public void setItemType (final String type);
-
- /**
- * Calculates total price by multipying amount and single price
- *
- * @return Total price of this item
- */
- public Float calculateTotalPrice ();
-
- /**
- * Compare method
- * @param item Item to compare to
- * @return Comparison value
- */
- @Override
- public int compareTo (final AddableBasketItem item);
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.item;
-
-import java.text.MessageFormat;
-import java.util.Objects;
-import org.mxchange.jshop.BaseShopCore;
-
-/**
- * An item (addedable to a basket) could respresent a product or a discount
- * coupon. This depends on the type of the item.
- *
- * @author Roland Haeder
- */
-public class BaseItem extends BaseShopCore implements AddableBasketItem {
- /**
- * Entry id (from database backend)
- */
- private Long id;
-
- /**
- * Item amount
- */
- private Long amount;
-
- /**
- * Item id number
- */
- private Long itemId;
-
- /**
- * Item type
- */
- private String itemType;
-
- @Override
- public Float calculateTotalPrice () {
- // product should be set
- if (this.getProduct() == null) {
- // Abort here
- throw new NullPointerException("product is null"); //NOI18N
- }
-
- // Calculate and return it
- // TODO: If later other purchaseable items (other than products) are handled through this class, this needs expansion
- return (this.getAmount() * this.getProduct().getPrice());
- }
-
- @Override
- public int compareTo (final AddableBasketItem item) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
-
- // item should not be null
- if (null == item) {
- throw new NullPointerException("item is null"); //NOI18N
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("this.itemId={0},item.itemId={1}", this.getItemId(), item.getItemId())); //NOI18N
-
- // Is the id the same?
- if (Objects.equals(this.getItemId(), item.getItemId())) {
- // Same id, means same item
- return 0;
- } else if (this.getItemId() > item.getItemId()) {
- // This id is larger than compared to
- return -1;
- }
-
- // The other id is larger
- return 1;
- }
-
- @Override
- public final Long getAmount () {
- return this.amount;
- }
-
- @Override
- public final void setAmount (final Long amount) {
- this.amount = amount;
- }
-
- @Override
- public final Long getId () {
- return this.id;
- }
-
- @Override
- public final void setId (final Long id) {
- this.id = id;
- }
-
- @Override
- public final Long getItemId () {
- return this.itemId;
- }
-
- @Override
- public final void setItemId( final Long itemId) {
- this.itemId = itemId;
- }
-
- @Override
- public final String getItemType () {
- return this.itemType;
- }
-
- @Override
- public final void setItemType (final String itemType) {
- this.itemType = itemType;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.item.basket;
-
-import java.text.MessageFormat;
-import org.mxchange.jshop.model.item.AddableBasketItem;
-import org.mxchange.jshop.model.item.BaseItem;
-import org.mxchange.jshop.model.product.Product;
-
-/**
- * A general basket item
- *
- * @author Roland Haeder
- */
-public class BasketItem extends BaseItem implements AddableBasketItem {
- /**
- * Default constructor
- */
- public BasketItem () {
- }
-
- /**
- * Constructor for an item from given Product instance
- *
- * @param product Product instance
- */
- public BasketItem (final Product product) {
- // Call default constructor
- this();
-
- // Trace message
- this.getLogger().debug(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
-
- // product must not be null
- if (null == product) {
- // Abort here
- throw new NullPointerException("product is null"); //NOI18N
- }
-
- // Copy all neccessary values
- this.setItemId(product.getItemId());
- this.setItemType("Product"); //NOI18N
- }
-}
+++ /dev/null
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.mxchange.jshop.model.product;
-
-import java.text.MessageFormat;
-import java.util.Objects;
-import org.mxchange.jshop.BaseShopCore;
-
-/**
- *
- * @author Roland Haeder
- */
-public class BaseProduct extends BaseShopCore implements Product {
- /**
- * Availability of product
- */
- private Boolean available;
-
- /**
- * Product category
- */
- private Long categoryId;
-
- /**
- * Id number of product item
- */
- private Long itemId;
-
- /**
- * Price of product
- */
- private Float price;
-
- /**
- * Title of product
- */
- private String title;
-
- @Override
- public int compareTo (final Product product) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
-
- // category should not be null
- if (null == product) {
- throw new NullPointerException("product is null"); //NOI18N
- }
-
- // Debug message
- this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getItemId(), product.getItemId())); //NOI18N
-
- // Is the id the same?
- if (Objects.equals(this.getItemId(), product.getItemId())) {
- // Same id, means same category
- return 0;
- } else if (this.getItemId() > product.getItemId()) {
- // This id is larger than compared to
- return 1;
- }
-
- // The other id is larger
- return -1;
- }
-
- @Override
- public final Boolean getAvailable () {
- return this.available;
- }
-
- @Override
- public final void setAvailable (final Boolean available) {
- this.available = available;
- }
-
- @Override
- public final Long getCategoryId () {
- return this.categoryId;
- }
-
- @Override
- public final void setCategoryId (final Long categoryId) {
- this.categoryId = categoryId;
- }
-
- @Override
- public final Long getItemId () {
- return this.itemId;
- }
-
- @Override
- public final void setItemId (final Long itemId) {
- this.itemId = itemId;
- }
-
- @Override
- public final Float getPrice () {
- return this.price;
- }
-
- @Override
- public final void setPrice (final Float price) {
- this.price = price;
- }
-
- @Override
- public final String getTitle () {
- return this.title;
- }
-
- @Override
- public final void setTitle (final String title) {
- this.title = title;
- }
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.product;
-
-import org.mxchange.jshop.ShopInterface;
-
-/**
- * An interface for in database storable products
- *
- * @author Roland Haeder
- */
-public interface Product extends ShopInterface, Comparable<Product> {
- /**
- * Getter for id number, suitable for form fields.
- *
- * @return Id number of product
- */
- public Long getItemId ();
-
- /**
- * Id number of product
- * @param id the id number to set
- */
- public void setItemId (final Long id);
-
- /**
- * Getter for title.
- *
- * @return Title of product
- */
- public String getTitle ();
-
- /**
- * Title of product
- * @param title the title to set
- */
- public void setTitle (final String title);
-
- /**
- * Getter for raw price.
- *
- * @return Single price of product
- */
- public Float getPrice ();
-
- /**
- * Price of product
- * @param price the price to set
- */
- public void setPrice (final Float price);
-
- /**
- * Getter for product category id
- *
- * @return Product category id
- */
- public Long getCategoryId ();
-
- /**
- * Setter for product category
- *
- * @param categoryId Product category
- */
- public void setCategoryId (final Long categoryId);
-
- /**
- * Getter for product availability
- *
- * @return Product availability
- */
- public Boolean getAvailable ();
-
- /**
- * Setter for product availability
- *
- * @param available Product availability
- */
- public void setAvailable (final Boolean available);
-
- /**
- * Compare method
- * @param product Product to compare to
- * @return Comparison value
- */
- @Override
- public int compareTo (final Product product);
-}
+++ /dev/null
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jshop.model.product.generic;
-
-import java.text.MessageFormat;
-import org.mxchange.jshop.model.product.BaseProduct;
-import org.mxchange.jshop.model.product.Product;
-
-/**
- * Generic product class
- *
- * @author Roland Haeder
- */
-public class GenericProduct extends BaseProduct implements Product {
- /**
- * Default constructor
- */
- public GenericProduct () {
- }
-
- /**
- * Constructor will all required data
- *
- * @param id Id number of product
- * @param title Name of product
- * @param price Price
- * @param categoryId Category id
- * @param available Availability (selectable by customer)
- */
- public GenericProduct (final Long id, final String title, final Float price, final Long categoryId, final Boolean available) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("id={0},title={1},price={2},categoryId={3},available={4} - CALLED!", id, title, price, categoryId, available)); //NOI18N
-
- // Set all here
- this.setItemId(id);
- this.setTitle(title);
- this.setPrice(price);
- this.setCategoryId(categoryId);
- this.setAvailable(available);
- }
-}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore;
+
+import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * A general shop class
+ *
+ * @author Roland Haeder
+ */
+public class BaseShopCore extends BaseFrameworkSystem implements ShopInterface {
+ /**
+ * Item instance
+ */
+ private Product product;
+
+ /**
+ * @return the product
+ */
+ @Override
+ public Product getProduct () {
+ return this.product;
+ }
+
+ /**
+ * @param product the product to set
+ */
+ @Override
+ public void setProduct (final Product product) {
+ this.product = product;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore;
+
+import org.mxchange.jcore.FrameworkInterface;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * A general shop interface
+ *
+ * @author Roland Haeder
+ */
+public interface ShopInterface extends FrameworkInterface {
+ /**
+ * @return the product
+ */
+ public Product getProduct ();
+
+ /**
+ * @param product the product to set
+ */
+ public void setProduct (final Product product);
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.exceptions;
+
+import java.text.MessageFormat;
+import org.mxchange.jshopcore.model.category.Category;
+
+/**
+ * An exception thrown when the given title is already used
+ *
+ * @author Roland Haeder
+ */
+public class CategoryTitleAlreadyUsedException extends Exception {
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 53751434673262L;
+
+ /**
+ * Constructor with HttpServletRequest instance
+ *
+ * @param category Category instance
+ */
+ public CategoryTitleAlreadyUsedException (final Category category) {
+ // Call super constructor
+ super(MessageFormat.format("Title {0} is already used.", category.getTitle())); //NOI18N
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.exceptions;
+
+import java.text.MessageFormat;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * An exception thrown when the given title is already used
+ *
+ * @author Roland Haeder
+ */
+public class ProductTitleAlreadyUsedException extends Exception {
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 4252734834174L;
+
+ /**
+ * Constructor with HttpServletRequest instance
+ *
+ * @param product Product instance
+ */
+ public ProductTitleAlreadyUsedException (final Product product) {
+ // Call super constructor
+ super(MessageFormat.format("Title {0} is already used.", product.getTitle())); //NOI18N
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.basket;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import java.text.MessageFormat;
+import java.util.Map;
+import org.mxchange.jshopcore.BaseShopCore;
+import org.mxchange.jshopcore.model.item.AddableBasketItem;
+
+/**
+ * A general basket class
+ *
+ * @author Roland Haeder
+ * @param <T> Any instance that implements AddableBasketItem
+ */
+public class BaseBasket<T extends AddableBasketItem> extends BaseShopCore implements Basket<T>, Serializable {
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 784396762230845717L;
+
+ /**
+ * Protected constructor with session instance
+ *
+ * @throws java.sql.SQLException If an SQL error occurs
+ */
+ protected BaseBasket () throws SQLException {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+ }
+
+ @Override
+ public void init () throws SQLException {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Is the bundle initialized?
+ if (!BaseShopCore.isBundledInitialized()) {
+ // Temporary initialize default bundle
+ // TODO The enum Gender uses this
+ this.initBundle();
+ }
+ }
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ // Trace call
+ this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
+
+ // item must not be null
+ if (null == item) {
+ // Then abort here
+ throw new NullPointerException("item is null"); //NOI18N
+ } else if (this.isAdded(item)) {
+ // Already been added
+ throw new IllegalArgumentException("item has already been added. Did you miss to call isAdded()?"); //NOI18N
+ }
+
+ // Add item to database
+ // TODO: ((BasketFrontend) this.getFrontend()).addItem(item, this.getSessionId());
+
+ // Trace call
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+
+ @Override
+ public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ // Deligate call to frontend
+ // TODO: return ((BasketFrontend) this.getFrontend()).isEmpty();
+ throw new UnsupportedOperationException("Not yet implmeneted.");
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Init map
+ // TODO: Map<Long, T> map = ((BasketFrontend) this.getFrontend()).getAll();
+ Map<Long, T> map = null;
+
+ // Trace message
+ this.getLogger().trace("map=" + map); //NOI18N
+
+ // Return it
+ return map;
+ }
+
+ @Override
+ public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ // Deligate to frontend
+ // TODO: return ((BasketFrontend) this.getFrontend()).getLast();
+ throw new UnsupportedOperationException("Not yet implmeneted.");
+ }
+
+ @Override
+ public int getLastNumRows () {
+ // Deligate to frontend
+ // TODO: return this.getFrontend().getLastNumRows();
+ throw new UnsupportedOperationException("Not yet implmeneted.");
+ }
+
+ @Override
+ public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ // Trace call
+ this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
+
+ // item must not be null
+ if (null == item) {
+ // Then abort here
+ throw new NullPointerException("item is null"); //NOI18N
+ }
+
+ // Call map's method
+ // TODO: boolean isAdded = ((BasketFrontend) this.getFrontend()).isAdded(item, this.getSessionId());
+ boolean isAdded = true;
+
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("isAdded={0} - EXIT!", isAdded)); //NOI18N
+
+ // Return it
+ return isAdded;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.basket;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.sql.SQLException;
+import java.util.Map;
+import org.mxchange.jshopcore.ShopInterface;
+import org.mxchange.jshopcore.model.item.AddableBasketItem;
+
+/**
+ * An interface for baskets
+ *
+ * @author Roland Haeder
+ * @param <T> Any addable basket items
+ */
+public interface Basket<T extends AddableBasketItem> extends Serializable, ShopInterface {
+
+ /**
+ * Adds given item instance to this basket
+ * @param item Item instance to add
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.lang.NoSuchMethodException If a method was not found
+ * @throws java.lang.IllegalAccessException If the invoked method is not public
+ * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ */
+ public void addItem (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+ /**
+ * Checks whether the given item as already been added. If the product's
+ * item id number was found in basket, the corresponding item instance will be set
+ *
+ * @param item Item instance to check
+ * @return Whether the given item has been found
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.lang.NoSuchMethodException If a method was not found
+ * @throws java.lang.IllegalAccessException If the invoked method is not public
+ * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ */
+ public boolean isAdded (final T item) throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+ /**
+ * Checks if the basket is empty
+ *
+ * @return Whether the basket is empty
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.lang.NoSuchMethodException If a method was not found
+ * @throws java.lang.IllegalAccessException If the invoked method is not public
+ * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ */
+ public boolean isEmpty () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+ /**
+ * Initializes this instance with given ServletContext
+ *
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.io.IOException If an IO error occurs
+ */
+ public void init () throws SQLException, IOException;
+
+ /**
+ * Some "getter" for all entries in this basket
+ *
+ * @return Map on all basket items
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.lang.NoSuchMethodException If a method was not found
+ * @throws java.lang.IllegalAccessException If the invoked method is not public
+ * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ */
+ public Map<Long, T> getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+ /**
+ * Getter for last entry
+ *
+ * @return Last added item in basket
+ * @throws java.io.IOException If an IO error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.lang.NoSuchMethodException If a method was not found
+ * @throws java.lang.IllegalAccessException If the invoked method is not public
+ * @throws java.lang.reflect.InvocationTargetException If anything else happened?
+ */
+ public AddableBasketItem getLast () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+
+ /**
+ * Getter for last num rows
+ *
+ * @return Last num rows
+ */
+ public int getLastNumRows ();
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.basket.item;
+
+import java.sql.SQLException;
+import org.mxchange.jshopcore.model.basket.BaseBasket;
+import org.mxchange.jshopcore.model.basket.Basket;
+import org.mxchange.jshopcore.model.item.AddableBasketItem;
+
+/**
+ * A basket for orderable items
+ *
+ * @author Roland Haeder
+ */
+public class ItemBasket extends BaseBasket<AddableBasketItem> implements Basket<AddableBasketItem> {
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 4384123923163957L;
+
+ /**
+ * Default constructor to be able to throw exceptions from super constructor
+ * @throws java.sql.SQLException If an SQL error occurs
+ */
+ public ItemBasket () throws SQLException {
+ // Call super constructor
+ super();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.category;
+
+import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
+import java.util.Objects;
+import org.mxchange.jshopcore.BaseShopCore;
+
+/**
+ * A general product category class
+ *
+ * @author Roland Haeder
+ */
+public class BaseCategory extends BaseShopCore implements Category {
+
+ /**
+ * Id number of category
+ */
+ private Long categoryId;
+
+ /**
+ * Parent category categoryId
+ */
+ private Long parentId;
+
+ /**
+ * Title of category
+ */
+ private String title;
+
+ /**
+ * Constructor which accepts all database fields
+ *
+ * @param categoryId Id number of database record
+ * @param title Category title
+ * @param parentId Parent categoryId
+ */
+ protected BaseCategory (final Long categoryId, final String title, final Long parentId) {
+ // Set all here
+ this.setCategoryId(categoryId);
+ this.setTitle(title);
+ this.setParentId(parentId);
+ }
+
+ /**
+ * Default constructor
+ */
+ protected BaseCategory () {
+ }
+
+ /**
+ * Compares two categories with each other
+ *
+ * @param category Category comparator
+ * @return Comparison value
+ */
+ @Override
+ public int compareTo (final Category category) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N
+
+ // category should not be null
+ if (null == category) {
+ throw new NullPointerException("category is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("this.id={0},category.id={1}", this.getCategoryId(), category.getCategoryId())); //NOI18N
+
+ // Is the categoryId the same?
+ if (Objects.equals(this.getCategoryId(), category.getCategoryId())) {
+ // Same categoryId, means same category
+ return 0;
+ } else if (this.getCategoryId() > category.getCategoryId()) {
+ // This categoryId is larger than compared to
+ return -1;
+ }
+
+ // The other categoryId is larger
+ return 1;
+ }
+
+ /**
+ * Decodes the UTF8-encoded title
+ *
+ * @return Decoded title
+ */
+ @Override
+ public final String getDecodedTitle () throws UnsupportedEncodingException {
+ // Get title
+ byte[] t = this.getTitle().getBytes();
+
+ // Decode it
+ return new String(t, "UTF-8"); //NOI18N
+ }
+
+ /**
+ * Id number of category
+ *
+ * @return the categoryId
+ */
+ @Override
+ public final Long getCategoryId () {
+ return this.categoryId;
+ }
+
+ /**
+ * Id number of category
+ *
+ * @param categoryId the categoryId to set
+ */
+ @Override
+ public final void setCategoryId (final Long categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ /**
+ * Parent category categoryId
+ *
+ * @return the parentId
+ */
+ @Override
+ public final Long getParentId () {
+ return this.parentId;
+ }
+
+ /**
+ * Parent category categoryId
+ *
+ * @param parentId the parentId to set
+ */
+ @Override
+ public final void setParentId (final Long parentId) {
+ this.parentId = parentId;
+ }
+
+ /**
+ * Title of category
+ *
+ * @return the title
+ */
+ @Override
+ public final String getTitle () {
+ return this.title;
+ }
+
+ /**
+ * Title of category
+ *
+ * @param title the title to set
+ */
+ @Override
+ public final void setTitle (final String title) {
+ this.title = title;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.category;
+
+import java.io.UnsupportedEncodingException;
+import org.mxchange.jshopcore.ShopInterface;
+
+/**
+ * An interface for categories
+ *
+ * @author Roland Haeder
+ */
+public interface Category extends ShopInterface, Comparable<Category> {
+
+ /**
+ * Id number of category
+ * @return the id
+ */
+ public Long getCategoryId ();
+
+ /**
+ * Id number of category
+ * @param id the id to set
+ */
+ public void setCategoryId (final Long id);
+
+ /**
+ * Parent category id
+ * @return the parent
+ */
+ public Long getParentId ();
+
+ /**
+ * Parent category id
+ * @param parent the parent to set
+ */
+ public void setParentId (final Long parent);
+
+ /**
+ * Title of category
+ * @return the title
+ */
+ public String getTitle ();
+
+ /**
+ * Title of category
+ * @param title the title to set
+ */
+ public void setTitle (final String title);
+
+ /**
+ * Compare method
+ * @param category Category to compare to
+ * @return Comparison value
+ */
+ @Override
+ public int compareTo (final Category category);
+
+ /**
+ * Decodes the UTF8-encoded title
+ *
+ * @return Decoded title
+ * @throws java.io.UnsupportedEncodingException If the encoding UTF-8 is not supported
+ */
+ public String getDecodedTitle () throws UnsupportedEncodingException ;
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.category.product;
+
+import org.mxchange.jshopcore.model.category.BaseCategory;
+
+/**
+ * A product category
+ * @author Roland Haeder
+ */
+public class ProductCategory extends BaseCategory {
+ /**
+ * Constructor which accepts all database fields
+ * @param id Id number of database record
+ * @param title Category title
+ * @param parent Parent id
+ */
+ public ProductCategory (final Long id, final String title, final Long parent) {
+ // Call parent constructor
+ super(id, title, parent);
+ }
+
+ /**
+ * Default constructor
+ */
+ public ProductCategory () {
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.customer;
+
+import org.mxchange.jcore.model.contact.Contact;
+
+/**
+ * A customer interface
+ *
+ * @author Roland Haeder
+ */
+public interface Customer extends Contact {
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.customer;
+
+import org.mxchange.jcore.model.contact.BaseContact;
+
+/**
+ * A shop customer class.
+ *
+ * @author Roland Haeder
+ */
+public class ShopCustomer extends BaseContact implements Customer {
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.item;
+
+import org.mxchange.jshopcore.ShopInterface;
+
+/**
+ * An interface for addable basket items
+ *
+ * @author Roland Haeder
+ */
+public interface AddableBasketItem extends ShopInterface, Comparable<AddableBasketItem> {
+
+ /**
+ * Item amount
+ * @return the amount
+ */
+ public Long getAmount ();
+
+ /**
+ * Item amount
+ * @param amount the amount to set
+ */
+ public void setAmount (final Long amount);
+
+ /**
+ * Entry id (from database backend)
+ * @return the id
+ */
+ public Long getId ();
+
+ /**
+ * Entry id (from database backend)
+ * @param id the id to set
+ */
+ public void setId (final Long id);
+
+ /**
+ * @return the id
+ */
+ public Long getItemId ();
+
+ /**
+ * @param id the id to set
+ */
+ public void setItemId (final Long id);
+
+ /**
+ * @return the type
+ */
+ public String getItemType ();
+
+ /**
+ * @param type the type to set
+ */
+ public void setItemType (final String type);
+
+ /**
+ * Calculates total price by multipying amount and single price
+ *
+ * @return Total price of this item
+ */
+ public Float calculateTotalPrice ();
+
+ /**
+ * Compare method
+ * @param item Item to compare to
+ * @return Comparison value
+ */
+ @Override
+ public int compareTo (final AddableBasketItem item);
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.item;
+
+import java.text.MessageFormat;
+import java.util.Objects;
+import org.mxchange.jshopcore.BaseShopCore;
+
+/**
+ * An item (addedable to a basket) could respresent a product or a discount
+ * coupon. This depends on the type of the item.
+ *
+ * @author Roland Haeder
+ */
+public class BaseItem extends BaseShopCore implements AddableBasketItem {
+ /**
+ * Entry id (from database backend)
+ */
+ private Long id;
+
+ /**
+ * Item amount
+ */
+ private Long amount;
+
+ /**
+ * Item id number
+ */
+ private Long itemId;
+
+ /**
+ * Item type
+ */
+ private String itemType;
+
+ @Override
+ public Float calculateTotalPrice () {
+ // product should be set
+ if (this.getProduct() == null) {
+ // Abort here
+ throw new NullPointerException("product is null"); //NOI18N
+ }
+
+ // Calculate and return it
+ // TODO: If later other purchaseable items (other than products) are handled through this class, this needs expansion
+ return (this.getAmount() * this.getProduct().getPrice());
+ }
+
+ @Override
+ public int compareTo (final AddableBasketItem item) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("item={0} - CALLED!", item)); //NOI18N
+
+ // item should not be null
+ if (null == item) {
+ throw new NullPointerException("item is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("this.itemId={0},item.itemId={1}", this.getItemId(), item.getItemId())); //NOI18N
+
+ // Is the id the same?
+ if (Objects.equals(this.getItemId(), item.getItemId())) {
+ // Same id, means same item
+ return 0;
+ } else if (this.getItemId() > item.getItemId()) {
+ // This id is larger than compared to
+ return -1;
+ }
+
+ // The other id is larger
+ return 1;
+ }
+
+ @Override
+ public final Long getAmount () {
+ return this.amount;
+ }
+
+ @Override
+ public final void setAmount (final Long amount) {
+ this.amount = amount;
+ }
+
+ @Override
+ public final Long getId () {
+ return this.id;
+ }
+
+ @Override
+ public final void setId (final Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public final Long getItemId () {
+ return this.itemId;
+ }
+
+ @Override
+ public final void setItemId( final Long itemId) {
+ this.itemId = itemId;
+ }
+
+ @Override
+ public final String getItemType () {
+ return this.itemType;
+ }
+
+ @Override
+ public final void setItemType (final String itemType) {
+ this.itemType = itemType;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.item.basket;
+
+import java.text.MessageFormat;
+import org.mxchange.jshopcore.model.item.AddableBasketItem;
+import org.mxchange.jshopcore.model.item.BaseItem;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * A general basket item
+ *
+ * @author Roland Haeder
+ */
+public class BasketItem extends BaseItem implements AddableBasketItem {
+ /**
+ * Default constructor
+ */
+ public BasketItem () {
+ }
+
+ /**
+ * Constructor for an item from given Product instance
+ *
+ * @param product Product instance
+ */
+ public BasketItem (final Product product) {
+ // Call default constructor
+ this();
+
+ // Trace message
+ this.getLogger().debug(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
+
+ // product must not be null
+ if (null == product) {
+ // Abort here
+ throw new NullPointerException("product is null"); //NOI18N
+ }
+
+ // Copy all neccessary values
+ this.setItemId(product.getItemId());
+ this.setItemType("Product"); //NOI18N
+ }
+}
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.mxchange.jshopcore.model.product;
+
+import java.text.MessageFormat;
+import java.util.Objects;
+import org.mxchange.jshopcore.BaseShopCore;
+
+/**
+ *
+ * @author Roland Haeder
+ */
+public class BaseProduct extends BaseShopCore implements Product {
+ /**
+ * Availability of product
+ */
+ private Boolean available;
+
+ /**
+ * Product category
+ */
+ private Long categoryId;
+
+ /**
+ * Id number of product item
+ */
+ private Long itemId;
+
+ /**
+ * Price of product
+ */
+ private Float price;
+
+ /**
+ * Title of product
+ */
+ private String title;
+
+ @Override
+ public int compareTo (final Product product) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
+
+ // category should not be null
+ if (null == product) {
+ throw new NullPointerException("product is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("this.id={0},product.id={1}", this.getItemId(), product.getItemId())); //NOI18N
+
+ // Is the id the same?
+ if (Objects.equals(this.getItemId(), product.getItemId())) {
+ // Same id, means same category
+ return 0;
+ } else if (this.getItemId() > product.getItemId()) {
+ // This id is larger than compared to
+ return 1;
+ }
+
+ // The other id is larger
+ return -1;
+ }
+
+ @Override
+ public final Boolean getAvailable () {
+ return this.available;
+ }
+
+ @Override
+ public final void setAvailable (final Boolean available) {
+ this.available = available;
+ }
+
+ @Override
+ public final Long getCategoryId () {
+ return this.categoryId;
+ }
+
+ @Override
+ public final void setCategoryId (final Long categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ @Override
+ public final Long getItemId () {
+ return this.itemId;
+ }
+
+ @Override
+ public final void setItemId (final Long itemId) {
+ this.itemId = itemId;
+ }
+
+ @Override
+ public final Float getPrice () {
+ return this.price;
+ }
+
+ @Override
+ public final void setPrice (final Float price) {
+ this.price = price;
+ }
+
+ @Override
+ public final String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public final void setTitle (final String title) {
+ this.title = title;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.product;
+
+import org.mxchange.jshopcore.ShopInterface;
+
+/**
+ * An interface for in database storable products
+ *
+ * @author Roland Haeder
+ */
+public interface Product extends ShopInterface, Comparable<Product> {
+ /**
+ * Getter for id number, suitable for form fields.
+ *
+ * @return Id number of product
+ */
+ public Long getItemId ();
+
+ /**
+ * Id number of product
+ * @param id the id number to set
+ */
+ public void setItemId (final Long id);
+
+ /**
+ * Getter for title.
+ *
+ * @return Title of product
+ */
+ public String getTitle ();
+
+ /**
+ * Title of product
+ * @param title the title to set
+ */
+ public void setTitle (final String title);
+
+ /**
+ * Getter for raw price.
+ *
+ * @return Single price of product
+ */
+ public Float getPrice ();
+
+ /**
+ * Price of product
+ * @param price the price to set
+ */
+ public void setPrice (final Float price);
+
+ /**
+ * Getter for product category id
+ *
+ * @return Product category id
+ */
+ public Long getCategoryId ();
+
+ /**
+ * Setter for product category
+ *
+ * @param categoryId Product category
+ */
+ public void setCategoryId (final Long categoryId);
+
+ /**
+ * Getter for product availability
+ *
+ * @return Product availability
+ */
+ public Boolean getAvailable ();
+
+ /**
+ * Setter for product availability
+ *
+ * @param available Product availability
+ */
+ public void setAvailable (final Boolean available);
+
+ /**
+ * Compare method
+ * @param product Product to compare to
+ * @return Comparison value
+ */
+ @Override
+ public int compareTo (final Product product);
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.product.generic;
+
+import java.text.MessageFormat;
+import org.mxchange.jshopcore.model.product.BaseProduct;
+import org.mxchange.jshopcore.model.product.Product;
+
+/**
+ * Generic product class
+ *
+ * @author Roland Haeder
+ */
+public class GenericProduct extends BaseProduct implements Product {
+ /**
+ * Default constructor
+ */
+ public GenericProduct () {
+ }
+
+ /**
+ * Constructor will all required data
+ *
+ * @param id Id number of product
+ * @param title Name of product
+ * @param price Price
+ * @param categoryId Category id
+ * @param available Availability (selectable by customer)
+ */
+ public GenericProduct (final Long id, final String title, final Float price, final Long categoryId, final Boolean available) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("id={0},title={1},price={2},categoryId={3},available={4} - CALLED!", id, title, price, categoryId, available)); //NOI18N
+
+ // Set all here
+ this.setItemId(id);
+ this.setTitle(title);
+ this.setPrice(price);
+ this.setCategoryId(categoryId);
+ this.setAvailable(available);
+ }
+}