]> git.mxchange.org Git - addressbook-mailer-ejb.git/blobdiff - src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookPhoneSessionBean.java
Moved to proper EJB: (please cherry-pick)
[addressbook-mailer-ejb.git] / src / java / org / mxchange / jphone / phonenumbers / phone / AddressbookPhoneSessionBean.java
index 17a100a993e28b650ea19463fa6b22b00675f03a..687cc28be4230553b71abebaf5054dc9a553fe49 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.jphone.phonenumbers.phone;
 
 import java.text.MessageFormat;
+import java.util.List;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
@@ -24,13 +25,17 @@ import org.mxchange.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
 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;
 
 /**
  * A general phone EJB
  * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@Stateless (name = "phone", mappedName = "ejb/stateless-addressbook-phone", description = "A bean handling phone data")
+@Stateless (name = "phone", description = "A bean handling phone data")
 public class AddressbookPhoneSessionBean extends BaseDatabaseBean implements PhoneSessionBeanRemote {
 
        /**
@@ -46,6 +51,9 @@ public class AddressbookPhoneSessionBean extends BaseDatabaseBean implements Pho
 
        @Override
        public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: cellphoneId={1} - CALLED!", this.getClass().getSimpleName(), cellphoneId)); //NOI18N
+
                // The id number should be valid
                if (null == cellphoneId) {
                        // Throw NPE
@@ -73,8 +81,68 @@ public class AddressbookPhoneSessionBean extends BaseDatabaseBean implements Pho
                        throw new PhoneEntityNotFoundException(cellphoneId, ex);
                }
 
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), cellphone)); //NOI18N
+
                // Return found instance
                return cellphone;
        }
 
+       @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;
+       }
+
 }