From 6dcc63162011891ebd3475b1943bcdcc4606bf7a Mon Sep 17 00:00:00 2001
From: Roland Haeder <roland@mxchange.org>
Date: Tue, 18 Aug 2015 08:46:47 +0200
Subject: [PATCH] =?utf8?q?Sorted=20members=20Signed-off-by:Roland=20H?=
 =?utf8?q?=C3=A4der=20<roland@mxchange.org>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 .../product/PizzaProductDatabaseFrontend.java | 132 +++++++++---------
 1 file changed, 66 insertions(+), 66 deletions(-)

diff --git a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java
index 452c0d52..7f3f2010 100644
--- a/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java
+++ b/src/java/org/mxchange/pizzaapplication/database/frontend/product/PizzaProductDatabaseFrontend.java
@@ -59,6 +59,53 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		this.initBackend();
 	}
 
+	/**
+	 * Adds product to database by given title, price and category id
+	 * @param title Product title
+	 * @param price Product price
+	 * @param category Product category id
+	 * @param available Availability of product (selectable by customer)
+	 * @throws java.sql.SQLException If any SQL errors occur
+	 */
+	@Override
+	public void addProduct (final String title, final Float price, final Long category, final Boolean available) throws SQLException, IOException {
+		// Trace message
+		this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); //NOI18N
+		
+		// Title should not be null
+		if (title == null) {
+			// Abort here
+			throw new NullPointerException("title is null"); //NOI18N
+		} else if (price == null) {
+			// Abort here
+			throw new NullPointerException("price is null"); //NOI18N
+		} else if (category == null) {
+			// Abort here
+			throw new NullPointerException("category is null"); //NOI18N
+		} else if (available == null) {
+			// Abort here
+			throw new NullPointerException("available is null"); //NOI18N
+		}
+		
+		// Clear dataset from previous usage
+		this.clearDataSet();
+		
+		// Add title and parent
+		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_TITLE, title);
+		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_PRICE, price);
+		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_CATEGORY, category);
+		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, available);
+		
+		// Handle this over to the backend
+		Result<? extends Storeable> result = this.doInsertDataSet();
+		
+		// Debug message
+		this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
+		
+		// Trace message
+		this.getLogger().trace("EXIT!"); //NOI18N
+	}
+
 	/**
 	 * Shuts down the database layer
 	 * 
@@ -106,18 +153,23 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		return v;
 	}
 
+	/**
+	 * An iterator on all products
+	 *
+	 * @return Iterator on all products
+	 * @throws java.io.IOException If any IO error occurs
+	 * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found in a file-based database backend's file ... ;-)
+	 * @throws java.sql.SQLException If any SQL errors occur
+	 */
 	@Override
 	@SuppressWarnings ("unchecked")
-	public Iterator<Product> getAvailableProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+	public Iterator<Product> getAllProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
 		// Trace message
 		this.getLogger().trace("CALLED!"); //NOI18N
 
 		// Instance search criteria
 		SearchableCriteria critera = new SearchCriteria();
 
-		// Add criteria
-		critera.addCriteria(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, true);
-
 		// Run the query
 		Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(critera);
 
@@ -134,23 +186,18 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		return (Iterator<Product>) iterator;
 	}
 
-	/**
-	 * An iterator on all products
-	 *
-	 * @return Iterator on all products
-	 * @throws java.io.IOException If any IO error occurs
-	 * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found in a file-based database backend's file ... ;-)
-	 * @throws java.sql.SQLException If any SQL errors occur
-	 */
 	@Override
 	@SuppressWarnings ("unchecked")
-	public Iterator<Product> getAllProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+	public Iterator<Product> getAvailableProducts () throws IOException, BadTokenException, SQLException, CorruptedDatabaseFileException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
 		// Trace message
 		this.getLogger().trace("CALLED!"); //NOI18N
 
 		// Instance search criteria
 		SearchableCriteria critera = new SearchCriteria();
 
+		// Add criteria
+		critera.addCriteria(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, true);
+		
 		// Run the query
 		Result<? extends Storeable> result = this.getBackend().doSelectByCriteria(critera);
 
@@ -167,6 +214,12 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		return (Iterator<Product>) iterator;
 	}
 
+	@Override
+	public String getIdName () {
+		// Return column id
+		return PizzaProductDatabaseConstants.COLUMN_ID;
+	}
+
 	/**
 	 * Gets a Result back from given ResultSet instance
 	 *
@@ -253,53 +306,6 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		return isFound;
 	}
 
-	/**
-	 * Adds product to database by given title, price and category id
-	 * @param title Product title
-	 * @param price Product price
-	 * @param category Product category id
-	 * @param available Availability of product (selectable by customer)
-	 * @throws java.sql.SQLException If any SQL errors occur
-	 */
-	@Override
-	public void addProduct (final String title, final Float price, final Long category, final Boolean available) throws SQLException, IOException {
-		// Trace message
-		this.getLogger().trace(MessageFormat.format("title={0},price={1},category={2} - CALLED!", title, price, category)); //NOI18N
-
-		// Title should not be null
-		if (title == null) {
-			// Abort here
-			throw new NullPointerException("title is null"); //NOI18N
-		} else if (price == null) {
-			// Abort here
-			throw new NullPointerException("price is null"); //NOI18N
-		} else if (category == null) {
-			// Abort here
-			throw new NullPointerException("category is null"); //NOI18N
-		} else if (available == null) {
-			// Abort here
-			throw new NullPointerException("available is null"); //NOI18N
-		}
-
-		// Clear dataset from previous usage
-		this.clearDataSet();
-
-		// Add title and parent
-		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_TITLE, title);
-		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_PRICE, price);
-		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_CATEGORY, category);
-		this.addToDataSet(PizzaProductDatabaseConstants.COLUMN_AVAILABLE, available);
-
-		// Handle this over to the backend
-		Result<? extends Storeable> result = this.doInsertDataSet();
-
-		// Debug message
-		this.getLogger().debug(MessageFormat.format("result={0}", result)); //NOI18N
-
-		// Trace message
-		this.getLogger().trace("EXIT!"); //NOI18N
-	}
-
 	/**
 	 * Converts the given map into a Storeable instance, depending on which class implements it. All
 	 * keys are being interpreted as class fields/attributes and their respective setters are being searched for. As
@@ -349,10 +355,4 @@ public class PizzaProductDatabaseFrontend extends BaseDatabaseFrontend implement
 		// Return it
 		return instance;
 	}
-
-	@Override
-	public String getIdName () {
-		// Return column id
-		return PizzaProductDatabaseConstants.COLUMN_ID;
-	}
 }
-- 
2.39.5