]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java
Updated copyright year
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / beans / business / basicdata / FinancialsAdminBasicDataWebRequestBean.java
index 74813183f84eb49ffd3793a19828b7315eb16a19..ed84fc9f8c8f7f2c9157dbdf27142647b55d42bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 - 2018 Free Software Foundation
+ * Copyright (C) 2016 - 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
@@ -96,6 +96,11 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
         */
        private String companyName;
 
+       /**
+        * Company's road number
+        */
+       private String companyRoadNumber;
+
        /**
         * Company short name
         */
@@ -166,10 +171,13 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                } else if (this.getCompanyShortName().isEmpty()) {
                        // Is null
                        throw new IllegalArgumentException("this.companyShortName is empty"); //NOI18N
+               } else if ((this.getCompanyName() != null) && (this.getCompanyName().isEmpty())) {
+                       // Is null
+                       throw new IllegalArgumentException("this.companyName is set empty"); //NOI18N
                }
 
                // Prepare entity
-               BasicData basicData = new BusinessBasicData(this.getCompanyShortName());
+               final BasicData basicData = new BusinessBasicData(this.getCompanyShortName());
 
                // Set all opther remaining data
                basicData.setCompanyComments(this.getCompanyComments());
@@ -178,15 +186,28 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                basicData.setCompanyFounder(this.getCompanyFounder());
                basicData.setCompanyHeadquarterData(this.getCompanyHeadQuarter());
                basicData.setCompanyName(this.getCompanyName());
+               basicData.setCompanyRoadNumber(this.getCompanyRoadNumber());
                basicData.setCompanyTaxNumber(this.getCompanyTaxNumber());
                basicData.setCompanyUserOwner(this.getCompanyUserOwner());
                basicData.setCompanyWebsiteUrl(this.getCompanyWebsiteUrl());
 
                // Set logo instance
                // @TODO basicData.setCompanyLogo();
-               // Generate phone number
-               DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
-               DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+               // Init varibables
+               DialableLandLineNumber landLine = null;
+               DialableFaxNumber fax = null;
+
+               // Are all 3 fields set?
+               if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) {
+                       // Initialize land number number instance
+                       landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+               }
+
+               // Are all 3 fields set?
+               if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) {
+                       // Initialzie fax number instance
+                       fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
+               }
 
                // Don't set null or wrong references
                if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
@@ -230,17 +251,20 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                        basicData.setCompanyFaxNumber(fax);
                }
 
+               // Init variable
+               final BasicData updatedBasicData;
+
                // Now try to send to EJB and get an updated version back
                try {
                        // Try it
-                       final BasicData updatedBasicData = this.adminBasicCompanyDataBean.addBusinessBasicData(basicData);
-
-                       // Fire event
-                       this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData));
+                       updatedBasicData = this.adminBasicCompanyDataBean.addBusinessBasicData(basicData);
                } catch (final BasicDataAlreadyAddedException e) {
                        // Does already exist
                        throw new FacesException(e);
                }
+
+               // Fire event
+               this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData));
        }
 
        /**
@@ -351,6 +375,24 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                this.companyName = companyName;
        }
 
+       /**
+        * Getter for company's road number
+        * <p>
+        * @return Company's road number
+        */
+       public String getCompanyRoadNumber () {
+               return this.companyRoadNumber;
+       }
+
+       /**
+        * Setter for company's road number
+        * <p>
+        * @param companyRoadNumber Company's road number
+        */
+       public void setCompanyRoadNumber (final String companyRoadNumber) {
+               this.companyRoadNumber = companyRoadNumber;
+       }
+
        /**
         * Getter for company short name
         * <p>