/*
- * Copyright (C) 2016 Roland Häder
+ * Copyright (C) 2016, 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
package org.mxchange.jjobs.beans.phone;
import java.text.MessageFormat;
+import java.util.Calendar;
import java.util.List;
import java.util.Objects;
+import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.BaseJobsController;
+import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent;
import org.mxchange.jphone.events.fax.deleted.AdminFaxNumberDeletedEvent;
import org.mxchange.jphone.events.fax.removed.AdminFaxNumberRemovedFromListEvent;
import org.mxchange.jphone.events.fax.removed.AdminRemoveFaxNumberFromListEvent;
import org.mxchange.jphone.events.fax.updated.AdminFaxNumberUpdatedEvent;
import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent;
import org.mxchange.jphone.events.landline.deleted.AdminLandLineNumberDeletedEvent;
import org.mxchange.jphone.events.landline.removed.AdminLandLineNumberRemovedFromListEvent;
import org.mxchange.jphone.events.landline.removed.AdminRemoveLandLineNumberFromListEvent;
import org.mxchange.jphone.events.landline.updated.AdminLandLineNumberUpdatedEvent;
import org.mxchange.jphone.events.landline.updated.AdminUpdatedLandLineNumberEvent;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent;
import org.mxchange.jphone.events.mobile.deleted.AdminMobileNumberDeletedEvent;
import org.mxchange.jphone.events.mobile.remove.AdminMobileNumberRemovedFromListEvent;
import org.mxchange.jphone.events.mobile.updated.AdminMobileNumberUpdatedEvent;
import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent;
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.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
-import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
/**
* Administrative controller (bean) for phone numbers
/**
* Remote EJB for phone number (administrative)
*/
+ @EJB (lookup = "java:global/jjobs-ejb/adminPhone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote")
private AdminPhoneSessionBeanRemote adminPhoneBean;
/**
- * Bean helper
+ * fax number
*/
- @Inject
- private JobsWebRequestHelperController beanHelper;
-
- /**
- * Choosen fax number
- */
- private DialableFaxNumber choosenFaxNumber;
-
- /**
- * Choosen land-line number
- */
- private DialableLandLineNumber choosenLandLineNumber;
-
- /**
- * Choosen mobile number
- */
- private DialableMobileNumber choosenMobileNumber;
+ private DialableFaxNumber faxNumber;
/**
* Event being fired when an administrator has deleted fax number
@Any
private Event<AdminDeletedFaxNumberEvent> faxNumberDeletedEvent;
-
/**
* Event being fired when an administrator has updated fax number
*/
@Inject
@Any
private Event<AdminUpdatedFaxNumberEvent> faxNumberUpdatedEvent;
+
+ /**
+ * land-line number
+ */
+ private DialableLandLineNumber landLineNumber;
+
/**
* Event being fired when an administrator has deleted land-line number
*/
@Inject
@Any
private Event<AdminUpdatedLandLineNumberEvent> landLineNumberUpdatedEvent;
+
+ /**
+ * Chosen mobile number
+ */
+ private DialableMobileNumber mobileNumber;
+
/**
* Event being fired when an administrator has deleted mobile number
*/
*/
private Country phoneCountry;
+ /**
+ * When the phone entry has been created (persisted)
+ */
+ private Calendar phoneEntryCreated;
+
+ /**
+ * When the phone entry has been updated
+ */
+ private Calendar phoneEntryUpdated;
+
+ /**
+ * Phone id (aka primary key)
+ */
+ private Long phoneId;
+
/**
* Phone number
*/
* Default constructor
*/
public JobsAdminPhoneWebRequestBean () {
+ // Call super constructor
+ super();
+
// String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[3].getClassName(), Thread.currentThread().getStackTrace()[3].getMethodName());
// System.out.println(MessageFormat.format("{0}: Constructed, caller: {1}", this.getClass().getSimpleName(), caller));
+ }
+
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * fax number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedFaxNumberEvent (@Observes final ObservableCreatedFaxNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getFaxNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.faxNumber is null"); //NOI18N
+ } else if (event.getFaxNumber().getPhoneId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.faxNumber.phoneId is null"); //NOI18N
+ } else if (event.getFaxNumber().getPhoneId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.faxNumber.phoneId={0} is invalid", event.getFaxNumber().getPhoneId())); //NOI18N
+ }
+
+ // Get fax number from event
+ DialableFaxNumber number = event.getFaxNumber();
- // Try it
- try {
- // Get initial context
- Context context = new InitialContext();
+ // Copy all data to this bean
+ this.setPhoneId(number.getPhoneId());
+ this.setPhoneCountry(number.getPhoneCountry());
+ this.setPhoneAreaCode(number.getPhoneAreaCode());
+ this.setPhoneNumber(number.getPhoneNumber());
+ this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+ this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+ }
- // Try to lookup the beans
- this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jjobs-ejb/adminPhone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw it again
- throw new FaceletException(e);
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * land-line number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedLandLineNumberEvent (@Observes final ObservableCreatedLandLineNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getLandLineNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.landLineNumber is null"); //NOI18N
+ } else if (event.getLandLineNumber().getPhoneId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.landLineNumber.phoneId is null"); //NOI18N
+ } else if (event.getLandLineNumber().getPhoneId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.landLineNumber.phoneId={0} is invalid", event.getLandLineNumber().getPhoneId())); //NOI18N
}
+
+ // Get fax number from event
+ DialableLandLineNumber number = event.getLandLineNumber();
+
+ // Copy all data to this bean
+ this.setPhoneId(number.getPhoneId());
+ this.setPhoneCountry(number.getPhoneCountry());
+ this.setPhoneAreaCode(number.getPhoneAreaCode());
+ this.setPhoneNumber(number.getPhoneNumber());
+ this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+ this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
}
- @Override
+ /**
+ * Observes events being fired when a bean helper has successfully created a
+ * mobile number instance.
+ * <p>
+ * @param event Event being fired
+ */
+ public void afterCreatedMobileNumberEvent (@Observes final ObservableCreatedMobileNumberEvent event) {
+ // The event instance must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getMobileNumber() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.mobileNumber is null"); //NOI18N
+ } else if (event.getMobileNumber().getPhoneId() == null) {
+ // Throw NPE yet again
+ throw new NullPointerException("event.mobileNumber.phoneId is null"); //NOI18N
+ } else if (event.getMobileNumber().getPhoneId() < 1) {
+ // Throw NPE yet again
+ throw new NullPointerException(MessageFormat.format("event.mobileNumber.phoneId={0} is invalid", event.getMobileNumber().getPhoneId())); //NOI18N
+ }
+
+ // Get fax number from event
+ DialableMobileNumber number = event.getMobileNumber();
+
+ // Copy all data to this bean
+ this.setPhoneId(number.getPhoneId());
+ this.setMobileProvider(number.getMobileProvider());
+ this.setPhoneNumber(number.getPhoneNumber());
+ this.setPhoneEntryCreated(number.getPhoneEntryCreated());
+ this.setPhoneEntryUpdated(number.getPhoneEntryUpdated());
+ }
+
+ /**
+ * Returns a list of all unused ("non-linked") land-line numbers
+ * <p>
+ * @return List with all unused land-line numbers
+ */
public List<DialableFaxNumber> allNonLinkedFaxNumbers () {
// Get list of all mobile numbers
List<DialableFaxNumber> list = this.phoneController.allFaxNumbers();
return list;
}
- @Override
+ /**
+ * Returns a list of all unused ("non-linked") land-line numbers
+ * <p>
+ * @return List with all unused land-line numbers
+ */
public List<DialableLandLineNumber> allNonLinkedLandLineNumbers () {
// Get list of all mobile numbers
List<DialableLandLineNumber> list = this.phoneController.allLandLineNumbers();
return list;
}
- @Override
+ /**
+ * Returns a list of all unused ("non-linked") mobile numbers
+ * <p>
+ * @return List with all unused mobile numbers
+ */
public List<DialableMobileNumber> allNonLinkedMobileNumbers () {
// Get list of all mobile numbers
List<DialableMobileNumber> list = this.phoneController.allMobileNumbers();
return list;
}
- @Override
- public String deleteFaxData (final DialableFaxNumber faxNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.deleteFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
+ /**
+ * Deletes given fax entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String deleteFaxData () {
+ // Get fax number from bean helper
+ DialableFaxNumber number = this.createFaxNumber();
// Is all data set
- if (faxNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
- } else if (faxNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
- } else if (faxNumber.getPhoneCountry() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getPhoneCountry() == null) {
// Throw NPE
throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
- } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
+ } else if (number.getPhoneCountry().getCountryId() == null) {
// Throw NPE
throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
- } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
+ } else if (number.getPhoneCountry().getCountryId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
- } else if (faxNumber.getPhoneAreaCode() == null) {
+ throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", number.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (number.getPhoneAreaCode() == null) {
// ... throw again
throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
- } else if (faxNumber.getPhoneAreaCode() < 1) {
+ } else if (number.getPhoneAreaCode() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
- } else if (faxNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", number.getPhoneAreaCode())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
}
// Call EJB
- this.adminPhoneBean.deleteFaxData(faxNumber);
+ this.adminPhoneBean.deleteFaxData(number);
// Fire event
- this.faxNumberDeletedEvent.fire(new AdminFaxNumberDeletedEvent(faxNumber));
+ this.faxNumberDeletedEvent.fire(new AdminFaxNumberDeletedEvent(number));
// All fine, redirect
return "admin_list_fax"; //NOI18N
}
- @Override
- public String deleteLandLineData (final DialableLandLineNumber landLineNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.deleteLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
+ /**
+ * Deletes given land-line entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String deleteLandLineData () {
+ // Get land-line number from helper
+ DialableLandLineNumber number = this.createLandLineNumber();
// Is all data set
- if (landLineNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
- } else if (landLineNumber.getPhoneCountry() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getPhoneCountry() == null) {
// Throw NPE
throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
- } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
+ } else if (number.getPhoneCountry().getCountryId() == null) {
// Throw NPE
throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
- } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
+ } else if (number.getPhoneCountry().getCountryId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
- } else if (landLineNumber.getPhoneAreaCode() == null) {
+ throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", number.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (number.getPhoneAreaCode() == null) {
// ... throw again
throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
- } else if (landLineNumber.getPhoneAreaCode() < 1) {
+ } else if (number.getPhoneAreaCode() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
- } else if (landLineNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", number.getPhoneAreaCode())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
}
// Call EJB
- this.adminPhoneBean.deleteLandLineData(landLineNumber);
+ this.adminPhoneBean.deleteLandLineData(number);
// Fire event
- this.landLineNumberDeletedEvent.fire(new AdminLandLineNumberDeletedEvent(landLineNumber));
+ this.landLineNumberDeletedEvent.fire(new AdminLandLineNumberDeletedEvent(number));
// All fine, redirect
return "admin_list_landline"; //NOI18N
}
- @Override
- public String deleteMobileData (final DialableMobileNumber mobileNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.deleteMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); //NOI18N
+ /**
+ * Deletes given mobile entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String deleteMobileData () {
+ // Get mobile number from helper
+ DialableMobileNumber number = this.createMobileNumber();
// Is all data set
- if (mobileNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
- } else if (mobileNumber.getMobileProvider() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
// Throw NPE
throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+ } else if (number.getMobileProvider().getProviderId() == null) {
// ... throw again
throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+ } else if (number.getMobileProvider().getProviderId() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
- } else if (mobileNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
}
// Call EJB
- this.adminPhoneBean.deleteMobileData(mobileNumber);
+ this.adminPhoneBean.deleteMobileData(number);
// Fire event
- this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(mobileNumber));
+ this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
// All fine, redirect
return "admin_list_mobile"; //NOI18N
}
- @Override
- public String editFaxData (final DialableFaxNumber faxNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editFaxData: faxNumber={1} - CALLED!", this.getClass().getSimpleName(), faxNumber)); //NOI18N
+ /**
+ * Changes fax entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doChangeFaxNumber () {
+ // Get fax number from bean helper
+ DialableFaxNumber number = this.createFaxNumber();
// Is all data set
- if (faxNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("faxNumber.phoneId is null"); //NOI18N
- } else if (faxNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", faxNumber.getPhoneId())); //NOI18N
- } else if (faxNumber.getPhoneCountry() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getPhoneCountry() == null) {
// Throw NPE
throw new NullPointerException("faxNumber.phoneCountry is null"); //NOI18N
- } else if (faxNumber.getPhoneCountry().getCountryId() == null) {
+ } else if (number.getPhoneCountry().getCountryId() == null) {
// Throw NPE
throw new NullPointerException("faxNumber.phoneCountry.countryId is null"); //NOI18N
- } else if (faxNumber.getPhoneCountry().getCountryId() < 1) {
+ } else if (number.getPhoneCountry().getCountryId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", faxNumber.getPhoneCountry().getCountryId())); //NOI18N
- } else if (faxNumber.getPhoneAreaCode() == null) {
+ throw new NullPointerException(MessageFormat.format("faxNumber.phoneCountry.countryId={0} is not valid", number.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (number.getPhoneAreaCode() == null) {
// ... throw again
throw new NullPointerException("faxNumber.phoneAreaCode is null"); //NOI18N
- } else if (faxNumber.getPhoneAreaCode() < 1) {
+ } else if (number.getPhoneAreaCode() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", faxNumber.getPhoneAreaCode())); //NOI18N
- } else if (faxNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneAreaCode={0} is not valid.", number.getPhoneAreaCode())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("faxNumber.phoneNumber is null"); //NOI18N
- } else if (faxNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", faxNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("faxNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
}
// Is the mobile provider and number the same?
- if ((Objects.equals(this.getPhoneCountry(), faxNumber.getPhoneCountry())) && (Objects.equals(this.getPhoneAreaCode(), faxNumber.getPhoneAreaCode())) && (Objects.equals(this.getPhoneNumber(), faxNumber.getPhoneNumber()))) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editFaxData: No difference - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
+ if ((Objects.equals(this.getPhoneCountry(), number.getPhoneCountry())) && (Objects.equals(this.getPhoneAreaCode(), number.getPhoneAreaCode())) && (Objects.equals(this.getPhoneNumber(), number.getPhoneNumber()))) {
// Show message
this.showFacesMessage("form_edit_fax:faxNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED"); //NOI18N
}
// Set all data
- faxNumber.setPhoneCountry(this.getPhoneCountry());
- faxNumber.setPhoneAreaCode(this.getPhoneAreaCode());
- faxNumber.setPhoneNumber(this.getPhoneNumber());
+ number.setPhoneCountry(this.getPhoneCountry());
+ number.setPhoneAreaCode(this.getPhoneAreaCode());
+ number.setPhoneNumber(this.getPhoneNumber());
// Send to bean
- DialableFaxNumber updatedNumber = this.adminPhoneBean.updateFaxData(faxNumber);
+ DialableFaxNumber updatedNumber = this.adminPhoneBean.updateFaxData(number);
// Fire event
this.faxNumberUpdatedEvent.fire(new AdminFaxNumberUpdatedEvent(updatedNumber));
return "admin_show_fax"; //NOI18N
}
- @Override
- public String editLandLineData (final DialableLandLineNumber landLineNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editLandLineData: landLineNumber={1} - CALLED!", this.getClass().getSimpleName(), landLineNumber)); //NOI18N
+ /**
+ * Changes land-line entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doChangeLandLineNumber () {
+ // Get land-line number from helper
+ DialableLandLineNumber number = this.createLandLineNumber();
// Is all data set
- if (landLineNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- } else if (landLineNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", landLineNumber.getPhoneId())); //NOI18N
- } else if (landLineNumber.getPhoneCountry() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getPhoneCountry() == null) {
// Throw NPE
throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18N
- } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
+ } else if (number.getPhoneCountry().getCountryId() == null) {
// Throw NPE
throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18N
- } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
+ } else if (number.getPhoneCountry().getCountryId() < 1) {
// Throw NPE
- throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18N
- } else if (landLineNumber.getPhoneAreaCode() == null) {
+ throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is not valid", number.getPhoneCountry().getCountryId())); //NOI18N
+ } else if (number.getPhoneAreaCode() == null) {
// ... throw again
throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18N
- } else if (landLineNumber.getPhoneAreaCode() < 1) {
+ } else if (number.getPhoneAreaCode() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", landLineNumber.getPhoneAreaCode())); //NOI18N
- } else if (landLineNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is not valid.", number.getPhoneAreaCode())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18N
- } else if (landLineNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", landLineNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("landLineNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
}
// Is the mobile provider and number the same?
- if ((Objects.equals(this.getPhoneCountry(), landLineNumber.getPhoneCountry())) && (Objects.equals(this.getPhoneAreaCode(), landLineNumber.getPhoneAreaCode())) && (Objects.equals(this.getPhoneNumber(), landLineNumber.getPhoneNumber()))) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editLandLineData: No difference - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
+ if ((Objects.equals(this.getPhoneCountry(), number.getPhoneCountry())) && (Objects.equals(this.getPhoneAreaCode(), number.getPhoneAreaCode())) && (Objects.equals(this.getPhoneNumber(), number.getPhoneNumber()))) {
// Show message
this.showFacesMessage("form_edit_landline:landLineNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED"); //NOI18N
}
// Set all data
- landLineNumber.setPhoneCountry(this.getPhoneCountry());
- landLineNumber.setPhoneAreaCode(this.getPhoneAreaCode());
- landLineNumber.setPhoneNumber(this.getPhoneNumber());
+ number.setPhoneCountry(this.getPhoneCountry());
+ number.setPhoneAreaCode(this.getPhoneAreaCode());
+ number.setPhoneNumber(this.getPhoneNumber());
// Send to bean
- DialableLandLineNumber updatedNumber = this.adminPhoneBean.updateLandLineData(landLineNumber);
+ DialableLandLineNumber updatedNumber = this.adminPhoneBean.updateLandLineData(number);
// Fire event
this.landLineNumberUpdatedEvent.fire(new AdminLandLineNumberUpdatedEvent(updatedNumber));
return "admin_show_landline"; //NOI18N
}
- @Override
- public String editMobileData (final DialableMobileNumber mobileNumber) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); //NOI18N
+ /**
+ * Changes mobile entry data
+ * <p>
+ * @return Redirect outcome
+ */
+ public String doUpdateMobileNumber () {
+ // Get mobile number from helper
+ DialableMobileNumber number = this.createMobileNumber();
// Is all data set
- if (mobileNumber == null) {
+ if (number == null) {
// Not set, throw NPE
throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() == null) {
+ } else if (number.getPhoneId() == null) {
// Throw NPE again
throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N
- } else if (mobileNumber.getPhoneId() < 1) {
+ } else if (number.getPhoneId() < 1) {
// Invalid number
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getPhoneId())); //NOI18N
- } else if (mobileNumber.getMobileProvider() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", number.getPhoneId())); //NOI18N
+ } else if (number.getMobileProvider() == null) {
// Throw NPE
throw new NullPointerException("mobileNumber.mobileProvider is null"); //NOI18N
- } else if (mobileNumber.getMobileProvider().getProviderId() == null) {
+ } else if (number.getMobileProvider().getProviderId() == null) {
// ... throw again
throw new NullPointerException("mobileNumber.mobileProvider.providerId is null"); //NOI18N
- } else if (mobileNumber.getMobileProvider().getProviderId() < 1) {
+ } else if (number.getMobileProvider().getProviderId() < 1) {
// Id not valid
- throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N
- } else if (mobileNumber.getPhoneNumber() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumber.mobileProvider.providerId={0} is not valid.", number.getMobileProvider().getProviderId())); //NOI18N
+ } else if (number.getPhoneNumber() == null) {
// Throw NPE again
throw new NullPointerException("mobileNumber.phoneNumber is null"); //NOI18N
- } else if (mobileNumber.getPhoneNumber() < 1) {
+ } else if (number.getPhoneNumber() < 1) {
// Throw NPE again
- throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", mobileNumber.getPhoneNumber())); //NOI18N
+ throw new NullPointerException(MessageFormat.format("mobileNumber.phoneNumber={0} is not valid.", number.getPhoneNumber())); //NOI18N
} else if (this.getMobileProvider() == null) {
// Not provided
this.showFacesMessage("form_edit_mobile:mobileProvider", "ERROR_ADMIN_NO_MOBILE_PROVIDER_SELECTED"); //NOI18N
return ""; //NOI18N
}
- // Log message
- System.out.println(MessageFormat.format("{0}.editMobileData: this.mobileProvider.providerId={1},mobileNumber.mobileProvider.providerId={2},this.phoneNumber={3},mobileNumber.phoneNumber={4}", this.getClass().getSimpleName(), this.getMobileProvider().getProviderId(), mobileNumber.getMobileProvider().getProviderId(), this.getPhoneNumber(), mobileNumber.getPhoneNumber())); //NOI18N
-
// Is the mobile provider and number the same?
- if ((Objects.equals(this.getMobileProvider(), mobileNumber.getMobileProvider())) && (Objects.equals(this.getPhoneNumber(), mobileNumber.getPhoneNumber()))) {
- // Log message
- System.out.println(MessageFormat.format("{0}.editMobileData: No difference - EXIT!", this.getClass().getSimpleName())); //NOI18N
-
+ if ((Objects.equals(this.getMobileProvider(), number.getMobileProvider())) && (Objects.equals(this.getPhoneNumber(), number.getPhoneNumber()))) {
// Show message
this.showFacesMessage("form_edit_mobile:mobileNumber", "ERROR_ADMIN_NO_CHANGE_ENTERED"); //NOI18N
}
// Set all data
- mobileNumber.setMobileProvider(this.getMobileProvider());
- mobileNumber.setPhoneNumber(this.getPhoneNumber());
+ number.setMobileProvider(this.getMobileProvider());
+ number.setPhoneNumber(this.getPhoneNumber());
// Send to bean
- DialableMobileNumber updatedNumber = this.adminPhoneBean.updateMobileData(mobileNumber);
+ DialableMobileNumber updatedNumber = this.adminPhoneBean.updateMobileData(number);
// Fire event
this.mobileNumberUpdatedEvent.fire(new AdminMobileNumberUpdatedEvent(updatedNumber));
return "admin_show_mobile"; //NOI18N
}
- @Override
- public DialableFaxNumber getChoosenFaxNumber () {
- // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
- // System.out.println(MessageFormat.format("{0}: Returning this.choosenFaxNumber={1}, caller: {2}", this.getClass().getSimpleName(), this.choosenFaxNumber, caller));
- return this.choosenFaxNumber;
+ /**
+ * Getter for chosen fax number
+ * <p>
+ * @return fax number
+ */
+ public DialableFaxNumber getFaxNumber () {
+ return this.faxNumber;
}
- @Override
- public void setChoosenFaxNumber (final DialableFaxNumber choosenFaxNumber) {
- // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName());
- // System.out.println(MessageFormat.format("{0}: Settin choosenFaxNumber={1}, previous: this.choosenFaxNumber={2}, caller: {3}", this.getClass().getSimpleName(), choosenFaxNumber, this.choosenFaxNumber, caller));
- this.choosenFaxNumber = choosenFaxNumber;
+ /**
+ * Setter for chosen fax number
+ * <p>
+ * @param faxNumber fax number
+ */
+ public void setFaxNumber (final DialableFaxNumber faxNumber) {
+ this.faxNumber = faxNumber;
}
- @Override
- public DialableLandLineNumber getChoosenLandLineNumber () {
- return this.choosenLandLineNumber;
+ /**
+ * Getter for chosen land-line number
+ * <p>
+ * @return land-line number
+ */
+ public DialableLandLineNumber getLandLineNumber () {
+ return this.landLineNumber;
}
- @Override
- public void setChoosenLandLineNumber (final DialableLandLineNumber choosenLandLineNumber) {
- this.choosenLandLineNumber = choosenLandLineNumber;
+ /**
+ * Setter for chosen land-line number
+ * <p>
+ * @param landLineNumber land-line number
+ */
+ public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
+ this.landLineNumber = landLineNumber;
}
- @Override
- public DialableMobileNumber getChoosenMobileNumber () {
- return this.choosenMobileNumber;
+ /**
+ * Getter for chosen mobile number
+ * <p>
+ * @return mobile number
+ */
+ public DialableMobileNumber getMobileNumber () {
+ return this.mobileNumber;
}
- @Override
- public void setChoosenMobileNumber (final DialableMobileNumber choosenMobileNumber) {
- this.choosenMobileNumber = choosenMobileNumber;
+ /**
+ * Setter for chosen mobile number
+ * <p>
+ * @param mobileNumber mobile number
+ */
+ public void setMobileNumber (final DialableMobileNumber mobileNumber) {
+ this.mobileNumber = mobileNumber;
}
- @Override
+ /**
+ * Getter for mobile provider
+ * <p>
+ * @return Mobile provider
+ */
public MobileProvider getMobileProvider () {
return this.mobileProvider;
}
- @Override
+ /**
+ * Setter for mobile provider
+ * <p>
+ * @param mobileProvider Mobile provider
+ */
public void setMobileProvider (final MobileProvider mobileProvider) {
this.mobileProvider = mobileProvider;
}
- @Override
+ /**
+ * Getter for phone area code
+ * <p>
+ * @return Phone area code
+ */
public Integer getPhoneAreaCode () {
return this.phoneAreaCode;
}
- @Override
+ /**
+ * Setter for phone area code
+ * <p>
+ * @param phoneAreaCode Phone area code
+ */
public void setPhoneAreaCode (final Integer phoneAreaCode) {
this.phoneAreaCode = phoneAreaCode;
}
- @Override
+ /**
+ * Getter for phone country (for dial prefix)
+ * <p>
+ * @return Phone country
+ */
public Country getPhoneCountry () {
return this.phoneCountry;
}
- @Override
+ /**
+ * Setter for phone country (for dial prefix)
+ * <p>
+ * @param phoneCountry Phone country
+ */
public void setPhoneCountry (final Country phoneCountry) {
this.phoneCountry = phoneCountry;
}
- @Override
+ /**
+ * Getter for phone entry created timestamp
+ * <p>
+ * @return Phone entry created timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getPhoneEntryCreated () {
+ return this.phoneEntryCreated;
+ }
+
+ /**
+ * Setter for phone entry created timestamp
+ * <p>
+ * @param phoneEntryCreated Phone entry created timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setPhoneEntryCreated (final Calendar phoneEntryCreated) {
+ this.phoneEntryCreated = phoneEntryCreated;
+ }
+
+ /**
+ * Getter for phone entry updated timestamp
+ * <p>
+ * @return Phone entry updated timestamp
+ */
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getPhoneEntryUpdated () {
+ return this.phoneEntryUpdated;
+ }
+
+ /**
+ * Setter for phone entry updated timestamp
+ * <p>
+ * @param phoneEntryUpdated Phone entry updated timestamp
+ */
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setPhoneEntryUpdated (final Calendar phoneEntryUpdated) {
+ this.phoneEntryUpdated = phoneEntryUpdated;
+ }
+
+ /**
+ * Getter for phone id
+ * <p>
+ * @return Phone id
+ */
+ public Long getPhoneId () {
+ return this.phoneId;
+ }
+
+ /**
+ * Setter for phone id
+ * <p>
+ * @param phoneId Phone id
+ */
+ public void setPhoneId (final Long phoneId) {
+ this.phoneId = phoneId;
+ }
+
+ /**
+ * Getter for dial number without prefix
+ * <p>
+ * @return Dial number without prefix
+ */
public Long getPhoneNumber () {
return this.phoneNumber;
}
- @Override
+ /**
+ * Setter for dial number without prefix
+ * <p>
+ * @param phoneNumber Dial number without prefix
+ */
public void setPhoneNumber (final Long phoneNumber) {
- System.out.println(MessageFormat.format("{0}: Setting phoneNumber={1},previous:{2}", this.getClass().getSimpleName(), phoneNumber, this.phoneNumber));
this.phoneNumber = phoneNumber;
}
+ /**
+ * Returns an instance of a DialableFaxNumber from all fields stored in this
+ * bean.
+ * <p>
+ * @return An instance of a DialableFaxNumber class
+ */
+ private DialableFaxNumber createFaxNumber () {
+ // Initialize it
+ DialableFaxNumber number = new FaxNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+ // Add all other data
+ number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+ number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+ // Is id number set?
+ if (this.getPhoneId() instanceof Long) {
+ // Set it
+ number.setPhoneId(this.getPhoneId());
+ }
+
+ // Return it
+ return number;
+ }
+
+ /**
+ * Returns an instance of a DialableLandLineNumber from all fields stored in
+ * this bean.
+ * <p>
+ * @return An instance of a DialableLandLineNumber class
+ */
+ private DialableLandLineNumber createLandLineNumber () {
+ // Initialize it
+ DialableLandLineNumber number = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
+
+ // Add all other data
+ number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+ number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+ // Is id number set?
+ if (this.getPhoneId() instanceof Long) {
+ // Set it
+ number.setPhoneId(this.getPhoneId());
+ }
+
+ // Return it
+ return number;
+ }
+
+ /**
+ * Returns an instance of a DialableMobileNumber from all fields stored in
+ * this bean.
+ * <p>
+ * @return An instance of a DialableMobileNumber class
+ */
+ private DialableMobileNumber createMobileNumber () {
+ // Initialize it
+ DialableMobileNumber number = new MobileNumber(this.getMobileProvider(), this.getPhoneNumber());
+
+ // Add all other data
+ number.setPhoneEntryCreated(this.getPhoneEntryCreated());
+ number.setPhoneEntryUpdated(this.getPhoneEntryUpdated());
+
+ // Is id number set?
+ if (this.getPhoneId() instanceof Long) {
+ // Set it
+ number.setPhoneId(this.getPhoneId());
+ }
+
+ // Return it
+ return number;
+ }
+
}