From a882caaa0ddaf5a41f50fc3ae60261ee1bb08cdd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 27 Apr 2016 08:52:40 +0200 Subject: [PATCH] Continued with contacts: - added hasContacts() / allContacts() - listing of contacts started, maybe later add a method that checks where the contact is being used and returns a message key? MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../JobsAdminContactWebRequestBean.java | 44 +++++-------------- .../contact/JobsContactWebSessionBean.java | 13 +++--- .../JobsContactWebSessionController.java | 8 ++++ web/admin/contact/admin_contact_list.xhtml | 2 +- 4 files changed, 27 insertions(+), 40 deletions(-) diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java index 0b55fce4..96d913f1 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java @@ -112,6 +112,12 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques */ private final ContactSessionBeanRemote contactBean; + /** + * General contact controller + */ + @Inject + private AddressbookContactWebSessionController contactController; + /** * Contact id */ @@ -292,39 +298,6 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques return this.contactController.allContacts(); } - @Override - public String changeContactData () { - // Get contact instance - Contact contact = this.adminHelper.getContact(); - - // Default is not same contact - if (this.isSameContactFound(contact)) { - // Already registered - throw new FaceletException(new ContactAlreadyAddedException(contact)); - } - - // Init contact - Contact updatedContact; - - // Try to call EJB - try { - // Call EJB - updatedContact = this.contactBean.addContact(contact); - } catch (final ContactAlreadyAddedException ex) { - // Throw again - throw new FaceletException(ex); - } - - // Fire event - this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact)); - - // Clear this bean - this.clear(); - - // Return outcome - return "admin_list_contact"; //NOI18N - } - @Override public void copyContactToController (final Contact contact) { // The contact instance must be valid @@ -659,6 +632,11 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques this.zipCode = zipCode; } + @Override + public boolean hasContacts () { + return (!this.allContacts().isEmpty()); + } + /** * Post-initialization of this class */ diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java index 324bd1a9..29abbe31 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java @@ -229,7 +229,7 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle @Override public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) { // Trace message - System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N // event should not be null if (null == event) { @@ -275,7 +275,7 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle @Override public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) { // Trace message - System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N // event should not be null if (null == event) { @@ -296,7 +296,7 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle Contact registeredContact = event.getRegisteredUser().getUserContact(); // Debug message - System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N // Copy all data from registered->user this.copyContact(registeredContact); @@ -308,13 +308,13 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle this.clear(); // Trace message - System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N + //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N } @Override public void afterUserLogin (final @Observes UserLoggedInEvent event) { // Trace message - System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N + //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N // event should not be null if (null == event) { @@ -335,10 +335,11 @@ public class JobsContactWebSessionBean implements JobsContactWebSessionControlle this.copyContact(event.getLoggedInUser().getUserContact()); // Trace message - System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N + //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N } @SuppressWarnings ("ReturnOfCollectionOrArrayField") + @Override public List allContacts () { return this.contactList; } diff --git a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java index d22da2f6..7b595fac 100644 --- a/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java @@ -18,6 +18,7 @@ package org.mxchange.jjobs.beans.contact; import java.io.Serializable; import java.util.Date; +import java.util.List; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; @@ -39,6 +40,13 @@ public interface JobsContactWebSessionController extends Serializable { */ public static final Integer MINIMUM_PASSWORD_LENGTH = 5; + /** + * Returns a list of all found contacts + *

+ * @return A list of all contacts. + */ + List allContacts(); + /** * Updates all data from bean in given contact instance *

diff --git a/web/admin/contact/admin_contact_list.xhtml b/web/admin/contact/admin_contact_list.xhtml index b496a407..dca2708a 100644 --- a/web/admin/contact/admin_contact_list.xhtml +++ b/web/admin/contact/admin_contact_list.xhtml @@ -1,4 +1,4 @@ -_ +