]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Continued some more:
authorRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 13:08:41 +0000 (15:08 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 17 Apr 2016 13:08:41 +0000 (15:08 +0200)
- added EJB for general contact purposes
- added EJB for administrative contact's phone purposes
- added EJB for administrative phone purposes

nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java [new file with mode: 0644]

index 5b1d5eae90c1a253a3403ed72da9a9a2d27f18ab..1a5c5a47202642fb8b9ff83408c38e3bacb08d51 100644 (file)
@@ -833,6 +833,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${reference.PizzaService-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.classes.dir}"/>
+        <copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.juser-core.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.juser-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jphone-core.jar}" todir="${build.classes.dir}"/>
@@ -849,6 +850,7 @@ exists or setup the property manually. For example like this:
         <basename file="${file.reference.jcore-logger-lib.jar}" property="manifest.file.reference.jcore-logger-lib.jar"/>
         <basename file="${reference.PizzaService-lib.jar}" property="manifest.reference.PizzaService-lib.jar"/>
         <basename file="${file.reference.jcontacts-core.jar}" property="manifest.file.reference.jcontacts-core.jar"/>
+        <basename file="${file.reference.jcontacts-lib.jar}" property="manifest.file.reference.jcontacts-lib.jar"/>
         <basename file="${file.reference.juser-core.jar}" property="manifest.file.reference.juser-core.jar"/>
         <basename file="${file.reference.juser-lib.jar}" property="manifest.file.reference.juser-lib.jar"/>
         <basename file="${file.reference.jphone-core.jar}" property="manifest.file.reference.jphone-core.jar"/>
@@ -857,7 +859,7 @@ exists or setup the property manually. For example like this:
         <basename file="${file.reference.jshop-ee-lib.jar}" property="manifest.file.reference.jshop-ee-lib.jar"/>
         <basename file="${file.reference.cdi-api.jar}" property="manifest.file.reference.cdi-api.jar"/>
         <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update">
-            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 "/>
+            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 jar-15 "/>
             <attribute name="jar-1-Extension-Name" value="${manifest.file.reference.jcore.jar}"/>
             <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcoreee.jar}"/>
             <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
@@ -865,13 +867,14 @@ exists or setup the property manually. For example like this:
             <attribute name="jar-5-Extension-Name" value="${manifest.file.reference.jcore-logger-lib.jar}"/>
             <attribute name="jar-6-Extension-Name" value="${manifest.reference.PizzaService-lib.jar}"/>
             <attribute name="jar-7-Extension-Name" value="${manifest.file.reference.jcontacts-core.jar}"/>
-            <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
-            <attribute name="jar-9-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
-            <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
-            <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.jphone-lib.jar}"/>
-            <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.jshop-core.jar}"/>
-            <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.jshop-ee-lib.jar}"/>
-            <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
+            <attribute name="jar-8-Extension-Name" value="${manifest.file.reference.jcontacts-lib.jar}"/>
+            <attribute name="jar-9-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
+            <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
+            <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.jphone-core.jar}"/>
+            <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.jphone-lib.jar}"/>
+            <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.jshop-core.jar}"/>
+            <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.jshop-ee-lib.jar}"/>
+            <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
         </manifest>
     </target>
     <target depends="compile" name="library-inclusion-in-manifest">
@@ -882,6 +885,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${reference.PizzaService-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jcontacts-core.jar}" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.juser-core.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.juser-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jphone-core.jar}" todir="${dist.ear.dir}/lib"/>
index 73bdb0ce187e7a1ca3f1ccd14b325afe68a2c1f7..4d5d680c8c98c9e3aa5673f4b4222ea260b68efc 100644 (file)
@@ -3,6 +3,6 @@ build.xml.script.CRC32=cabe2e92
 build.xml.stylesheet.CRC32=5910fda3@1.51.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=3b2a403d
-nbproject/build-impl.xml.script.CRC32=eb9d30fc
+nbproject/build-impl.xml.data.CRC32=01d50d77
+nbproject/build-impl.xml.script.CRC32=eac55053
 nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.55.1
index 3b9f031c7fc07312ec4438bd7c3d5b6f61d2c24d..2510ad76412a779e6a35a06a31f01436fcdf2930 100644 (file)
@@ -23,6 +23,7 @@ endorsed.classpath=
 excludes=
 file.reference.cdi-api.jar=lib/cdi-api.jar
 file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
+file.reference.jcontacts-lib.jar=lib/jcontacts-lib.jar
 file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar
 file.reference.jcore.jar=lib/jcore.jar
 file.reference.jcoreee.jar=lib/jcoreee.jar
@@ -56,6 +57,7 @@ javac.classpath=\
     ${file.reference.jcore-logger-lib.jar}:\
     ${reference.PizzaService-lib.jar}:\
     ${file.reference.jcontacts-core.jar}:\
+    ${file.reference.jcontacts-lib.jar}:\
     ${file.reference.juser-core.jar}:\
     ${file.reference.juser-lib.jar}:\
     ${file.reference.jphone-core.jar}:\
@@ -101,6 +103,7 @@ run.test.classpath=\
 runmain.jvmargs=
 source.encoding=UTF-8
 source.reference.jcontacts-core.jar=../jcontacts-core/src/
+source.reference.jcontacts-lib.jar=../jcontacts-lib/src/
 source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/
 source.reference.jcore.jar=../jcore/src/
 source.reference.jcoreee.jar=../../jcoreee/src/
index 61f3efe8f9cd84f5eb914268aa04daeb64b03f25..4d43a5be05c47a1ca0bd0bb27ef485a99cf1c0c9 100644 (file)
@@ -12,6 +12,7 @@
             <included-library dirs="200">file.reference.jcore-logger-lib.jar</included-library>
             <included-library dirs="200">reference.PizzaService-lib.jar</included-library>
             <included-library dirs="200">file.reference.jcontacts-core.jar</included-library>
+            <included-library dirs="200">file.reference.jcontacts-lib.jar</included-library>
             <included-library dirs="200">file.reference.juser-core.jar</included-library>
             <included-library dirs="200">file.reference.juser-lib.jar</included-library>
             <included-library dirs="200">file.reference.jphone-core.jar</included-library>
diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java
new file mode 100644 (file)
index 0000000..f41072c
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@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/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java
new file mode 100644 (file)
index 0000000..69c0e89
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@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<Contact> 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<Contact> 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
new file mode 100644 (file)
index 0000000..86bca75
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.phonenumbers.phone;
+
+import javax.ejb.Stateless;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+
+/**
+ * An EJB for administrative phone purposes
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@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;
+
+}