/*
- * Copyright (C) 2016, 2017 Roland Häder
+ * 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
*/
private String companyName;
+ /**
+ * Company's road number
+ */
+ private String companyRoadNumber;
+
+ /**
+ * Company short name
+ */
+ private String companyShortName;
+
/**
* Tax number
*/
/**
* 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) {
+ public void addBusinessBasicData () {
+ // Check if company short name is set
+ if (this.getCompanyShortName() == null) {
// Is null
- throw new NullPointerException("this.companyName is null"); //NOI18N
- } else if (this.getCompanyName().isEmpty()) {
+ throw new NullPointerException("this.companyShortName is null"); //NOI18N
+ } else if (this.getCompanyShortName().isEmpty()) {
// Is null
- throw new IllegalArgumentException("this.companyName is empty"); //NOI18N
+ 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.getCompanyName());
+ final BasicData basicData = new BusinessBasicData(this.getCompanyShortName());
// Set all opther remaining data
basicData.setCompanyComments(this.getCompanyComments());
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)) {
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);
}
- // Continue to list again
- return "admin_list_basic_data"; //NOI18N
+ // Fire event
+ this.businessDataAddedEvent.fire(new AdminAddedBusinessBasicDataEvent(updatedBasicData));
}
/**
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>