From fdc389434946579f812966abb7a6525edb9f1baa Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Wed, 19 Dec 2018 20:13:54 +0100
Subject: [PATCH] Product-only: - implemented newly added method
 updatedProductCategory()
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 ...ncialsAdminProductCategorySessionBean.java | 49 ++++++++++++++++++-
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/java/org/mxchange/jproduct/model/category/FinancialsAdminProductCategorySessionBean.java b/src/java/org/mxchange/jproduct/model/category/FinancialsAdminProductCategorySessionBean.java
index 93950bd..e4dc3bf 100644
--- a/src/java/org/mxchange/jproduct/model/category/FinancialsAdminProductCategorySessionBean.java
+++ b/src/java/org/mxchange/jproduct/model/category/FinancialsAdminProductCategorySessionBean.java
@@ -55,7 +55,7 @@ public class FinancialsAdminProductCategorySessionBean extends BaseFinancialsPro
 	@Override
 	public Category addProductCategory (final Category category) throws CategoryAlreadyAddedException {
 		// Trace message
-		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.adminAddProductCategory: category={1} - CALLED!", this.getClass().getSimpleName(), category)); //NOI18N
+		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addProductCategory: category={1} - CALLED!", this.getClass().getSimpleName(), category)); //NOI18N
 
 		// Validate parameter
 		if (null == category) {
@@ -91,7 +91,52 @@ public class FinancialsAdminProductCategorySessionBean extends BaseFinancialsPro
 		this.getEntityManager().persist(category);
 
 		// Trace message
-		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.adminAddProductCategory: category.categoryId={1} - EXIT!", this.getClass().getSimpleName(), category.getCategoryId())); //NOI18N
+		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.addProductCategory: category.categoryId={1} - EXIT!", this.getClass().getSimpleName(), category.getCategoryId())); //NOI18N
+
+		// Return it
+		return category;
+	}
+
+	@Override
+	public Category updateProductCategory (final Category category) {
+		// Trace message
+		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductCategory: category={1} - CALLED!", this.getClass().getSimpleName(), category)); //NOI18N
+
+		// Validate parameter
+		if (null == category) {
+			// Throw NPE
+			throw new NullPointerException("category is null"); //NOI18N
+		} else if (category.getCategoryI18nKey() == null) {
+			// Throw it again
+			throw new NullPointerException("category.categoryI18nKey is null"); //NOI18N
+		} else if (category.getCategoryI18nKey().isEmpty()) {
+			// Throw it again
+			throw new IllegalArgumentException("category.categoryI18nKey is empty"); //NOI18N
+		} else if (category.getCategoryId() == null) {
+			// Throw it again ...
+			throw new NullPointerException("category.categoryId is null"); //NOI18N
+		} else if (category.getCategoryId() < 1) {
+			// Throw IAE
+			throw new IllegalArgumentException(MessageFormat.format("category.categoryId={0} is invalid.", category.getCategoryId())); //NOI18N
+		}
+
+		// Is a parent category set?
+		if (category.getParentCategory() instanceof Category) {
+			// Then make it managed
+			final Category managedCategory = this.createManaged(category.getParentCategory());
+
+			// Set it back
+			category.setParentCategory(managedCategory);
+		}
+
+		// Set updated instance
+		category.setCategoryUpdated(new Date());
+
+		// Persist it
+		this.getEntityManager().persist(category);
+
+		// Trace message
+		this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductCategory: category.categoryId={1} - EXIT!", this.getClass().getSimpleName(), category.getCategoryId())); //NOI18N
 
 		// Return it
 		return category;
-- 
2.39.5