]> git.mxchange.org Git - jfinancials-ejb.git/commitdiff
Product-only:
authorRoland Häder <roland@mxchange.org>
Tue, 19 May 2020 23:31:42 +0000 (01:31 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 19 May 2020 23:31:42 +0000 (01:31 +0200)
- let's use createManaged() where possible to avoid some duplicate code. It may
  look a bit to much encapsulation or to fine-granulated, the createManaged()
  method contains some validation on the entity instance and that is a good
  reason to have it encapsulated away.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/enterprise/product/BaseFinancialsProductEnterpriseBean.java
src/java/org/mxchange/jproduct/model/category/FinancialsAdminProductCategorySessionBean.java

index 7cdb1295201de5c9cfab6fa2d9cde23cd6d958aa..a473bed4c0d4ab275d94a1349df88bbe1ce3150d 100644 (file)
@@ -154,10 +154,7 @@ public abstract class BaseFinancialsProductEnterpriseBean extends BaseFinancials
                detachedProduct.setProductEntryUpdated(new Date());
 
                // Get product from it and find it
-               final Product foundProduct = this.getEntityManager().find(detachedProduct.getClass(), detachedProduct.getProductId());
-
-               // Should be found
-               assert (foundProduct instanceof Product) : MessageFormat.format("Product with id {0} not found, but should be.", detachedProduct.getProductId()); //NOI18N
+               final Product foundProduct = this.createManaged(detachedProduct);
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeProductData: foundProduct.productId={0}", foundProduct.getProductId())); //NOI18N
@@ -202,10 +199,7 @@ public abstract class BaseFinancialsProductEnterpriseBean extends BaseFinancials
                detachedCategory.setCategoryEntryUpdated(new Date());
 
                // Get category from it and find it
-               final Category foundCategory = this.getEntityManager().find(detachedCategory.getClass(), detachedCategory.getCategoryId());
-
-               // Should be found
-               assert (foundCategory instanceof Category) : MessageFormat.format("Category with id {0} not found, but should be.", detachedCategory.getCategoryId()); //NOI18N
+               final Category foundCategory = this.createManaged(detachedCategory);
 
                // Debug message
                this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeCategoryData: foundCategory.categoryId={0}", foundCategory.getCategoryId())); //NOI18N
index 82da89f2290315c9e93b1d6df87e9c66431d6f35..5542b9f8357ad769b881794214d7e6b01a5d2666 100644 (file)
@@ -130,13 +130,13 @@ public class FinancialsAdminProductCategorySessionBean extends BaseFinancialsPro
                }
 
                // Update instance
-               final Category updatedCategory = this.mergeProductCategoryData(category);
+               final Category managedCategory = this.mergeProductCategoryData(category);
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductCategory: updatedCategory.categoryId={1} - EXIT!", this.getClass().getSimpleName(), updatedCategory.getCategoryId())); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductCategory: managedCategory.categoryId={1} - EXIT!", this.getClass().getSimpleName(), managedCategory.getCategoryId())); //NOI18N
 
                // Return it
-               return updatedCategory;
+               return managedCategory;
        }
 
        /**