From: Roland Häder Date: Sat, 18 Apr 2020 13:31:11 +0000 (+0200) Subject: Don't cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eec1092b5c406c10060389d2456b0aa3c5668658;p=addressbook-ejb.git Don't cherry-pick: - renamed for Addressbook application Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jcontacts/model/contact/AddressbookAdminContactSessionBean.java b/src/java/org/mxchange/jcontacts/model/contact/AddressbookAdminContactSessionBean.java index f4c558a..80f9255 100644 --- a/src/java/org/mxchange/jcontacts/model/contact/AddressbookAdminContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/model/contact/AddressbookAdminContactSessionBean.java @@ -40,7 +40,7 @@ public class AddressbookAdminContactSessionBean extends BaseAddressbookEnterpris /** * EJB for general contact purposes */ - @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote") + @EJB (lookup = "java:global/addressbook-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote") private ContactSessionBeanRemote contactBean; /** diff --git a/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java index 42878bd..87e193d 100644 --- a/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java @@ -40,7 +40,7 @@ public class AddressbookAdminCountrySingletonBean extends BaseAddressbookEnterpr /** * Remote country EJB */ - @EJB (lookup = "java:global/jfinancials-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote") + @EJB (lookup = "java:global/addressbook-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote") private CountrySingletonBeanRemote countryBean; /** diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java new file mode 100644 index 0000000..8fc58c3 --- /dev/null +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * 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.model.phonenumbers.mobile; + +import java.text.MessageFormat; +import java.util.Date; +import javax.ejb.Stateless; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; + +/** + * An EJB for administrative mobile number purposes + *

+ * @author Roland Häder + */ +@Stateless (name = "adminMobile", description = "An administrative bean handling mobile number data") +public class AddressbookAdminMobileSessionBean extends BaseAddressbookEnterpriseBean implements AdminMobileSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 18_597_165_817_401_854L; + + /** + * Default constructor + */ + public AddressbookAdminMobileSessionBean () { + // Call super constructor + super(); + } + + @Override + public void deleteMobileData (final DialableMobileNumber mobileNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); + + // Is all data set + if (null == mobileNumber) { + // Not set, throw NPE + throw new NullPointerException("mobileNumber is null"); //NOI18N + } else if (mobileNumber.getMobileId() == null) { + // Throw NPE again + throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N + } else if (mobileNumber.getMobileId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getMobileId())); //NOI18N + } else if (mobileNumber.getMobileProvider() == null) { + // Throw NPE + throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N + } else if (mobileNumber.getMobileProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N + } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N + } else if (mobileNumber.getMobileNumber() == null) { + // Throw NPE again + throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N + } else if (mobileNumber.getMobileNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", mobileNumber.getMobileNumber())); //NOI18N + } + + // Get a managed instance + final DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getMobileId()); + + // Remove it from database + this.getEntityManager().remove(managedNumber); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName())); + } + + @Override + public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); + + // Is all data set + if (null == mobileNumber) { + // Not set, throw NPE + throw new NullPointerException("mobileNumber is null"); //NOI18N + } else if (mobileNumber.getMobileId() == null) { + // Throw NPE again + throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N + } else if (mobileNumber.getMobileId() < 1) { + // Invalid number + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getMobileId())); //NOI18N + } else if (mobileNumber.getMobileProvider() == null) { + // Throw NPE + throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N + } else if (mobileNumber.getMobileProvider().getProviderId() == null) { + // ... throw again + throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N + } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { + // Id not valid + throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N + } else if (mobileNumber.getMobileNumber() == null) { + // Throw NPE again + throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N + } else if (mobileNumber.getMobileNumber() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", mobileNumber.getMobileNumber())); //NOI18N + } + + // Get contact from it and find it + final DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getMobileId()); + + // Should be found + assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getMobileId()); //NOI18N + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getMobileId())); //NOI18N + + // Set updated timestamp + MobileNumbers.copyMobileNumber(mobileNumber, managedNumber); + managedNumber.setMobileEntryUpdated(new Date()); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N + + // Return it + return managedNumber; + } + +} diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookMobileSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookMobileSessionBean.java new file mode 100644 index 0000000..b7f3744 --- /dev/null +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookMobileSessionBean.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 - 2020 Free Software Foundation + * + * 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.model.phonenumbers.mobile; + +import java.text.MessageFormat; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.Query; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; + +/** + * A general mobile number EJB + *

+ * @author Roland Häder + */ +@Stateless (name = "mobile", description = "A bean handling mobile number data") +public class AddressbookMobileSessionBean extends BaseAddressbookEnterpriseBean implements MobileSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 134_945_698_127_602L; + + /** + * Default constructor + */ + public AddressbookMobileSessionBean () { + // Call super constructor + super(); + } + + @SuppressWarnings ("unchecked") + @Override + public List fetchAllMobileNumbers () { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N + + // Get query + final Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N + + // Get list from it + final 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; + } + +} diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsAdminMobileSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsAdminMobileSessionBean.java deleted file mode 100644 index 5040db6..0000000 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsAdminMobileSessionBean.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * 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.model.phonenumbers.mobile; - -import java.text.MessageFormat; -import java.util.Date; -import javax.ejb.Stateless; -import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean; - -/** - * An EJB for administrative mobile number purposes - *

- * @author Roland Häder - */ -@Stateless (name = "adminMobile", description = "An administrative bean handling mobile number data") -public class FinancialsAdminMobileSessionBean extends BaseFinancialsEnterpriseBean implements AdminMobileSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_597_165_817_401_854L; - - /** - * Default constructor - */ - public FinancialsAdminMobileSessionBean () { - // Call super constructor - super(); - } - - @Override - public void deleteMobileData (final DialableMobileNumber mobileNumber) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); - - // Is all data set - if (null == mobileNumber) { - // Not set, throw NPE - throw new NullPointerException("mobileNumber is null"); //NOI18N - } else if (mobileNumber.getMobileId() == null) { - // Throw NPE again - throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N - } else if (mobileNumber.getMobileId() < 1) { - // Invalid number - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getMobileId())); //NOI18N - } else if (mobileNumber.getMobileProvider() == null) { - // Throw NPE - throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N - } else if (mobileNumber.getMobileProvider().getProviderId() == null) { - // ... throw again - throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N - } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { - // Id not valid - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N - } else if (mobileNumber.getMobileNumber() == null) { - // Throw NPE again - throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N - } else if (mobileNumber.getMobileNumber() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", mobileNumber.getMobileNumber())); //NOI18N - } - - // Get a managed instance - final DialableMobileNumber managedNumber = this.getEntityManager().getReference(mobileNumber.getClass(), mobileNumber.getMobileId()); - - // Remove it from database - this.getEntityManager().remove(managedNumber); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteMobileData: EXIT!", this.getClass().getSimpleName())); - } - - @Override - public DialableMobileNumber updateMobileData (final DialableMobileNumber mobileNumber) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: mobileNumber={1} - CALLED!", this.getClass().getSimpleName(), mobileNumber)); - - // Is all data set - if (null == mobileNumber) { - // Not set, throw NPE - throw new NullPointerException("mobileNumber is null"); //NOI18N - } else if (mobileNumber.getMobileId() == null) { - // Throw NPE again - throw new NullPointerException("mobileNumber.phoneId is null"); //NOI18N - } else if (mobileNumber.getMobileId() < 1) { - // Invalid number - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.phoneId={0} is not valid", mobileNumber.getMobileId())); //NOI18N - } else if (mobileNumber.getMobileProvider() == null) { - // Throw NPE - throw new NullPointerException("mobileNumber.cellphoneProvider is null"); //NOI18N - } else if (mobileNumber.getMobileProvider().getProviderId() == null) { - // ... throw again - throw new NullPointerException("mobileNumber.cellphoneProvider.providerId is null"); //NOI18N - } else if (mobileNumber.getMobileProvider().getProviderId() < 1) { - // Id not valid - throw new IllegalArgumentException(MessageFormat.format("mobileNumber.cellphoneProvider.providerId={0} is not valid.", mobileNumber.getMobileProvider().getProviderId())); //NOI18N - } else if (mobileNumber.getMobileNumber() == null) { - // Throw NPE again - throw new NullPointerException("mobileNumber.mobileNumber is null"); //NOI18N - } else if (mobileNumber.getMobileNumber() < 1) { - // Throw NPE again - throw new NullPointerException(MessageFormat.format("mobileNumber.mobileNumber={0} is not valid.", mobileNumber.getMobileNumber())); //NOI18N - } - - // Get contact from it and find it - final DialableMobileNumber managedNumber = this.getEntityManager().find(mobileNumber.getClass(), mobileNumber.getMobileId()); - - // Should be found - assert (managedNumber instanceof DialableMobileNumber) : MessageFormat.format("Cell phone number with id {0} not found, but should be.", mobileNumber.getMobileId()); //NOI18N - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getMobileId())); //NOI18N - - // Set updated timestamp - MobileNumbers.copyMobileNumber(mobileNumber, managedNumber); - managedNumber.setMobileEntryUpdated(new Date()); - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateMobileData: managedNumber={1} - EXIT!", this.getClass().getSimpleName(), managedNumber)); //NOI18N - - // Return it - return managedNumber; - } - -} diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsMobileSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsMobileSessionBean.java deleted file mode 100644 index 8e2e899..0000000 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/FinancialsMobileSessionBean.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 Free Software Foundation - * - * 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.model.phonenumbers.mobile; - -import java.text.MessageFormat; -import java.util.List; -import javax.ejb.Stateless; -import javax.persistence.Query; -import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean; - -/** - * A general mobile number EJB - *

- * @author Roland Häder - */ -@Stateless (name = "mobile", description = "A bean handling mobile number data") -public class FinancialsMobileSessionBean extends BaseFinancialsEnterpriseBean implements MobileSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 134_945_698_127_602L; - - /** - * Default constructor - */ - public FinancialsMobileSessionBean () { - // Call super constructor - super(); - } - - @SuppressWarnings ("unchecked") - @Override - public List fetchAllMobileNumbers () { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allMobileNumbers: CALLED!", this.getClass().getSimpleName())); //NOI18N - - // Get query - final Query query = this.getEntityManager().createNamedQuery("AllMobileNumbers", MobileNumber.class); //NOI18N - - // Get list from it - final 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; - } - -}