]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/beans/business/branchoffice/action/FinancialsAdminBranchOfficeActionWebRequestBean.java
Updated copyright year
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / beans / business / branchoffice / action / FinancialsAdminBranchOfficeActionWebRequestBean.java
index d84e53ab63974d8d5157b857944389b39366246d..6fc0eee961cc6048cb0ade616365e08a216e6b69 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 - 2020 Free Software Foundation
+ * Copyright (C) 2017 - 2022 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
@@ -29,6 +29,7 @@ import javax.faces.FacesException;
 import javax.faces.application.FacesMessage;
 import javax.inject.Inject;
 import javax.inject.Named;
+import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontactsbusiness.events.branchoffice.added.AdminBranchOfficeAddedEvent;
 import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableAdminBranchOfficeAddedEvent;
 import org.mxchange.jcontactsbusiness.events.branchoffice.updated.AdminBranchOfficeUpdatedEvent;
@@ -40,7 +41,6 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessio
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
 import org.mxchange.jcoreee.dates.DayOfTheWeek;
@@ -91,7 +91,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
        /**
         * Contact person in branch office
         */
-       private Employable branchContactEmployee;
+       private Contact branchContactEmployee;
 
        /**
         * Country
@@ -144,7 +144,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
        /**
         * Owner/leader of branch office
         */
-       private Employable branchOwnerEmployee;
+       private Contact branchOwnerEmployee;
 
        /**
         * Store
@@ -396,7 +396,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
         * <p>
         * @return Branch office contact person
         */
-       public Employable getBranchContactEmployee () {
+       public Contact getBranchContactEmployee () {
                return this.branchContactEmployee;
        }
 
@@ -405,7 +405,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
         * <p>
         * @param branchContactEmployee Branch office contact person
         */
-       public void setBranchContactEmployee (final Employable branchContactEmployee) {
+       public void setBranchContactEmployee (final Contact branchContactEmployee) {
                this.branchContactEmployee = branchContactEmployee;
        }
 
@@ -560,7 +560,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
         * <p>
         * @return Branch office contact person
         */
-       public Employable getBranchOwnerEmployee () {
+       public Contact getBranchOwnerEmployee () {
                return this.branchOwnerEmployee;
        }
 
@@ -569,7 +569,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
         * <p>
         * @param branchOwnerEmployee Branch office contact person
         */
-       public void setBranchOwnerEmployee (final Employable branchOwnerEmployee) {
+       public void setBranchOwnerEmployee (final Contact branchOwnerEmployee) {
                this.branchOwnerEmployee = branchOwnerEmployee;
        }
 
@@ -871,8 +871,17 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
         * @return Redirection outcome
         */
        public String updateBranchOffice () {
-               // Id should be set
-               if (this.getBranchId() == null) {
+               // Validate current product instance and id
+               if (this.getCurrentBranchOffice() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.product is null"); //NOI18N
+               } else if (this.getCurrentBranchOffice().getBranchId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.product.branchId is null"); //NOI18N
+               } else if (this.getCurrentBranchOffice().getBranchId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("this.product.branchId={0} is not valid.", this.getCurrentBranchOffice().getBranchId())); //NOI18N
+               } else if (this.getBranchId() == null) {
                        // Throw NPE
                        throw new NullPointerException("this.branchId is null"); //NOI18N
                } else if (this.getBranchId() < 1) {
@@ -911,7 +920,7 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
                this.updatedBranchOfficeEvent.fire(new AdminBranchOfficeUpdatedEvent(updatedBranchOffice));
 
                // Redirect to list view
-               return "admin_list_branch_office"; //NOI18N
+               return "admin_list_branch_offices"; //NOI18N
        }
 
        /**
@@ -996,13 +1005,13 @@ public class FinancialsAdminBranchOfficeActionWebRequestBean extends BaseFinanci
                DialableFaxNumber fax = null;
 
                // Are all required fields set?
-               if (this.getLandLineAreaCode() != null && this.getLandLineCountry() != null && this.getLandLineNumber() != null) {
+               if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) {
                        // Initialize land-line instance
                        landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
                }
 
                // Are all required fields set?
-               if (this.getFaxAreaCode() != null && this.getFaxCountry() != null && this.getFaxNumber() != null) {
+               if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) {
                        // Initialize fax instance
                        fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
                }