--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.business.branchoffice;
+
+import java.util.List;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.addressbook.beans.BaseAddressbookController;
+import org.mxchange.jcontactsbusiness.events.branchoffice.added.BranchOfficeAddedEvent;
+import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent;
+import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
+import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice;
+import org.mxchange.jcontactsbusiness.model.employee.Employee;
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * An administrative bean for branch offices
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("adminBranchOfficeController")
+@RequestScoped
+public class AddressbookAdminBranchOfficeWebRequestBean extends BaseAddressbookController implements AddressbookAdminBranchOfficeWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 5_028_697_360_461L;
+
+ /**
+ * EJB for administrative purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/adminBranchOffice!org.mxchange.jcontactsbusiness.branchoffice.AdminBranchOfficeSessionBeanRemote")
+ private AdminBranchOfficeSessionBeanRemote adminBranchOfficeBean;
+
+ /**
+ * City
+ */
+ private String branchCity;
+
+ /**
+ * Assigned company for this branch office
+ */
+ private BusinessBasicData branchCompany;
+
+ /**
+ * Contact person in branch office
+ */
+ private Employee branchContactEmployee;
+
+ /**
+ * Country
+ */
+ private Country branchCountry;
+
+ /**
+ * Email address
+ */
+ private String branchEmailAddress;
+
+ /**
+ * House number
+ */
+ private Short branchHouseNumber;
+
+ /**
+ * An event being fired when a branch office has been successfully added
+ */
+ @Inject
+ @Any
+ private Event<ObservableBranchOfficeAddedEvent> branchOfficeAddedEvent;
+
+ /**
+ * A general branch office controller (backing bean)
+ */
+ @Inject
+ private AddressbookBranchOfficeWebRequestController branchOfficeController;
+
+ /**
+ * Store
+ */
+ private Short branchStore;
+
+ /**
+ * Branch office street name
+ */
+ private String branchStreet;
+
+ /**
+ * Suite number
+ */
+ private Short branchSuiteNumber;
+
+ /**
+ * Owning user instance (which this branch office is assigned to)
+ */
+ private User branchUserOwner;
+
+ /**
+ * ZIP code
+ */
+ private Integer branchZipCode;
+
+ /**
+ * Area code for fax number
+ */
+ private Integer faxAreaCode;
+
+ /**
+ * Country for fax number
+ */
+ private Country faxCountry;
+
+ /**
+ * Dial number for fax number
+ */
+ private Long faxNumber;
+
+ /**
+ * Area code for land-line number
+ */
+ private Integer landLineAreaCode;
+
+ /**
+ * Country for land-line number
+ */
+ private Country landLineCountry;
+
+ /**
+ * Dial number for land-line number
+ */
+ private Long landLineNumber;
+
+ /**
+ * Default constructor
+ */
+ public AddressbookAdminBranchOfficeWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Adds branch office with all data from this backing bean. First this
+ * action method will validate if the branch office's address is already
+ * registered and if found, it will output a proper faces message.
+ * <p>
+ * @return Redirect outcome
+ */
+ public String addBranchOffice () {
+ // Get instance
+ final BranchOffice branchOffice = this.createBranchOffice();
+
+ // Is the branch office not created yet?
+ if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) {
+ // Then show proper faces message
+ this.showFacesMessage("form_admin_add_branch_office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Delcare updated instance
+ final BranchOffice updatedOffice;
+
+ try {
+ // Try to call EJB
+ updatedOffice = this.adminBranchOfficeBean.addBranchOffice(branchOffice);
+ } catch (final BranchOfficeAlreadyAddedException ex) {
+ // Output message
+ this.showFacesMessage("form_admin_add_branch_office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
+ return ""; //NOI18N
+ }
+
+ // Fire event
+ this.branchOfficeAddedEvent.fire(new BranchOfficeAddedEvent(updatedOffice));
+
+ // Redirect to list
+ return "admin_list_branch_offices"; //NOI18N
+ }
+
+ /**
+ * Getter for city
+ * <p>
+ * @return City
+ */
+ public String getBranchCity () {
+ return this.branchCity;
+ }
+
+ /**
+ * Setter for city
+ * <p>
+ * @param branchCity City
+ */
+ public void setBranchCity (final String branchCity) {
+ this.branchCity = branchCity;
+ }
+
+ /**
+ * Getter for basic company data
+ * <p>
+ * @return Basic company data
+ */
+ public BusinessBasicData getBranchCompany () {
+ return this.branchCompany;
+ }
+
+ /**
+ * Setter for basic company data
+ * <p>
+ * @param branchCompany Basic company data
+ */
+ public void setBranchCompany (final BusinessBasicData branchCompany) {
+ this.branchCompany = branchCompany;
+ }
+
+ /**
+ * Getter for branch office contact person
+ * <p>
+ * @return Branch office contact person
+ */
+ public Employee getBranchContactEmployee () {
+ return this.branchContactEmployee;
+ }
+
+ /**
+ * Setter for branch office contact person
+ * <p>
+ * @param branchContactEmployee Branch office contact person
+ */
+ public void setBranchContactEmployee (final Employee branchContactEmployee) {
+ this.branchContactEmployee = branchContactEmployee;
+ }
+
+ /**
+ * Getter for country
+ * <p>
+ * @return Country
+ */
+ public Country getBranchCountry () {
+ return this.branchCountry;
+ }
+
+ /**
+ * Setter for country
+ * <p>
+ * @param branchCountry Country
+ */
+ public void setBranchCountry (final Country branchCountry) {
+ this.branchCountry = branchCountry;
+ }
+
+ /**
+ * Getter for email address
+ * <p>
+ * @return Email address
+ */
+ public String getBranchEmailAddress () {
+ return this.branchEmailAddress;
+ }
+
+ /**
+ * Getter for email address
+ * <p>
+ * @param branchEmailAddress Email address
+ */
+ public void setBranchEmailAddress (final String branchEmailAddress) {
+ this.branchEmailAddress = branchEmailAddress;
+ }
+
+ /**
+ * Getter for house number
+ * <p>
+ * @return House number
+ */
+ public Short getBranchHouseNumber () {
+ return this.branchHouseNumber;
+ }
+
+ /**
+ * Setter for house number
+ * <p>
+ * @param branchHouseNumber House number
+ */
+ public void setBranchHouseNumber (final Short branchHouseNumber) {
+ this.branchHouseNumber = branchHouseNumber;
+ }
+
+ /**
+ * Getter for store
+ * <p>
+ * @return Store
+ */
+ public Short getBranchStore () {
+ return this.branchStore;
+ }
+
+ /**
+ * Setter for store
+ * <p>
+ * @param branchStore Store
+ */
+ public void setBranchStore (final Short branchStore) {
+ this.branchStore = branchStore;
+ }
+
+ /**
+ * Getter for street name
+ * <p>
+ * @return Street name
+ */
+ public String getBranchStreet () {
+ return this.branchStreet;
+ }
+
+ /**
+ * Setter for street name
+ * <p>
+ * @param branchStreet Street name
+ */
+ public void setBranchStreet (final String branchStreet) {
+ this.branchStreet = branchStreet;
+ }
+
+ /**
+ * Getter for suite number
+ * <p>
+ * @return Suite number
+ */
+ public Short getBranchSuiteNumber () {
+ return this.branchSuiteNumber;
+ }
+
+ /**
+ * Setter for suite number
+ * <p>
+ * @param branchSuiteNumber Suite number
+ */
+ public void setBranchSuiteNumber (final Short branchSuiteNumber) {
+ this.branchSuiteNumber = branchSuiteNumber;
+ }
+
+ /**
+ * Getter for owning user instance
+ * <p>
+ * @return Owning user instance
+ */
+ public User getBranchUserOwner () {
+ return this.branchUserOwner;
+ }
+
+ /**
+ * Setter for owning user instance
+ * <p>
+ * @param branchUserOwner Owning user instance
+ */
+ public void setBranchUserOwner (final User branchUserOwner) {
+ this.branchUserOwner = branchUserOwner;
+ }
+
+ /**
+ * Getter for ZIP code\
+ * <p>
+ * @return ZIP code
+ */
+ public Integer getBranchZipCode () {
+ return this.branchZipCode;
+ }
+
+ /**
+ * Setter for ZIP code\
+ * <p>
+ * @param branchZipCode ZIP code
+ */
+ public void setBranchZipCode (final Integer branchZipCode) {
+ this.branchZipCode = branchZipCode;
+ }
+
+ /**
+ * Getter for fax number's area code
+ * <p>
+ * @return Fax number's area code
+ */
+ public Integer getFaxAreaCode () {
+ return this.faxAreaCode;
+ }
+
+ /**
+ * Setter for fax number's area code
+ * <p>
+ * @param faxAreaCode Fax number's area code
+ */
+ public void setFaxAreaCode (final Integer faxAreaCode) {
+ this.faxAreaCode = faxAreaCode;
+ }
+
+ /**
+ * Getter for fax's country instance
+ * <p>
+ * @return Fax' country instance
+ */
+ public Country getFaxCountry () {
+ return this.faxCountry;
+ }
+
+ /**
+ * Setter for fax's country instance
+ * <p>
+ * @param faxCountry Fax' country instance
+ */
+ public void setFaxCountry (final Country faxCountry) {
+ this.faxCountry = faxCountry;
+ }
+
+ /**
+ * Getter for fax number
+ * <p>
+ * @return Fax number
+ */
+ public Long getFaxNumber () {
+ return this.faxNumber;
+ }
+
+ /**
+ * Setter for fax number
+ * <p>
+ * @param faxNumber Fax number
+ */
+ public void setFaxNumber (final Long faxNumber) {
+ this.faxNumber = faxNumber;
+ }
+
+ /**
+ * Getter for land-line number's area code
+ * <p>
+ * @return Land-line number's area code
+ */
+ public Integer getLandLineAreaCode () {
+ return this.landLineAreaCode;
+ }
+
+ /**
+ * Setter for land-line number's area code
+ * <p>
+ * @param landLineAreaCode Land-line number's area code
+ */
+ public void setLandLineAreaCode (final Integer landLineAreaCode) {
+ this.landLineAreaCode = landLineAreaCode;
+ }
+
+ /**
+ * Getter for land-line number's country instance
+ * <p>
+ * @return Land-line number's country instance
+ */
+ public Country getLandLineCountry () {
+ return this.landLineCountry;
+ }
+
+ /**
+ * Setter for land-line number's country instance
+ * <p>
+ * @param landLineCountry Land-line number's country instance
+ */
+ public void setLandLineCountry (final Country landLineCountry) {
+ this.landLineCountry = landLineCountry;
+ }
+
+ /**
+ * Getter for land-line number
+ * <p>
+ * @return Land-line number
+ */
+ public Long getLandLineNumber () {
+ return this.landLineNumber;
+ }
+
+ /**
+ * Setter for land-line number
+ * <p>
+ * @param landLineNumber Land-line number
+ */
+ public void setLandLineNumber (final Long landLineNumber) {
+ this.landLineNumber = landLineNumber;
+ }
+
+ /**
+ * Prepares an instance of a BranchOffice object (entity) with all data from
+ * this bean. If a complete fax number or land-line number was provided, it
+ * will be set in the instance as well.
+ * <p>
+ * @return An instance of a BranchOffice class (entity)
+ */
+ private BranchOffice createBranchOffice () {
+ // Create new branch office instance
+ final BranchOffice branchOffice = new CompanyBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber());
+
+ // Add all other fields, too
+ branchOffice.setBranchContactEmployee(this.getBranchContactEmployee());
+ branchOffice.setBranchEmailAddress(this.getBranchEmailAddress());
+ branchOffice.setBranchStore(this.getBranchStore());
+ branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber());
+ branchOffice.setBranchUserOwner(this.getBranchUserOwner());
+
+ // Generate phone number
+ final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
+ final 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
+ branchOffice.setBranchLandLineNumber(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
+ branchOffice.setBranchFaxNumber(fax);
+ }
+
+ // Return fully prepared instance
+ return branchOffice;
+ }
+
+ /**
+ * Checks whether the given branch office's address is already found in
+ * local cache. Please note that this method fully relies on the cache, so
+ * you must always fire proper events that add/update/delete entries in
+ * cache.
+ * <p>
+ * @param branchOffice Branch office to check it's address
+ * <p>
+ * @return Whether the address has been found
+ */
+ private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
+ // Get full list from other bean
+ final List<BranchOffice> branchOffices = this.branchOfficeController.allBranchOffices();
+
+ // Default is not found
+ boolean isFound = false;
+
+ // Now check each entry
+ for (final BranchOffice bo : branchOffices) {
+ // Is same address?
+ if (BranchOffices.isSameAddress(bo, branchOffice)) {
+ // Found one
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return flag
+ return isFound;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.business.branchoffice;
+
+import java.io.Serializable;
+
+/**
+ * An interface for administrative branch office controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface AddressbookAdminBranchOfficeWebRequestController extends Serializable {
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.business.branchoffice;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.addressbook.beans.BaseAddressbookController;
+import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote;
+
+/**
+ * A general bean for branch offices
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("branchOfficeController")
+@RequestScoped
+public class AddressbookBranchOfficeWebRequestBean extends BaseAddressbookController implements AddressbookBranchOfficeWebRequestController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 5_028_697_360_461L;
+
+ /**
+ * EJB for administrative purposes
+ */
+ @EJB (lookup = "java:global/jfinancials-ejb/branchOffice!org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeSessionBeanRemote")
+ private BranchOfficeSessionBeanRemote branchOfficeBean;
+
+ /**
+ * A list of all branch offices (globally)
+ */
+ @Inject
+ @NamedCache (cacheName = "branchOfficeCache")
+ private Cache<Long, BranchOffice> branchOfficeCache;
+
+ /**
+ * Default constructor
+ */
+ public AddressbookBranchOfficeWebRequestBean () {
+ // Call super constructor
+ super();
+ }
+
+ /**
+ * Observes events being fired when a branch office has been added.
+ * <p>
+ * @param event Event being fired
+ * <p>
+ * @throws NullPointerException If the parameter or it's carried instance is null
+ * @throws IllegalArgumentException If the branchId is zero or lower
+ */
+ public void afterBranchOfficeAddedEvent (@Observes final ObservableBranchOfficeAddedEvent event) {
+ // Validate parameter
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getBranchOffice() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.branchOffice is null"); //NOI18N
+ } else if (event.getBranchOffice().getBranchId() == null) {
+ // Throw it again
+ throw new NullPointerException("event.branchOffice.branchId is null"); //NOI18N
+ } else if (event.getBranchOffice().getBranchId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("event.branchOffice.branchId={0} is not valid", event.getBranchOffice().getBranchId())); //NOI18N
+ }
+
+ // Add instance to cache
+ this.branchOfficeCache.put(event.getBranchOffice().getBranchId(), event.getBranchOffice());
+ }
+
+ @Override
+ public List<BranchOffice> allBranchOffices () {
+ // Init list
+ final List<BranchOffice> list = new LinkedList<>();
+
+ // Get iterator
+ final Iterator<Cache.Entry<Long, BranchOffice>> iterator = this.branchOfficeCache.iterator();
+
+ // Loop over all
+ while (iterator.hasNext()) {
+ // Get next entry
+ final Cache.Entry<Long, BranchOffice> next = iterator.next();
+
+ // Add value to list
+ list.add(next.getValue());
+ }
+
+ // Return it
+ return list;
+ }
+
+ /**
+ * Initializer method
+ */
+ @PostConstruct
+ public void initializeList () {
+ // Is cache there?
+ if (!this.branchOfficeCache.iterator().hasNext()) {
+ // Get whole list
+ final List<BranchOffice> list = this.branchOfficeBean.allBranchOffices();
+
+ // Add all
+ for (final Iterator<BranchOffice> iterator = list.iterator(); iterator.hasNext();) {
+ // Get next element
+ final BranchOffice next = iterator.next();
+
+ // Add it to cache
+ this.branchOfficeCache.put(next.getBranchId(), next);
+ }
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.business.branchoffice;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+
+/**
+ * An interface for general branch office controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface AddressbookBranchOfficeWebRequestController extends Serializable {
+
+ /**
+ * Returns a list of all branch offices
+ * <p>
+ * @return A list of all branch offices
+ */
+ List<BranchOffice> allBranchOffices ();
+
+}
+++ /dev/null
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.business.branchoffice;
-
-import java.util.List;
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.basicdata.BusinessBasicData;
-import org.mxchange.jcontactsbusiness.branchoffice.AdminBranchOfficeSessionBeanRemote;
-import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeUtils;
-import org.mxchange.jcontactsbusiness.branchoffice.CompanyBranchOffice;
-import org.mxchange.jcontactsbusiness.employee.Employee;
-import org.mxchange.jcontactsbusiness.events.branchoffice.added.BranchOfficeAddedEvent;
-import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent;
-import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
-import org.mxchange.jcountry.data.Country;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * An administrative bean for branch offices
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("adminBranchOfficeController")
-@RequestScoped
-public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsController implements FinancialsAdminBranchOfficeWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 5_028_697_360_461L;
-
- /**
- * EJB for administrative purposes
- */
- @EJB (lookup = "java:global/jfinancials-ejb/adminBranchOffice!org.mxchange.jcontactsbusiness.branchoffice.AdminBranchOfficeSessionBeanRemote")
- private AdminBranchOfficeSessionBeanRemote adminBranchOfficeBean;
-
- /**
- * City
- */
- private String branchCity;
-
- /**
- * Assigned company for this branch office
- */
- private BusinessBasicData branchCompany;
-
- /**
- * Contact person in branch office
- */
- private Employee branchContactEmployee;
-
- /**
- * Country
- */
- private Country branchCountry;
-
- /**
- * Email address
- */
- private String branchEmailAddress;
-
- /**
- * House number
- */
- private Short branchHouseNumber;
-
- /**
- * An event being fired when a branch office has been successfully added
- */
- @Inject
- @Any
- private Event<ObservableBranchOfficeAddedEvent> branchOfficeAddedEvent;
-
- /**
- * A general branch office controller (backing bean)
- */
- @Inject
- private FinancialsBranchOfficeWebRequestController branchOfficeController;
-
- /**
- * Store
- */
- private Short branchStore;
-
- /**
- * Branch office street name
- */
- private String branchStreet;
-
- /**
- * Suite number
- */
- private Short branchSuiteNumber;
-
- /**
- * Owning user instance (which this branch office is assigned to)
- */
- private User branchUserOwner;
-
- /**
- * ZIP code
- */
- private Integer branchZipCode;
-
- /**
- * Area code for fax number
- */
- private Integer faxAreaCode;
-
- /**
- * Country for fax number
- */
- private Country faxCountry;
-
- /**
- * Dial number for fax number
- */
- private Long faxNumber;
-
- /**
- * Area code for land-line number
- */
- private Integer landLineAreaCode;
-
- /**
- * Country for land-line number
- */
- private Country landLineCountry;
-
- /**
- * Dial number for land-line number
- */
- private Long landLineNumber;
-
- /**
- * Default constructor
- */
- public FinancialsAdminBranchOfficeWebRequestBean () {
- // Call super constructor
- super();
- }
-
- /**
- * Adds branch office with all data from this backing bean. First this
- * action method will validate if the branch office's address is already
- * registered and if found, it will output a proper faces message.
- * <p>
- * @return Redirect outcome
- */
- public String addBranchOffice () {
- // Get instance
- final BranchOffice branchOffice = this.createBranchOffice();
-
- // Is the branch office not created yet?
- if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) {
- // Then show proper faces message
- this.showFacesMessage("form_admin_add_branch_office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
- return ""; //NOI18N
- }
-
- // Delcare updated instance
- final BranchOffice updatedOffice;
-
- try {
- // Try to call EJB
- updatedOffice = this.adminBranchOfficeBean.addBranchOffice(branchOffice);
- } catch (final BranchOfficeAlreadyAddedException ex) {
- // Output message
- this.showFacesMessage("form_admin_add_branch_office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
- return ""; //NOI18N
- }
-
- // Fire event
- this.branchOfficeAddedEvent.fire(new BranchOfficeAddedEvent(updatedOffice));
-
- // Redirect to list
- return "admin_list_branch_offices"; //NOI18N
- }
-
- /**
- * Getter for city
- * <p>
- * @return City
- */
- public String getBranchCity () {
- return this.branchCity;
- }
-
- /**
- * Setter for city
- * <p>
- * @param branchCity City
- */
- public void setBranchCity (final String branchCity) {
- this.branchCity = branchCity;
- }
-
- /**
- * Getter for basic company data
- * <p>
- * @return Basic company data
- */
- public BusinessBasicData getBranchCompany () {
- return this.branchCompany;
- }
-
- /**
- * Setter for basic company data
- * <p>
- * @param branchCompany Basic company data
- */
- public void setBranchCompany (final BusinessBasicData branchCompany) {
- this.branchCompany = branchCompany;
- }
-
- /**
- * Getter for branch office contact person
- * <p>
- * @return Branch office contact person
- */
- public Employee getBranchContactEmployee () {
- return this.branchContactEmployee;
- }
-
- /**
- * Setter for branch office contact person
- * <p>
- * @param branchContactEmployee Branch office contact person
- */
- public void setBranchContactEmployee (final Employee branchContactEmployee) {
- this.branchContactEmployee = branchContactEmployee;
- }
-
- /**
- * Getter for country
- * <p>
- * @return Country
- */
- public Country getBranchCountry () {
- return this.branchCountry;
- }
-
- /**
- * Setter for country
- * <p>
- * @param branchCountry Country
- */
- public void setBranchCountry (final Country branchCountry) {
- this.branchCountry = branchCountry;
- }
-
- /**
- * Getter for email address
- * <p>
- * @return Email address
- */
- public String getBranchEmailAddress () {
- return this.branchEmailAddress;
- }
-
- /**
- * Getter for email address
- * <p>
- * @param branchEmailAddress Email address
- */
- public void setBranchEmailAddress (final String branchEmailAddress) {
- this.branchEmailAddress = branchEmailAddress;
- }
-
- /**
- * Getter for house number
- * <p>
- * @return House number
- */
- public Short getBranchHouseNumber () {
- return this.branchHouseNumber;
- }
-
- /**
- * Setter for house number
- * <p>
- * @param branchHouseNumber House number
- */
- public void setBranchHouseNumber (final Short branchHouseNumber) {
- this.branchHouseNumber = branchHouseNumber;
- }
-
- /**
- * Getter for store
- * <p>
- * @return Store
- */
- public Short getBranchStore () {
- return this.branchStore;
- }
-
- /**
- * Setter for store
- * <p>
- * @param branchStore Store
- */
- public void setBranchStore (final Short branchStore) {
- this.branchStore = branchStore;
- }
-
- /**
- * Getter for street name
- * <p>
- * @return Street name
- */
- public String getBranchStreet () {
- return this.branchStreet;
- }
-
- /**
- * Setter for street name
- * <p>
- * @param branchStreet Street name
- */
- public void setBranchStreet (final String branchStreet) {
- this.branchStreet = branchStreet;
- }
-
- /**
- * Getter for suite number
- * <p>
- * @return Suite number
- */
- public Short getBranchSuiteNumber () {
- return this.branchSuiteNumber;
- }
-
- /**
- * Setter for suite number
- * <p>
- * @param branchSuiteNumber Suite number
- */
- public void setBranchSuiteNumber (final Short branchSuiteNumber) {
- this.branchSuiteNumber = branchSuiteNumber;
- }
-
- /**
- * Getter for owning user instance
- * <p>
- * @return Owning user instance
- */
- public User getBranchUserOwner () {
- return this.branchUserOwner;
- }
-
- /**
- * Setter for owning user instance
- * <p>
- * @param branchUserOwner Owning user instance
- */
- public void setBranchUserOwner (final User branchUserOwner) {
- this.branchUserOwner = branchUserOwner;
- }
-
- /**
- * Getter for ZIP code\
- * <p>
- * @return ZIP code
- */
- public Integer getBranchZipCode () {
- return this.branchZipCode;
- }
-
- /**
- * Setter for ZIP code\
- * <p>
- * @param branchZipCode ZIP code
- */
- public void setBranchZipCode (final Integer branchZipCode) {
- this.branchZipCode = branchZipCode;
- }
-
- /**
- * Getter for fax number's area code
- * <p>
- * @return Fax number's area code
- */
- public Integer getFaxAreaCode () {
- return this.faxAreaCode;
- }
-
- /**
- * Setter for fax number's area code
- * <p>
- * @param faxAreaCode Fax number's area code
- */
- public void setFaxAreaCode (final Integer faxAreaCode) {
- this.faxAreaCode = faxAreaCode;
- }
-
- /**
- * Getter for fax's country instance
- * <p>
- * @return Fax' country instance
- */
- public Country getFaxCountry () {
- return this.faxCountry;
- }
-
- /**
- * Setter for fax's country instance
- * <p>
- * @param faxCountry Fax' country instance
- */
- public void setFaxCountry (final Country faxCountry) {
- this.faxCountry = faxCountry;
- }
-
- /**
- * Getter for fax number
- * <p>
- * @return Fax number
- */
- public Long getFaxNumber () {
- return this.faxNumber;
- }
-
- /**
- * Setter for fax number
- * <p>
- * @param faxNumber Fax number
- */
- public void setFaxNumber (final Long faxNumber) {
- this.faxNumber = faxNumber;
- }
-
- /**
- * Getter for land-line number's area code
- * <p>
- * @return Land-line number's area code
- */
- public Integer getLandLineAreaCode () {
- return this.landLineAreaCode;
- }
-
- /**
- * Setter for land-line number's area code
- * <p>
- * @param landLineAreaCode Land-line number's area code
- */
- public void setLandLineAreaCode (final Integer landLineAreaCode) {
- this.landLineAreaCode = landLineAreaCode;
- }
-
- /**
- * Getter for land-line number's country instance
- * <p>
- * @return Land-line number's country instance
- */
- public Country getLandLineCountry () {
- return this.landLineCountry;
- }
-
- /**
- * Setter for land-line number's country instance
- * <p>
- * @param landLineCountry Land-line number's country instance
- */
- public void setLandLineCountry (final Country landLineCountry) {
- this.landLineCountry = landLineCountry;
- }
-
- /**
- * Getter for land-line number
- * <p>
- * @return Land-line number
- */
- public Long getLandLineNumber () {
- return this.landLineNumber;
- }
-
- /**
- * Setter for land-line number
- * <p>
- * @param landLineNumber Land-line number
- */
- public void setLandLineNumber (final Long landLineNumber) {
- this.landLineNumber = landLineNumber;
- }
-
- /**
- * Prepares an instance of a BranchOffice object (entity) with all data from
- * this bean. If a complete fax number or land-line number was provided, it
- * will be set in the instance as well.
- * <p>
- * @return An instance of a BranchOffice class (entity)
- */
- private BranchOffice createBranchOffice () {
- // Create new branch office instance
- final BranchOffice branchOffice = new CompanyBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber());
-
- // Add all other fields, too
- branchOffice.setBranchContactEmployee(this.getBranchContactEmployee());
- branchOffice.setBranchEmailAddress(this.getBranchEmailAddress());
- branchOffice.setBranchStore(this.getBranchStore());
- branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber());
- branchOffice.setBranchUserOwner(this.getBranchUserOwner());
-
- // Generate phone number
- final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
- final 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
- branchOffice.setBranchLandLineNumber(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
- branchOffice.setBranchFaxNumber(fax);
- }
-
- // Return fully prepared instance
- return branchOffice;
- }
-
- /**
- * Checks whether the given branch office's address is already found in
- * local cache. Please note that this method fully relies on the cache, so
- * you must always fire proper events that add/update/delete entries in
- * cache.
- * <p>
- * @param branchOffice Branch office to check it's address
- * <p>
- * @return Whether the address has been found
- */
- private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
- // Get full list from other bean
- final List<BranchOffice> branchOffices = this.branchOfficeController.allBranchOffices();
-
- // Default is not found
- boolean isFound = false;
-
- // Now check each entry
- for (final BranchOffice bo : branchOffices) {
- // Is same address?
- if (BranchOfficeUtils.isSameAddress(bo, branchOffice)) {
- // Found one
- isFound = true;
- break;
- }
- }
-
- // Return flag
- return isFound;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.business.branchoffice;
-
-import java.io.Serializable;
-
-/**
- * An interface for administrative branch office controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsAdminBranchOfficeWebRequestController extends Serializable {
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.business.branchoffice;
-
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
-import javax.ejb.EJB;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeSessionBeanRemote;
-import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent;
-import org.mxchange.jfinancials.beans.BaseFinancialsController;
-
-/**
- * A general bean for branch offices
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("branchOfficeController")
-@RequestScoped
-public class FinancialsBranchOfficeWebRequestBean extends BaseFinancialsController implements FinancialsBranchOfficeWebRequestController {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 5_028_697_360_461L;
-
- /**
- * EJB for administrative purposes
- */
- @EJB (lookup = "java:global/jfinancials-ejb/branchOffice!org.mxchange.jcontactsbusiness.branchoffice.BranchOfficeSessionBeanRemote")
- private BranchOfficeSessionBeanRemote branchOfficeBean;
-
- /**
- * A list of all branch offices (globally)
- */
- @Inject
- @NamedCache (cacheName = "branchOfficeCache")
- private Cache<Long, BranchOffice> branchOfficeCache;
-
- /**
- * Default constructor
- */
- public FinancialsBranchOfficeWebRequestBean () {
- // Call super constructor
- super();
- }
-
- /**
- * Observes events being fired when a branch office has been added.
- * <p>
- * @param event Event being fired
- * <p>
- * @throws NullPointerException If the parameter or it's carried instance is null
- * @throws IllegalArgumentException If the branchId is zero or lower
- */
- public void afterBranchOfficeAddedEvent (@Observes final ObservableBranchOfficeAddedEvent event) {
- // Validate parameter
- if (null == event) {
- // Throw NPE
- throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getBranchOffice() == null) {
- // Throw NPE again
- throw new NullPointerException("event.branchOffice is null"); //NOI18N
- } else if (event.getBranchOffice().getBranchId() == null) {
- // Throw it again
- throw new NullPointerException("event.branchOffice.branchId is null"); //NOI18N
- } else if (event.getBranchOffice().getBranchId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("event.branchOffice.branchId={0} is not valid", event.getBranchOffice().getBranchId())); //NOI18N
- }
-
- // Add instance to cache
- this.branchOfficeCache.put(event.getBranchOffice().getBranchId(), event.getBranchOffice());
- }
-
- @Override
- public List<BranchOffice> allBranchOffices () {
- // Init list
- final List<BranchOffice> list = new LinkedList<>();
-
- // Get iterator
- final Iterator<Cache.Entry<Long, BranchOffice>> iterator = this.branchOfficeCache.iterator();
-
- // Loop over all
- while (iterator.hasNext()) {
- // Get next entry
- final Cache.Entry<Long, BranchOffice> next = iterator.next();
-
- // Add value to list
- list.add(next.getValue());
- }
-
- // Return it
- return list;
- }
-
- /**
- * Initializer method
- */
- @PostConstruct
- public void initializeList () {
- // Is cache there?
- if (!this.branchOfficeCache.iterator().hasNext()) {
- // Get whole list
- final List<BranchOffice> list = this.branchOfficeBean.allBranchOffices();
-
- // Add all
- for (final Iterator<BranchOffice> iterator = list.iterator(); iterator.hasNext();) {
- // Get next element
- final BranchOffice next = iterator.next();
-
- // Add it to cache
- this.branchOfficeCache.put(next.getBranchId(), next);
- }
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.business.branchoffice;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontactsbusiness.branchoffice.BranchOffice;
-
-/**
- * An interface for general branch office controller
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsBranchOfficeWebRequestController extends Serializable {
-
- /**
- * Returns a list of all branch offices
- * <p>
- * @return A list of all branch offices
- */
- List<BranchOffice> allBranchOffices ();
-
-}
}
// Remove it from list
- this.contacts.remove(event.getUnlinkedFaxNumber());
+ this.contactsPhoneCache.remove(event.getUnlinkedFaxNumber());
// Clear all data
this.clear();
}
// Remove it from list
- this.contacts.remove(event.getUnlinkedLandLineNumber());
+ this.contactsPhoneCache.remove(event.getUnlinkedLandLineNumber());
// Clear all data
this.clear();
}
// Remove it from list
- this.contacts.remove(event.getUnlinkedMobileNumber());
+ this.contactsPhoneCache.remove(event.getUnlinkedMobileNumber());
// Clear all data
this.clear();
final DialableFaxNumber number = this.getFaxNumber();
// Is cache there?
- if (this.contacts.containsKey(number)) {
+ if (this.contactsPhoneCache.containsKey(number)) {
// Return cached version
- return this.contacts.get(number);
+ return this.contactsPhoneCache.get(number);
} else {
// Ask bean
final List<Contact> list = new LinkedList<>();
}
// Store result in cache
- this.contacts.put(number, list);
+ this.contactsPhoneCache.put(number, list);
// Return now-cached list
return list;
final DialableLandLineNumber number = this.getLandLineNumber();
// Is cache there?
- if (this.contacts.containsKey(number)) {
+ if (this.contactsPhoneCache.containsKey(number)) {
// Return cached version
- return this.contacts.get(number);
+ return this.contactsPhoneCache.get(number);
} else {
// Ask bean
final List<Contact> list = new LinkedList<>();
}
// Store result in cache
- this.contacts.put(number, list);
+ this.contactsPhoneCache.put(number, list);
// Return now-cached list
return list;
final DialableMobileNumber number = this.getMobileNumber();
// Is cache there?
- if (this.contacts.containsKey(number)) {
+ if (this.contactsPhoneCache.containsKey(number)) {
// Return cached version
- return this.contacts.get(number);
+ return this.contactsPhoneCache.get(number);
} else {
// Ask bean
final List<Contact> list = new LinkedList<>();
}
// Store result in cache
- this.contacts.put(number, list);
+ this.contactsPhoneCache.put(number, list);
// Return now-cached list
return list;