From: Roland Haeder Date: Fri, 4 Sep 2015 21:18:48 +0000 (+0200) Subject: Inital import X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=acd0e74325ccb7c7569ac9b78490b97dbc46b7b8;p=jshop-core.git Inital import Signed-off-by: Roland Häder --- acd0e74325ccb7c7569ac9b78490b97dbc46b7b8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cd7a86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/nbproject/private/ +/manifest.mf +/build/ +/dist/ +/*.properties diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..6379c06 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project jshop-core. + + + diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..2cc00f0 Binary files /dev/null and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/jcore.jar b/lib/jcore.jar new file mode 100644 index 0000000..f9fd3c4 Binary files /dev/null and b/lib/jcore.jar differ diff --git a/lib/log4j-api-2.3.jar b/lib/log4j-api-2.3.jar new file mode 100644 index 0000000..2a61bbe Binary files /dev/null and b/lib/log4j-api-2.3.jar differ diff --git a/lib/log4j-core-2.3.jar b/lib/log4j-core-2.3.jar new file mode 100644 index 0000000..5438b0b Binary files /dev/null and b/lib/log4j-core-2.3.jar differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties new file mode 100644 index 0000000..6d0afb5 --- /dev/null +++ b/lib/nblibraries.properties @@ -0,0 +1,4 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=2.0 diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..e841dc3 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1438 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..a684ce4 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=622c8e1d +build.xml.script.CRC32=fa35cacf +build.xml.stylesheet.CRC32=8064a381@1.75.2.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=622c8e1d +nbproject/build-impl.xml.script.CRC32=40bf9247 +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..46c3400 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,99 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=jshop-core +application.vendor=Roland Haeder +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/jshop-core.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.jcore.jar=lib/jcore.jar +file.reference.lib-CopyLibs=lib/CopyLibs/ +file.reference.log4j-api-2.3.jar=lib/log4j-api-2.3.jar +file.reference.log4j-core-2.3.jar=lib/log4j-core-2.3.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.lib-CopyLibs}:\ + ${file.reference.jcore.jar}:\ + ${file.reference.log4j-api-2.3.jar}:\ + ${file.reference.log4j-core-2.3.jar} +# Space-separated list of extra javac options +javac.compilerargs=-Xlint:unchecked -Xlint:deprecation +javac.deprecation=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=true +javadoc.splitindex=true +javadoc.use=true +javadoc.version=true +javadoc.windowtitle=Jave Shop Core +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +project.license=gpl30 +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +source.reference.jcore.jar=../jcore/src/ +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..815ee3d --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + jshop-core + + + + + + + + + ./lib/nblibraries.properties + + + diff --git a/src/org/mxchange/jshop/BaseShopCore.java b/src/org/mxchange/jshop/BaseShopCore.java new file mode 100644 index 0000000..4c1acba --- /dev/null +++ b/src/org/mxchange/jshop/BaseShopCore.java @@ -0,0 +1,48 @@ +/* + * 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 . + */ +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; + } +} diff --git a/src/org/mxchange/jshop/ShopInterface.java b/src/org/mxchange/jshop/ShopInterface.java new file mode 100644 index 0000000..9e3091c --- /dev/null +++ b/src/org/mxchange/jshop/ShopInterface.java @@ -0,0 +1,37 @@ +/* + * 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 . + */ +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); +} diff --git a/src/org/mxchange/jshop/exceptions/CategoryTitleAlreadyUsedException.java b/src/org/mxchange/jshop/exceptions/CategoryTitleAlreadyUsedException.java new file mode 100644 index 0000000..d7d90dd --- /dev/null +++ b/src/org/mxchange/jshop/exceptions/CategoryTitleAlreadyUsedException.java @@ -0,0 +1,42 @@ +/* + * 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 . + */ +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 + } +} diff --git a/src/org/mxchange/jshop/exceptions/ProductTitleAlreadyUsedException.java b/src/org/mxchange/jshop/exceptions/ProductTitleAlreadyUsedException.java new file mode 100644 index 0000000..18c3340 --- /dev/null +++ b/src/org/mxchange/jshop/exceptions/ProductTitleAlreadyUsedException.java @@ -0,0 +1,42 @@ +/* + * 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 . + */ +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 + } +} diff --git a/src/org/mxchange/jshop/model/basket/BaseBasket.java b/src/org/mxchange/jshop/model/basket/BaseBasket.java new file mode 100644 index 0000000..4fec090 --- /dev/null +++ b/src/org/mxchange/jshop/model/basket/BaseBasket.java @@ -0,0 +1,144 @@ +/* + * 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 . + */ +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 Any instance that implements AddableBasketItem + */ +public class BaseBasket extends BaseShopCore implements Basket, 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 getAll () throws IOException, SQLException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + // Trace message + this.getLogger().trace("CALLED!"); //NOI18N + + // Init map + // TODO: Map map = ((BasketFrontend) this.getFrontend()).getAll(); + Map 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; + } +} diff --git a/src/org/mxchange/jshop/model/basket/Basket.java b/src/org/mxchange/jshop/model/basket/Basket.java new file mode 100644 index 0000000..97148b6 --- /dev/null +++ b/src/org/mxchange/jshop/model/basket/Basket.java @@ -0,0 +1,110 @@ +/* + * 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 . + */ +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 Any addable basket items + */ +public interface Basket 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 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 (); +} diff --git a/src/org/mxchange/jshop/model/basket/item/ItemBasket.java b/src/org/mxchange/jshop/model/basket/item/ItemBasket.java new file mode 100644 index 0000000..1e3045f --- /dev/null +++ b/src/org/mxchange/jshop/model/basket/item/ItemBasket.java @@ -0,0 +1,43 @@ +/* + * 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 . + */ +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 implements Basket { + /** + * 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(); + } +} diff --git a/src/org/mxchange/jshop/model/category/BaseCategory.java b/src/org/mxchange/jshop/model/category/BaseCategory.java new file mode 100644 index 0000000..2a4264d --- /dev/null +++ b/src/org/mxchange/jshop/model/category/BaseCategory.java @@ -0,0 +1,171 @@ +/* + * 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 . + */ +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; + } +} diff --git a/src/org/mxchange/jshop/model/category/Category.java b/src/org/mxchange/jshop/model/category/Category.java new file mode 100644 index 0000000..d8ae5b0 --- /dev/null +++ b/src/org/mxchange/jshop/model/category/Category.java @@ -0,0 +1,80 @@ +/* + * 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 . + */ +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 { + + /** + * 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 ; +} diff --git a/src/org/mxchange/jshop/model/category/product/ProductCategory.java b/src/org/mxchange/jshop/model/category/product/ProductCategory.java new file mode 100644 index 0000000..7787b1f --- /dev/null +++ b/src/org/mxchange/jshop/model/category/product/ProductCategory.java @@ -0,0 +1,42 @@ +/* + * 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 . + */ +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 () { + } +} diff --git a/src/org/mxchange/jshop/model/customer/Customer.java b/src/org/mxchange/jshop/model/customer/Customer.java new file mode 100644 index 0000000..61fb863 --- /dev/null +++ b/src/org/mxchange/jshop/model/customer/Customer.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +package org.mxchange.jshop.model.customer; + +import org.mxchange.jcore.model.contact.Contact; + +/** + * A customer interface + * + * @author Roland Haeder + */ +public interface Customer extends Contact { +} diff --git a/src/org/mxchange/jshop/model/customer/ShopCustomer.java b/src/org/mxchange/jshop/model/customer/ShopCustomer.java new file mode 100644 index 0000000..4fd24c0 --- /dev/null +++ b/src/org/mxchange/jshop/model/customer/ShopCustomer.java @@ -0,0 +1,27 @@ +/* + * 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 . + */ +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 { +} diff --git a/src/org/mxchange/jshop/model/item/AddableBasketItem.java b/src/org/mxchange/jshop/model/item/AddableBasketItem.java new file mode 100644 index 0000000..066a76c --- /dev/null +++ b/src/org/mxchange/jshop/model/item/AddableBasketItem.java @@ -0,0 +1,86 @@ +/* + * 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 . + */ +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 { + + /** + * 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); +} diff --git a/src/org/mxchange/jshop/model/item/BaseItem.java b/src/org/mxchange/jshop/model/item/BaseItem.java new file mode 100644 index 0000000..53c9a53 --- /dev/null +++ b/src/org/mxchange/jshop/model/item/BaseItem.java @@ -0,0 +1,128 @@ +/* + * 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 . + */ +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; + } +} diff --git a/src/org/mxchange/jshop/model/item/basket/BasketItem.java b/src/org/mxchange/jshop/model/item/basket/BasketItem.java new file mode 100644 index 0000000..633a3ef --- /dev/null +++ b/src/org/mxchange/jshop/model/item/basket/BasketItem.java @@ -0,0 +1,58 @@ +/* + * 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 . + */ +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 + } +} diff --git a/src/org/mxchange/jshop/model/product/BaseProduct.java b/src/org/mxchange/jshop/model/product/BaseProduct.java new file mode 100644 index 0000000..bb2cb40 --- /dev/null +++ b/src/org/mxchange/jshop/model/product/BaseProduct.java @@ -0,0 +1,117 @@ +/* + * 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; + } +} diff --git a/src/org/mxchange/jshop/model/product/Product.java b/src/org/mxchange/jshop/model/product/Product.java new file mode 100644 index 0000000..75a0839 --- /dev/null +++ b/src/org/mxchange/jshop/model/product/Product.java @@ -0,0 +1,101 @@ +/* + * 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 . + */ +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 { + /** + * 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); +} diff --git a/src/org/mxchange/jshop/model/product/generic/GenericProduct.java b/src/org/mxchange/jshop/model/product/generic/GenericProduct.java new file mode 100644 index 0000000..cad00b8 --- /dev/null +++ b/src/org/mxchange/jshop/model/product/generic/GenericProduct.java @@ -0,0 +1,55 @@ +/* + * 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 . + */ +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); + } +}