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
*
// 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;
- }
}