From: Roland Häder <roland@mxchange.org> Date: Thu, 25 Aug 2016 15:54:15 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a9e052f7a1bb0849f5acf23e22539cb536baf68e;p=jjobs-war.git Please cherry-pick: - renamed helper interface and class according to naming convention - added link in administrative user links including navigation rule - added + implemented controller method allCurrentUsersActivityLog() which requires beanHeper.user being set Signed-off-by: Roland Häder <roland@mxchange.org> --- diff --git a/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java index 5cd11863..edc4f1b9 100644 --- a/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/confirmlink/JobsConfirmationLinkWebRequestBean.java @@ -31,7 +31,6 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; import org.mxchange.jusercore.events.confirmation.ConfirmedUserAccountEvent; import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; @@ -40,6 +39,7 @@ import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.jusercore.model.user.status.UserAccountStatus; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * A web request bean for confirmation link handling @@ -59,7 +59,7 @@ public class JobsConfirmationLinkWebRequestBean extends BaseJobsController imple * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * Confirmation key diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index b0027aca..99cf6b91 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -45,13 +45,13 @@ import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jphone.phonenumbers.DialableNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * An administrative user controller (bean) @@ -83,7 +83,7 @@ public class JobsAdminContactWebRequestBean extends BaseJobsController implement * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * Birth day diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java index aa9975df..a6d52804 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsAdminContactPhoneWebRequestBean.java @@ -45,7 +45,6 @@ import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEv import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote; import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController; import org.mxchange.jphone.exceptions.PhoneNumberAlreadyLinkedException; import org.mxchange.jphone.exceptions.PhoneNumberNotLinkedException; @@ -57,6 +56,7 @@ import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * An administrative contact phone controller (bean) @@ -113,7 +113,7 @@ public class JobsAdminContactPhoneWebRequestBean extends BaseJobsController impl * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * Event being fired when a fax number has been unlinked diff --git a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java index f69d7d95..ece8bd7e 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/phone/JobsContactPhoneWebSessionBean.java @@ -34,12 +34,12 @@ import org.mxchange.jcontacts.events.landline.unlinked.AdminUnlinkedLandLineNumb import org.mxchange.jcontacts.events.mobile.unlinked.AdminUnlinkedMobileNumberEvent; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jphone.phonenumbers.DialableNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * An administrative contact phone controller (bean) @@ -59,7 +59,7 @@ public class JobsContactPhoneWebSessionBean extends BaseJobsController implement * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * General contact controller diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewController.java deleted file mode 100644 index 1127b736..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewController.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * 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.jjobs.beans.helper; - -import java.io.Serializable; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for general bean helper - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -public interface JobsWebViewController extends Serializable { - - /** - * Copies currently set fax number's data to admin phone controller - */ - void copyFaxNumberToController (); - - /** - * Copies currently set land-line number's data to admin phone controller - */ - void copyLandLineNumberToController (); - - /** - * Copies currently set mobile number's data to admin phone controller - */ - void copyMobileNumberToController (); - - /** - * Copies currently set contact instance's data to adminContactController - */ - void copyContactToController (); - - /** - * Copies currently set user instance's data to adminUserController - */ - void copyUserToController (); - - /** - * Returns a message key depending on if this contact is a user and/or a - * contact. If this contact is unused, a default key is returned. - * <p> - * @param contact Contact instance to check - * <p> - * @return Message key - */ - String getContactUsageMessageKey (final Contact contact); - - /** - * Getter for contact instance - * <p> - * @return Contact instance - */ - Contact getContact (); - - /** - * Setter for contact instance - * <p> - * @param contact Contact instance - */ - void setContact (final Contact contact); - - /** - * Getter for user instance - * <p> - * @return User instance - */ - User getUser (); - - /** - * Setter for user instance - * <p> - * @param user User instance - */ - void setUser (final User user); - - /** - * Getter for dialable mobile number - * <p> - * @return Dialable mobile number - */ - DialableMobileNumber getMobileNumber (); - - /** - * Setter for dialable mobile number - * <p> - * @param mobileNumber Dialable mobile number - */ - void setMobileNumber (final DialableMobileNumber mobileNumber); - - /** - * Getter for dialable land-line number - * <p> - * @return Dialable land-line number - */ - DialableLandLineNumber getLandLineNumber (); - - /** - * Setter for dialable land-line number - * <p> - * @param landLine Dialable land-line number - */ - void setLandLineNumber (final DialableLandLineNumber landLine); - - /** - * Getter for dialable fax number - * <p> - * @return Dialable fax number - */ - DialableFaxNumber getFaxNumber (); - - /** - * Setter for dialable fax number - * <p> - * @param faxNumber Dialable fax number - */ - void setFaxNumber (final DialableFaxNumber faxNumber); - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelper.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelper.java deleted file mode 100644 index cff4ca67..00000000 --- a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelper.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * 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.jjobs.beans.helper; - -import java.text.MessageFormat; -import javax.faces.view.ViewScoped; -import javax.inject.Inject; -import javax.inject.Named; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; -import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController; -import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; -import org.mxchange.jusercore.model.user.User; - -/** - * A general helper for beans - * <p> - * @author Roland Haeder<roland@mxchange.org> - */ -@Named ("adminHelper") -@ViewScoped -public class JobsWebViewHelper extends BaseJobsController implements JobsWebViewController { - - /** - * Call-stack instance (5 may show BeanELResolver.getValue as caller) - */ - private static final short THREAD_STACK = 5; - - /** - * Serial number - */ - private static final long serialVersionUID = 17_258_793_567_145_701L; - - /** - * Administrative contact controller - */ - @Inject - private JobsAdminContactWebRequestController adminContactController; - - /** - * Administrative phone controller - */ - @Inject - private JobsAdminPhoneWebRequestController adminPhoneController; - - /** - * Contact instance - */ - private Contact contact; - - /** - * Fax number - */ - private DialableFaxNumber faxNumber; - - /** - * Land-line number - */ - private DialableLandLineNumber landLineNumber; - - /** - * Mobile number - */ - private DialableMobileNumber mobileNumber; - - /** - * User instance - */ - private User user; - - /** - * Regular user controller - */ - @Inject - private JobsUserWebSessionController userController; - - /** - * Default constructor - */ - public JobsWebViewHelper () { - // 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)); - } - - @Override - public void copyContactToController () { - // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName()); - // System.out.println(MessageFormat.format("{0}.copyContactToController: CALLED, caller: {2}", this.getClass().getSimpleName(), this.contact, caller)); - - // Validate contact instance - if (this.getContact() == null) { - // Throw NPE - throw new NullPointerException("this.contact is null"); //NOI18N - } else if (this.getContact().getContactId() == null) { - // Throw NPE again - throw new NullPointerException("this.contact.contactId is null"); //NOI18N - } else if (this.getContact().getContactId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N - } - - // Set all phone instances - this.setPhoneInstances(this.getContact()); - - // Set all fields: user - this.adminContactController.copyContactToController(this.getContact()); - } - - @Override - public void copyFaxNumberToController () { - // Validate fax instance - if (this.getFaxNumber() == null) { - // Throw NPE - throw new NullPointerException("this.faxNumber is null"); - } else if (this.getFaxNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.faxNumber.phoneId is null"); - } else if (this.getFaxNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); - } else if (this.getFaxNumber().getPhoneAreaCode() == null) { - // Throw again - throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); - } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); - } else if (this.getFaxNumber().getPhoneCountry() == null) { - // Throw NPE again - throw new NullPointerException("this.faxNumber.phoneCountry is null"); - } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) { - // ... throw again - throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); - } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); - } else if (this.getFaxNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.faxNumber.phoneNumber is null"); - } else if (this.getFaxNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); - } - - // Copy all (changeable) data fields to admin controller - this.adminPhoneController.setPhoneAreaCode(this.getFaxNumber().getPhoneAreaCode()); - this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry()); - this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber()); - } - - @Override - public void copyLandLineNumberToController () { - // Validate land-line instance - if (this.getLandLineNumber() == null) { - // Throw NPE - throw new NullPointerException("this.landLineNumber is null"); - } else if (this.getLandLineNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.landLineNumber.phoneId is null"); - } else if (this.getLandLineNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); - } else if (this.getLandLineNumber().getPhoneAreaCode() == null) { - // Throw again - throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); - } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); - } else if (this.getLandLineNumber().getPhoneCountry() == null) { - // Throw NPE again - throw new NullPointerException("this.landLineNumber.phoneCountry is null"); - } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) { - // ... throw again - throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); - } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); - } else if (this.getLandLineNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.landLineNumber.phoneNumber is null"); - } else if (this.getLandLineNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); - } - - // Copy all (changeable) data fields to admin controller - this.adminPhoneController.setPhoneAreaCode(this.getLandLineNumber().getPhoneAreaCode()); - this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry()); - this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber()); - } - - @Override - public void copyMobileNumberToController () { - // Validate mobile instance - if (this.getMobileNumber() == null) { - // Throw NPE - throw new NullPointerException("this.mobileNumber is null"); - } else if (this.getMobileNumber().getPhoneId() == null) { - // Throw again - throw new NullPointerException("this.mobileNumber.phoneId is null"); - } else if (this.getMobileNumber().getPhoneId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); - } else if (this.getMobileNumber().getMobileProvider() == null) { - // Throw NPE again - throw new NullPointerException("this.mobileNumber.mobileProvider is null"); - } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) { - // ... throw again - throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); - } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); - } else if (this.getMobileNumber().getPhoneNumber() == null) { - // Throw NPE again ... - throw new NullPointerException("this.mobileNumber.phoneNumber is null"); - } else if (this.getMobileNumber().getPhoneNumber() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); - } - - // Copy all (changeable) data fields to admin controller - this.adminPhoneController.setMobileProvider(this.getMobileNumber().getMobileProvider()); - this.adminPhoneController.setPhoneNumber(this.getMobileNumber().getPhoneNumber()); - } - - @Override - public void copyUserToController () { - // Log message - //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N - - // Validate user instance - if (this.getUser() == null) { - // Throw NPE - throw new NullPointerException("this.user is null"); - } else if (this.getUser().getUserId() == null) { - // Throw NPE again - throw new NullPointerException("this.user.userId is null"); - } else if (this.getUser().getUserId() < 1) { - // Not valid - throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); - } - - // Get contact - Contact userContact = this.getUser().getUserContact(); - - // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs. - this.setContact(userContact); - - // Set all phone instances - this.setPhoneInstances(userContact); - - // Set all fields: user - this.userController.setUserName(this.getUser().getUserName()); - } - - @Override - public Contact getContact () { - // 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.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller)); - return this.contact; - } - - @Override - public void setContact (final Contact contact) { - // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName()); - // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller)); - this.contact = contact; - } - - @Override - public String getContactUsageMessageKey (final Contact contact) { - // The contact must be valid - if (null == contact) { - // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { - // Throw again ... - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N - } - - // Default key is "unused" - String messageKey = "CONTACT_IS_UNUSED"; //NOI18N - - // Check user - boolean isUserContact = this.userController.isContactFound(contact); - - // Check user first - if (isUserContact) { - // Only user - messageKey = "CONTACT_IS_USER"; //NOI18N - } - - // Return message key - return messageKey; - } - - @Override - public DialableFaxNumber getFaxNumber () { - return this.faxNumber; - } - - @Override - public void setFaxNumber (final DialableFaxNumber faxNumber) { - this.faxNumber = faxNumber; - } - - @Override - public DialableLandLineNumber getLandLineNumber () { - return this.landLineNumber; - } - - @Override - public void setLandLineNumber (final DialableLandLineNumber landLineNumber) { - this.landLineNumber = landLineNumber; - } - - @Override - public DialableMobileNumber getMobileNumber () { - return this.mobileNumber; - } - - @Override - public void setMobileNumber (final DialableMobileNumber mobileNumber) { - this.mobileNumber = mobileNumber; - } - - @Override - public User getUser () { - return this.user; - } - - @Override - public void setUser (final User user) { - this.user = user; - } - - /** - * Set's all given contact's phone instances: land-line, mobile and - * faxNumber - * <p> - * @param contact Contact to set phone instances for - */ - private void setPhoneInstances (final Contact contact) { - // The contact must be valid - if (null == contact) { - // Throw NPE - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { - // Throw again ... - throw new NullPointerException("contact.contactId is null"); //NOI18N - } else if (contact.getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N - } - - // Is mobile set? - if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { - // Yes, then set it in admin controller - this.setMobileNumber(contact.getContactMobileNumber()); - } - - // Is land-line set? - if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { - // Yes, then set it in admin controller - this.setLandLineNumber(contact.getContactLandLineNumber()); - } - - // Is faxNumber set? - if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { - // Yes, then set it in admin controller - this.setFaxNumber(contact.getContactFaxNumber()); - } - } - -} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java new file mode 100644 index 00000000..dcc1a4f7 --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperBean.java @@ -0,0 +1,395 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * 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.jjobs.beans.helper; + +import java.text.MessageFormat; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jjobs.beans.BaseJobsController; +import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; +import org.mxchange.jjobs.beans.phone.JobsAdminPhoneWebRequestController; +import org.mxchange.jjobs.beans.user.JobsUserWebSessionController; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * A general helper for beans + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +@Named ("adminHelper") +@ViewScoped +public class JobsWebViewHelperBean extends BaseJobsController implements JobsWebViewHelperController { + + /** + * Call-stack instance (5 may show BeanELResolver.getValue as caller) + */ + private static final short THREAD_STACK = 5; + + /** + * Serial number + */ + private static final long serialVersionUID = 17_258_793_567_145_701L; + + /** + * Administrative contact controller + */ + @Inject + private JobsAdminContactWebRequestController adminContactController; + + /** + * Administrative phone controller + */ + @Inject + private JobsAdminPhoneWebRequestController adminPhoneController; + + /** + * Contact instance + */ + private Contact contact; + + /** + * Fax number + */ + private DialableFaxNumber faxNumber; + + /** + * Land-line number + */ + private DialableLandLineNumber landLineNumber; + + /** + * Mobile number + */ + private DialableMobileNumber mobileNumber; + + /** + * User instance + */ + private User user; + + /** + * Regular user controller + */ + @Inject + private JobsUserWebSessionController userController; + + /** + * Default constructor + */ + public JobsWebViewHelperBean () { + // 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)); + } + + @Override + public void copyContactToController () { + // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName()); + // System.out.println(MessageFormat.format("{0}.copyContactToController: CALLED, caller: {2}", this.getClass().getSimpleName(), this.contact, caller)); + + // Validate contact instance + if (this.getContact() == null) { + // Throw NPE + throw new NullPointerException("this.contact is null"); //NOI18N + } else if (this.getContact().getContactId() == null) { + // Throw NPE again + throw new NullPointerException("this.contact.contactId is null"); //NOI18N + } else if (this.getContact().getContactId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N + } + + // Set all phone instances + this.setPhoneInstances(this.getContact()); + + // Set all fields: user + this.adminContactController.copyContactToController(this.getContact()); + } + + @Override + public void copyFaxNumberToController () { + // Validate fax instance + if (this.getFaxNumber() == null) { + // Throw NPE + throw new NullPointerException("this.faxNumber is null"); + } else if (this.getFaxNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneId is null"); + } else if (this.getFaxNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); + } else if (this.getFaxNumber().getPhoneAreaCode() == null) { + // Throw again + throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); + } else if (this.getFaxNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); + } else if (this.getFaxNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.faxNumber.phoneCountry is null"); + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); + } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); + } else if (this.getFaxNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.faxNumber.phoneNumber is null"); + } else if (this.getFaxNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); + } + + // Copy all (changeable) data fields to admin controller + this.adminPhoneController.setPhoneAreaCode(this.getFaxNumber().getPhoneAreaCode()); + this.adminPhoneController.setPhoneCountry(this.getFaxNumber().getPhoneCountry()); + this.adminPhoneController.setPhoneNumber(this.getFaxNumber().getPhoneNumber()); + } + + @Override + public void copyLandLineNumberToController () { + // Validate land-line instance + if (this.getLandLineNumber() == null) { + // Throw NPE + throw new NullPointerException("this.landLineNumber is null"); + } else if (this.getLandLineNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneId is null"); + } else if (this.getLandLineNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); + } else if (this.getLandLineNumber().getPhoneAreaCode() == null) { + // Throw again + throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); + } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); + } else if (this.getLandLineNumber().getPhoneCountry() == null) { + // Throw NPE again + throw new NullPointerException("this.landLineNumber.phoneCountry is null"); + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) { + // ... throw again + throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); + } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); + } else if (this.getLandLineNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.landLineNumber.phoneNumber is null"); + } else if (this.getLandLineNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); + } + + // Copy all (changeable) data fields to admin controller + this.adminPhoneController.setPhoneAreaCode(this.getLandLineNumber().getPhoneAreaCode()); + this.adminPhoneController.setPhoneCountry(this.getLandLineNumber().getPhoneCountry()); + this.adminPhoneController.setPhoneNumber(this.getLandLineNumber().getPhoneNumber()); + } + + @Override + public void copyMobileNumberToController () { + // Validate mobile instance + if (this.getMobileNumber() == null) { + // Throw NPE + throw new NullPointerException("this.mobileNumber is null"); + } else if (this.getMobileNumber().getPhoneId() == null) { + // Throw again + throw new NullPointerException("this.mobileNumber.phoneId is null"); + } else if (this.getMobileNumber().getPhoneId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); + } else if (this.getMobileNumber().getMobileProvider() == null) { + // Throw NPE again + throw new NullPointerException("this.mobileNumber.mobileProvider is null"); + } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); + } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); + } else if (this.getMobileNumber().getPhoneNumber() == null) { + // Throw NPE again ... + throw new NullPointerException("this.mobileNumber.phoneNumber is null"); + } else if (this.getMobileNumber().getPhoneNumber() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); + } + + // Copy all (changeable) data fields to admin controller + this.adminPhoneController.setMobileProvider(this.getMobileNumber().getMobileProvider()); + this.adminPhoneController.setPhoneNumber(this.getMobileNumber().getPhoneNumber()); + } + + @Override + public void copyUserToController () { + // Log message + //* NOISY-DEBUG: */ System.out.println("AdminHelper::copyUserToController - CALLED!"); //NOI18N + + // Validate user instance + if (this.getUser() == null) { + // Throw NPE + throw new NullPointerException("this.user is null"); + } else if (this.getUser().getUserId() == null) { + // Throw NPE again + throw new NullPointerException("this.user.userId is null"); + } else if (this.getUser().getUserId() < 1) { + // Not valid + throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); + } + + // Get contact + Contact userContact = this.getUser().getUserContact(); + + // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs. + this.setContact(userContact); + + // Set all phone instances + this.setPhoneInstances(userContact); + + // Set all fields: user + this.userController.setUserName(this.getUser().getUserName()); + } + + @Override + public Contact getContact () { + // 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.contact={1}, caller: {2}", this.getClass().getSimpleName(), this.contact, caller)); + return this.contact; + } + + @Override + public void setContact (final Contact contact) { + // String caller = MessageFormat.format("{0}.{1}", Thread.currentThread().getStackTrace()[THREAD_STACK].getClassName(), Thread.currentThread().getStackTrace()[THREAD_STACK].getMethodName()); + // System.out.println(MessageFormat.format("{0}: Setting contact={1}, previous: {2}, caller: {3}", this.getClass().getSimpleName(), contact, this.contact, caller)); + this.contact = contact; + } + + @Override + public String getContactUsageMessageKey (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Default key is "unused" + String messageKey = "CONTACT_IS_UNUSED"; //NOI18N + + // Check user + boolean isUserContact = this.userController.isContactFound(contact); + + // Check user first + if (isUserContact) { + // Only user + messageKey = "CONTACT_IS_USER"; //NOI18N + } + + // Return message key + return messageKey; + } + + @Override + public DialableFaxNumber getFaxNumber () { + return this.faxNumber; + } + + @Override + public void setFaxNumber (final DialableFaxNumber faxNumber) { + this.faxNumber = faxNumber; + } + + @Override + public DialableLandLineNumber getLandLineNumber () { + return this.landLineNumber; + } + + @Override + public void setLandLineNumber (final DialableLandLineNumber landLineNumber) { + this.landLineNumber = landLineNumber; + } + + @Override + public DialableMobileNumber getMobileNumber () { + return this.mobileNumber; + } + + @Override + public void setMobileNumber (final DialableMobileNumber mobileNumber) { + this.mobileNumber = mobileNumber; + } + + @Override + public User getUser () { + return this.user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + + /** + * Set's all given contact's phone instances: land-line, mobile and + * faxNumber + * <p> + * @param contact Contact to set phone instances for + */ + private void setPhoneInstances (final Contact contact) { + // The contact must be valid + if (null == contact) { + // Throw NPE + throw new NullPointerException("contact is null"); //NOI18N + } else if (contact.getContactId() == null) { + // Throw again ... + throw new NullPointerException("contact.contactId is null"); //NOI18N + } else if (contact.getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N + } + + // Is mobile set? + if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { + // Yes, then set it in admin controller + this.setMobileNumber(contact.getContactMobileNumber()); + } + + // Is land-line set? + if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) { + // Yes, then set it in admin controller + this.setLandLineNumber(contact.getContactLandLineNumber()); + } + + // Is faxNumber set? + if (contact.getContactFaxNumber() instanceof DialableFaxNumber) { + // Yes, then set it in admin controller + this.setFaxNumber(contact.getContactFaxNumber()); + } + } + +} diff --git a/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java new file mode 100644 index 00000000..84688ada --- /dev/null +++ b/src/java/org/mxchange/jjobs/beans/helper/JobsWebViewHelperController.java @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * 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.jjobs.beans.helper; + +import java.io.Serializable; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for general bean helper + * <p> + * @author Roland Haeder<roland@mxchange.org> + */ +public interface JobsWebViewHelperController extends Serializable { + + /** + * Copies currently set fax number's data to admin phone controller + */ + void copyFaxNumberToController (); + + /** + * Copies currently set land-line number's data to admin phone controller + */ + void copyLandLineNumberToController (); + + /** + * Copies currently set mobile number's data to admin phone controller + */ + void copyMobileNumberToController (); + + /** + * Copies currently set contact instance's data to adminContactController + */ + void copyContactToController (); + + /** + * Copies currently set user instance's data to adminUserController + */ + void copyUserToController (); + + /** + * Returns a message key depending on if this contact is a user and/or a + * contact. If this contact is unused, a default key is returned. + * <p> + * @param contact Contact instance to check + * <p> + * @return Message key + */ + String getContactUsageMessageKey (final Contact contact); + + /** + * Getter for contact instance + * <p> + * @return Contact instance + */ + Contact getContact (); + + /** + * Setter for contact instance + * <p> + * @param contact Contact instance + */ + void setContact (final Contact contact); + + /** + * Getter for user instance + * <p> + * @return User instance + */ + User getUser (); + + /** + * Setter for user instance + * <p> + * @param user User instance + */ + void setUser (final User user); + + /** + * Getter for dialable mobile number + * <p> + * @return Dialable mobile number + */ + DialableMobileNumber getMobileNumber (); + + /** + * Setter for dialable mobile number + * <p> + * @param mobileNumber Dialable mobile number + */ + void setMobileNumber (final DialableMobileNumber mobileNumber); + + /** + * Getter for dialable land-line number + * <p> + * @return Dialable land-line number + */ + DialableLandLineNumber getLandLineNumber (); + + /** + * Setter for dialable land-line number + * <p> + * @param landLine Dialable land-line number + */ + void setLandLineNumber (final DialableLandLineNumber landLine); + + /** + * Getter for dialable fax number + * <p> + * @return Dialable fax number + */ + DialableFaxNumber getFaxNumber (); + + /** + * Setter for dialable fax number + * <p> + * @param faxNumber Dialable fax number + */ + void setFaxNumber (final DialableFaxNumber faxNumber); + +} diff --git a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java index 32815fda..024020b7 100644 --- a/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/phone/JobsAdminPhoneWebRequestBean.java @@ -30,7 +30,6 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcountry.data.Country; import org.mxchange.jjobs.beans.BaseJobsController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent; import org.mxchange.jphone.events.fax.deleted.AdminFaxNumberDeletedEvent; import org.mxchange.jphone.events.fax.removed.AdminFaxNumberRemovedFromListEvent; @@ -54,6 +53,7 @@ import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * Administrative controller (bean) for phone numbers @@ -83,7 +83,7 @@ public class JobsAdminPhoneWebRequestBean extends BaseJobsController implements * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * Choosen fax number diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java index 80d1848d..a806e1a6 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebRequestBean.java @@ -34,7 +34,6 @@ import org.mxchange.jcoreee.utils.FacesUtils; import org.mxchange.jjobs.beans.BaseJobsController; import org.mxchange.jjobs.beans.contact.JobsAdminContactWebRequestController; import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController; -import org.mxchange.jjobs.beans.helper.JobsWebViewController; import org.mxchange.jusercore.container.login.UserLoginContainer; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent; @@ -61,6 +60,7 @@ import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.jusercore.model.user.UserUtils; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; import org.mxchange.jusercore.model.user.status.UserAccountStatus; +import org.mxchange.jjobs.beans.helper.JobsWebViewHelperController; /** * A user controller (bean) @@ -98,7 +98,7 @@ public class JobsAdminUserWebRequestBean extends BaseJobsController implements J * Admin helper instance */ @Inject - private JobsWebViewController beanHelper; + private JobsWebViewHelperController beanHelper; /** * Regular contact controller diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index d3592ed7..9e2e6036 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -736,3 +736,5 @@ ADMIN_RESEND_USER_CONFIRMATION_LINK_NOTICE=Durch das Zuschicken eines neuen Best PAGE_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Neuen Best\u00e4tigungslink versenden CONTENT_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Neuen Best\u00e4tigungslink versenden: ADMIN_SHOW_USER_ID=Benutzer-Id: +TABLE_SUMMARY_ADMIN_LIST_USER_ACTIVITY_LOG=Diese Tabelle enth\u00e4lt die Aktivit\u00e4ten des ausgew\u00e4hlten Benutzeraccounts. +ADMIN_LINK_SHOW_USER_ACTIVITY_LOG=Aktivit\u00e4ten des Benutzers auflisten diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 21e71bef..fc84a6fe 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -737,3 +737,5 @@ ADMIN_RESEND_USER_CONFIRMATION_LINK_NOTICE=By sending a new confirmation link to PAGE_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Send new confirmation link CONTENT_TITLE_ADMIN_RESEND_USER_CONFIRMATION_LINK=Send new confirmation link: ADMIN_SHOW_USER_ID=User id: +TABLE_SUMMARY_ADMIN_LIST_USER_ACTIVITY_LOG=This table shows choosen user's activity log. +ADMIN_LINK_SHOW_USER_ACTIVITY_LOG=List user's actitivy log diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index bda2c669..0d3ed4ef 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -380,6 +380,10 @@ <from-outcome>admin_unlock_user</from-outcome> <to-view-id>/admin/user/admin_user_unlock.xhtml</to-view-id> </navigation-case> + <navigation-case> + <from-outcome>admin_show_user_activity_log</from-outcome> + <to-view-id>/admin/user/admin_user_activity_log.xhtml</to-view-id> + </navigation-case> <navigation-case> <from-outcome>admin_edit_contact</from-outcome> <to-view-id>/admin/contact/admin_contact_edit.xhtml</to-view-id> diff --git a/web/WEB-INF/templates/admin/user/admin_user_links.tpl b/web/WEB-INF/templates/admin/user/admin_user_links.tpl index d42ad00e..4f627ec4 100644 --- a/web/WEB-INF/templates/admin/user/admin_user_links.tpl +++ b/web/WEB-INF/templates/admin/user/admin_user_links.tpl @@ -51,6 +51,12 @@ <f:param name="userId" value="#{beanHelper.user.userId}" /> </h:link> </li> + + <li> + <h:link outcome="admin_show_user_activity_log" value="#{msg.ADMIN_LINK_SHOW_USER_ACTIVITY_LOG}" title="#{msg.ADMIN_LINK_SHOW_USER_ACTIVITY_LOG_TITLE}"> + <f:param name="userId" value="#{beanHelper.user.userId}" /> + </h:link> + </li> </ul> </div> </h:panelGroup> diff --git a/web/admin/user/admin_user_activity_log.xhtml b/web/admin/user/admin_user_activity_log.xhtml new file mode 100644 index 00000000..8af7f226 --- /dev/null +++ b/web/admin/user/admin_user_activity_log.xhtml @@ -0,0 +1,107 @@ +<!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="metadata"> + <f:metadata> + <f:viewParam name="userId" value="#{beanHelper.user}" converter="UserConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}" /> + <f:viewAction onPostback="true" action="#{beanHelper.copyUserToController()}" /> + </f:metadata> + </ui:define> + + <ui:define name="admin_title"> + <h:outputText value="#{msg.PAGE_TITLE_ADMIN_USER_ACTIVITY_LOG}" /> + </ui:define> + + <ui:define name="content_header"> + <h:outputText value="#{msg.CONTENT_TITLE_ADMIN_USER_ACTIVITY_LOG}" /> + </ui:define> + + <ui:define name="content"> + <ui:fragment rendered="#{empty beanHelper.user}"> + <ui:include src="/WEB-INF/templates/generic/message_box.tpl"> + <ui:param name="message" value="#{msg.ERROR_USER_ID_NOT_FOUND}" /> + <ui:param name="styleClass" value="errors" /> + </ui:include> + </ui:fragment> + + <h:dataTable id="table_user_activity_log" var="userActivity" value="#{userActivityController.allCurrentUsersActivityLog()}" styleClass="table_full" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_USER_ACTIVITY_LOG}" rendered="#{not empty beanHelper.user}"> + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_ID}" /> + </f:facet> + + <h:link outcome="admin_show_user" title="#{msg.ADMIN_LINK_SHOW_USER_TITLE}" value="#{user.userId}"> + <f:param name="userId" value="#{userActivity.activityUser.userId}" /> + </h:link> + </h:column> + + <ui:fragment rendered="#{featureController.isFeatureEnabled('user_name_required')}"> + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_NAME}" /> + </f:facet> + + <h:outputText value="#{userActivity.activityUserName}" /> + </h:column> + </ui:fragment> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_GENDER}" /> + </f:facet> + + <h:outputText value="#{msg[userActivity.activityGender.messageKey]}" /> + </h:column> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_FIRST_NAME}" /> + </f:facet> + + <h:outputText value="#{userActivity.activityFirstName}" /> + </h:column> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_FAMILY_NAME}" /> + </f:facet> + + <h:outputText value="#{userActivity.activityFamilyName}" /> + </h:column> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_ACTIVIRY_LOG_MESSAGE}" /> + </f:facet> + + <h:outputText value="#{userActivity.activityMessage}" /> + </h:column> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_ACTIVIRY_LOG_TYPE}" /> + </f:facet> + + <h:outputText value="#{msg['ADMIN_ACTIVITY_' + userActivity.activityType]}" /> + </h:column> + + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_ACTIVITY_LOG_TIMESTAMP}" /> + </f:facet> + + <h:outputText id="userCreated" value="#{userActivity.activityTimestamp.time}"> + <f:convertDateTime for="userCreated" type="both" timeStyle="short" dateStyle="short" /> + </h:outputText> + </h:column> + </h:dataTable> + </ui:define> + </ui:composition> +</html> diff --git a/web/admin/user/admin_user_list.xhtml b/web/admin/user/admin_user_list.xhtml index 45885d92..02a58ddb 100644 --- a/web/admin/user/admin_user_list.xhtml +++ b/web/admin/user/admin_user_list.xhtml @@ -35,13 +35,15 @@ </h:link> </h:column> - <h:column> - <f:facet name="header"> - <h:outputText value="#{msg.ADMIN_LIST_USER_NAME}" /> - </f:facet> - - <h:outputText value="#{user.userName}" /> - </h:column> + <ui:fragment rendered="#{featureController.isFeatureEnabled('user_name_required')}"> + <h:column> + <f:facet name="header"> + <h:outputText value="#{msg.ADMIN_LIST_USER_NAME}" /> + </f:facet> + + <h:outputText value="#{user.userName}" /> + </h:column> + </ui:fragment> <h:column> <f:facet name="header">