]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
toStoreable() is now "basicly finished"
authorRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 22:47:29 +0000 (00:47 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 14 Aug 2015 22:47:29 +0000 (00:47 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java
src/java/org/mxchange/pizzaapplication/product/pizza/PizzaProduct.java

index decfe1473c4f4defa2cfbf587d6696717907e9e4..993d10a831a53d185a839ae40a6b4d366b8d2ea4 100644 (file)
@@ -309,8 +309,45 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
         * @return An instance of a Storeable implementation
         */
        @Override
-       public Storeable toStoreable (final Map<String, String> map) {
-               throw new UnsupportedOperationException("Not supported yet: map=" + map);
+       public Storeable toStoreable (final Map<String, String> map) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace("map=" + map + " - CALLED!");
+
+               // Is map null?
+               if (map == null) {
+                       // Is null
+                       throw new NullPointerException("map is null");
+               } else if (map.isEmpty()) {
+                       // Map is empty
+                       throw new IllegalArgumentException("map is empty.");
+               }
+
+               // Debug message
+               this.getLogger().debug("Has to handle " + map.size() + " entries");
+
+               // Get iterator on all entries
+               Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
+
+               // Init object instance
+               Storeable instance = new PizzaProduct();
+
+               // Iterate over all
+               while (iterator.hasNext()) {
+                       // Get next entry
+                       Map.Entry<String, String> entry = iterator.next();
+
+                       // Debug message
+                       this.getLogger().debug("entry:" + entry.getKey() + "=" + entry.getValue());
+
+                       // Try to set value
+                       instance.setValueFromColumn(entry.getKey(), entry.getValue());
+               }
+
+               // Trace message
+               this.getLogger().trace("instance=" + instance + " - EXIT!");
+
+               // Return it
+               return instance;
        }
 
        @Override
index c6881a7f95ce2fe670a1d968d3a7ea2154f86d9d..7070029d061ce5c62ca42c59d96c049ff0da5caf 100644 (file)
@@ -25,24 +25,10 @@ import org.mxchange.pizzaapplication.product.Product;
  * @author Roland Haeder
  */
 public class PizzaProduct extends BaseProduct implements Product {
-
        /**
-        * Constructor for products with a name and a price.
-        * 
-        * @param id Id number of product
-        * @param title Name of product
-        * @param price Price
-        * @deprecated Please use constructor with category and available
+        * Default constructor
         */
-       @Deprecated
-       public PizzaProduct (final Long id, final String title, final Float price) {
-               // Trace message
-               this.getLogger().trace("id=" + id + ",title=" + title + ",price=" + price + " - CALLED!");
-
-               // Set all
-               this.setId(id);
-               this.setTitle(title);
-               this.setPrice(price);
+       public PizzaProduct () {
        }
 
        /**