]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with contacts:
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 06:52:40 +0000 (08:52 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 29 Apr 2016 19:42:29 +0000 (21:42 +0200)
- 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?

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/contact/JobsAdminContactWebRequestBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java
web/admin/contact/admin_contact_list.xhtml

index 0b55fce42fe48e49c56e2c8832ee58bb547a3b24..96d913f10a6e3d7a3ff0283aa46f735d1d2cb95a 100644 (file)
@@ -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
         */
index 324bd1a96b81d34d74820d4745a97d1c3eb91474..29abbe3111e7edf6e5b6f20d315de6bca51dfccf 100644 (file)
@@ -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<Contact> allContacts () {
                return this.contactList;
        }
index d22da2f631fdd2f94a57ec9f646331afe7983576..7b595fac5bf67a4ea1e59c5e8a829aed3cedc263 100644 (file)
@@ -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
+        * <p>
+        * @return A list of all contacts.
+        */
+       List<Contact> allContacts();
+
        /**
         * Updates all data from bean in given contact instance
         * <p>
index b496a40772f07f78ca5c363280f21554b37ede49..dca2708a54f7f30d2ed86748891c277b3c660070 100644 (file)
@@ -1,4 +1,4 @@
-_<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 <!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}"