- added method addItem() for adding items, please make sure to call ...
- added method isItemAdded() which checks if the given item is found by its id number
- added method getItem() to get an item from given Product instance
Signed-off-by:Roland Häder <roland@mxchange.org>
j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.5
-j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.persistence.jar
+j2ee.platform.classpath=${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
-j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar
-j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar
+j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar
+j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath=
j2ee.server.type=gfv3ee6
jar.compress=false
import java.io.Serializable;
import java.sql.SQLException;
import java.text.MessageFormat;
-import java.util.LinkedHashMap;
-import java.util.Map;
import org.mxchange.jcore.BaseFrameworkSystem;
import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
import org.mxchange.pizzaapplication.database.frontend.basket.BasketDatabaseFrontend;
*/
private static final long serialVersionUID = 784396762230845717L;
- /**
- * Item map
- */
- private final Map<Long, T> items;
-
/**
* Protected constructor with session instance
*
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- // Init item map instance
- this.items = new LinkedHashMap<>();
-
// Create frontend instance
BasketFrontend frontend = new BasketDatabaseFrontend();
throw new IllegalArgumentException("item has already been added. Did you miss to call isItemAdded()?"); //NOI18N
}
- // Add it to map
- this.items.put(item.getId(), item);
+ // Add item to database
+ ((BasketFrontend) this.getFrontend()).addItem(item);
// Trace call
this.getLogger().trace("EXIT!"); //NOI18N
}
@Override
- public T getItem (final Product product) {
+ public AddableBasketItem getItem (final Product product) {
// Trace message
this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product)); //NOI18N
this.getLogger().debug("Product " + product.getTitle() + " has id " + product.getId()); //NOI18N
// Get item instance from map by product's id number (both are the same)
- T item = this.items.get(product.getId());
+ AddableBasketItem item = ((BasketFrontend) this.getFrontend()).getItem(product);
// Is it null?
if (item == null) {
}
// Call map's method
- boolean isAdded = this.items.containsKey(item.getId());
+ boolean isAdded = ((BasketFrontend) this.getFrontend()).isItemAdded(item);
// Trace message
this.getLogger().trace(MessageFormat.format("isAdded={0} - EXIT!", isAdded)); //NOI18N
* @param product Product instance
* @return Item instance or null
*/
- public T getItem (final Product product);
+ public AddableBasketItem getItem (final Product product);
}
import org.mxchange.jcore.database.frontend.BaseDatabaseFrontend;
import org.mxchange.jcore.database.storage.Storeable;
import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
+import org.mxchange.pizzaapplication.item.AddableBasketItem;
+import org.mxchange.pizzaapplication.product.Product;
/**
* A database frontend for baskets
this.initBackend();
}
+ @Override
+ public void addItem (final AddableBasketItem item) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
/**
* Shuts down the database layer
*
throw new UnsupportedOperationException("Not supported yet.");
}
+ @Override
+ public AddableBasketItem getItem (final Product product) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
@Override
public Storeable getStoreableAtRow (final int rowIndex) {
throw new UnsupportedOperationException("Not supported yet: rowIndex=" + rowIndex);
}
+ @Override
+ public boolean isItemAdded (final AddableBasketItem item) {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
@Override
public Storeable toStoreable (final Map<String, String> map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
throw new UnsupportedOperationException("Not supported yet: map=" + map);
package org.mxchange.pizzaapplication.database.frontend.basket;
import org.mxchange.jcore.database.frontend.DatabaseFrontend;
+import org.mxchange.pizzaapplication.item.AddableBasketItem;
+import org.mxchange.pizzaapplication.product.Product;
/**
* An interface for basket database frontends
* @author Roland Haeder
*/
public interface BasketFrontend extends DatabaseFrontend {
+ /**
+ * Adds given item instance to database. Please note that the item's id
+ * comes from product table.
+ *
+ * @param item Item instance to add
+ */
+ public void addItem (final AddableBasketItem item);
+
+ /**
+ * Gets an item instance for given Product instance
+ *
+ * @param product Prodduct instance
+ * @return An item instance
+ */
+ public AddableBasketItem getItem (final Product product);
+
+ /**
+ * Checks if given item instance is found in basket by its id number.
+ *
+ * @param item Item instance to check
+ * @return Whether the item is already added to the basket
+ */
+ public boolean isItemAdded (final AddableBasketItem item);
}