]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Product-only:
authorRoland Häder <roland@mxchange.org>
Thu, 30 Apr 2020 21:38:27 +0000 (23:38 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 30 Apr 2020 21:38:27 +0000 (23:38 +0200)
- added administrative action backing bean for product categories and moved
  addProductCategory() method over there.
- added admin-edit-product-category view
- implemented editProductCategory()
- renamed backing bean property allCategories to allProductCategories
- added missing i18n strings

Signed-off-by: Roland Häder <roland@mxchange.org>
20 files changed:
src/java/org/mxchange/jfinancials/beans/generic_product/list/FinancialsProductListWebViewBean.java
src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestController.java [deleted file]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java [deleted file]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/product_category/list/FinancialsCategoryListWebViewBean.java
src/java/org/mxchange/localization/product_de_DE.properties
src/java/org/mxchange/localization/product_en_US.properties
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/generic_product/admin_form_generic_product_data.tpl
web/WEB-INF/templates/admin/product_category/admin_form_generic_product_data.tpl [new file with mode: 0644]
web/admin/generic_product/admin_generic_product_list.xhtml
web/admin/product_category/admin_product_category_edit.xhtml [new file with mode: 0644]
web/admin/product_category/admin_product_category_list.xhtml

index 45fbd855ccab30ed30a9556974b9b2fd5fb54d75..30a544c67dd23813c103fcbeb96981cd4efce737 100644 (file)
@@ -213,11 +213,11 @@ public class FinancialsProductListWebViewBean extends BaseFinancialsBean impleme
         * Initialization of this bean
         */
        @PostConstruct
-       public void init () {
+       public void initializeList () {
                // Is cache there?
                if (!this.productCache.iterator().hasNext()) {
                        // "Walk" through all entries and add to cache
-                       for (final Product product : this.productBean.fetchAllProducts()) {
+                       for (final Product product : this.productBean.fetchAllGenericProducts()) {
                                // Add it by primary key
                                this.productCache.put(product.getProductId(), product);
                        }
@@ -237,8 +237,7 @@ public class FinancialsProductListWebViewBean extends BaseFinancialsBean impleme
                                public int compare (final Product product1, final Product product2) {
                                        return product1.getProductId() > product2.getProductId() ? 1 : product1.getProductId() < product2.getProductId() ? -1 : 0;
                                }
-                       }
-                       );
+                       });
 
                        // Set whole list
                        this.setFilteredProducts(this.getAllProducts());
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestBean.java
deleted file mode 100644 (file)
index e1a5185..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.product_category;
-
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.faces.FacesException;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewController;
-import org.mxchange.jproduct.events.category.added.AddedCategoryEvent;
-import org.mxchange.jproduct.events.category.added.CategoryAddedEvent;
-import org.mxchange.jproduct.exceptions.category.CategoryAlreadyAddedException;
-import org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote;
-import org.mxchange.jproduct.model.category.Category;
-import org.mxchange.jproduct.model.category.ProductCategory;
-
-/**
- * Main application class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminCategoryController")
-@RequestScoped
-public class FinancialAdminCategoryWebRequestBean extends BaseFinancialsBean implements FinancialAdminCategoryWebRequestController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 5_819_375_183_472_871L;
-
-       /**
-        * Event for added shop categories
-        */
-       @Inject
-       @Any
-       private Event<AddedCategoryEvent> categoryAddedEvent;
-
-       /**
-        * Remote bean for categories
-        */
-       @EJB (lookup = "java:global/jfinancials-ejb/adminCategory!org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote")
-       private AdminCategorySessionBeanRemote categoryBean;
-
-       /**
-        * Category categoryI18nKey
-        */
-       private String categoryI18nKey;
-
-       /**
-        * General category controller
-        */
-       @Inject
-       private FinancialsCategoryListWebViewController categoryListController;
-
-       /**
-        * Whether this category is shown in statistics
-        */
-       private Boolean categoryShownInStatistics;
-
-       /**
-        * Parent category
-        */
-       private Category parentCategory;
-
-       /**
-        * Default constructor
-        */
-       public FinancialAdminCategoryWebRequestBean () {
-               // Call super constructor
-               super();
-       }
-
-       /**
-        * Adds given category data from request to database
-        * <p>
-        * @throws FaceletException If something unexpected happened
-        */
-       public void addCategory () throws FaceletException {
-               // Is i18n key already used?
-               if (this.categoryListController.isCategoryI18nKeyAdded(this.getCategoryI18nKey())) {
-                       // Throw exception
-                       throw new FacesException("Category i18n key " + this.getCategoryI18nKey() + " is already used.");
-               }
-
-               // Create category
-               final Category category = this.createCategoryInstance();
-
-               // Declare updated category instance
-               final Category updatedCategory;
-
-               try {
-                       // Deligate to remote bean
-                       updatedCategory = this.categoryBean.addProductCategory(category);
-               } catch (final CategoryAlreadyAddedException ex) {
-                       // Continue to throw
-                       throw new FacesException(ex);
-               }
-
-               // Fire event
-               this.categoryAddedEvent.fire(new CategoryAddedEvent(updatedCategory));
-       }
-
-       /**
-        * Getter for category i18n key
-        * <p>
-        * @return Category i18n key
-        */
-       public String getCategoryI18nKey () {
-               return this.categoryI18nKey;
-       }
-
-       /**
-        * Setter for category i18n key
-        * <p>
-        * @param categoryI18nKey Category i18n key
-        */
-       public void setCategoryI18nKey (final String categoryI18nKey) {
-               this.categoryI18nKey = categoryI18nKey;
-       }
-
-       /**
-        * Getter for whether category is shown in statistics
-        * <p>
-        * @return Whether category is shown in statistics
-        */
-       public Boolean getCategoryShownInStatistics () {
-               return this.categoryShownInStatistics;
-       }
-
-       /**
-        * Setter for whether category is shown in statistics
-        * <p>
-        * @param categoryShownInStatistics Whether category is shown in statistics
-        */
-       public void setCategoryShownInStatistics (final Boolean categoryShownInStatistics) {
-               this.categoryShownInStatistics = categoryShownInStatistics;
-       }
-
-       /**
-        * Getter for parent id
-        * <p>
-        * @return Parent id
-        */
-       public Category getParentCategory () {
-               return this.parentCategory;
-       }
-
-       /**
-        * Setter for parent category
-        * <p>
-        * @param parentCategory Parent category to set
-        */
-       public void setParentCategory (final Category parentCategory) {
-               this.parentCategory = parentCategory;
-       }
-
-       /**
-        * Creates a category instance with all fields (except primary key)
-        * <p>
-        * @return Category instance
-        */
-       private Category createCategoryInstance () {
-               // Create category
-               final Category category = new ProductCategory(
-                                          this.getCategoryI18nKey(),
-                                          this.getCategoryShownInStatistics()
-                          );
-
-               // Set all optional fields
-               category.setParentCategory(this.getParentCategory());
-
-               // Return it
-               return category;
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminCategoryWebRequestController.java
deleted file mode 100644 (file)
index 740d0f8..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.product_category;
-
-import java.io.Serializable;
-
-/**
- * An interface for product controllers for "ADMIN" role
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialAdminCategoryWebRequestController extends Serializable {
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestBean.java
new file mode 100644 (file)
index 0000000..edc7f1a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * Administrative backing bean for product categories application class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminProductCategoryController")
+@RequestScoped
+public class FinancialAdminProductCategoryWebRequestBean extends BaseFinancialsBean implements FinancialAdminProductCategoryWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_819_375_183_472_871L;
+
+       /**
+        * Default constructor
+        */
+       public FinancialAdminProductCategoryWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialAdminProductCategoryWebRequestController.java
new file mode 100644 (file)
index 0000000..8c13ad5
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category;
+
+import java.io.Serializable;
+
+/**
+ * An interface for product controllers for "ADMIN" role
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialAdminProductCategoryWebRequestController extends Serializable {
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestBean.java
deleted file mode 100644 (file)
index 80e8d4a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.product_category;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Named;
-import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-
-/**
- * General (product) category controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("categoryController")
-@RequestScoped
-public class FinancialCategoryWebRequestBean extends BaseFinancialsBean implements FinancialCategoryWebRequestController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 58_137_539_530_279L;
-
-       /**
-        * Default constructor
-        */
-       public FinancialCategoryWebRequestBean () {
-               // Call super constructor
-               super();
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialCategoryWebRequestController.java
deleted file mode 100644 (file)
index 5a25e84..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2016 - 2020 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.beans.product_category;
-
-import java.io.Serializable;
-
-/**
- * An interface for (product) categories
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialCategoryWebRequestController extends Serializable {
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestBean.java
new file mode 100644 (file)
index 0000000..86f70d4
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category;
+
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * General (product) category controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("categoryController")
+@RequestScoped
+public class FinancialProductCategoryWebRequestBean extends BaseFinancialsBean implements FinancialProductCategoryWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 58_137_539_530_279L;
+
+       /**
+        * Default constructor
+        */
+       public FinancialProductCategoryWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/FinancialProductCategoryWebRequestController.java
new file mode 100644 (file)
index 0000000..5b7d63c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category;
+
+import java.io.Serializable;
+
+/**
+ * An interface for (product) categories
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialProductCategoryWebRequestController extends Serializable {
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestBean.java
new file mode 100644 (file)
index 0000000..87d7c80
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category.action;
+
+import java.text.MessageFormat;
+import java.util.Objects;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.product_category.list.FinancialsCategoryListWebViewController;
+import org.mxchange.jproduct.events.category.added.AdminAddedCategoryEvent;
+import org.mxchange.jproduct.events.category.added.ObservableAdminAddedCategoryEvent;
+import org.mxchange.jproduct.events.category.updated.AdminUpdatedCategoryEvent;
+import org.mxchange.jproduct.events.category.updated.ObservableAdminUpdatedCategoryEvent;
+import org.mxchange.jproduct.exceptions.category.CategoryAlreadyAddedException;
+import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException;
+import org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote;
+import org.mxchange.jproduct.model.category.Categories;
+import org.mxchange.jproduct.model.category.Category;
+import org.mxchange.jproduct.model.category.ProductCategory;
+
+/**
+ * Administrative action backing bean for product categories
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminProductCategoryActionController")
+@RequestScoped
+public class FinancialAdminProductCategoryActionWebRequestBean extends BaseFinancialsBean implements FinancialAdminProductCategoryActionWebRequestController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_819_375_183_472_873L;
+
+       /**
+        * Event for added shop categories
+        */
+       @Inject
+       @Any
+       private Event<ObservableAdminAddedCategoryEvent> adminAddedCategoryEvent;
+
+       /**
+        * Remote bean for categories
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/adminCategory!org.mxchange.jproduct.model.category.AdminCategorySessionBeanRemote")
+       private AdminCategorySessionBeanRemote adminCategoryBean;
+
+       /**
+        * Event for added shop categories
+        */
+       @Inject
+       @Any
+       private Event<ObservableAdminUpdatedCategoryEvent> adminUpdatedCategoryEvent;
+
+       /**
+        * Category categoryI18nKey
+        */
+       private String categoryI18nKey;
+
+       /**
+        * Category's primary key
+        */
+       private Long categoryId;
+
+       /**
+        * Whether this category is shown in statistics
+        */
+       private Boolean categoryShownInStatistics;
+
+       /**
+        * Currently worked on category
+        */
+       private Category currentCategory;
+
+       /**
+        * Parent category
+        */
+       private Category parentCategory;
+
+       /**
+        * General category controller
+        */
+       @Inject
+       private FinancialsCategoryListWebViewController productCategoryListController;
+
+       /**
+        * Default constructor
+        */
+       public FinancialAdminProductCategoryActionWebRequestBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Adds given category data from request to database
+        */
+       public void addCategory () {
+               // Is i18n key already used?
+               if (this.productCategoryListController.isCategoryI18nKeyAdded(this.getCategoryI18nKey())) {
+                       // Throw exception
+                       throw new FacesException(MessageFormat.format("Category i18n key {0} is already used.", this.getCategoryI18nKey())); //NOI18N
+               }
+
+               // Create category
+               final Category category = this.createCategoryInstance();
+
+               // Declare updated category instance
+               final Category updatedCategory;
+
+               try {
+                       // Deligate to remote bean
+                       updatedCategory = this.adminCategoryBean.addProductCategory(category);
+               } catch (final CategoryAlreadyAddedException ex) {
+                       // Continue to throw
+                       throw new FacesException(ex);
+               }
+
+               // Fire event
+               this.adminAddedCategoryEvent.fire(new AdminAddedCategoryEvent(updatedCategory));
+       }
+
+       /**
+        * Copies all properties from current category instance to backing bean
+        * properties.
+        */
+       public void copyAllCategoryProperties () {
+               // Check if current category is set
+               if (this.getCurrentCategory() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.currentCategory is null"); //NOI18N
+               } else if (this.getCurrentCategory().getCategoryId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.currentCategory.categoryId is null"); //NOI18N
+               } else if (this.getCurrentCategory().getCategoryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("this.currentCategory.categoryId={0} is invalid", this.getCurrentCategory().getCategoryId())); //NOI18N
+               }
+
+               // Copy all fields, except timestamps
+               this.setCategoryI18nKey(this.getCurrentCategory().getCategoryI18nKey());
+               this.setCategoryId(this.getCurrentCategory().getCategoryId());
+               this.setCategoryShownInStatistics(this.getCurrentCategory().getCategoryShownInStatistics());
+               this.setParentCategory(this.getCurrentCategory().getParentCategory());
+       }
+
+       /**
+        * Getter for category i18n key
+        * <p>
+        * @return Category i18n key
+        */
+       public String getCategoryI18nKey () {
+               return this.categoryI18nKey;
+       }
+
+       /**
+        * Setter for category i18n key
+        * <p>
+        * @param categoryI18nKey Category i18n key
+        */
+       public void setCategoryI18nKey (final String categoryI18nKey) {
+               this.categoryI18nKey = categoryI18nKey;
+       }
+
+       /**
+        * Getter for category's primary key
+        * <p>
+        * @return Category's primary key
+        */
+       public Long getCategoryId () {
+               return this.categoryId;
+       }
+
+       /**
+        * Setter for category's primary key
+        * <p>
+        * @param categoryId Current category
+        */
+       public void setCategoryId (final Long categoryId) {
+               this.categoryId = categoryId;
+       }
+
+       /**
+        * Getter for whether category is shown in statistics
+        * <p>
+        * @return Whether category is shown in statistics
+        */
+       public Boolean getCategoryShownInStatistics () {
+               return this.categoryShownInStatistics;
+       }
+
+       /**
+        * Setter for whether category is shown in statistics
+        * <p>
+        * @param categoryShownInStatistics Whether category is shown in statistics
+        */
+       public void setCategoryShownInStatistics (final Boolean categoryShownInStatistics) {
+               this.categoryShownInStatistics = categoryShownInStatistics;
+       }
+
+       /**
+        * Getter for current category
+        * <p>
+        * @return Current category
+        */
+       public Category getCurrentCategory () {
+               return this.currentCategory;
+       }
+
+       /**
+        * Setter for current category
+        * <p>
+        * @param currentCategory Current category
+        */
+       public void setCurrentCategory (final Category currentCategory) {
+               this.currentCategory = currentCategory;
+       }
+
+       /**
+        * Getter for parent id
+        * <p>
+        * @return Parent id
+        */
+       public Category getParentCategory () {
+               return this.parentCategory;
+       }
+
+       /**
+        * Setter for parent category
+        * <p>
+        * @param parentCategory Parent category to set
+        */
+       public void setParentCategory (final Category parentCategory) {
+               this.parentCategory = parentCategory;
+       }
+
+       /**
+        * Updates given category data from request to database
+        * <p>
+        * @return Redirection outcome
+        */
+       public String updateCategory () {
+               // Check if current category is set
+               if (this.getCurrentCategory() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.currentCategory is null"); //NOI18N
+               } else if (this.getCurrentCategory().getCategoryId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.currentCategory.categoryId is null"); //NOI18N
+               } else if (this.getCurrentCategory().getCategoryId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("this.currentCategory.categoryId={0} is invalid.", this.getCurrentCategory().getCategoryId())); //NOI18N
+               }
+
+               // Create category
+               final Category category = this.createCategoryInstance();
+
+               // Has the product changed?
+               if (Objects.equals(category, this.getCurrentCategory())) {
+                       // Is the same product data, output message
+                       this.showFacesMessage("admin-form-edit-product-category:categoryI18nKey", "ADMIN_PRODUCT_CATEGORY_NOT_UPDATED", FacesMessage.SEVERITY_WARN); //NOI18N
+                       return ""; //NOI18N
+               }
+
+               // Copy all fields from it to current
+               Categories.copyCategoryData(category, this.getCurrentCategory());
+
+               // Declare updated category instance
+               final Category updatedCategory;
+
+               try {
+                       // Deligate to remote bean
+                       updatedCategory = this.adminCategoryBean.updateProductCategory(this.getCurrentCategory());
+               } catch (final CategoryNotFoundException ex) {
+                       // Continue to throw
+                       throw new FacesException(ex);
+               }
+
+               // Fire event
+               this.adminUpdatedCategoryEvent.fire(new AdminUpdatedCategoryEvent(updatedCategory));
+
+               // Return outcome to admin-list
+               return "admin_list_product_categories"; //NOI18N
+       }
+
+       /**
+        * Creates a category instance with all fields (except primary key)
+        * <p>
+        * @return Category instance
+        */
+       private Category createCategoryInstance () {
+               // Create category
+               final Category category = new ProductCategory(
+                                          this.getCategoryI18nKey(),
+                                          this.getCategoryShownInStatistics()
+                          );
+
+               // Set all optional fields
+               category.setCategoryId(this.getCategoryId());
+               category.setParentCategory(this.getParentCategory());
+
+               // Return it
+               return category;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/product_category/action/FinancialAdminProductCategoryActionWebRequestController.java
new file mode 100644 (file)
index 0000000..abc8dc6
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 - 2020 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.product_category.action;
+
+import java.io.Serializable;
+
+/**
+ * An interface for product controllers for "ADMIN" role
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialAdminProductCategoryActionWebRequestController extends Serializable {
+
+}
index bd850fc39c31bfb0ced041c601b3ac6ff64bfd3a..34aa90e33a573edeac2cd46f11b8ecb1e9d55297 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jfinancials.beans.product_category.list;
 import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
 import java.util.Comparator;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
@@ -30,7 +31,8 @@ import javax.faces.view.ViewScoped;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
-import org.mxchange.jproduct.events.category.added.AddedCategoryEvent;
+import org.mxchange.jproduct.events.category.added.ObservableAdminAddedCategoryEvent;
+import org.mxchange.jproduct.events.category.updated.ObservableAdminUpdatedCategoryEvent;
 import org.mxchange.jproduct.exceptions.category.CategoryNotFoundException;
 import org.mxchange.jproduct.model.category.Category;
 import org.mxchange.jproduct.model.category.CategorySessionBeanRemote;
@@ -40,7 +42,7 @@ import org.mxchange.jproduct.model.category.CategorySessionBeanRemote;
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@Named ("categoryListController")
+@Named ("productCategoryListController")
 @ViewScoped
 public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implements FinancialsCategoryListWebViewController {
 
@@ -52,7 +54,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
        /**
         * List of all categories
         */
-       private final List<Category> allCategories;
+       private final List<Category> allProductCategories;
 
        /**
         * EJB for general category stuff
@@ -70,7 +72,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
        /**
         * A list of filtered categories
         */
-       private List<Category> filteredCategories;
+       private List<Category> filteredProductCategories;
 
        /**
         * Selected category
@@ -85,7 +87,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
                super();
 
                // Init list
-               this.allCategories = new LinkedList<>();
+               this.allProductCategories = new LinkedList<>();
        }
 
        /**
@@ -93,7 +95,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
         * <p>
         * @param event Event to be observed
         */
-       public void afterCategoryAddedEvent (@Observes final AddedCategoryEvent event) {
+       public void afterAdminAddedCategoryEvent (@Observes final ObservableAdminAddedCategoryEvent event) {
                // Is all valid?
                if (null == event) {
                        // Throw NPE
@@ -111,7 +113,33 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
 
                // Add the category
                this.categoryCache.put(event.getAddedCategory().getCategoryId(), event.getAddedCategory());
-               this.getAllCategories().add(event.getAddedCategory());
+               this.uniqueAddProductCategory(event.getAddedCategory());
+       }
+
+       /**
+        * Observes events fired after a new product category has been updated
+        * <p>
+        * @param event Event to be observed
+        */
+       public void afterAdminUpdatedCategoryEvent (@Observes final ObservableAdminUpdatedCategoryEvent event) {
+               // Is all valid?
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedCategory() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("event.updatedCategory is null"); //NOI18N
+               } else if (event.getUpdatedCategory().getCategoryId() == null) {
+                       // And again ...
+                       throw new NullPointerException("event.updatedCategory.categoryId is null"); //NOI18N
+               } else if (event.getUpdatedCategory().getCategoryId() < 1) {
+                       // Id is invalid
+                       throw new IllegalArgumentException(MessageFormat.format("event.updatedCategory.categoryId={0} is not valid.", event.getUpdatedCategory().getCategoryId())); //NOI18N
+               }
+
+               // Add the category
+               this.categoryCache.put(event.getUpdatedCategory().getCategoryId(), event.getUpdatedCategory());
+               this.uniqueAddProductCategory(event.getUpdatedCategory());
        }
 
        @Override
@@ -141,9 +169,9 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
         * @return All categories
         */
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Category> getAllCategories () {
+       public List<Category> getAllProductCategories () {
                // Return it
-               return this.allCategories;
+               return this.allProductCategories;
        }
 
        /**
@@ -152,18 +180,18 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
         * @return Filtered category list
         */
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Category> getFilteredCategories () {
-               return this.filteredCategories;
+       public List<Category> getFilteredProductCategories () {
+               return this.filteredProductCategories;
        }
 
        /**
         * Setter for filtered category list
         * <p>
-        * @param filteredCategories Filtered category list
+        * @param filteredProductCategories Filtered category list
         */
        @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setFilteredCategories (final List<Category> filteredCategories) {
-               this.filteredCategories = filteredCategories;
+       public void setFilteredProductCategories (final List<Category> filteredProductCategories) {
+               this.filteredProductCategories = filteredProductCategories;
        }
 
        /**
@@ -188,26 +216,26 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
         * Initialization of this bean
         */
        @PostConstruct
-       public void init () {
+       public void initializeList () {
                // Is cache there?
                if (!this.categoryCache.iterator().hasNext()) {
                        // "Walk" through all entries and add to cache
-                       for (final Category category : this.categoryBean.fetchAllCategories()) {
+                       for (final Category category : this.categoryBean.fetchAllProductCategories()) {
                                // Add it by primary key
                                this.categoryCache.put(category.getCategoryId(), category);
                        }
                }
 
                // Is the list empty, but filled cache?
-               if (this.allCategories.isEmpty() && this.categoryCache.iterator().hasNext()) {
+               if (this.getAllProductCategories().isEmpty() && this.categoryCache.iterator().hasNext()) {
                        // Build up list
                        for (final Cache.Entry<Long, Category> currentEntry : this.categoryCache) {
                                // Add to list
-                               this.allCategories.add(currentEntry.getValue());
+                               this.getAllProductCategories().add(currentEntry.getValue());
                        }
 
                        // Sort list
-                       this.allCategories.sort(new Comparator<Category>() {
+                       this.getAllProductCategories().sort(new Comparator<Category>() {
                                @Override
                                public int compare (final Category category1, final Category category2) {
                                        return category1.getCategoryId() > category2.getCategoryId() ? 1 : category1.getCategoryId() < category2.getCategoryId() ? -1 : 0;
@@ -216,7 +244,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
                        );
 
                        // Set whole list
-                       this.setFilteredCategories(this.getAllCategories());
+                       this.setFilteredProductCategories(this.getAllProductCategories());
                }
        }
 
@@ -235,7 +263,7 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
                boolean isFound = false;
 
                // Check all added,products
-               for (final Category category : this.getAllCategories()) {
+               for (final Category category : this.getAllProductCategories()) {
                        // Is i18n key the same?
                        if (Objects.equals(category.getCategoryI18nKey(), categoryI18nKey)) {
                                // Found it
@@ -248,4 +276,30 @@ public class FinancialsCategoryListWebViewBean extends BaseFinancialsBean implem
                return isFound;
        }
 
+       /**
+        * Uniquely adds given category to "all" list
+        * <p>
+        * @param category Category instance
+        */
+       private void uniqueAddProductCategory (final Category category) {
+               // Get iterator from
+               final Iterator<Category> iterator = this.getAllProductCategories().iterator();
+
+               // Loop through all
+               while (iterator.hasNext()) {
+                       // Get current element
+                       final Category currentCategory = iterator.next();
+
+                       // Does primary key match?
+                       if (Objects.equals(category.getCategoryId(), currentCategory.getCategoryId())) {
+                               // Remove it and stop iterating
+                               iterator.remove();
+                               break;
+                       }
+               }
+
+               // Re-add it
+               this.getAllProductCategories().add(category);
+       }
+
 }
index 36d982fb21825be2d2e840645336158e27d9a6c0..166e2e932f5ddd13118459814ec4383aa22addf0 100644 (file)
@@ -205,3 +205,14 @@ ERROR_PRODUCT_FSC_NUMBER_NOT_VALID=Fehler: FSC-Nummer des Produktes entspricht n
 ADMIN_GENERIC_PRODUCT_NOT_UPDATED=Sie haben keine Aenderungen am dem Produkt vorgenommen.
 ADMIN_PRODUCT_FSC_NUMBER_HEADER=FSC-Nummer:
 PRODUCT_FSC_NUMBER_TITLE=The FSC-Nummer des Produktes.
+ERROR_PARAMETER_CATEGORY_ID_NOT_SET=Fehler: Parameter "categoryId" ist nicht gesetzt.
+PARAMETER_CATEGORY_ID_INVALID=Produkt mit Parameter "categoryId" nicht gefunden.
+PAGE_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT=Produktkategorien editieren
+CONTENT_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT=Produktkategorien editieren:
+#@TODO Please fix German umlauts!
+ADMIN_EDIT_PRODUCT_CATEGORY_MINIMUM_DATA=Geben Sie mindestens den I18n-Schluessel ein, um diese Produktkategorie zu editieren.
+#@TODO Please fix German umlauts!
+BUTTON_ADMIN_EDIT_PRODUCT_CATEGORY=Produktkategorie aendern
+ADMIN_EDIT_PRODUCT_CATEGORY_TITLE=Produktkategorie mit Id {0} editieren:
+#@TODO Please fix German umlauts!
+ADMIN_PRODUCT_CATEGORY_NOT_UPDATED=Sie haben die Produktkategorie nicht gaendert.
index e2e86e0bd4c86620403f93fa2f21970b89e4deaa..aff88ae38953db418b99c11a57ce4b79e8ac42d9 100644 (file)
@@ -164,3 +164,11 @@ ERROR_PRODUCT_FSC_NUMBER_NOT_VALID=Error: FSC number not valid format: Cxxxxxx
 ADMIN_GENERIC_PRODUCT_NOT_UPDATED=You have not changed any product data.
 ADMIN_PRODUCT_FSC_NUMBER_HEADER=FSC number:
 PRODUCT_FSC_NUMBER_TITLE=The FSC number of the product.
+ERROR_PARAMETER_CATEGORY_ID_NOT_SET=Error: Parameter "categoryId" is not set.
+PARAMETER_CATEGORY_ID_INVALID=Product category with given "categoryId" not found.
+PAGE_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT=Edit product category
+CONTENT_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT=Edit product category:
+ADMIN_EDIT_PRODUCT_CATEGORY_MINIMUM_DATA=Please enter at least the i18n key to edit this product category.
+BUTTON_ADMIN_EDIT_PRODUCT_CATEGORY=Change product category
+ADMIN_EDIT_PRODUCT_CATEGORY_TITLE=Edit product category Id {0}:
+ADMIN_PRODUCT_CATEGORY_NOT_UPDATED=You have not changed the product category.
index 532c3a14b3a0e7785e553d604fcee461b429f4f7..fa377e6cf18192f6c1af66a589e4917be53a69df 100644 (file)
                        <to-view-id>/admin/product_category/admin_product_category_assign_parent.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/admin/product_category/admin_product_category_edit.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>admin_list_product_categories</from-outcome>
+                       <to-view-id>/admin/product_category/admin_product_category_list.xhtml</to-view-id>
+                       <redirect></redirect>
+               </navigation-case>
+       </navigation-rule>
        <navigation-rule>
                <from-view-id>/admin/generic_product/admin_generic_product_list.xhtml</from-view-id>
                <navigation-case>
index 29ad4f67d828180334c0bad39034fd210a32189f..2cb9d0622643e1ca69369b42824407fa42230e8e 100644 (file)
@@ -37,7 +37,7 @@
                                        />
 
                                <f:selectItems
-                                       value="#{categoryListController.allCategories}"
+                                       value="#{productCategoryListController.allProductCategories}"
                                        var="category"
                                        itemValue="#{category}"
                                        itemLabel="#{productBeanHelper.renderProductCategory(category)}"
diff --git a/web/WEB-INF/templates/admin/product_category/admin_form_generic_product_data.tpl b/web/WEB-INF/templates/admin/product_category/admin_form_generic_product_data.tpl
new file mode 100644 (file)
index 0000000..4586203
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://xmlns.jcp.org/jsf/core"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:p="http://primefaces.org/ui"
+       >
+
+       <p:fieldset legend="#{product.ADMIN_PRODUCT_CATEGORY_DATA_LEGEND}">
+               <p:panelGrid
+                       layout="grid"
+                       columns="2"
+                       columnClasses="ui-grid-col-4,ui-grid-col-8"
+                       styleClass="ui-noborder"
+                       >
+                       <p:outputLabel for="parentCategory" value="#{product.ADMIN_ASSIGN_PARENT_PRODUCT_CATEGORY}" />
+                       <p:selectOneMenu
+                               id="parentCategory"
+                               value="#{adminProductCategoryActionController.parentCategory}"
+                               filter="true"
+                               filterMatchMode="contains"
+                               title="#{product.ADMIN_ASSIGN_PARENT_PRODUCT_CATEGORY_TITLE}"
+                               >
+
+                               <f:converter converterId="ProductCategoryConverter" />
+
+                               <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
+
+                               <f:selectItems
+                                       value="#{productCategoryListController.allProductCategories}"
+                                       var="category"
+                                       itemValue="#{category}"
+                                       itemLabel="#{productBeanHelper.renderProductCategory(category)}"
+                                       />
+                       </p:selectOneMenu>
+
+                       <p:outputLabel for="categoryI18nKey" value="#{product.ADMIN_ENTER_CATEGORY_I18N_KEY}" />
+                       <p:inputText
+                               id="categoryI18nKey"
+                               value="#{adminProductCategoryActionController.categoryI18nKey}"
+                               maxlength="255"
+                               required="true"
+                               requiredMessage="#{product.ADMIN_CATEGORY_I18N_KEY_REQUIRED}"
+                               title="#{product.ADMIN_ENTER_CATEGORY_I18N_KEY_TITLE}"
+                               validatorMessage="#{product.ADMIN_ENTERED_CATEGORY_I18N_KEY_ALREADY_ADDED}"
+                               >
+                               <f:validator validatorId="ProductCategoryValidator" />
+                       </p:inputText>
+
+                       <p:outputLabel for="categoryShownInStatistics" value="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS}" />
+                       <p:selectBooleanCheckbox
+                               id="categoryShownInStatistics"
+                               value="#{adminProductCategoryActionController.categoryShownInStatistics}"
+                               required="true"
+                               requiredMessage="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS_REQUIRED}"
+                               title="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS_TITLE}"
+                               />
+               </p:panelGrid>
+       </p:fieldset>
+</ui:composition>
index cb23b86b754f8c097b399ca2a79042dafc84c86e..b13f54eb18388c8e5253c9cb93df8970b2279252 100644 (file)
                                                        <f:converter converterId="ProductCategoryConverter" />
 
                                                        <f:selectItems
-                                                               value="#{categoryListController.allCategories}"
+                                                               value="#{productCategoryListController.allProductCategories}"
                                                                var="category"
                                                                itemValue="#{category}"
                                                                itemLabel="#{productBeanHelper.renderProductCategory(category)}"
diff --git a/web/admin/product_category/admin_product_category_edit.xhtml b/web/admin/product_category/admin_product_category_edit.xhtml
new file mode 100644 (file)
index 0000000..d80f14a
--- /dev/null
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       template="/WEB-INF/templates/admin/admin_base.tpl"
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:h="http://xmlns.jcp.org/jsf/html"
+       xmlns:f="http://xmlns.jcp.org/jsf/core"
+       xmlns:p="http://primefaces.org/ui"
+       >
+
+       <ui:define name="metadata">
+               <f:metadata>
+                       <f:viewParam
+                               name="categoryId"
+                               value="#{adminProductCategoryActionController.currentCategory}"
+                               converter="ProductCategoryConverter"
+                               required="true"
+                               requiredMessage="#{product.ERROR_PARAMETER_CATEGORY_ID_NOT_SET}"
+                               converterMessage="#{product.PARAMETER_CATEGORY_ID_INVALID}"
+                               />
+
+                       <f:viewAction
+                               action="#{adminProductCategoryActionController.copyAllCategoryProperties()}"
+                               />
+               </f:metadata>
+       </ui:define>
+
+       <ui:define name="document_admin_title">
+               <h:outputText value="#{product.PAGE_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT}" />
+       </ui:define>
+
+       <ui:define name="content_header">
+               <h:outputText value="#{product.CONTENT_TITLE_ADMIN_PRODUCT_CATEGORY_EDIT}" />
+       </ui:define>
+
+       <ui:define name="content">
+               <h:form
+                       id="admin-form-edit-generic-product"
+                       rendered="#{not empty adminProductCategoryActionController.currentCategory}"
+                       >
+                       <h:inputHidden value="#{adminProductCategoryActionController.categoryId}" />
+
+                       <p:panelGrid
+                               columns="1"
+                               layout="grid"
+                               >
+                               <f:facet name="header">
+                                       <h:outputFormat
+                                               value="#{product.ADMIN_EDIT_PRODUCT_CATEGORY_TITLE}"
+                                               title="#{local[adminProductCategoryActionController.categoryI18nKey]}"
+                                               >
+                                               <f:param value="#{adminProductCategoryActionController.categoryId}" />
+                                       </h:outputFormat>
+                               </f:facet>
+
+                               <h:panelGroup styleClass="para" layout="block">
+                                       <h:outputText value="#{product.ADMIN_EDIT_PRODUCT_CATEGORY_MINIMUM_DATA}" />
+                               </h:panelGroup>
+
+                               <ui:include src="/WEB-INF/templates/admin/product_category/admin_form_generic_product_data.tpl" />
+
+                               <f:facet name="footer">
+                                       <p:panelGrid columns="2" layout="grid">
+                                               <p:commandButton
+                                                       type="reset"
+                                                       value="#{msg.BUTTON_RESET_FORM}"
+                                                       />
+
+                                               <p:commandButton
+                                                       type="submit"
+                                                       value="#{product.BUTTON_ADMIN_EDIT_PRODUCT_CATEGORY}"
+                                                       action="#{adminProductCategoryActionController.updateCategory()}"
+                                                       />
+                                       </p:panelGrid>
+                               </f:facet>
+                       </p:panelGrid>
+               </h:form>
+       </ui:define>
+</ui:composition>
index 9f5f9f64c9626c938d28f252fb91b92a4fcc2141..67c61b13e273b0f23245f2384f0dc41c13e6acba 100644 (file)
                        <p:dataTable
                                id="categoryList"
                                var="category"
-                               value="#{categoryListController.allCategories}"
+                               value="#{productCategoryListController.allProductCategories}"
                                paginator="true"
                                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
-                               filteredValue="#{categoryListController.filteredCategories}"
+                               filteredValue="#{productCategoryListController.filteredProductCategories}"
                                rows="10"
                                rowKey="#{category.categoryId}"
                                reflow="true"
@@ -35,7 +35,7 @@
                                emptyMessage="#{product.ADMIN_EMPTY_LIST_PRODUCT_CATEGORIES}"
                                widgetVar="categoryList"
                                selectionMode="single"
-                               selection="#{categoryListController.selectedCategory}"
+                               selection="#{productCategoryListController.selectedCategory}"
                                skipChildren="true"
                                >
 
                                                        <f:converter converterId="ProductCategoryConverter" />
 
                                                        <f:selectItems
-                                                               value="#{categoryListController.allCategories}"
+                                                               value="#{productCategoryListController.allProductCategories}"
                                                                var="category"
                                                                itemValue="#{category}"
                                                                itemLabel="#{productBeanHelper.renderProductCategory(category)}"
                                responsive="true"
                                >
                                <p:outputPanel id="category-details">
-                                       <p:panelGrid columns="2" rendered="#{not empty categoryListController.selectedCategory}">
+                                       <p:panelGrid columns="2" rendered="#{not empty productCategoryListController.selectedCategory}">
                                                <f:facet name="header">
                                                        <h:outputFormat value="#{product.ADMIN_CATEGORY_DETAILS_HEADER}">
-                                                               <f:param value="#{local[categoryListController.selectedCategory.categoryI18nKey]}" />
-                                                               <f:param value="#{categoryListController.selectedCategory.categoryId}" />
+                                                               <f:param value="#{local[productCategoryListController.selectedCategory.categoryI18nKey]}" />
+                                                               <f:param value="#{productCategoryListController.selectedCategory.categoryId}" />
                                                        </h:outputFormat>
                                                </f:facet>
 
                                                <p:outputLabel value="#{msg.ID_HEADER}" title="#{product.CATEGORY_ID_NUMBER_TITLE}" />
-                                               <h:outputText value="#{categoryListController.selectedCategory.categoryId}" />
+                                               <h:outputText value="#{productCategoryListController.selectedCategory.categoryId}" />
 
                                                <p:outputLabel value="#{msg.ADMIN_I18N_KEY_HEADER}" title="#{product.CATEGORY_I18N_KEY_TITLE}" />
-                                               <h:outputText value="#{categoryListController.selectedCategory.categoryI18nKey}" title="#{local[categoryListController.selectedCategory.categoryI18nKey]}" />
+                                               <h:outputText value="#{productCategoryListController.selectedCategory.categoryI18nKey}" title="#{local[productCategoryListController.selectedCategory.categoryI18nKey]}" />
 
                                                <p:outputLabel value="#{product.CATEGORY_IN_STATISTICS_HEADER}" title="#{product.CATEGORY_SHOW_IN_STATISTICS_TITLE}" />
-                                               <h:outputText value="#{categoryListController.selectedCategory.categoryShownInStatistics ? msg.CHOICE_YES : msg.CHOICE_NO}" />
+                                               <h:outputText value="#{productCategoryListController.selectedCategory.categoryShownInStatistics ? msg.CHOICE_YES : msg.CHOICE_NO}" />
 
                                                <p:outputLabel value="#{product.CATEGORY_PARENT_HEADER}" title="#{product.CATEGORY_PARENT_TITLE}" />
                                                <p:link
                                                        outcome="admin_show_product_category"
-                                                       value="#{local[categoryListController.selectedCategory.parentCategory.categoryI18nKey]}"
+                                                       value="#{local[productCategoryListController.selectedCategory.parentCategory.categoryI18nKey]}"
                                                        title="#{product.ADMIN_LINK_SHOW_PRODUCT_CATEGORY_TITLE}"
-                                                       rendered="#{not empty categoryListController.selectedCategory.parentCategory}"
+                                                       rendered="#{not empty productCategoryListController.selectedCategory.parentCategory}"
                                                        >
-                                                       <f:param name="categoryId" value="#{categoryListController.selectedCategory.parentCategory.categoryId}" />
+                                                       <f:param name="categoryId" value="#{productCategoryListController.selectedCategory.parentCategory.categoryId}" />
                                                </p:link>
-                                               <h:outputText value="#{product.CATEGORY_HAS_NO_PARENT}" rendered="#{empty categoryListController.selectedCategory.parentCategory}" />
+                                               <h:outputText value="#{product.CATEGORY_HAS_NO_PARENT}" rendered="#{empty productCategoryListController.selectedCategory.parentCategory}" />
 
                                                <p:outputLabel value="#{msg.ENTRY_CREATED_HEADER}" title="#{product.ADMIN_CATEGORY_ENTRY_CREATED_TITLE}" />
-                                               <h:outputText value="#{categoryListController.selectedCategory.categoryEntryCreated}">
+                                               <h:outputText value="#{productCategoryListController.selectedCategory.categoryEntryCreated}">
                                                        <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
                                                </h:outputText>
 
                                                <p:outputLabel value="#{msg.ENTRY_UPDATED_HEADER}" title="#{product.ADMIN_CATEGORY_ENTRY_UPDATED_TITLE}" />
-                                               <h:outputText value="#{categoryListController.selectedCategory.categoryEntryUpdated}">
+                                               <h:outputText value="#{productCategoryListController.selectedCategory.categoryEntryUpdated}">
                                                        <f:convertDateTime type="both" timeStyle="short" dateStyle="short" />
                                                </h:outputText>
                                        </p:panelGrid>
                                        <h:outputText value="#{product.ADMIN_ADD_PRODUCT_CATEGORY_MINIMUM_DATA}" />
                                </h:panelGroup>
 
-                               <p:fieldset legend="#{product.ADMIN_PRODUCT_CATEGORY_DATA_LEGEND}">
-                                       <p:panelGrid
-                                               layout="grid"
-                                               columns="2"
-                                               columnClasses="ui-grid-col-4,ui-grid-col-8"
-                                               styleClass="ui-noborder"
-                                               >
-                                               <p:outputLabel for="parentCategory" value="#{product.ADMIN_ASSIGN_PARENT_PRODUCT_CATEGORY}" />
-                                               <p:selectOneMenu
-                                                       id="parentCategory"
-                                                       value="#{adminCategoryController.parentCategory}"
-                                                       filter="true"
-                                                       filterMatchMode="contains"
-                                                       title="#{product.ADMIN_ASSIGN_PARENT_PRODUCT_CATEGORY_TITLE}"
-                                                       >
-
-                                                       <f:converter converterId="ProductCategoryConverter" />
-
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-
-                                                       <f:selectItems
-                                                               value="#{categoryListController.allCategories}"
-                                                               var="category"
-                                                               itemValue="#{category}"
-                                                               itemLabel="#{productBeanHelper.renderProductCategory(category)}"
-                                                               />
-                                               </p:selectOneMenu>
-
-                                               <p:outputLabel for="categoryI18nKey" value="#{product.ADMIN_ENTER_CATEGORY_I18N_KEY}" />
-                                               <p:inputText
-                                                       id="categoryI18nKey"
-                                                       value="#{adminCategoryController.categoryI18nKey}"
-                                                       maxlength="255"
-                                                       required="true"
-                                                       requiredMessage="#{product.ADMIN_CATEGORY_I18N_KEY_REQUIRED}"
-                                                       title="#{product.ADMIN_ENTER_CATEGORY_I18N_KEY_TITLE}"
-                                                       validatorMessage="#{product.ADMIN_ENTERED_CATEGORY_I18N_KEY_ALREADY_ADDED}"
-                                                       >
-                                                       <f:validator validatorId="ProductCategoryValidator" />
-                                               </p:inputText>
-
-                                               <p:outputLabel for="categoryShownInStatistics" value="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS}" />
-                                               <p:selectBooleanCheckbox
-                                                       id="categoryShownInStatistics"
-                                                       value="#{adminCategoryController.categoryShownInStatistics}"
-                                                       required="true"
-                                                       requiredMessage="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS_REQUIRED}"
-                                                       title="#{product.ADMIN_ENABLE_CATEGORY_IN_STATISTICS_TITLE}"
-                                                       />
-                                       </p:panelGrid>
-                               </p:fieldset>
+                               <ui:include src="/WEB-INF/templates/admin/product_category/admin_form_generic_product_data.tpl" />
 
                                <f:facet name="footer">
                                        <p:panelGrid columns="2" layout="grid">