]> 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 cb40dce13c9402c4a432a39a21b61fdf4ad59149..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,16 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
         */
        private String companyName;
 
+       /**
+        * Company's road number
+        */
+       private String companyRoadNumber;
+
+       /**
+        * Company short name
+        */
+       private String companyShortName;
+
        /**
         * Tax number
         */
@@ -154,17 +164,20 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
         * <p>
         */
        public void addBusinessBasicData () {
-               // First, validate all parameter
-               if (this.getCompanyName() == null) {
+               // Check if company short name is set
+               if (this.getCompanyShortName() == null) {
+                       // Is null
+                       throw new NullPointerException("this.companyShortName is null"); //NOI18N
+               } else if (this.getCompanyShortName().isEmpty()) {
                        // Is null
-                       throw new NullPointerException("this.companyName is null"); //NOI18N
-               } else if (this.getCompanyName().isEmpty()) {
+                       throw new IllegalArgumentException("this.companyShortName is empty"); //NOI18N
+               } else if ((this.getCompanyName() != null) && (this.getCompanyName().isEmpty())) {
                        // Is null
-                       throw new IllegalArgumentException("this.companyName is empty"); //NOI18N
+                       throw new IllegalArgumentException("this.companyName is set empty"); //NOI18N
                }
 
                // Prepare entity
-               BasicData basicData = new BusinessBasicData(this.getCompanyName());
+               final BasicData basicData = new BusinessBasicData(this.getCompanyShortName());
 
                // Set all opther remaining data
                basicData.setCompanyComments(this.getCompanyComments());
@@ -172,15 +185,29 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                basicData.setCompanyEmailAddress(this.getCompanyEmailAddress());
                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)) {
@@ -224,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));
        }
 
        /**
@@ -345,6 +375,42 @@ 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>
+        * @return Company short name
+        */
+       public String getCompanyShortName () {
+               return this.companyShortName;
+       }
+
+       /**
+        * Setter for company short name
+        * <p>
+        * @param companyShortName Company short name
+        */
+       public void setCompanyShortName (final String companyShortName) {
+               this.companyShortName = companyShortName;
+       }
+
        /**
         * Getter for company tax number
         * <p>