* @author Roland Haeder<roland@mxchange.org>
*/
public interface PizzaApplication extends Application {
+
/**
- * Some "getter" for a linked list of only available products
- *
- * @return Only available products
+ * Adds given category data from request to database
+ *
+ * @param category Category instance
+ * @throws org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException If the category's title has been used
*/
- public Deque<Product> getAvailableProducts ();
+ public void doAdminAddCategory (final Category category) throws CategoryTitleAlreadyUsedException;
/**
- * Some "getter" for a linked list of all products
+ * Adds given product data from request to database
*
- * @return All products
+ * @param product Product instance
+ * @throws org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException If the * product's title has been used
*/
- public Deque<Product> getAllProducts ();
+ public void doAdminAddProduct (final Product product) throws ProductTitleAlreadyUsedException;
/**
* Some "getter" for a linked list of all categories
public Deque<Category> getAllCategories ();
/**
- * Initializes this instance with given ServletContext
+ * Some "getter" for a an array of all categories
*
- * @throws java.sql.SQLException If an SQL error occurs
- * @throws java.io.IOException If an IO error occurs
+ * @return All categories
*/
- public void init () throws SQLException, IOException;
+ public Iterator<Category> getAllCategoriesIterator ();
/**
- * Some "getter" for a an array of only available products
- *
- * @return Only available products
+ * Some "getter" for a linked list of all products
+ *
+ * @return All products
*/
- public Iterator<Product> getAvailableProductsIterator ();
+ public Deque<Product> getAllProducts ();
/**
* Some "getter" for a an array of all products
public Iterator<Product> getAllProductsIterator ();
/**
- * Some "getter" for a an array of all categories
+ * Some "getter" for a linked list of only available products
*
- * @return All categories
+ * @return Only available products
*/
- public Iterator<Category> getAllCategoriesIterator ();
+ public Deque<Product> getAvailableProducts ();
/**
- * Adds given category data from request to database
+ * Some "getter" for a an array of only available products
*
- * @param category Category instance
- * @throws org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException If the category's title has been used
+ * @return Only available products
*/
- public void doAdminAddCategory (final Category category) throws CategoryTitleAlreadyUsedException;
+ public Iterator<Product> getAvailableProductsIterator ();
/**
- * Adds given product data from request to database
+ * Initializes this instance with given ServletContext
*
- * @param product Product instance
- * @throws org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException If the product's title has been used
+ * @throws java.sql.SQLException If an SQL error occurs
+ * @throws java.io.IOException If an IO error occurs
*/
- public void doAdminAddProduct (final Product product) throws ProductTitleAlreadyUsedException;
+ public void init () throws SQLException, IOException;
}
* @author Roland Haeder<roland@mxchange.org>
*/
public class PizzaServiceApplication extends BaseFrameworkSystem implements PizzaApplication {
+
/**
* Default constructor
*/
this.getLogger().trace("CALLED!"); //NOI18N
}
- @Override
- public Deque<Category> getAllCategories () {
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- @Override
- public Deque<Product> getAllProducts () {
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- @Override
- public Deque<Product> getAvailableProducts () {
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- @Override
- public void init () throws SQLException {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Is the bundle initialized?
- if (!BaseFrameworkSystem.isBundledInitialized()) {
- // Temporary initialize default bundle
- // TODO The enum Gender uses this
- this.initBundle();
- }
-
- // Trace message
- this.getLogger().trace("EXIT!"); //NOI18N
- }
-
- @Override
- public void doBootstrap () {
- throw new UnsupportedOperationException("Not supported yet."); //NOI18N
- }
-
- @Override
- public void doMainLoop () {
- throw new UnsupportedOperationException("Not supported yet."); //NOI18N
- }
-
- @Override
- public void doShutdown () {
- throw new UnsupportedOperationException("Not supported yet."); //NOI18N
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public Iterator<Product> getAvailableProductsIterator () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public Iterator<Product> getAllProductsIterator () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- @Override
- @SuppressWarnings ("unchecked")
- public Iterator<Category> getAllCategoriesIterator () {
- // Trace message
- this.getLogger().trace("CALLED!"); //NOI18N
-
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
- /**
- * Checks whether given category title is already used
- *
- * @param title Title of category to check
- * @return Whether it has been found
- */
- private boolean isCategoryTitleUsed(final String title) {
- // Trace message
- this.getLogger().trace(MessageFormat.format("title={0} - CALLED!", title)); //NOI18N
-
- // Unfinished
- throw new UnsupportedOperationException("Unfinished method.");
- }
-
@Override
public void doAdminAddCategory (final Category category) throws CategoryTitleAlreadyUsedException {
// Trace message
// Get all fields
String title = category.getTitle();
- Long parentId = category.getParentId();
+ Category parentCategory = category.getParentCategory();
// Debug message
- this.getLogger().debug(MessageFormat.format("title={0},parentId={1}", title, parentId)); //NOI18N
+ this.getLogger().debug(MessageFormat.format("title={0},parentCategory={1}", title, parentCategory)); //NOI18N
// Init variables for casting
Integer id = 0;
} else if (title.isEmpty()) {
// Is left empty
throw new IllegalArgumentException("title is empty."); //NOI18N
- } else if ((parentId == null) || (parentId == 0)) {
+ } else if (null == parentCategory) {
// Is left empty
- throw new IllegalArgumentException("parentId is empty."); //NOI18N
+ throw new IllegalArgumentException("parentCategory is null."); //NOI18N
}
// Try to check if title is used already
//this.getLogger().trace("EXIT!"); //NOI18N
}
+ @Override
+ public void doBootstrap () {
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+ }
+
+ @Override
+ public void doMainLoop () {
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+ }
+
+ @Override
+ public void doShutdown () {
+ throw new UnsupportedOperationException("Not supported yet."); //NOI18N
+ }
+
+ @Override
+ public Deque<Category> getAllCategories () {
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public Iterator<Category> getAllCategoriesIterator () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ public Deque<Product> getAllProducts () {
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public Iterator<Product> getAllProductsIterator () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ public Deque<Product> getAvailableProducts () {
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ @SuppressWarnings ("unchecked")
+ public Iterator<Product> getAvailableProductsIterator () {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ @Override
+ public void init () throws SQLException {
+ // Trace message
+ this.getLogger().trace("CALLED!"); //NOI18N
+
+ // Is the bundle initialized?
+ if (!BaseFrameworkSystem.isBundledInitialized()) {
+ // Temporary initialize default bundle
+ // TODO The enum Gender uses this
+ this.initBundle();
+ }
+
+ // Trace message
+ this.getLogger().trace("EXIT!"); //NOI18N
+ }
+
/**
- * Checks if product's title is already used.
- *
- * @param product Product instance
+ * Checks whether given category title is already used
+ *
+ * @param title Title of category to check
+ * @return Whether it has been found
+ */
+ private boolean isCategoryTitleUsed (final String title) {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("title={0} - CALLED!", title)); //NOI18N
+
+ // Unfinished
+ throw new UnsupportedOperationException("Unfinished method.");
+ }
+
+ /**
+ * Checks if category's title is already used.
+ *
+ * @param category Category instance
* @return Whether the product title is already used
*/
- private boolean isProductTitleUsed (final Product product) {
+ private boolean isCategoryTitleUsed (final Category category) {
// Trace message
- this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", product)); //NOI18N
+ this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N
// Init title
- String title = product.getTitle();
+ String title = category.getTitle();
// category must not be null and "title" must be found and non-empty
- if (null == product) {
+ if (null == category) {
// Abort here
throw new NullPointerException("category is null"); //NOI18N
} else if (null == title) {
// title is not set
- throw new IllegalArgumentException("product title is not set"); //NOI18N
+ throw new IllegalArgumentException("category title is not set."); //NOI18N
} else if (title.isEmpty()) {
// Is left empty
- throw new IllegalArgumentException("product title is empty"); //NOI18N
+ throw new IllegalArgumentException("category title is empty."); //NOI18N
}
// Default is not used
- // TODO Call backend
- throw new UnsupportedOperationException("not finished yet.");
+ boolean isUsed = this.isCategoryTitleUsed(title);
// Trace message
- //this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N
+ this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N
// Return it
- //return isUsed;
+ return isUsed;
}
/**
- * Checks if category's title is already used.
- *
- * @param category Category instance
+ * Checks if product's title is already used.
+ *
+ * @param product Product instance
* @return Whether the product title is already used
*/
- private boolean isCategoryTitleUsed (final Category category) {
+ private boolean isProductTitleUsed (final Product product) {
// Trace message
- this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", category)); //NOI18N
+ this.getLogger().trace(MessageFormat.format("category={0} - CALLED!", product)); //NOI18N
// Init title
- String title = category.getTitle();
+ String title = product.getTitle();
// category must not be null and "title" must be found and non-empty
- if (null == category) {
+ if (null == product) {
// Abort here
throw new NullPointerException("category is null"); //NOI18N
} else if (null == title) {
// title is not set
- throw new IllegalArgumentException("category title is not set."); //NOI18N
+ throw new IllegalArgumentException("product title is not set"); //NOI18N
} else if (title.isEmpty()) {
// Is left empty
- throw new IllegalArgumentException("category title is empty."); //NOI18N
+ throw new IllegalArgumentException("product title is empty"); //NOI18N
}
// Default is not used
- boolean isUsed = this.isCategoryTitleUsed(title);
+ // TODO Call backend
+ throw new UnsupportedOperationException("not finished yet.");
// Trace message
- this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N
+ //this.getLogger().trace(MessageFormat.format("isUsed={0} - EXIT!", isUsed)); //NOI18N
// Return it
- return isUsed;
+ //return isUsed;
}
}