]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with contact:
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 15:51:06 +0000 (17:51 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 10 May 2016 18:46:57 +0000 (20:46 +0200)
- added observers for events being fired when admin added new contact
- cleared admin contact bean after adding contact

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
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java

index 936b6fba8912486328386ceffcceb0a8426220b1..48d8e53f186b3494a1bbb9217972decbb2258b60 100644 (file)
@@ -285,6 +285,9 @@ public class JobsAdminContactWebRequestBean implements JobsAdminContactWebReques
                // Fire event
                this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
 
+               // Clear this bean
+               this.clear();
+
                // Return outcome
                return "admin_list_contact"; //NOI18N
        }
index c5b011c879a765f2b98c71f3c1fbb9461d9cdae7..9770590cdf4380b057a9ae13c7013338a2adccf4 100644 (file)
@@ -36,6 +36,7 @@ import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jcontacts.contact.gender.Gender;
 import org.mxchange.jcontacts.contact.utils.ContactUtils;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcountry.data.Country;
index 811e4db8f3f76902db1290c95779a84cbb66a1c6..dd508b54f8c13671a5b55144b1be874854752b0d 100644 (file)
@@ -21,6 +21,7 @@ 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.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
 import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcountry.data.Country;
@@ -69,13 +70,6 @@ public interface JobsContactWebSessionController extends Serializable {
         */
        void updateContactDataFromController (final Contact userContact);
 
-       /**
-        * Adds given email address to list
-        * <p>
-        * @param contactEmailAddress Email address to add
-        */
-       void addEmailAddress (final String contactEmailAddress);
-
        /**
         * Tries to lookup contact by given id number. If the user is not found a
         * proper exceptions are thrown.
@@ -95,6 +89,14 @@ public interface JobsContactWebSessionController extends Serializable {
         */
        void afterRegistrationEvent (final UserRegisteredEvent 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 admins
         * <p>
index 64bc0049f71aa8327a54541dabc1445a5b929776..485fbe2575c6c11e3b503c7cc5d26622dded905e 100644 (file)
@@ -33,12 +33,9 @@ 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.jjobs.beans.contact.JobsContactWebSessionController;
 import org.mxchange.jjobs.beans.login.JobsUserLoginWebSessionController;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
-import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
@@ -152,6 +149,27 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController {
                }
        }
 
+       @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.customerId is null"); //NOI18N
+               } else if (event.getAddedContact().getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("event.addedContact.customerId={0} is not valid", event.getAddedContact().getContactId())); //NOI18N //NOI18N
+               }
+
+               // Call other method
+               this.selectableContacts.add(event.getAddedContact());
+       }
+
        @Override
        public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
                // Trace message
index e7869ec9c37c4798ca31a1a2882150519f1b9789..ddb7d4e996d3167ba9f509664de66f38d5957f71 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.jjobs.beans.user;
 import java.io.Serializable;
 import java.util.List;
 import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
@@ -105,6 +106,14 @@ public interface JobsUserWebSessionController extends Serializable {
         */
        boolean isContactFound (final Contact contact);
 
+       /**
+        * Observes events being fired when an administrator has added a new
+        * contact.
+        * <p>
+        * @param event Event being fired
+        */
+       void afterAdminAddedContact (final AdminAddedContactEvent event);
+
        /**
         * Checks whether a public user account is registered. This means that at
         * least one user profile has its flag "public user profile" enabled.