@Column (name = "headquarter_city", length = 100, nullable = false)
private String headquarterCity;
+ /**
+ * Headquarter's company name
+ */
+ @Basic (optional = false)
+ @Column (name = "headquarter_company_name", length = 100, nullable = false, unique = true)
+ private String headquarterCompanyName;
+
/**
* Reference to contact person
*/
/**
* Opening times for this branch office
*/
- @JoinTable (name = "headquarter_opening_times", joinColumns =@JoinColumn (name = "headquarter_opening_id", referencedColumnName = "headquarter_id"), inverseJoinColumns = @JoinColumn (name = "opening_headquarter_id", referencedColumnName = "opening_times_id"))
+ @JoinTable (name = "headquarter_opening_times", joinColumns =
+ @JoinColumn (name = "headquarter_opening_id", referencedColumnName = "headquarter_id"), inverseJoinColumns =
+ @JoinColumn (name = "opening_headquarter_id", referencedColumnName = "opening_times_id"))
@ManyToMany (targetEntity = BusinessOpeningTime.class, cascade = CascadeType.ALL)
private List<OpeningTime> headquarterOpeningTimes;
/**
* Constructor with all required fields
* <p>
+ * @param headquarterCompanyName Headquarter's company name
* @param headquarterCity City
* @param headquarterCountry Country
* @param headquarterStreet Street name
* @param headquarterZipCode ZIP code
* @param headquarterHouseNumber House number
*/
- public BusinessHeadquarter (final String headquarterCity, final Country headquarterCountry, final String headquarterStreet, final Integer headquarterZipCode, final Short headquarterHouseNumber) {
+ public BusinessHeadquarter (final String headquarterCompanyName, final String headquarterCity, final Country headquarterCountry, final String headquarterStreet, final Integer headquarterZipCode, final Short headquarterHouseNumber) {
// Call other constructor first
this();
- // Validate parameters
- if (null == headquarterCity) {
+ // First, validate all parameter
+ if (headquarterCompanyName == null) {
+ // Is null
+ throw new NullPointerException("headquarterCompanyName is null"); //NOI18N
+ } else if (headquarterCompanyName.isEmpty()) {
+ // Is null
+ throw new IllegalArgumentException("headquarterCompanyName is empty"); //NOI18N
+ } else if (null == headquarterCity) {
// Throw NPE
throw new NullPointerException("headquarterCity is null"); //NOI18N
} else if (headquarterCity.isEmpty()) {
}
// Set all fields
+ this.headquarterCompanyName = headquarterCompanyName;
this.headquarterCity = headquarterCity;
this.headquarterCountry = headquarterCountry;
this.headquarterHouseNumber = headquarterHouseNumber;
this.headquarterCity = headquarterCity;
}
+ @Override
+ public String getHeadquarterCompanyName () {
+ return this.headquarterCompanyName;
+ }
+
+ @Override
+ public void setHeadquarterCompanyName (final String headquarterCompanyName) {
+ this.headquarterCompanyName = headquarterCompanyName;
+ }
+
@Override
public Employable getHeadquarterContactEmployee () {
return this.headquarterContactEmployee;