<Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project">
- <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="1150" y="150" zoom="true"/>
- <Node id="user/login_logout.xhtml" x="2900" y="150" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_delete.xhtml" x="1400" y="300" zoom="true"/>
- <Node id="admin/contact/admin_contact_show.xhtml" x="1150" y="900" zoom="true"/>
- <Node id="privacy.xhtml" x="1900" y="300" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="1400" y="150" zoom="true"/>
- <Node id="guest/user/show_addressbook.xhtml" x="400" y="900" zoom="true"/>
- <Node id="admin/user/admin_user_show.xhtml" x="2400" y="150" zoom="true"/>
- <Node id="admin/index.xhtml" x="400" y="450" zoom="true"/>
- <Node id="user/login_own_addressbooks.xhtml" x="650" y="1200" zoom="true"/>
- <Node id="user/login_user_data_saved.xhtml" x="1150" y="300" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_show.xhtml" x="900" y="1200" zoom="true"/>
+ <Node id="user/login_logout.xhtml" x="150" y="450" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_list.xhtml" x="1650" y="300" zoom="true"/>
+ <Node id="admin/cellphone/admin_cellphone_delete.xhtml" x="1150" y="450" zoom="true"/>
+ <Node id="admin/contact/admin_contact_show.xhtml" x="900" y="300" zoom="true"/>
+ <Node id="privacy.xhtml" x="1150" y="150" zoom="true"/>
+ <Node id="guest/user/show_addressbook.xhtml" x="650" y="150" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_show.xhtml" x="2900" y="150" zoom="true"/>
+ <Node id="admin/user/admin_user_show.xhtml" x="1900" y="300" zoom="true"/>
+ <Node id="admin/index.xhtml" x="650" y="750" zoom="true"/>
+ <Node id="user/login_own_addressbooks.xhtml" x="2150" y="150" zoom="true"/>
+ <Node id="user/login_user_data_saved.xhtml" x="1150" y="900" zoom="true"/>
+ <Node id="admin/cellphone/admin_cellphone_show.xhtml" x="400" y="450" zoom="true"/>
<Node id="admin/admin_logout.xhtml" x="400" y="150" zoom="true"/>
- <Node id="user/login_data_saved.xhtml" x="2150" y="150" zoom="true"/>
- <Node id="admin/user/admin_user_unlock.xhtml" x="900" y="750" zoom="true"/>
- <Node id="admin/cellphone/admin_cellphone_edit.xhtml" x="400" y="1050" zoom="true"/>
- <Node id="guest/user/user_list.xhtml" x="150" y="300" zoom="true"/>
- <Node id="index.xhtml" x="150" y="1650" zoom="true"/>
- <Node id="user/login_edit_user_data.xhtml" x="150" y="900" zoom="true"/>
- <Node id="*" x="150" y="1200" zoom="true"/>
- <Node id="admin/admin_category_delete.xhtml" x="900" y="900" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="650" y="300" zoom="true"/>
- <Node id="user/login_index.xhtml" x="900" y="450" zoom="true"/>
- <Node id="guest/user/lost_passwd.xhtml" x="900" y="1050" zoom="true"/>
- <Node id="guest/user/register_done.xhtml" x="150" y="600" zoom="true"/>
- <Node id="guest/user/show_addressbook_entries.xhtml" x="650" y="1050" zoom="true"/>
- <Node id="user/login.xhtml" x="900" y="300" zoom="true"/>
- <Node id="admin/country/admin_country_list.xhtml" x="650" y="450" zoom="true"/>
- <Node id="login/login_edit_user_data.xhtml" x="650" y="900" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="1400" y="900" zoom="true"/>
- <Node id="guest/user/login_error.xhtml" x="1400" y="750" zoom="true"/>
- <Node id="admin/user/admin_user_export.xhtml" x="150" y="450" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="150" y="150" zoom="true"/>
- <Node id="guest/user/resend_done.xhtml" x="1900" y="450" zoom="true"/>
- <Node id="user/login_change_password.xhtml" x="150" y="1350" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="2650" y="150" zoom="true"/>
+ <Node id="user/login_data_saved.xhtml" x="1900" y="150" zoom="true"/>
+ <Node id="admin/user/admin_user_unlock.xhtml" x="2650" y="150" zoom="true"/>
+ <Node id="admin/cellphone/admin_cellphone_edit.xhtml" x="2150" y="450" zoom="true"/>
+ <Node id="index.xhtml" x="150" y="300" zoom="true"/>
+ <Node id="guest/user/user_list.xhtml" x="1650" y="450" zoom="true"/>
+ <Node id="user/login_edit_user_data.xhtml" x="900" y="450" zoom="true"/>
+ <Node id="*" x="150" y="600" zoom="true"/>
+ <Node id="admin/admin_category_delete.xhtml" x="400" y="1200" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_edit.xhtml" x="150" y="1200" zoom="true"/>
+ <Node id="user/login_index.xhtml" x="2400" y="300" zoom="true"/>
+ <Node id="guest/user/lost_passwd.xhtml" x="400" y="900" zoom="true"/>
+ <Node id="guest/user/register_done.xhtml" x="650" y="1200" zoom="true"/>
+ <Node id="guest/user/show_addressbook_entries.xhtml" x="1650" y="150" zoom="true"/>
+ <Node id="user/login.xhtml" x="150" y="1050" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_unlink.xhtml" x="150" y="150" zoom="true"/>
+ <Node id="admin/country/admin_country_list.xhtml" x="400" y="600" zoom="true"/>
+ <Node id="login/login_edit_user_data.xhtml" x="650" y="1050" zoom="true"/>
+ <Node id="guest/user/login_error.xhtml" x="1650" y="600" zoom="true"/>
+ <Node id="admin/user/admin_user_export.xhtml" x="400" y="1500" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_delete.xhtml" x="400" y="300" zoom="true"/>
+ <Node id="guest/user/resend_done.xhtml" x="2650" y="300" zoom="true"/>
+ <Node id="user/login_change_password.xhtml" x="900" y="750" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_list.xhtml" x="400" y="1050" zoom="true"/>
<Node id="admin/contact/admin_contact_export.xhtml" x="1150" y="1050" zoom="true"/>
- <Node id="guest/user/user_profile.xhtml" x="400" y="300" zoom="true"/>
- <Node id="guest/user/confirm_account.xhtml" x="1900" y="150" zoom="true"/>
- <Node id="admin/user/admin_user_delete.xhtml" x="1150" y="600" zoom="true"/>
- <Node id="exception.xhtml" x="1900" y="600" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="400" y="1500" zoom="true"/>
- <Node id="login/login_index.xhtml" x="150" y="1500" zoom="true"/>
- <Node id="admin/user/admin_user_edit.xhtml" x="650" y="600" zoom="true"/>
- <Node id="guest/user/register_page2.xhtml" x="1650" y="600" zoom="true"/>
- <Node id="terms.xhtml" x="400" y="750" zoom="true"/>
- <Node id="admin/contact/admin_contact_list.xhtml" x="1150" y="450" zoom="true"/>
- <Node id="admin/contact/admin_contact_edit.xhtml" x="2650" y="300" zoom="true"/>
- <Node id="admin/user/admin_user_lock.xhtml" x="650" y="150" zoom="true"/>
- <Node id="admin/admin_user_add.xhtml" x="1650" y="150" zoom="true"/>
- <Node id="admin/user/admin_user_list.xhtml" x="1650" y="750" zoom="true"/>
- <Node id="admin/country/admin_country_delete.xhtml" x="1400" y="450" zoom="true"/>
- <Node id="user/login_change_personal_data.xhtml" x="650" y="1350" zoom="true"/>
- <Node id="admin/country/admin_country_edit.xhtml" x="650" y="750" zoom="true"/>
- <Node id="logout.xhtml" x="1650" y="300" zoom="true"/>
- <Node id="user/login_add_addressbook.xhtml" x="900" y="150" zoom="true"/>
- <Node id="guest/user/resend_link.xhtml" x="2150" y="300" zoom="true"/>
- <Node id="user/login_contact_data_saved.xhtml" x="1150" y="750" zoom="true"/>
- <Node id="user/user_profile.xhtml" x="150" y="1050" zoom="true"/>
- <Node id="admin/contact/admin_contact_delete.xhtml" x="400" y="1350" zoom="true"/>
- <Node id="imprint.xhtml" x="2400" y="300" zoom="true"/>
- <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="1650" y="450" zoom="true"/>
- <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="1400" y="600" zoom="true"/>
- <Node id="guest/user/login.xhtml" x="400" y="600" zoom="true"/>
- <Node id="admin/admin_product_delete.xhtml" x="400" y="1200" zoom="true"/>
- <Node id="guest/user/register.xhtml" x="900" y="600" zoom="true"/>
- <Node id="user/login_change_email_address.xhtml" x="150" y="750" zoom="true"/>
- <Node id="user/login/login_data_saved.xhtml" x="2150" y="450" zoom="true"/>
+ <Node id="guest/user/user_profile.xhtml" x="400" y="750" zoom="true"/>
+ <Node id="guest/user/confirm_account.xhtml" x="1400" y="750" zoom="true"/>
+ <Node id="admin/user/admin_user_delete.xhtml" x="1400" y="150" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_delete.xhtml" x="1400" y="450" zoom="true"/>
+ <Node id="exception.xhtml" x="400" y="1350" zoom="true"/>
+ <Node id="login/login_index.xhtml" x="650" y="1350" zoom="true"/>
+ <Node id="admin/user/admin_user_edit.xhtml" x="1150" y="600" zoom="true"/>
+ <Node id="guest/user/register_page2.xhtml" x="1650" y="750" zoom="true"/>
+ <Node id="terms.xhtml" x="900" y="900" zoom="true"/>
+ <Node id="admin/contact/admin_contact_list.xhtml" x="650" y="300" zoom="true"/>
+ <Node id="admin/contact/admin_contact_edit.xhtml" x="650" y="600" zoom="true"/>
+ <Node id="admin/user/admin_user_lock.xhtml" x="900" y="600" zoom="true"/>
+ <Node id="admin/user/admin_user_list.xhtml" x="2150" y="300" zoom="true"/>
+ <Node id="admin/admin_user_add.xhtml" x="1900" y="450" zoom="true"/>
+ <Node id="admin/country/admin_country_delete.xhtml" x="1400" y="300" zoom="true"/>
+ <Node id="user/login_change_personal_data.xhtml" x="900" y="1050" zoom="true"/>
+ <Node id="logout.xhtml" x="900" y="150" zoom="true"/>
+ <Node id="admin/country/admin_country_edit.xhtml" x="650" y="900" zoom="true"/>
+ <Node id="user/login_add_addressbook.xhtml" x="650" y="450" zoom="true"/>
+ <Node id="guest/user/resend_link.xhtml" x="2400" y="450" zoom="true"/>
+ <Node id="admin/cellphone/admin_cellphone_list.xhtml" x="1400" y="600" zoom="true"/>
+ <Node id="user/login_contact_data_saved.xhtml" x="150" y="1350" zoom="true"/>
+ <Node id="admin/contact/admin_contact_delete.xhtml" x="150" y="1500" zoom="true"/>
+ <Node id="user/user_profile.xhtml" x="1900" y="600" zoom="true"/>
+ <Node id="imprint.xhtml" x="1400" y="900" zoom="true"/>
+ <Node id="admin/mobile_provider/admin_mobile_provider_edit.xhtml" x="150" y="1650" zoom="true"/>
+ <Node id="admin/cellphone/admin_contact_cellphone_show.xhtml" x="2400" y="150" zoom="true"/>
+ <Node id="guest/user/login.xhtml" x="1150" y="750" zoom="true"/>
+ <Node id="admin/admin_product_delete.xhtml" x="900" y="1200" zoom="true"/>
+ <Node id="guest/user/register.xhtml" x="150" y="900" zoom="true"/>
+ <Node id="user/login_change_email_address.xhtml" x="1150" y="300" zoom="true"/>
+ <Node id="user/login/login_data_saved.xhtml" x="150" y="750" zoom="true"/>
</Scope>
<Scope Scope="All Faces Configurations"/>
</Scene>
--- /dev/null
+/*
+ * Copyright (C) 2016 Cho-Time GmbH
+ *
+ * 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 de.chotime.landingpage.beans.phone;
+
+import de.chotime.landingpage.beans.BaseLandingController;
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+
+/**
+ * Regular bean (controller) for phone numbers
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@Named ("phoneController")
+@ApplicationScoped
+public class LandingPhoneWebApplicationBean extends BaseLandingController implements LandingPhoneWebApplicationController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 491_058_674_675_690_105L;
+
+ /**
+ * All cell phone numbers
+ */
+ private final List<DialableCellphoneNumber> cellphoneNumbers;
+
+ /**
+ * All fax numbers
+ */
+ private final List<DialableFaxNumber> faxNumbers;
+
+ /**
+ * All land-line numbers
+ */
+ private final List<DialableLandLineNumber> landLineNumbers;
+
+ /**
+ * General EJB for phone numbers
+ */
+ private PhoneSessionBeanRemote phoneBean;
+
+ /**
+ * Default constructor
+ */
+ public LandingPhoneWebApplicationBean () {
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup the beans
+ this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw it again
+ throw new FaceletException(e);
+ }
+
+ // Init all lists
+ this.cellphoneNumbers = new LinkedList<>();
+ this.faxNumbers = new LinkedList<>();
+ this.landLineNumbers = new LinkedList<>();
+ }
+
+ @Override
+ public void afterAdminAddedContact (@Observes final AdminAddedContactEvent event) {
+ // The event must be valid
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("event.addedContact is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() == null) {
+ // ... and again
+ throw new NullPointerException("event.addedContact.contactId is null"); //NOI18N
+ } else if (event.getAddedContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+ }
+
+ // Update contact's cellphone, land-line and fax number
+ this.updateContactPhoneNumbers(event.getAddedContact());
+
+ // Clear this bean
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getAddedUser() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.addedUser is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() == null) {
+ // userId is null
+ throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
+ } else if (event.getAddedUser().getUserId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
+ }
+
+ // Update contact's cellphone, land-line and fax number
+ this.updateContactPhoneNumbers(event.getAddedUser().getUserContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
+ // event should not be null
+ if (null == event) {
+ // Throw NPE
+ throw new NullPointerException("event is null"); //NOI18N
+ } else if (event.getUpdatedContact() == null) {
+ // Throw NPE again
+ throw new NullPointerException("event.updatedContact is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() == null) {
+ // userId is null
+ throw new NullPointerException("event.updatedContact.contactId is null"); //NOI18N
+ } else if (event.getUpdatedContact().getContactId() < 1) {
+ // Not avalid id
+ throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
+ }
+
+ // Update contact's cellphone, land-line and fax number
+ this.updateContactPhoneNumbers(event.getUpdatedContact());
+
+ // Clear all data
+ this.clear();
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableCellphoneNumber> allCellphoneNumbers () {
+ return this.cellphoneNumbers;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableFaxNumber> allFaxNumbers () {
+ return this.faxNumbers;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+ public List<DialableLandLineNumber> allLandLineNumbers () {
+ return this.landLineNumbers;
+ }
+
+ /**
+ * Post-construction method
+ */
+ @PostConstruct
+ public void init () {
+ // All phone numbers
+ this.cellphoneNumbers.addAll(this.phoneBean.allCellphoneNumbers());
+ this.faxNumbers.addAll(this.phoneBean.allFaxNumbers());
+ this.landLineNumbers.addAll(this.phoneBean.allLandLineNumbers());
+ }
+
+ /**
+ * Clears this bean
+ */
+ private void clear () {
+ // Clear all data
+ }
+
+ /**
+ * Uniquely add given cellphone number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param cellphoneNumber Cellphone number to add
+ */
+ private void uniqueAddCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
+ // Make sure the parameter is valid
+ if (null == cellphoneNumber) {
+ // Throw NPE
+ throw new NullPointerException("cellphoneNumber is null");
+ } else if (cellphoneNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("cellphoneNumber.phoneId is null");
+ } else if (cellphoneNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("cellphoneNumber.phoneId={0} is not valid.", cellphoneNumber.getPhoneId()));
+ }
+
+ // First remove it by object
+ if (!this.cellphoneNumbers.remove(cellphoneNumber)) {
+ // Did not work, try by id number
+ for (final DialableCellphoneNumber cell : this.cellphoneNumbers) {
+ // Is id number the same?
+ if (Objects.equals(cell.getPhoneId(), cellphoneNumber.getPhoneId())) {
+ // Found it
+ this.cellphoneNumbers.remove(cell);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.cellphoneNumbers.add(cellphoneNumber);
+ }
+
+ /**
+ * Uniquely add given fax number to this bean's list. First remove the old
+ * instance (by id number), then re-add it again.
+ * <p>
+ * @param faxNumber number to add
+ */
+ private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
+ // Make sure the parameter is valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null");
+ } else if (faxNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("faxNumber.phoneId is null");
+ } else if (faxNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId()));
+ }
+
+ // First remove it
+ if (!this.faxNumbers.remove(faxNumber)) {
+ // Did not work, try by id number
+ for (final DialableFaxNumber fax : this.faxNumbers) {
+ // Is id number the same?
+ if (Objects.equals(fax.getPhoneId(), faxNumber.getPhoneId())) {
+ // Found it
+ this.faxNumbers.remove(fax);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.faxNumbers.add(faxNumber);
+ }
+
+ /**
+ * Uniquely add given land-line number to this bean's list. First remove the
+ * old instance (by id number), then re-add it again.
+ * <p>
+ * @param landLineNumber Land-line number to add
+ */
+ private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
+ // Make sure the parameter is valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null");
+ } else if (landLineNumber.getPhoneId() == null) {
+ // Throw again ...
+ throw new NullPointerException("landLineNumber.phoneId is null");
+ } else if (landLineNumber.getPhoneId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId()));
+ }
+
+ // First remove it
+ if (!this.landLineNumbers.remove(landLineNumber)) {
+ // Did not work, try by id number
+ for (final DialableLandLineNumber landLine : this.landLineNumbers) {
+ // Is id number the same?
+ if (Objects.equals(landLine.getPhoneId(), landLineNumber.getPhoneId())) {
+ // Found it
+ this.landLineNumbers.remove(landLine);
+ break;
+ }
+ }
+ }
+
+ // ... then add it
+ this.landLineNumbers.add(landLineNumber);
+ }
+
+ /**
+ * Updates given contact's cellphone, land-line and fax number
+ * <p>
+ * @param contact Contact instance
+ */
+ private void updateContactPhoneNumbers (final Contact contact) {
+ // Parameter must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null");
+ } else if (contact.getContactId() == null) {
+ // Throw again
+ throw new NullPointerException("contact.contactId is null");
+ } else if (contact.getContactId() < 1) {
+ // Id number is not valid
+ }
+
+ // Is cellphone set?
+ if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+ // Unique-add it
+ this.uniqueAddCellphoneNumber(contact.getContactCellphoneNumber());
+ }
+
+ // Is land-line set?
+ if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+ // Unique-add it
+ this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
+ }
+
+ // Is fax set?
+ if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+ // Unique-add it
+ this.uniqueAddFaxNumber(contact.getContactFaxNumber());
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Cho-Time GmbH
+ *
+ * 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 de.chotime.landingpage.beans.phone;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.ejb.Local;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
+
+/**
+ * An interface for a request web controller (bean) for administrative phone
+ * number purposes.
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@Local
+public interface LandingPhoneWebApplicationController extends Serializable {
+
+ /**
+ * Event observer for newly added users by adminstrator
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
+
+ /**
+ * Observes events being fired when an administrator has added a new
+ * contact.
+ * <p>
+ * @param event Event being fired
+ */
+ void afterAdminAddedContact (final AdminAddedContactEvent event);
+
+ /**
+ * Event observer for updated contact data by administrators
+ * <p>
+ * @param event Updated contact data event
+ */
+ void afterAdminUpdatedContactDataEvent (final AdminUpdatedContactEvent event);
+
+ /**
+ * Returns a list of all cellphone numbers. For performance reasons, the
+ * controller (bean) should be application-scoped as from user to user
+ * nothing changes. And the controller's post-construct method should load
+ * all numbers and cache it in the controller.
+ * <p>
+ * @return List of all cell phone numbers
+ */
+ List<DialableCellphoneNumber> allCellphoneNumbers ();
+
+ /**
+ * Returns a list of all fax numbers. For performance reasons, the
+ * controller (bean) should be application-scoped as from user to user
+ * nothing changes. And the controller's post-construct method should load
+ * all numbers and cache it in the controller.
+ * <p>
+ * @return List of all fax numbers
+ */
+ List<DialableFaxNumber> allFaxNumbers ();
+
+ /**
+ * Returns a list of all land-line numbers. For performance reasons, the
+ * controller (bean) should be application-scoped as from user to user
+ * nothing changes. And the controller's post-construct method should load
+ * all numbers and cache it in the controller.
+ * <p>
+ * @return List of all land-line numbers
+ */
+ List<DialableLandLineNumber> allLandLineNumbers ();
+
+}
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController;
import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote;
+import org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
/**
- * A general contact bean (controller)
+ * A general contact phone bean (controller)
* <p>
* @author Roland Haeder<roland@mxchange.org>
*/
*/
private static final long serialVersionUID = 542_145_347_916L;
- /**
- * Remote EJB for phone number (administrative)
- */
- private AdminPhoneSessionBeanRemote adminPhoneBean;
-
/**
* Administrative phone controller
*/
@Inject
private JobsAdminPhoneWebRequestController adminPhoneController;
- /**
- * All cell phone numbers
- */
- private final List<DialableCellphoneNumber> cellphoneNumbers;
-
- /**
- * All fax numbers
- */
- private final List<DialableFaxNumber> faxNumbers;
-
- /**
- * All land-line numbers
- */
- private final List<DialableLandLineNumber> landLineNumbers;
-
/**
* General contact controller
*/
*/
private final Map<Long, List<Contact>> contacts;
+ /**
+ * Remote EJB for phone number (administrative)
+ */
+ private PhoneSessionBeanRemote phoneBean;
+
/**
* Default constructor
*/
Context context = new InitialContext();
// Try to lookup the beans
- this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N
+ this.phoneBean = (PhoneSessionBeanRemote) context.lookup("java:global/jlandingpage-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote"); //NOI18N
} catch (final NamingException e) {
// Throw again
throw new FaceletException(e);
}
// Init lists/maps
- this.cellphoneNumbers = new LinkedList<>();
- this.faxNumbers = new LinkedList<>();
- this.landLineNumbers = new LinkedList<>();
this.contacts = new HashMap<>(10);
}
throw new IllegalArgumentException(MessageFormat.format("event.addedContact.contactId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
}
- // Update contact's cellphone, land-line and fax number
- this.updateContactPhoneNumbers(event.getAddedContact());
-
// Clear this bean
this.clear();
}
throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
}
- // Update contact's cellphone, land-line and fax number
- this.updateContactPhoneNumbers(event.getAddedUser().getUserContact());
-
// Clear all data
this.clear();
}
throw new IllegalArgumentException(MessageFormat.format("contactId of contact={0} is not valid: {1}", event.getUpdatedContact(), event.getUpdatedContact().getContactId())); //NOI18N
}
- // Update contact's cellphone, land-line and fax number
- this.updateContactPhoneNumbers(event.getUpdatedContact());
-
// Clear all data
this.clear();
}
*/
@PostConstruct
public void init () {
- // All phone numbers
- this.cellphoneNumbers.addAll(this.adminPhoneBean.allCellphoneNumbers());
}
/**
// Clear all data
}
- /**
- * Uniquely add given cellphone number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param cellphoneNumber Cellphone number to add
- */
- private void uniqueAddCellphoneNumber (final DialableCellphoneNumber cellphoneNumber) {
- // Make sure the parameter is valid
- if (null == cellphoneNumber) {
- // Throw NPE
- throw new NullPointerException("cellphoneNumber is null");
- } else if (cellphoneNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("cellphoneNumber.phoneId is null");
- } else if (cellphoneNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("cellphoneNumber.phoneId={0} is not valid.", cellphoneNumber.getPhoneId()));
- }
-
- // First remove it by object
- if (!this.cellphoneNumbers.remove(cellphoneNumber)) {
- // Did not work, try by id number
- for (final DialableCellphoneNumber cell : this.cellphoneNumbers) {
- // Is id number the same?
- if (Objects.equals(cell.getPhoneId(), cellphoneNumber.getPhoneId())) {
- // Found it
- this.cellphoneNumbers.remove(cell);
- break;
- }
- }
- }
-
- // ... then add it
- this.cellphoneNumbers.add(cellphoneNumber);
- }
-
- /**
- * Uniquely add given fax number to this bean's list. First remove the old
- * instance (by id number), then re-add it again.
- * <p>
- * @param faxNumber number to add
- */
- private void uniqueAddFaxNumber (final DialableFaxNumber faxNumber) {
- // Make sure the parameter is valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null");
- } else if (faxNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("faxNumber.phoneId is null");
- } else if (faxNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("faxNumber.phoneId={0} is not valid.", faxNumber.getPhoneId()));
- }
-
- // First remove it
- if (!this.faxNumbers.remove(faxNumber)) {
- // Did not work, try by id number
- for (final DialableFaxNumber fax : this.faxNumbers) {
- // Is id number the same?
- if (Objects.equals(fax.getPhoneId(), faxNumber.getPhoneId())) {
- // Found it
- this.faxNumbers.remove(fax);
- break;
- }
- }
- }
-
- // ... then add it
- this.faxNumbers.add(faxNumber);
- }
-
- /**
- * Uniquely add given land-line number to this bean's list. First remove the
- * old instance (by id number), then re-add it again.
- * <p>
- * @param landLineNumber Land-line number to add
- */
- private void uniqueAddLandLineNumber (final DialableLandLineNumber landLineNumber) {
- // Make sure the parameter is valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null");
- } else if (landLineNumber.getPhoneId() == null) {
- // Throw again ...
- throw new NullPointerException("landLineNumber.phoneId is null");
- } else if (landLineNumber.getPhoneId() < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is not valid.", landLineNumber.getPhoneId()));
- }
-
- // First remove it
- if (!this.landLineNumbers.remove(landLineNumber)) {
- // Did not work, try by id number
- for (final DialableLandLineNumber landLine : this.landLineNumbers) {
- // Is id number the same?
- if (Objects.equals(landLine.getPhoneId(), landLineNumber.getPhoneId())) {
- // Found it
- this.landLineNumbers.remove(landLine);
- break;
- }
- }
- }
-
- // ... then add it
- this.landLineNumbers.add(landLineNumber);
- }
-
- /**
- * Updates given contact's cellphone, land-line and fax number
- * <p>
- * @param contact Contact instance
- */
- private void updateContactPhoneNumbers (final Contact contact) {
- // Parameter must be valid
- if (null == contact) {
- // Throw NPE
- throw new NullPointerException("contact is null");
- } else if (contact.getContactId() == null) {
- // Throw again
- throw new NullPointerException("contact.contactId is null");
- } else if (contact.getContactId() < 1) {
- // Id number is not valid
- }
-
- // Is cellphone set?
- if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
- // Unique-add it
- this.uniqueAddCellphoneNumber(contact.getContactCellphoneNumber());
- }
-
- // Is land-line set?
- if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
- // Unique-add it
- this.uniqueAddLandLineNumber(contact.getContactLandLineNumber());
- }
-
- // Is fax set?
- if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
- // Unique-add it
- this.uniqueAddFaxNumber(contact.getContactFaxNumber());
- }
- }
-
}
ERROR_BEAN_HELPER_CONTACT_NOT_SET=Fehler: Instanz 'contact' im Bean-Helper nicht gesetzt.
ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET=Fehler: Instanz 'cellPhone' in administrativer Bean nicht gesetzt.
CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=Mobiltelefonnummern auflisten:
+ADMIN_LIST_CELLPHONE_EMPTY=Es sind keine Mobilfunknummern gespeichert.
+ADMIN_MENU_PHONE_NUMBERS_TITLE=Telefonnummern:
+LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS=Handynummern ...
+LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS_TITLE=Alle Mobilfunknummern auflisten.
+ADMIN_SHOW_CELLPHONE_CREATED=Erstellt:
+ADMIN_SHOW_CELLPHONE_UPDATED=Zuletzt ge\u00e4ndert:
ERROR_BEAN_HELPER_CONTACT_NOT_SET=Error: Instance 'contact' not set in bean helper.
ERROR_ADMIN_BEAN_CELLPHONE_NUMBER_NOT_SET=Error: Instance 'cellPhone' in administrative bean not set.
CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE=List mobile phone numbers:
+ADMIN_LIST_CELLPHONE_EMPTY=No cell phone numbers are saved.
+ADMIN_MENU_PHONE_NUMBERS_TITLE=Phone numbers:
+LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS=Cell phone numbers ...
+LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS_TITLE=List all cell phone numbers.
+ADMIN_SHOW_CELLPHONE_CREATED=Created:
+ADMIN_SHOW_CELLPHONE_UPDATED=Last changed:
<from-outcome>user_profile</from-outcome>
<to-view-id>/user/user_profile.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>admin_list_cellphone</from-outcome>
+ <to-view-id>/admin/cellphone/admin_cellphone_list.xhtml</to-view-id>
+ </navigation-case>
<navigation-case>
<from-outcome>admin_list_countries</from-outcome>
<to-view-id>/admin/country/admin_country_list.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
- <from-view-id>/admin/cellphone/admin_contact_cellphone_list.xhtml</from-view-id>
+ <from-view-id>/admin/cellphone/admin_cellphone_list.xhtml</from-view-id>
<navigation-case>
<from-outcome>admin_show_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_show.xhtml</to-view-id>
+ <to-view-id>/admin/cellphone/admin_cellphone_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_edit.xhtml</to-view-id>
+ <to-view-id>/admin/cellphone/admin_cellphone_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_delete.xhtml</to-view-id>
+ <to-view-id>/admin/cellphone/admin_cellphone_delete.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
- <from-view-id>/admin/cellphone/admin_contact_cellphone_show.xhtml</from-view-id>
+ <from-view-id>/admin/cellphone/admin_cellphone_show.xhtml</from-view-id>
<navigation-case>
<from-outcome>admin_show_mobile_provider</from-outcome>
<to-view-id>/admin/mobile_provider/admin_mobile_provider_show.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_edit_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_edit.xhtml</to-view-id>
+ <to-view-id>/admin/cellphone/admin_cellphone_edit.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_delete_cellphone</from-outcome>
- <to-view-id>/admin/cellphone/admin_contact_cellphone_delete.xhtml</to-view-id>
+ <to-view-id>/admin/cellphone/admin_cellphone_delete.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>admin_unlink_contact_cellphone</from-outcome>
<li><h:link title="#{msg.LINK_ADMIN_EXPORT_CONTACT_TITLE}" outcome="admin_export_contact" value="#{msg.LINK_ADMIN_EXPORT_CONTACT}" /></li>
</ul>
+ <div class="menu_header">
+ <h:outputText value="#{msg.ADMIN_MENU_PHONE_NUMBERS_TITLE}" />
+ </div>
+
+ <ul>
+ <li><h:link title="#{msg.LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS_TITLE}" outcome="admin_list_cellphone" value="#{msg.LINK_ADMIN_LIST_CELLPHONE_PHONE_NUMBERS}" /></li>
+ </ul>
+
<div class="menu_header">
<h:outputText value="#{msg.ADMIN_MENU_COUNTRY_TITLE}" />
</div>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
+ lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+ xmlns:h="http://xmlns.jcp.org/jsf/html"
+ xmlns:f="http://xmlns.jcp.org/jsf/core"
+ >
+
+ <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+ <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}</ui:define>
+
+ <ui:define name="content_header">
+ #{msg.CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}
+ </ui:define>
+
+ <ui:define name="content">
+ <h:dataTable id="table_list_cellphones" var="cellphone" value="#{phoneController.allCellphoneNumbers()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CELLPHONES}" rendered="#{not phoneController.allCellphoneNumbers().isEmpty()}">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
+ </f:facet>
+
+ <h:link outcome="admin_show_cellphone">
+ <h:outputText value="#{cellphone.phoneId}" title="#{msg.ADMIN_LINK_SHOW_SHORT_TITLE}" />
+ <f:param name="phoneId" value="#{cellphone.phoneId}" />
+ </h:link>
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_PROVIDER_NAME}" />
+ </f:facet>
+
+ <h:link outcome="admin_show_mobile_provider">
+ <f:param name="providerId" value="#{cellphone.cellphoneProvider.providerId}" />
+ <h:outputText value="#{cellphone.cellphoneProvider.providerName}" />
+ </h:link>
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_NUMBER_COMPLETE}" />
+ </f:facet>
+
+ <h:outputText value="#{cellphone.cellphoneProvider.providerCountry.countryExternalDialPrefix}#{cellphone.cellphoneProvider.providerDialPrefix}-#{cellphone.phoneNumber}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_CREATED}" />
+ </f:facet>
+
+ <h:outputText value="#{cellphone.phoneEntryCreated.time}">
+ <f:convertDateTime type="both" />
+ </h:outputText>
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_UPDATED}" />
+ </f:facet>
+
+ <h:outputText value="#{cellphone.phoneEntryUpdated.time}">
+ <f:convertDateTime type="both" />
+ </h:outputText>
+ </h:column>
+ </h:dataTable>
+
+ <h:outputText styleClass="errors" value="#{msg.ADMIN_LIST_CELLPHONE_EMPTY}" rendered="#{phoneController.allCellphoneNumbers().isEmpty()}" />
+ </ui:define>
+ </ui:composition>
+</html>
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
- lang="#{localizationController.language}" xml:lang="#{localizationController.language}"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
- xmlns:h="http://xmlns.jcp.org/jsf/html"
- xmlns:f="http://xmlns.jcp.org/jsf/core"
- >
-
- <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
- <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}</ui:define>
-
- <ui:define name="content_header">
- #{msg.CONTENT_TITLE_ADMIN_LIST_CONTACT_CELLPHONE}
- </ui:define>
-
- <ui:define name="content">
- <h:dataTable id="table_list_cellphones" var="cellphone" value="#{phoneController.allCellphones()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CELLPHONES}" rendered="#{not phoneController.allCellphones().isEmpty()}">
- <h:column>
- <f:facet name="header">
- <h:outputText value="#{msg.ADMIN_SHOW_CELLPHONE_ID}" />
- </f:facet>
- </h:column>
- </h:dataTable>
- </ui:define>
- </ui:composition>
-</html>