]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Organized members
authorRoland Haeder <roland@mxchange.org>
Tue, 18 Aug 2015 12:58:26 +0000 (14:58 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 18 Aug 2015 12:58:26 +0000 (14:58 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/database/frontend/category/PizzaCategoryDatabaseFrontend.java

index 7824c3c9e915875dcdd31186df8708d3f574a2f0..4b358b421dafe10bf48ac5ede8298bc06a01a561 100644 (file)
@@ -167,6 +167,72 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
                return (Iterator<Category>) iterator;
        }
 
+       @Override
+       public Category getCategory (final Product product) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product));
+               
+               // product must not be null
+               if (product == null) {
+                       // Abort here
+                       throw new NullPointerException("product is null");
+               }
+               
+               // Get category id from it
+               Long id = product.getCategory();
+               
+               // Debug message
+               this.getLogger().debug(MessageFormat.format("id={0}", id));
+               
+               // It should be >0 here
+               assert(id > 0) : MessageFormat.format("id={0} must be larger zero", id);
+               
+               // Then construct a search instance
+               SearchableCriteria criteria = new SearchCriteria();
+               
+               // Add id to it
+               criteria.addCriteria(PizzaCategoryDatabaseConstants.COLUMN_ID, id);
+               
+               // Only one entry is find
+               criteria.setLimit(1);
+               
+               // Run it on backend
+               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
+               
+               // Debug log
+               this.getLogger().debug(MessageFormat.format("result({0})={1}", result, result.size()));
+               
+               // Init category instance
+               Category category = null;
+               
+               // Is there one entry?
+               if (result.hasNext()) {
+                       // Read result from it
+                       Storeable storeable = result.next();
+                       
+                       // Debug message
+                       this.getLogger().debug(MessageFormat.format("storeable={0}", storeable));
+                       
+                       // Is it instance of Category?
+                       if (storeable instanceof Category) {
+                               // Then cast it
+                               category = (Category) storeable;
+                       }
+               }
+               
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("category={0} - EXIT!", category));
+               
+               // Return it
+               return category;
+       }
+
+       @Override
+       public String getIdName () {
+               // Return column id
+               return PizzaCategoryDatabaseConstants.COLUMN_ID;
+       }
+
        /**
         * Gets a Result back from given ResultSet instance
         *
@@ -297,70 +363,4 @@ public class PizzaCategoryDatabaseFrontend extends BaseDatabaseFrontend implemen
                // Return it
                return instance;
        }
-
-       @Override
-       public String getIdName () {
-               // Return column id
-               return PizzaCategoryDatabaseConstants.COLUMN_ID;
-       }
-
-       @Override
-       public Category getCategory (final Product product) throws IOException, BadTokenException, CorruptedDatabaseFileException, SQLException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("product={0} - CALLED!", product));
-
-               // product must not be null
-               if (product == null) {
-                       // Abort here
-                       throw new NullPointerException("product is null");
-               }
-
-               // Get category id from it
-               Long id = product.getCategory();
-
-               // Debug message
-               this.getLogger().debug(MessageFormat.format("id={0}", id));
-
-               // It should be >0 here
-               assert(id > 0) : MessageFormat.format("id={0} must be larger zero", id);
-
-               // Then construct a search instance
-               SearchableCriteria criteria = new SearchCriteria();
-
-               // Add id to it
-               criteria.addCriteria(PizzaCategoryDatabaseConstants.COLUMN_ID, id);
-
-               // Only one entry is find
-               criteria.setLimit(1);
-
-               // Run it on backend
-               Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(criteria);
-
-               // Debug log
-               this.getLogger().debug(MessageFormat.format("result({0})={1}", result, result.size()));
-
-               // Init category instance
-               Category category = null;
-
-               // Is there one entry?
-               if (result.hasNext()) {
-                       // Read result from it
-                       Storeable storeable = result.next();
-
-                       // Debug message
-                       this.getLogger().debug(MessageFormat.format("storeable={0}", storeable));
-
-                       // Is it instance of Category?
-                       if (storeable instanceof Category) {
-                               // Then cast it
-                               category = (Category) storeable;
-                       }
-               }
-
-               // Trace message
-               this.getLogger().trace(MessageFormat.format("category={0} - EXIT!", category));
-
-               // Return it
-               return category;
-       }
 }