/*
- * Copyright (C) 2017 - 2020 Free Software Foundation
+ * Copyright (C) 2017 - 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
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import javax.inject.Named;
+import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jcontactsbusiness.events.branchoffice.added.AdminBranchOfficeAddedEvent;
import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableAdminBranchOfficeAddedEvent;
import org.mxchange.jcontactsbusiness.events.branchoffice.updated.AdminBranchOfficeUpdatedEvent;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
-import org.mxchange.jcontactsbusiness.model.employee.Employable;
import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
import org.mxchange.jcoreee.dates.DayOfTheWeek;
/**
* Contact person in branch office
*/
- private Employable branchContactEmployee;
+ private Contact branchContactEmployee;
/**
* Country
/**
* Owner/leader of branch office
*/
- private Employable branchOwnerEmployee;
+ private Contact branchOwnerEmployee;
/**
* Store
* <p>
* @return Branch office contact person
*/
- public Employable getBranchContactEmployee () {
+ public Contact getBranchContactEmployee () {
return this.branchContactEmployee;
}
* <p>
* @param branchContactEmployee Branch office contact person
*/
- public void setBranchContactEmployee (final Employable branchContactEmployee) {
+ public void setBranchContactEmployee (final Contact branchContactEmployee) {
this.branchContactEmployee = branchContactEmployee;
}
* <p>
* @return Branch office contact person
*/
- public Employable getBranchOwnerEmployee () {
+ public Contact getBranchOwnerEmployee () {
return this.branchOwnerEmployee;
}
* <p>
* @param branchOwnerEmployee Branch office contact person
*/
- public void setBranchOwnerEmployee (final Employable branchOwnerEmployee) {
+ public void setBranchOwnerEmployee (final Contact branchOwnerEmployee) {
this.branchOwnerEmployee = branchOwnerEmployee;
}
* @return Redirection outcome
*/
public String updateBranchOffice () {
- // Id should be set
- if (this.getBranchId() == null) {
+ // Validate current product instance and id
+ if (this.getCurrentBranchOffice() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.product is null"); //NOI18N
+ } else if (this.getCurrentBranchOffice().getBranchId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.product.branchId is null"); //NOI18N
+ } else if (this.getCurrentBranchOffice().getBranchId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("this.product.branchId={0} is not valid.", this.getCurrentBranchOffice().getBranchId())); //NOI18N
+ } else if (this.getBranchId() == null) {
// Throw NPE
throw new NullPointerException("this.branchId is null"); //NOI18N
} else if (this.getBranchId() < 1) {
this.updatedBranchOfficeEvent.fire(new AdminBranchOfficeUpdatedEvent(updatedBranchOffice));
// Redirect to list view
- return "admin_list_branch_office"; //NOI18N
+ return "admin_list_branch_offices"; //NOI18N
}
/**
DialableFaxNumber fax = null;
// Are all required fields set?
- if (this.getLandLineAreaCode() != null && this.getLandLineCountry() != null && this.getLandLineNumber() != null) {
+ if (this.getLandLineAreaCode() != null && this.getLandLineCountry() instanceof Country && this.getLandLineNumber() != null) {
// Initialize land-line instance
landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
}
// Are all required fields set?
- if (this.getFaxAreaCode() != null && this.getFaxCountry() != null && this.getFaxNumber() != null) {
+ if (this.getFaxAreaCode() != null && this.getFaxCountry() instanceof Country && this.getFaxNumber() != null) {
// Initialize fax instance
fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
}