From: Roland Haeder Date: Sun, 17 Apr 2016 10:40:08 +0000 (+0200) Subject: renamed after project's name X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d8a8406b215843b6f35bcfa5149376ec6dc3d982;p=pizzaservice-mailer-ejb.git renamed after project's name --- diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookPhoneSessionBean.java new file mode 100644 index 0000000..17a100a --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookPhoneSessionBean.java @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package org.mxchange.jphone.phonenumbers.phone; + +import java.text.MessageFormat; +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; + +/** + * A general phone EJB + *

+ * @author Roland Haeder + */ +@Stateless (name = "phone", mappedName = "ejb/stateless-addressbook-phone", description = "A bean handling phone data") +public class AddressbookPhoneSessionBean extends BaseDatabaseBean implements PhoneSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 134_945_698_127_601L; + + /** + * Default constructor + */ + public AddressbookPhoneSessionBean () { + } + + @Override + public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException { + // The id number should be valid + if (null == cellphoneId) { + // Throw NPE + throw new NullPointerException("cellphoneId is null"); //NOI18N + } else if (cellphoneId < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("cellphoneId={0} is not valid.", cellphoneId)); //NOI18N + } + + // Now find it + Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", CellphoneNumber.class); //NOI18N + + // Set parameter + query.setParameter("cellphoneId", cellphoneId); //NOI18N + + // Init instance + DialableCellphoneNumber cellphone = null; + + // Try to get a result + try { + // Get a single result + cellphone = (DialableCellphoneNumber) query.getSingleResult(); + } catch (NoResultException ex) { + // The entry was not found, so throw it again + throw new PhoneEntityNotFoundException(cellphoneId, ex); + } + + // Return found instance + return cellphone; + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java deleted file mode 100644 index b903705..0000000 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package org.mxchange.jphone.phonenumbers.phone; - -import java.text.MessageFormat; -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; - -/** - * 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 { - - /** - * Serial number - */ - private static final long serialVersionUID = 134_945_698_127_601L; - - /** - * Default constructor - */ - public PizzaPhoneSessionBean () { - } - - @Override - public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException { - // The id number should be valid - if (null == cellphoneId) { - // Throw NPE - throw new NullPointerException("cellphoneId is null"); //NOI18N - } else if (cellphoneId < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("cellphoneId={0} is not valid.", cellphoneId)); //NOI18N - } - - // Now find it - Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", CellphoneNumber.class); //NOI18N - - // Set parameter - query.setParameter("cellphoneId", cellphoneId); //NOI18N - - // Init instance - DialableCellphoneNumber cellphone = null; - - // Try to get a result - try { - // Get a single result - cellphone = (DialableCellphoneNumber) query.getSingleResult(); - } catch (NoResultException ex) { - // The entry was not found, so throw it again - throw new PhoneEntityNotFoundException(cellphoneId, ex); - } - - // Return found instance - return cellphone; - } - -}