X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Fjava%2Forg%2Fmxchange%2Fjphone%2Fphonenumbers%2Fphone%2FPizzaPhoneSessionBean.java;h=19bf926200f9aeed4f12c0a3cebd28ef23412852;hb=76ea7e8743458d474075e21806b9f54d063bf78a;hp=e1794e5532c04ce259bf0af11507b17f2857031f;hpb=a533efd802cfccc2428b313d8cbd2855bc9fa562;p=pizzaservice-ejb.git
diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java
index e1794e5..19bf926 100644
--- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java
+++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java
@@ -17,21 +17,26 @@
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;
-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;
+import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean;
+import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
/**
* A general phone EJB
*
* @author Roland Haeder
*/
-@Stateless (name = "phone", mappedName = "ejb/stateless-pizza-phone", description = "A bean handling phone data")
-public class PizzaPhoneSessionBean extends BaseDatabaseBean implements PhoneSessionBeanRemote {
+@Stateless (name = "phone", description = "A bean handling phone data")
+public class PizzaPhoneSessionBean extends BasePizzaDatabaseBean implements PhoneSessionBeanRemote {
/**
* Serial number
@@ -44,40 +49,97 @@ public class PizzaPhoneSessionBean extends BaseDatabaseBean implements PhoneSess
public PizzaPhoneSessionBean () {
}
+ @SuppressWarnings ("unchecked")
@Override
- public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException {
+ public List allMobileNumbers () {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("findCellphoneById: cellphoneId={0} - CALLED!", cellphoneId)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
+ // Get query
+ Query query = this.getEntityManager().createNamedQuery("AllCellphoneNumbers", MobileNumber.class); //NOI18N
+
+ // Get list from it
+ List list = query.getResultList();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: list.size()={1} - EXIT!", this.getClass().getSimpleName(), list.size())); //NOI18N
+
+ // Return it
+ return list;
+ }
+
+ @SuppressWarnings ("unchecked")
+ @Override
+ public List 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 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 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 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;
+ }
+
+ @Override
+ public DialableMobileNumber findMobileNumberById (final Long mobileNumberId) throws PhoneEntityNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: mobileNumberId={1} - CALLED!", this.getClass().getSimpleName(), mobileNumberId)); //NOI18N
// The id number should be valid
- if (null == cellphoneId) {
+ if (null == mobileNumberId) {
// Throw NPE
- throw new NullPointerException("cellphoneId is null"); //NOI18N
- } else if (cellphoneId < 1) {
+ throw new NullPointerException("mobileNumberId is null"); //NOI18N
+ } else if (mobileNumberId < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("cellphoneId={0} is not valid.", cellphoneId)); //NOI18N
+ throw new IllegalArgumentException(MessageFormat.format("mobileNumberId={0} is not valid.", mobileNumberId)); //NOI18N
}
// Now find it
- Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", CellphoneNumber.class); //NOI18N
+ Query query = this.getEntityManager().createNamedQuery("SearchMobileNumberId", MobileNumber.class); //NOI18N
// Set parameter
- query.setParameter("cellphoneId", cellphoneId); //NOI18N
+ query.setParameter("mobileNumberId", mobileNumberId); //NOI18N
// Init instance
- DialableCellphoneNumber cellphone = null;
+ DialableMobileNumber cellphone = null;
// Try to get a result
try {
// Get a single result
- cellphone = (DialableCellphoneNumber) query.getSingleResult();
+ cellphone = (DialableMobileNumber) query.getSingleResult();
} catch (NoResultException ex) {
// The entry was not found, so throw it again
- throw new PhoneEntityNotFoundException(cellphoneId, ex);
+ throw new PhoneEntityNotFoundException(mobileNumberId, ex);
}
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("findCellphoneById: cellphone={0} - EXIT!", cellphone)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findCellphoneById: cellphone={1} - EXIT!", this.getClass().getSimpleName(), cellphone)); //NOI18N
// Return found instance
return cellphone;