+ /**
+ * Adds a basic business data entry, if not yet found.
+ * <p>
+ * @return Redirect outcome
+ */
+ public String addBusinessBasicData () {
+ // First, validate all parameter
+ if (this.getCompanyName() == null) {
+ // Is null
+ throw new NullPointerException("this.companyName is null"); //NOI18N
+ } else if (this.getCompanyName().isEmpty()) {
+ // Is null
+ throw new IllegalArgumentException("this.companyName is empty"); //NOI18N
+ }
+
+ // Prepare entity
+ BusinessBasicData basicData = new CompanyBasicData(this.getCompanyName());
+
+ // Set all opther remaining data
+ basicData.setCompanyComments(this.getCompanyComments());
+ basicData.setCompanyContactEmployee(this.getCompanyContactEmployee());
+ basicData.setCompanyEmailAddress(this.getCompanyEmailAddress());
+ basicData.setCompanyFounder(this.getCompanyFounder());
+ basicData.setCompanyHeadQuartersData(this.getCompanyHeadQuarters());
+ 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());
+
+ // 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)) {
+ // Now the number must be given
+ if (landLine.getPhoneAreaCode() == null) {
+ // Is null
+ throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
+ } else if (landLine.getPhoneAreaCode() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
+ } else if (landLine.getPhoneNumber() == null) {
+ // Is null
+ throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
+ } else if (landLine.getPhoneNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set phone number
+ basicData.setCompanyLandLineNumber(landLine);
+ }
+
+ // Don't set null or wrong references
+ if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
+ // Now the number must be given
+ if (fax.getPhoneAreaCode() == null) {
+ // Is null
+ throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
+ } else if (fax.getPhoneAreaCode() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
+ } else if (fax.getPhoneNumber() == null) {
+ // Is null
+ throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
+ } else if (fax.getPhoneNumber() < 1) {
+ // Abort here
+ throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
+ }
+
+ // Set fax number
+ basicData.setCompanyFaxNumber(fax);
+ }
+
+ // Now try to send to EJB and get an updated version back
+ try {
+ // Try it
+ BusinessBasicData updatedBasicData = this.adminBasicCompanyDataBean.addCompanyBasicData(basicData);
+
+ // Fire event
+ this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData));
+ } catch (final BasicCompanyDataAlreadyAddedException e) {
+ // Does already exist
+ throw new FacesException(e);
+ }
+
+ // Continue to list again
+ return "admin_list_business_contacts"; //NOI18N
+ }
+