<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
<project default="-deploy-ant" basedir=".">
<target name="-init-cl-deployment-env" if="deploy.ant.enabled">
<property file="${deploy.ant.properties.file}" />
<tempfile prefix="gfv3" property="gfv3.password.file" destdir="${java.io.tmpdir}"/> <!-- do not forget to delete this! -->
<echo message="AS_ADMIN_PASSWORD=${gfv3.password}" file="${gfv3.password.file}"/>
</target>
-
+
<target name="-parse-sun-web" depends="-init-cl-deployment-env" if="sun.web.present">
<tempfile prefix="gfv3" property="temp.sun.web" destdir="${java.io.tmpdir}"/>
<copy file="${deploy.ant.docbase.dir}/WEB-INF/sun-web.xml" tofile="${temp.sun.web}"/>
<formatter type="brief" usefile="false"/>
<formatter type="xml"/>
<jvmarg value="-ea"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
<formatter type="xml"/>
<jvmarg value="-ea"/>
<jvmarg line="${run.jvmargs.ide}"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/>
<customize/>
</junit>
</sequential>
</macrodef>
</target>
<target name="-init-debug-args">
- <property name="version-output" value="java version "${ant.java.version}"/>
- <condition property="have-jdk-older-than-1.4">
- <or>
- <contains string="${version-output}" substring="java version "1.0"/>
- <contains string="${version-output}" substring="java version "1.1"/>
- <contains string="${version-output}" substring="java version "1.2"/>
- <contains string="${version-output}" substring="java version "1.3"/>
- </or>
- </condition>
- <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
- <istrue value="${have-jdk-older-than-1.4}"/>
- </condition>
<condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
<os family="windows"/>
</condition>
<element name="customize" optional="true"/>
<sequential>
<java classname="@{classname}" fork="true">
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+ <jvmarg value="-agentlib:jdwp=transport=${debug-transport},address=${jpda.address}"/>
<jvmarg line="${runmain.jvmargs}"/>
<classpath>
<path path="@{classpath}"/>
<copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jcontacts-business-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jproduct-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jproduct-lib.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcustomer-core.jar}" todir="${build.classes.dir}"/>
- <copyfiles files="${file.reference.jcustomer-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.juser-login-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-activity-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.juser-activity-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${file.reference.jmailer-ee.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jaddressbook-core.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jaddressbook-lib.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jaddressbook-share-core.jar}" todir="${build.classes.dir}"/>
+ <copyfiles files="${file.reference.jaddressbook-share-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${reference.addressbook-core.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${reference.addressbook-lib.jar}" todir="${build.classes.dir}"/>
<copyfiles files="${reference.addressbook-mailer-lib.jar}" todir="${build.classes.dir}"/>
<basename file="${file.reference.jcontacts-lib.jar}" property="manifest.file.reference.jcontacts-lib.jar"/>
<basename file="${file.reference.jcontacts-business-core.jar}" property="manifest.file.reference.jcontacts-business-core.jar"/>
<basename file="${file.reference.jcontacts-business-lib.jar}" property="manifest.file.reference.jcontacts-business-lib.jar"/>
- <basename file="${file.reference.jproduct-core.jar}" property="manifest.file.reference.jproduct-core.jar"/>
- <basename file="${file.reference.jproduct-lib.jar}" property="manifest.file.reference.jproduct-lib.jar"/>
- <basename file="${file.reference.jcustomer-core.jar}" property="manifest.file.reference.jcustomer-core.jar"/>
- <basename file="${file.reference.jcustomer-lib.jar}" property="manifest.file.reference.jcustomer-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.juser-login-core.jar}" property="manifest.file.reference.juser-login-core.jar"/>
<basename file="${file.reference.juser-activity-core.jar}" property="manifest.file.reference.juser-activity-core.jar"/>
<basename file="${file.reference.juser-activity-lib.jar}" property="manifest.file.reference.juser-activity-lib.jar"/>
<basename file="${file.reference.jmailer-ee.jar}" property="manifest.file.reference.jmailer-ee.jar"/>
+ <basename file="${file.reference.jaddressbook-core.jar}" property="manifest.file.reference.jaddressbook-core.jar"/>
+ <basename file="${file.reference.jaddressbook-lib.jar}" property="manifest.file.reference.jaddressbook-lib.jar"/>
+ <basename file="${file.reference.jaddressbook-share-core.jar}" property="manifest.file.reference.jaddressbook-share-core.jar"/>
+ <basename file="${file.reference.jaddressbook-share-lib.jar}" property="manifest.file.reference.jaddressbook-share-lib.jar"/>
<basename file="${reference.addressbook-core.jar}" property="manifest.reference.addressbook-core.jar"/>
<basename file="${reference.addressbook-lib.jar}" property="manifest.reference.addressbook-lib.jar"/>
<basename file="${reference.addressbook-mailer-lib.jar}" property="manifest.reference.addressbook-mailer-lib.jar"/>
<attribute name="jar-7-Extension-Name" value="${manifest.file.reference.jcontacts-lib.jar}"/>
<attribute name="jar-8-Extension-Name" value="${manifest.file.reference.jcontacts-business-core.jar}"/>
<attribute name="jar-9-Extension-Name" value="${manifest.file.reference.jcontacts-business-lib.jar}"/>
- <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.jproduct-core.jar}"/>
- <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.jproduct-lib.jar}"/>
- <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.jcustomer-core.jar}"/>
- <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.jcustomer-lib.jar}"/>
- <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
- <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
- <attribute name="jar-16-Extension-Name" value="${manifest.file.reference.juser-login-core.jar}"/>
- <attribute name="jar-17-Extension-Name" value="${manifest.file.reference.juser-login-lib.jar}"/>
- <attribute name="jar-18-Extension-Name" value="${manifest.file.reference.juser-activity-core.jar}"/>
- <attribute name="jar-19-Extension-Name" value="${manifest.file.reference.juser-activity-lib.jar}"/>
- <attribute name="jar-20-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
+ <attribute name="jar-10-Extension-Name" value="${manifest.file.reference.juser-core.jar}"/>
+ <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
+ <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.juser-login-core.jar}"/>
+ <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.juser-login-lib.jar}"/>
+ <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.juser-activity-core.jar}"/>
+ <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.juser-activity-lib.jar}"/>
+ <attribute name="jar-16-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
+ <attribute name="jar-17-Extension-Name" value="${manifest.file.reference.jaddressbook-core.jar}"/>
+ <attribute name="jar-18-Extension-Name" value="${manifest.file.reference.jaddressbook-lib.jar}"/>
+ <attribute name="jar-19-Extension-Name" value="${manifest.file.reference.jaddressbook-share-core.jar}"/>
+ <attribute name="jar-20-Extension-Name" value="${manifest.file.reference.jaddressbook-share-lib.jar}"/>
<attribute name="jar-21-Extension-Name" value="${manifest.reference.addressbook-core.jar}"/>
<attribute name="jar-22-Extension-Name" value="${manifest.reference.addressbook-lib.jar}"/>
<attribute name="jar-23-Extension-Name" value="${manifest.reference.addressbook-mailer-lib.jar}"/>
<copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jcontacts-business-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jproduct-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jproduct-lib.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcustomer-core.jar}" todir="${dist.ear.dir}/lib"/>
- <copyfiles files="${file.reference.jcustomer-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.juser-login-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-activity-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.juser-activity-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${file.reference.jmailer-ee.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jaddressbook-core.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jaddressbook-lib.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jaddressbook-share-core.jar}" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jaddressbook-share-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.addressbook-core.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.addressbook-lib.jar}" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.addressbook-mailer-lib.jar}" todir="${dist.ear.dir}/lib"/>
</target>
<target depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
<target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test-method" name="debug-test-method"/>
+ <target depends="debug-test-method" name="debug-single-method"/>
<target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
<ejbjarproject1:nbjpdareload dir="${build.test.classes.dir}"/>
</target>
j2ee.compile.on.save=true
j2ee.deploy.on.save=true
j2ee.platform=1.7
-j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
+j2ee.platform.classpath=${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.enterprise-api.jar:${j2ee.server.home}/modules/javax.security.enterprise.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcontacts.model.contact.Contacts;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
import org.mxchange.jcontactsbusiness.model.department.Department;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+import org.mxchange.jcontactsbusiness.model.utils.BranchOfficeUtils;
+import org.mxchange.jcontactsbusiness.model.utils.DepartmentUtils;
import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper;
import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
+import org.mxchange.jphone.model.utils.FaxNumberUtils;
+import org.mxchange.jphone.model.utils.LandLineNumberUtils;
+import org.mxchange.jphone.model.utils.MobileNumberUtils;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.Users;
+import org.mxchange.jusercore.model.utils.UserUtils;
/**
* A helper class for beans that access the database.
return managedHeadquarter;
}
-
/**
* Get back a managed instance from given mobile provider
* <p>
}
/**
- * Returns a detached instance from given mobile instance
- * <p>
- * @param mobileNumber Mobile instance
- * @param fetchedNumber Found mobile number in database
- * <p>
- * @return Detached instance
- */
- protected DialableMobileNumber getDetached (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: mobileNumber={0},fetchedNumber={1} - CALLED!", mobileNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == mobileNumber) {
- // Throw NPE
- throw new NullPointerException("mobileNumber is null"); //NOI18N
- } else if (fetchedNumber.getMobileId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getMobileId())); //NOI18N
-
- // Init query instance
- final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getMobileId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableMobileNumber detachedNumber = null;
-
- // Is there a difference?
- if (!MobileNumbers.isSameMobileNumber(mobileNumber, fetchedNumber)) {
- // @TODO Copy all to foundNumber, then merge
-
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a detached instance from given land-line instance
- * <p>
- * @param landLineNumber Land-line instance
- * @param fetchedNumber Found land-line number in database
- * <p>
- * @return Detached instance
- */
- protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
-
- // Should be valid
- if (null == landLineNumber) {
- // Throw NPE
- throw new NullPointerException("landLineNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
- }
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
-
- // Init query instance
- final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
-
- // Default is null
- DialableLandLineNumber detachedNumber = null;
-
- // Is there a difference?
- if (!LandLineNumbers.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
- // @TODO Copy all to foundNumber, then merge
-
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
-
- // Return it
- return detachedNumber;
- }
-
- /**
- * Returns a detached instance from given fax instance
+ * Merges given branch office's data
* <p>
- * @param faxNumber Fax instance
- * @param fetchedNumber Found fax number in database
+ * @param detachedBranchOffice Branch office instance to merge
* <p>
- * @return Detached instance
+ * @return Detached contact instance
*/
- protected DialableFaxNumber getDetached (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+ protected BranchOffice mergeBranchOfficeData (final BranchOffice detachedBranchOffice) {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeBranchOfficeData: detachedBranchOffice={0} - CALLED!", detachedBranchOffice)); //NOI18N
- // Should be valid
- if (null == faxNumber) {
- // Throw NPE
- throw new NullPointerException("faxNumber is null"); //NOI18N
- } else if (fetchedNumber.getPhoneId() == null) {
- // ..and again
- throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ // The contact instance must be valid
+ if (null == detachedBranchOffice) {
+ // Throw NPE again
+ throw new NullPointerException("detachedBranchOffice is null"); //NOI18N
+ } else if (detachedBranchOffice.getBranchId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedBranchOffice.branchId is null"); //NOI18N
+ } else if (detachedBranchOffice.getBranchId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("detachedBranchOffice.branchId ={0} is not valid.", detachedBranchOffice.getBranchId())); //NOI18N
}
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+ // Get contact from it and find it
+ final BranchOffice foundBranchOffice = this.getEntityManager().find(detachedBranchOffice.getClass(), detachedBranchOffice.getBranchId());
- // Init query instance
- final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+ // Should be found
+ assert (foundBranchOffice instanceof BranchOffice) : MessageFormat.format("Branch office with id {0} not found, but should be.", detachedBranchOffice.getBranchId()); //NOI18N
// Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeBranchOfficeData: foundContact.contactId={0}", foundBranchOffice.getBranchId())); //NOI18N
- // Default is null
- DialableFaxNumber detachedNumber = null;
+ // Copy all
+ BranchOfficeUtils.copyBranchOfficeData(detachedBranchOffice, foundBranchOffice);
- // Is there a difference?
- if (!FaxNumbers.isSameFaxNumber(faxNumber, fetchedNumber)) {
- // @TODO Copy all to foundNumber, then merge
+ // Merge contact instance
+ final BranchOffice managedBranchOffice = this.getEntityManager().merge(foundBranchOffice);
- // Merge this entry
- detachedNumber = this.getEntityManager().merge(foundNumber);
- }
+ // Set updated timestamp
+ managedBranchOffice.setBranchEntryUpdated(new Date());
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeBranchOfficeData: managedBranchOffice={0} - EXIT!", managedBranchOffice)); //NOI18N
- // Return it
- return detachedNumber;
+ // Return detached contact
+ return managedBranchOffice;
}
/**
throw new NullPointerException("detachedContact is null"); //NOI18N
} else if (detachedContact.getContactId() == null) {
// Throw NPE again
- throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+ throw new NullPointerException("detachedContact.contactId is null"); //NOI18N
} else if (detachedContact.getContactId() < 1) {
// Not valid
throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
}
- // Set updated timestamp
- detachedContact.setContactEntryUpdated(new Date());
-
// Get contact from it and find it
- final Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId());
-
- // Should be found
- assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N
+ final Contact foundContact = this.createManaged(detachedContact);
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeContactData: foundContact.contactId={0}", foundContact.getContactId())); //NOI18N
// Copy all
- Contacts.copyContactData(detachedContact, foundContact);
+ ContactUtils.copyContactData(detachedContact, foundContact);
// Merge contact instance
final Contact managedContact = this.getEntityManager().merge(foundContact);
+ // Set updated timestamp
+ managedContact.setContactEntryUpdated(new Date());
+
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: managedContact={0} - EXIT!", managedContact)); //NOI18N
throw new NullPointerException("detachedContact is null"); //NOI18N
} else if (detachedContact.getContactId() == null) {
// Throw NPE again
- throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N
+ throw new NullPointerException("detachedContact.contactId is null"); //NOI18N
} else if (detachedContact.getContactId() < 1) {
// Not valid
throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N
assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getMobileId()); //NOI18N
// Copy all
- MobileNumbers.copyMobileNumberData(detachedContact.getContactMobileNumber(), foundMobile);
+ MobileNumberUtils.copyMobileNumberData(detachedContact.getContactMobileNumber(), foundMobile);
// Then merge it, too
final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
// Copy all
- FaxNumbers.copyFaxNumberData(detachedContact.getContactFaxNumber(), foundFax);
+ FaxNumberUtils.copyFaxNumberData(detachedContact.getContactFaxNumber(), foundFax);
// Then merge it, too
final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
// Copy all
- LandLineNumbers.copyLandLineNumberData(detachedContact.getContactLandLineNumber(), foundLandLine);
+ LandLineNumberUtils.copyLandLineNumberData(detachedContact.getContactLandLineNumber(), foundLandLine);
// Then merge it, too
final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
this.getLoggerBeanLocal().logTrace("mergeContactsMobileLandLineFaxNumbers: EXIT!"); //NOI18N
}
+ /**
+ * Merges given department's data
+ * <p>
+ * @param detachedDepartment Department instance to merge
+ * <p>
+ * @return Detached contact instance
+ */
+ protected Department mergeDepartmentData (final Department detachedDepartment) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeDepartmentData: detachedDepartment={0} - CALLED!", detachedDepartment)); //NOI18N
+
+ // The contact instance must be valid
+ if (null == detachedDepartment) {
+ // Throw NPE again
+ throw new NullPointerException("detachedDepartment is null"); //NOI18N
+ } else if (detachedDepartment.getDepartmentId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("detachedDepartment.departmentId is null"); //NOI18N
+ } else if (detachedDepartment.getDepartmentId() < 1) {
+ // Not valid
+ throw new IllegalStateException(MessageFormat.format("detachedDepartment.departmentId ={0} is not valid.", detachedDepartment.getDepartmentId())); //NOI18N
+ }
+
+ // Get contact from it and find it
+ final Department foundDepartment = this.createManaged(detachedDepartment);
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("mergeDepartmentData: foundContact.contactId={0}", foundDepartment.getDepartmentId())); //NOI18N
+
+ // Copy all
+ DepartmentUtils.copyDepartmentData(detachedDepartment, foundDepartment);
+
+ // Merge contact instance
+ final Department managedDepartment = this.getEntityManager().merge(foundDepartment);
+
+ // Set updated timestamp
+ managedDepartment.setDepartmentEntryUpdated(new Date());
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeDepartmentData: managedDepartment={0} - EXIT!", managedDepartment)); //NOI18N
+
+ // Return detached contact
+ return managedDepartment;
+ }
+
+ /**
+ * Returns a detached instance from given fax instance merged into current.
+ * <p>
+ * @param faxNumber Fax instance
+ * @param fetchedNumber Found fax number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableFaxNumber mergeFaxNumberData (final DialableFaxNumber faxNumber, final DialableFaxNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: faxNumber={0},fetchedNumber={1} - CALLED!", faxNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == faxNumber) {
+ // Throw NPE
+ throw new NullPointerException("faxNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableFaxNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableFaxNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!FaxNumberUtils.isSameFaxNumber(faxNumber, fetchedNumber)) {
+ // @TODO Copy all to foundNumber, then merge
+
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a detached instance from given land-line instance merged with
+ * current.
+ * <p>
+ * @param landLineNumber Land-line instance
+ * @param fetchedNumber Found land-line number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableLandLineNumber mergeLandLineNumberData (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == landLineNumber) {
+ // Throw NPE
+ throw new NullPointerException("landLineNumber is null"); //NOI18N
+ } else if (fetchedNumber.getPhoneId() == null) {
+ // ..and again
+ throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N
+
+ // Init query instance
+ final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableLandLineNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!LandLineNumberUtils.isSameLandLineNumber(landLineNumber, fetchedNumber)) {
+ // @TODO Copy all to foundNumber, then merge
+
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
+ /**
+ * Returns a detached instance from given mobile instance merged with
+ * current.
+ * <p>
+ * @param mobileNumber Mobile instance
+ * @param fetchedNumber Found mobile number in database
+ * <p>
+ * @return Detached instance
+ */
+ protected DialableMobileNumber mergeMobileNumberData (final DialableMobileNumber mobileNumber, final DialableMobileNumber fetchedNumber) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: mobileNumber={0},fetchedNumber={1} - CALLED!", mobileNumber, fetchedNumber)); //NOI18N
+
+ // Should be valid
+ if (null == mobileNumber) {
+ // Throw NPE
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
+ } else if (fetchedNumber.getMobileId() == null) {
+ // ..and again
+ throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N
+ }
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getMobileId())); //NOI18N
+
+ // Init query instance
+ final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getMobileId());
+
+ // Debug message
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N
+
+ // Default is null
+ DialableMobileNumber detachedNumber = null;
+
+ // Is there a difference?
+ if (!MobileNumberUtils.isSameMobileNumber(mobileNumber, fetchedNumber)) {
+ // @TODO Copy all to foundNumber, then merge
+
+ // Merge this entry
+ detachedNumber = this.getEntityManager().merge(foundNumber);
+ }
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N
+
+ // Return it
+ return detachedNumber;
+ }
+
/**
* Sends an email with given subject line, template name to given recipient
* and user data
}
// Set all values
- final Properties variables = Users.getAllUserFields(user);
+ final Properties variables = UserUtils.getAllUserFields(user);
// Set base URL and random password
variables.put("baseUrl", baseUrl); //NOI18N
this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactMobileNumber={0}", other.getContactMobileNumber())); //NOI18N
// Is other mobile not set?
- if ((other.getContactMobileNumber() == null) || (MobileNumbers.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
+ if ((other.getContactMobileNumber() == null) || (MobileNumberUtils.isSameMobileNumber(contact.getContactMobileNumber(), other.getContactMobileNumber()))) {
// Debug message
this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying mobile entry ..."); //NOI18N
// Is the fax number set?
if (other.getContactMobileNumber() instanceof DialableMobileNumber) {
// Copy mobile number
- contact.setContactMobileNumber(this.getDetached(other.getContactMobileNumber(), contact.getContactMobileNumber()));
+ contact.setContactMobileNumber(this.mergeMobileNumberData(other.getContactMobileNumber(), contact.getContactMobileNumber()));
} else {
// Null it
contact.setContactMobileNumber(null);
this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactLandLineNumber={0}", other.getContactLandLineNumber())); //NOI18N
// Is other mobile not set?
- if ((other.getContactLandLineNumber() == null) || (LandLineNumbers.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
+ if ((other.getContactLandLineNumber() == null) || (LandLineNumberUtils.isSameLandLineNumber(contact.getContactLandLineNumber(), other.getContactLandLineNumber()))) {
// Debug message
this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying land-line entry ..."); //NOI18N
// Is the land-line number set?
if (other.getContactLandLineNumber() instanceof DialableLandLineNumber) {
// Copy land-line number
- contact.setContactLandLineNumber(this.getDetached(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
+ contact.setContactLandLineNumber(this.mergeLandLineNumberData(other.getContactLandLineNumber(), contact.getContactLandLineNumber()));
} else {
// Null it
contact.setContactLandLineNumber(null);
this.getLoggerBeanLocal().logDebug(MessageFormat.format("setAllContactPhoneEntries: other.contactFaxNumber={0}", other.getContactFaxNumber())); //NOI18N
// Is other mobile not set?
- if ((other.getContactFaxNumber() == null) || (FaxNumbers.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
+ if ((other.getContactFaxNumber() == null) || (FaxNumberUtils.isSameFaxNumber(contact.getContactFaxNumber(), other.getContactFaxNumber()))) {
// Debug message
this.getLoggerBeanLocal().logDebug("setAllContactPhoneEntries: Copying fax entry ..."); //NOI18N
// Is the fax number set?
if (other.getContactFaxNumber() instanceof DialableFaxNumber) {
// Copy fax number
- contact.setContactFaxNumber(this.getDetached(other.getContactFaxNumber(), contact.getContactFaxNumber()));
+ contact.setContactFaxNumber(this.mergeFaxNumberData(other.getContactFaxNumber(), contact.getContactFaxNumber()));
} else {
// Null it
contact.setContactFaxNumber(null);
throw new NullPointerException("contact is null"); //NOI18N
} else if (contact.getContactId() == null) {
// Throw NPE again
- throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
} else if (contact.getContactId() < 1) {
// Not valid
throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
import org.mxchange.jusercore.model.user.User;
*/
private static final long serialVersionUID = 129_857_871_287_691L;
- @Override
- @SuppressWarnings ("unchecked")
- public List<AddressbookEntry> allEntries (final Addressbook addressbook) {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("allEntries: addressbook={0} - CALLED!", addressbook)); //NOI18N
-
- // Validate parameter
- if (null == addressbook) {
- // Throw NPE
- throw new NullPointerException("addressbook is null");
- } else if (addressbook.getAddressbookId() == null) {
- // Throw NPE again
- throw new NullPointerException("addressbook.addressbookId is null");
- } else if (addressbook.getAddressbookId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId()));
- } else if (addressbook.getAddressbookUser() == null) {
- // Throw again NPE
- throw new NullPointerException("addressbook.addressbookUser is null");
- } else if (addressbook.getAddressbookUser().getUserId() == null) {
- // Throw again NPE
- throw new NullPointerException("addressbook.addressbookUser.userId is null");
- } else if (addressbook.getAddressbookUser().getUserId() < 1) {
- // Invalid id number again
- throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId()));
- }
-
- // Generate query
- Query query = this.getEntityManager().createNamedQuery("SearchUsersAddressbookEntries", List.class); //NOI18N
-
- // Set parameters
- query.setParameter("addressbook", addressbook); //NOI18N
- query.setParameter("owner", addressbook.getAddressbookUser()); //NOI18N
-
- // Return it
- return query.getResultList();
- }
-
@Override
public Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException {
// Is it not null?
return addressbook;
}
- @Override
- public Addressbook getAddressbookById (final Long addressbookId) throws AddressbookNotFoundException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("getAddressbookById: addressbookId={0} - CALLED!", addressbookId)); //NOI18N
-
- // addressbookId should not be null or below 1
- if (null == addressbookId) {
- // Throw NPE
- throw new NullPointerException("addressbookId is null"); //NOI18N
- } else if (addressbookId < 1) {
- // Not valid
- throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N
- } else if (!this.isAddressbookIdUsed(addressbookId)) {
- // No address book found
- throw new AddressbookNotFoundException(addressbookId);
- }
-
- // Get named query instance
- Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N
-
- // Set parameter
- query.setParameter("id", addressbookId); //NOI18N
-
- // Return it
- return (Addressbook) query.getSingleResult();
- }
-
@Override
@SuppressWarnings ("unchecked")
- public List<Addressbook> getUsersAddressbookList (final User loggedInUser) {
+ public List<Addressbook> fetchAddressbooksByUser (final User loggedInUser) {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); //NOI18N
}
// Get query instance
- Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N
+ final Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N
// Set parameter
query.setParameter("param", loggedInUser); //NOI18N
// Get full list from JPA
- List<Addressbook> addressbooks = query.getResultList();
+ final List<Addressbook> addressbooks = query.getResultList();
// Return it
return addressbooks;
}
+ @Override
+ @SuppressWarnings ("unchecked")
+ public List<AddressbookEntry> fetchAllAddressbookEntries (final Addressbook addressbook) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("allEntries: addressbook={0} - CALLED!", addressbook)); //NOI18N
+
+ // Validate parameter
+ if (null == addressbook) {
+ // Throw NPE
+ throw new NullPointerException("addressbook is null");
+ } else if (addressbook.getAddressbookId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("addressbook.addressbookId is null");
+ } else if (addressbook.getAddressbookId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId()));
+ } else if (addressbook.getAddressbookUser() == null) {
+ // Throw again NPE
+ throw new NullPointerException("addressbook.addressbookUser is null");
+ } else if (addressbook.getAddressbookUser().getUserId() == null) {
+ // Throw again NPE
+ throw new NullPointerException("addressbook.addressbookUser.userId is null");
+ } else if (addressbook.getAddressbookUser().getUserId() < 1) {
+ // Invalid id number again
+ throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId()));
+ }
+
+ // Generate query
+ Query query = this.getEntityManager().createNamedQuery("SearchUsersAddressbookEntries", List.class); //NOI18N
+
+ // Set parameters
+ query.setParameter("addressbook", addressbook); //NOI18N
+ query.setParameter("owner", addressbook.getAddressbookUser()); //NOI18N
+
+ // Return it
+ return query.getResultList();
+ }
+
@Override
public boolean isAddressbookIdUsed (final Long addressbookId) {
// Trace message
}
// Get query instance
- Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N
+ final Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N
// Set parameter
query.setParameter("id", addressbookId); //NOI18N
// Try it again, yes no other way
try {
// Get single result
- Addressbook addressbook = (Addressbook) query.getSingleResult();
+ final Addressbook addressbook = (Addressbook) query.getSingleResult();
// Debug message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbook={0} - FOUND!", addressbook)); //NOI18N
@Override
public boolean isAddressbookNameUsed (final Addressbook addressbook) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookNameUsed: addressbook={0} - CALLED!", addressbook));
+
// Is it not null?
if (null == addressbook) {
// Abort here
}
// Get query instance
- Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); //NOI18N
+ final Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); //NOI18N
// Set parameter
query.setParameter("user", addressbook.getAddressbookUser()); //NOI18N
// Try it
try {
// Get a single result
- Addressbook dummy = (Addressbook) query.getSingleResult();
+ final Addressbook dummy = (Addressbook) query.getSingleResult();
// Log it
this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: Found an address book: {0}", dummy)); //NOI18N
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
import org.mxchange.jphone.exceptions.phone.PhoneNumberAlreadyLinkedException;
}
@Override
- public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException {
+ public Contact linkExistingFaxNumberWithContact (final Contact contact, final DialableFaxNumber faxNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingFaxNumberWithContact: contact={1},faxNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, faxNumber)); //NOI18N
}
@Override
- public Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException {
+ public Contact linkExistingLandLineNumberWithContact (final Contact contact, final DialableLandLineNumber landLineNumber) throws PhoneNumberAlreadyLinkedException, ContactNotFoundException {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.linkExistingLandLineNumberWithContact: contact={1},landLineNumber={2} - CALLED!", this.getClass().getSimpleName(), contact, landLineNumber)); //NOI18N
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
+import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+import org.mxchange.jcontactsbusiness.model.utils.BranchOfficeUtils;
import org.mxchange.jcountry.model.data.Country;
import org.mxchange.jusercore.model.user.User;
/**
* General branch office bean
*/
- @EJB (lookup = "java:global/addressbook-ejb/branchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote")
+ @EJB (lookup = "java:global/jfinancials-ejb/branchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.BranchOfficeSessionBeanRemote")
private BranchOfficeSessionBeanRemote branchOfficeBean;
/**
// Add created timestamp
branchOffice.setBranchEntryCreated(new Date());
+ // Is contact employee set?
+ if (branchOffice.getBranchContactEmployee() instanceof Contact) {
+ // Get managed lead contact
+ final Contact managedContact = this.createManaged(branchOffice.getBranchContactEmployee());
+
+ // Set it back
+ branchOffice.setBranchContactEmployee(managedContact);
+ }
+
+ // Is owner employee set?
+ if (branchOffice.getBranchOwnerEmployee() instanceof Contact) {
+ // Get managed lead contact
+ final Contact managedContact = this.createManaged(branchOffice.getBranchOwnerEmployee());
+
+ // Set it back
+ branchOffice.setBranchOwnerEmployee(managedContact);
+ }
+
// Is user instance set?
if (branchOffice.getBranchCompany() instanceof BasicData) {
// Get managed instance back
final List<OpeningTime> openingTimes = branchOffice.getBranchOpeningTimes();
// Debugging:
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addBranchOffice(): branchOffice.branchOfficeOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes));
+ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.addBranchOffice(): branchOffice.branchOfficeOpeningTimes={1}", this.getClass().getSimpleName(), openingTimes)); //NOI18N
// Is opening times set and not empty?
if ((openingTimes instanceof List) && (!openingTimes.isEmpty())) {
return branchOffice;
}
+ @Override
+ public BranchOffice updateBranchOffice (final BranchOffice branchOffice) throws BranchOfficeNotFoundException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateBranchOffice(): branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
+
+ // Is parameter valid?
+ if (null == branchOffice) {
+ // Throw NPE
+ throw new NullPointerException("branchOffice is null"); //NOI18N
+ } else if (branchOffice.getBranchId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("branchOffice.branchId is null"); //NOI18N
+ } else if (branchOffice.getBranchId() < 1) {
+ // Throw IAE again
+ throw new IllegalArgumentException(MessageFormat.format("branchOffice.branchId={0} is invalid", branchOffice.getBranchId())); //NOI18N
+ } else if (!this.isBranchOfficeFound(branchOffice)) {
+ // Not found
+ throw new BranchOfficeNotFoundException(branchOffice.getBranchId());
+ }
+
+ // Merge data
+ final BranchOffice updatedBranchOffice = this.mergeBranchOfficeData(branchOffice);
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateBranchOffice(): updatedBranchOffice={1} - EXIT!", this.getClass().getSimpleName(), updatedBranchOffice));
+
+ // Return updated instance
+ return updatedBranchOffice;
+ }
+
/**
* Checks if given branch office's address is already persisted. The whole
* (persisted) list is being loaded and each address is being matched
* @return Whether it has been found
*/
private boolean isBranchOfficeFound (final BranchOffice branchOffice) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isBranchOfficeFound(): branchOffice={1} - CALLED!", this.getClass().getSimpleName(), branchOffice)); //NOI18N
+
// Get whole list
final List<BranchOffice> branchOffices = this.branchOfficeBean.fetchAllBranchOffices();
// Check all single addresses
for (final BranchOffice bo : branchOffices) {
// Is the same address found?
- if (Objects.equals(bo.getBranchId(), branchOffice.getBranchId()) || BranchOffices.isSameAddress(bo, branchOffice)) {
+ if (Objects.equals(bo.getBranchId(), branchOffice.getBranchId()) || BranchOfficeUtils.isSameAddress(bo, branchOffice)) {
// Found one
isFound = true;
break;
}
}
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.isBranchOfficeFound(): isFound={1} - EXIT!", this.getClass().getSimpleName(), isFound)); //NOI18N
+
// Return flag
return isFound;
}