]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Continued: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Mon, 8 Aug 2016 14:27:05 +0000 (16:27 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 8 Aug 2016 18:43:01 +0000 (20:43 +0200)
- implemented allSomeNumbers() methods
- used MessageFormat
- ignored strings for i18n
- exposed list to method body to have it being logged in trace message

Signed-off-by: Roland Häder <roland@haeder.net>
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontacts/phone/JobsAdminContactPhoneSessionBean.java
src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java

index d55bbfbcaf06ebb25dec36ac3fd814485c73cbcb..42daebc8947c374d9f7d218148399027227ebdd7 100644 (file)
  */
 package org.mxchange.jcontacts.phone;
 
-import java.text.MessageFormat;
-import java.util.LinkedList;
-import java.util.List;
 import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote;
 import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
-import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
 
 /**
  * A session EJB for administrative contact's phone number purposes
@@ -41,45 +33,4 @@ public class JobsAdminContactPhoneSessionBean extends BaseJobsDatabaseBean imple
         */
        private static final long serialVersionUID = 189_217_561_460_237_108L;
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<Contact> allContacts (final DialableCellphoneNumber cellPhone) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allContacts: cellPhone={1} - CALLED!", this.getClass().getSimpleName(), cellPhone)); //NOI18N
-
-               // The parameter should be valid
-               if (null == cellPhone) {
-                       // Throw NPE
-                       throw new NullPointerException("cellPhone is null"); //NOI18N
-               } else if (cellPhone.getPhoneId() == null) {
-                       // Phone id is null, means not persisted or correclty updated instance
-                       throw new NullPointerException("cellPhone.phoneId is null"); //NOI18N
-               } else if (cellPhone.getPhoneId() < 1) {
-                       // Not valid id number
-                       throw new IllegalArgumentException(MessageFormat.format("cellPhone.phoneId={0} is not valid", cellPhone.getPhoneId())); //NOI18N
-               }
-
-               // Init list instance
-               List<Contact> contacts = new LinkedList<>();
-
-               // Get query object from all found contact-cellphone links
-               Query query = this.getEntityManager().createNamedQuery("AllContactsByCellphone", UserContact.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("cellPhone", cellPhone); //NOI18N
-
-               // Try to find all
-               try {
-                       contacts = query.getResultList();
-               } catch (final NoResultException ex) {
-                       // No results found
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allContacts: contacts.size()={1} - EXIT!", this.getClass().getSimpleName(), contacts.size())); //NOI18N
-
-               // Return list
-               return contacts;
-       }
-
 }
index 187d1d446b7903504d99f983b6afdae63b26d640..d8ddfa0955dbe23fbf2a1fc84e3a78faa8fd574f 100644 (file)
  */
 package org.mxchange.jphone.phonenumbers.phone;
 
+import java.text.MessageFormat;
+import java.util.List;
 import javax.ejb.Stateless;
+import javax.persistence.Query;
 import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
+import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
+import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
 
 /**
  * An EJB for administrative phone purposes
@@ -32,4 +41,61 @@ public class JobsAdminPhoneSessionBean extends BaseJobsDatabaseBean implements A
         */
        private static final long serialVersionUID = 18_597_165_817_401_853L;
 
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableCellphoneNumber> allCellphoneNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCellphoneNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               Query query = this.getEntityManager().createNamedQuery("AllCellphoneNumbers", CellphoneNumber.class); //NOI18N
+
+               // Get list from it
+               List<DialableCellphoneNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allCellphoneNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableFaxNumber> allFaxNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               Query query = this.getEntityManager().createNamedQuery("AllFaxNumbers", FaxNumber.class); //NOI18N
+
+               // Get list from it
+               List<DialableFaxNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allFaxNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
+       @SuppressWarnings ("unchecked")
+       @Override
+       public List<DialableLandLineNumber> allLandLineNumbers () {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+               // Get query
+               Query query = this.getEntityManager().createNamedQuery("AllLandLineNumbers", LandLineNumber.class); //NOI18N
+
+               // Get list from it
+               List<DialableLandLineNumber> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allLandLineNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+               // Return it
+               return list;
+       }
+
 }