From: Roland Haeder Date: Sun, 17 Apr 2016 13:17:54 +0000 (+0200) Subject: renamed after project's name X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9a344d9aed0802ab26ede011ae9dbbb85c166cdd;p=jjobs-ejb.git renamed after project's name --- diff --git a/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java new file mode 100644 index 0000000..029ac1d --- /dev/null +++ b/src/java/org/mxchange/jcontacts/contact/JobsContactSessionBean.java @@ -0,0 +1,78 @@ +/* + * 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.jcontacts.contact; + +import java.text.MessageFormat; +import javax.ejb.Stateless; +import javax.persistence.NoResultException; +import javax.persistence.Query; +import org.mxchange.jcontacts.exceptions.ContactNotFoundException; +import org.mxchange.jcoreee.database.BaseDatabaseBean; + +/** + * A contact EJB + *

+ * @author Roland Haeder + */ +@Stateless (name = "contact", mappedName = "ejb/stateless-jjobs-contact", description = "A bean handling contact data") +public class JobsContactSessionBean extends BaseDatabaseBean implements ContactSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 542_145_347_916L; + + /** + * Default constructor + */ + public JobsContactSessionBean () { + } + + @Override + public Contact findContactById (final Long contactId) throws ContactNotFoundException { + // The parameter must be valid + if (null == contactId) { + // Throw NPE + throw new NullPointerException("contactId is null"); //NOI18N + } else if (contactId < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N + } + + // Get query instance + Query query = this.getEntityManager().createNamedQuery("SearchContactId", UserContact.class); //NOI18N + + // Set parameter + query.setParameter("contactId", contactId); //NOI18N + + // Init contact instance + Contact contact; + + // Try to find a result + try { + // Find a single result + contact = (Contact) query.getSingleResult(); + } catch (final NoResultException ex) { + // No result found + throw new ContactNotFoundException(contactId, ex); + } + + // Return found instance + return contact; + } + +} diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java deleted file mode 100644 index f41072c..0000000 --- a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java +++ /dev/null @@ -1,78 +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.jcontacts.contact; - -import java.text.MessageFormat; -import javax.ejb.Stateless; -import javax.persistence.NoResultException; -import javax.persistence.Query; -import org.mxchange.jcontacts.exceptions.ContactNotFoundException; -import org.mxchange.jcoreee.database.BaseDatabaseBean; - -/** - * A contact EJB - *

- * @author Roland Haeder - */ -@Stateless (name = "contact", mappedName = "ejb/stateless-pizza-contact", description = "A bean handling contact data") -public class PizzaContactSessionBean extends BaseDatabaseBean implements ContactSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 542_145_347_916L; - - /** - * Default constructor - */ - public PizzaContactSessionBean () { - } - - @Override - public Contact findContactById (final Long contactId) throws ContactNotFoundException { - // The parameter must be valid - if (null == contactId) { - // Throw NPE - throw new NullPointerException("contactId is null"); //NOI18N - } else if (contactId < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("contactId={0} is not valid", contactId)); //NOI18N - } - - // Get query instance - Query query = this.getEntityManager().createNamedQuery("SearchContactId", UserContact.class); //NOI18N - - // Set parameter - query.setParameter("contactId", contactId); //NOI18N - - // Init contact instance - Contact contact; - - // Try to find a result - try { - // Find a single result - contact = (Contact) query.getSingleResult(); - } catch (final NoResultException ex) { - // No result found - throw new ContactNotFoundException(contactId, ex); - } - - // Return found instance - return contact; - } - -} diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSingletonBean.java new file mode 100644 index 0000000..7ecf338 --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/JobsAdminMobileProviderSingletonBean.java @@ -0,0 +1,91 @@ +/* + * 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.mobileprovider; + +import java.text.MessageFormat; +import java.util.GregorianCalendar; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import org.mxchange.jcoreee.database.BaseDatabaseBean; +import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; + +/** + * An administrative singleton EJB for mobile provider informations + *

+ * @author Roland Haeder + */ +@Startup +@Singleton (name = "adminmobileprovider", mappedName = "ejb/jjobs-singleton-admin-mobile-provider", description = "A singleton session bean for mobile provider informations, admin-edition") +public class JobsAdminMobileProviderSingletonBean extends BaseDatabaseBean implements AdminMobileProviderSingletonBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 15_846_983_298_691_207L; + + @Override + public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException { + // Log trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N + + // Is the instance valid? + if (null == mobileProvider) { + // Throw NPE + throw new NullPointerException("mobileProvider is null"); //NOI18N + } else if (mobileProvider.getProviderDialPrefix() == null) { + // Throw NPE again + throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N + } else if (mobileProvider.getProviderDialPrefix() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N + } else if (mobileProvider.getProviderCountry() == null) { + // Throw again a NPE + throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N + } else if (mobileProvider.getProviderMailPattern() == null) { + // ... and again ... + throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N + } else if (mobileProvider.getProviderMailPattern().isEmpty()) { + // Empty pattern set (not allowed) + throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N + } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N + // No place-holder found + throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N + } else if (mobileProvider.getProviderName() == null) { + // Throw NPE again + throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N + } else if (mobileProvider.getProviderName().isEmpty()) { + // Empty name is not allowed + throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N + } + + // Set creation timestamp + mobileProvider.setProviderEntryCreated(new GregorianCalendar()); + + // Persist it + this.getEntityManager().persist(mobileProvider); + + // ... and flush it to get id back + this.getEntityManager().flush(); + + // Log trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N + + // Return updated + return mobileProvider; + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java deleted file mode 100644 index 4ba7008..0000000 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaAdminMobileProviderSingletonBean.java +++ /dev/null @@ -1,91 +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.mobileprovider; - -import java.text.MessageFormat; -import java.util.GregorianCalendar; -import javax.ejb.Singleton; -import javax.ejb.Startup; -import org.mxchange.jcoreee.database.BaseDatabaseBean; -import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; - -/** - * An administrative singleton EJB for mobile provider informations - *

- * @author Roland Haeder - */ -@Startup -@Singleton (name = "adminmobileprovider", mappedName = "ejb/pizzaservice-singleton-admin-mobile-provider", description = "A singleton session bean for mobile provider informations, admin-edition") -public class PizzaAdminMobileProviderSingletonBean extends BaseDatabaseBean implements AdminMobileProviderSingletonBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 15_846_983_298_691_207L; - - @Override - public MobileProvider addMobileProvider (final MobileProvider mobileProvider) throws MobileProviderAlreadyAddedException { - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider={0} - CALLED!", mobileProvider)); //NOI18N - - // Is the instance valid? - if (null == mobileProvider) { - // Throw NPE - throw new NullPointerException("mobileProvider is null"); //NOI18N - } else if (mobileProvider.getProviderDialPrefix() == null) { - // Throw NPE again - throw new NullPointerException("mobileProvider.providerDialPrefix is null"); //NOI18N - } else if (mobileProvider.getProviderDialPrefix() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerDialPrefix={0} is not valid.", mobileProvider.getProviderDialPrefix())); //NOI18N - } else if (mobileProvider.getProviderCountry() == null) { - // Throw again a NPE - throw new NullPointerException("mobileProvider.providerCountry is null"); //NOI18N - } else if (mobileProvider.getProviderMailPattern() == null) { - // ... and again ... - throw new NullPointerException("mobileProvider.providerMailPattern is null"); //NOI18N - } else if (mobileProvider.getProviderMailPattern().isEmpty()) { - // Empty pattern set (not allowed) - throw new IllegalArgumentException("mobileProvider.providerMailPattern is empty."); //NOI18N - } else if (!mobileProvider.getProviderMailPattern().contains("%s")) { //NOI18N - // No place-holder found - throw new IllegalArgumentException(MessageFormat.format("mobileProvider.providerMailPattern={0} does not contain '%s' which is need to be replaced with the full mobile number.", mobileProvider.getProviderMailPattern())); //NOI18N - } else if (mobileProvider.getProviderName() == null) { - // Throw NPE again - throw new NullPointerException("mobileProvider.providerName is null"); //NOI18N - } else if (mobileProvider.getProviderName().isEmpty()) { - // Empty name is not allowed - throw new IllegalArgumentException("mobileProvider.providerName is empty"); //NOI18N - } - - // Set creation timestamp - mobileProvider.setProviderEntryCreated(new GregorianCalendar()); - - // Persist it - this.getEntityManager().persist(mobileProvider); - - // ... and flush it to get id back - this.getEntityManager().flush(); - - // Log trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("addMobileProvider: mobileProvider.providerId={0} - EXIT!", mobileProvider.getProviderId())); //NOI18N - - // Return updated - return mobileProvider; - } - -} diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java new file mode 100644 index 0000000..cecc04d --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminContactPhoneSessionBean.java @@ -0,0 +1,77 @@ +/* + * 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 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.phone.AdminContactsPhoneSessionBeanRemote; +import org.mxchange.jcoreee.database.BaseDatabaseBean; +import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; + +/** + * A session EJB for administrative contact's phone number purposes + *

+ * @author Roland Haeder + */ +@Stateless (name = "admincontactphone", mappedName = "ejb/stateless-jjobs-admin-contact-phone", description = "An administrative bean handling contact's phone data") +public class JobsAdminContactPhoneSessionBean extends BaseDatabaseBean implements AdminContactsPhoneSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 189_217_561_460_237_108L; + + @Override + @SuppressWarnings ("unchecked") + public List allContacts (final DialableCellphoneNumber cellPhone) { + // 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 contacts = null; + + // Get query object from all found contact-cellphone links + Query query = this.getEntityManager().createNamedQuery("AllContactsByCellphone", List.class); //NOI18N + + // Set parameter + query.setParameter("cellPhone", cellPhone); //NOI18N + + // Try to find all + try { + contacts = query.getResultList(); + } catch (final NoResultException ex) { + // No results found + } + + // Return list + return contacts; + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java new file mode 100644 index 0000000..f32c3e0 --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java @@ -0,0 +1,35 @@ +/* + * 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 javax.ejb.Stateless; +import org.mxchange.jcoreee.database.BaseDatabaseBean; + +/** + * An EJB for administrative phone purposes + *

+ * @author Roland Haeder + */ +@Stateless (name = "adminphone", mappedName = "ejb/stateless-jjobs-admin-phone", description = "An administrative bean handling phone data") +public class JobsAdminPhoneSessionBean extends BaseDatabaseBean implements AdminPhoneSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_597_165_817_401_853L; + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java deleted file mode 100644 index 69c0e89..0000000 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java +++ /dev/null @@ -1,77 +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 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.phone.AdminContactsPhoneSessionBeanRemote; -import org.mxchange.jcoreee.database.BaseDatabaseBean; -import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber; - -/** - * A session EJB for administrative contact's phone number purposes - *

- * @author Roland Haeder - */ -@Stateless (name = "admincontactphone", mappedName = "ejb/stateless-pizza-admin-contact-phone", description = "An administrative bean handling contact's phone data") -public class PizzaAdminContactPhoneSessionBean extends BaseDatabaseBean implements AdminContactsPhoneSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 189_217_561_460_237_108L; - - @Override - @SuppressWarnings ("unchecked") - public List allContacts (final DialableCellphoneNumber cellPhone) { - // 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 contacts = null; - - // Get query object from all found contact-cellphone links - Query query = this.getEntityManager().createNamedQuery("AllContactsByCellphone", List.class); //NOI18N - - // Set parameter - query.setParameter("cellPhone", cellPhone); //NOI18N - - // Try to find all - try { - contacts = query.getResultList(); - } catch (final NoResultException ex) { - // No results found - } - - // Return list - return contacts; - } - -} diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java deleted file mode 100644 index 86bca75..0000000 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java +++ /dev/null @@ -1,35 +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 javax.ejb.Stateless; -import org.mxchange.jcoreee.database.BaseDatabaseBean; - -/** - * An EJB for administrative phone purposes - *

- * @author Roland Haeder - */ -@Stateless (name = "adminphone", mappedName = "ejb/stateless-pizza-admin-phone", description = "An administrative bean handling phone data") -public class PizzaAdminPhoneSessionBean extends BaseDatabaseBean implements AdminPhoneSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_597_165_817_401_853L; - -}