- added 2 beans (controller) for handling gender and user. These classes/interfaces has been taken from my pizzaservice-war project and renamed to fit with this project.
- added more required jars
Signed-off-by:Roland Häder <roland@mxchange.org>
</target>
<target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
<target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
+ <copyfiles files="${file.reference.jcore.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcoreee.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcore-logger-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcontacts-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcontacts-business-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.jcontacts-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<copyfiles files="${reference.addressbook-lib.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.cdi-api.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+ <copyfiles files="${file.reference.gf-client.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
<mkdir dir="${build.web.dir}/META-INF"/>
<manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
</target>
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
+ <copyfiles files="${file.reference.jcore.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcoreee.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcore-logger-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcontacts-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcontacts-business-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.jcontacts-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
<copyfiles files="${reference.addressbook-lib.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.cdi-api.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+ <copyfiles files="${file.reference.gf-client.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
</target>
<target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
<delete dir="${build.web.dir}/WEB-INF/lib"/>
-build.xml.data.CRC32=35b2ba60
+build.xml.data.CRC32=8c263e2e
build.xml.script.CRC32=be5f34f7
build.xml.stylesheet.CRC32=651128d4@1.68.1.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=35b2ba60
-nbproject/build-impl.xml.script.CRC32=a9cd461e
+nbproject/build-impl.xml.data.CRC32=8c263e2e
+nbproject/build-impl.xml.script.CRC32=51a78ef4
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
dist.ear.war=${dist.dir}/${war.ear.name}
dist.javadoc.dir=${dist.dir}/javadoc
dist.war=${dist.dir}/${war.name}
+endorsed.classpath=
excludes=
+file.reference.cdi-api.jar=lib/cdi-api.jar
+file.reference.gf-client.jar=lib/gf-client.jar
+file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.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
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
j2ee.server.type=gfv3ee6
jar.compress=false
javac.classpath=\
- ${reference.addressbook-lib.jar}
+ ${file.reference.jcore.jar}:\
+ ${file.reference.jcoreee.jar}:\
+ ${file.reference.jcore-logger-lib.jar}:\
+ ${file.reference.jcontacts-core.jar}:\
+ ${file.reference.jcontacts-business-core.jar}:\
+ ${file.reference.jcontacts-lib.jar}:\
+ ${reference.addressbook-lib.jar}:\
+ ${file.reference.cdi-api.jar}:\
+ ${file.reference.gf-client.jar}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
javac.debug=true
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
runmain.jvmargs=
source.encoding=UTF-8
+source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
+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/
source.root=src
src.dir=${source.root}/java
test.src.dir=test
<name>addressbook-war</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<web-module-libraries>
+ <library dirs="200">
+ <file>${file.reference.jcore.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcoreee.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcore-logger-lib.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcontacts-core.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcontacts-business-core.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcontacts-lib.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
<library dirs="200">
<file>${reference.addressbook-lib.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war>
</library>
+ <library dirs="200">
+ <file>${file.reference.cdi-api.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.gf-client.jar}</file>
+ <path-in-war>WEB-INF/lib</path-in-war>
+ </library>
</web-module-libraries>
<web-module-additional-libraries/>
<source-roots>
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.gender;
+
+import java.util.List;
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Named;
+import org.mxchange.jcontacts.contact.gender.Gender;
+import org.mxchange.jcontacts.contact.gender.GenderUtils;
+
+/**
+ * A gender bean
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("gender")
+@ApplicationScoped
+public class GenderWebBean implements GenderWebController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 835_482_364_189L;
+
+ /**
+ * Default constructor
+ */
+ public GenderWebBean () {
+ }
+
+ @Override
+ public Gender[] getAllGenders () {
+ // Return it
+ return Gender.values();
+ }
+
+ @Override
+ public List<Gender> getSelectableGenders () {
+ // Init array
+ // TODO Call EJB here?
+ List<Gender> genders = GenderUtils.selectableGenders();
+
+ // Return it
+ return genders;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.gender;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcontacts.contact.gender.Gender;
+
+/**
+ * An interface for data beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface GenderWebController extends Serializable {
+
+ /**
+ * Getter for all genders as array
+ * <p>
+ * @return All genders as array
+ */
+ public Gender[] getAllGenders ();
+
+ /**
+ * Getter for only selectable genders as array, UNKNOWN is not selectable
+ * <p>
+ * @return All genders as array
+ */
+ public List<Gender> getSelectableGenders ();
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.user;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jcontacts.contact.gender.Gender;
+
+/**
+ * A user bean (controller)
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("userController")
+@SessionScoped
+public class UserWebBean implements UserWebController {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 542_145_347_916L;
+
+ /////////////////////// Properties /////////////////////
+ /**
+ * Cellphone number
+ */
+ private String cellphoneNumber;
+
+ /**
+ * City
+ */
+ private String city;
+
+ /**
+ * Optional comments
+ */
+ private String comment;
+
+ /**
+ * Company name
+ */
+ private String companyName;
+
+ /**
+ * Country code
+ */
+ private String countryCode;
+
+ /**
+ * Remote user bean
+ */
+ private final UserSessionBeanRemote userBean;
+
+ /**
+ * Email address
+ */
+ private String emailAddress;
+
+ /**
+ * Family name
+ */
+ private String familyName;
+
+ /**
+ * Fax number
+ */
+ private String faxNumber;
+
+ /**
+ * First name
+ */
+ private String firstName;
+
+ /**
+ * Gender instance
+ */
+ private Gender gender;
+
+ /**
+ * House number
+ */
+ private Short houseNumber;
+
+ /**
+ * Phone number
+ */
+ private String phoneNumber;
+
+ /**
+ * Street
+ */
+ private String street;
+
+ /**
+ * ZIP code
+ */
+ private Integer zipCode;
+
+ /**
+ * Default constructor
+ */
+ public UserWebBean () {
+ // Set gender to UNKNOWN
+ this.gender = Gender.UNKNOWN;
+
+ // Try it
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userBean = (UserSessionBeanRemote) context.lookup("ejb/stateless-user");
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+ }
+
+ @Override
+ public User createCustomerInstance () {
+ // User message
+ //this.getLogger().logTrace("createInstance: CALLED!");
+
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+ // Create new user instance
+ User user = new AddressbookUser();
+
+ // Create new contact
+ Contact contact = new UserContact(this.getGender(), this.getFirstName(), this.getFamilyName(), this.getCompanyName());
+ contact.setStreet(this.getStreet());
+ contact.setHouseNumber(this.getHouseNumber());
+ contact.setZipCode(this.getZipCode());
+ contact.setCity(this.getCity());
+ contact.setPhoneNumber(this.getPhoneNumber());
+ contact.setFaxNumber(this.getFaxNumber());
+ contact.setCellphoneNumber(this.getCellphoneNumber());
+
+ // Set contact in user
+ user.setContact(contact);
+
+ // Trace message
+ //this.getLogger().logTrace(MessageFormat.format("createInstance: user={0} - EXIT!", user));
+ // Return it
+ return user;
+ }
+
+ @Override
+ public String getCellphoneNumber () {
+ return this.cellphoneNumber;
+ }
+
+ @Override
+ public void setCellphoneNumber (final String cellphoneNumber) {
+ this.cellphoneNumber = cellphoneNumber;
+ }
+
+ @Override
+ public String getCity () {
+ return this.city;
+ }
+
+ @Override
+ public void setCity (final String city) {
+ this.city = city;
+ }
+
+ @Override
+ public String getCompanyName () {
+ return this.companyName;
+ }
+
+ @Override
+ public void setCompanyName (final String companyName) {
+ this.companyName = companyName;
+ }
+
+ @Override
+ public String getCountryCode () {
+ return this.countryCode;
+ }
+
+ @Override
+ public void setCountryCode (final String countryCode) {
+ this.countryCode = countryCode;
+ }
+
+ @Override
+ public String getEmailAddress () {
+ return this.emailAddress;
+ }
+
+ @Override
+ public void setEmailAddress (final String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ @Override
+ public String getFamilyName () {
+ return this.familyName;
+ }
+
+ @Override
+ public void setFamilyName (final String familyName) {
+ this.familyName = familyName;
+ }
+
+ @Override
+ public String getFaxNumber () {
+ return this.faxNumber;
+ }
+
+ @Override
+ public void setFaxNumber (final String faxNumber) {
+ this.faxNumber = faxNumber;
+ }
+
+ @Override
+ public String getFirstName () {
+ return this.firstName;
+ }
+
+ @Override
+ public void setFirstName (final String firstName) {
+ this.firstName = firstName;
+ }
+
+ @Override
+ public Gender getGender () {
+ return this.gender;
+ }
+
+ @Override
+ public void setGender (final Gender gender) {
+ this.gender = gender;
+ }
+
+ @Override
+ public Short getHouseNumber () {
+ return this.houseNumber;
+ }
+
+ @Override
+ public void setHouseNumber (final Short houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ @Override
+ public String getPhoneNumber () {
+ return this.phoneNumber;
+ }
+
+ @Override
+ public void setPhoneNumber (final String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+
+ @Override
+ public String getStreet () {
+ return this.street;
+ }
+
+ @Override
+ public void setStreet (final String street) {
+ this.street = street;
+ }
+
+ @Override
+ public Integer getZipCode () {
+ return this.zipCode;
+ }
+
+ @Override
+ public void setZipCode (final Integer zipCode) {
+ this.zipCode = zipCode;
+ }
+
+ @Override
+ public boolean isRequiredPersonalDataSet () {
+ return ((this.getGender() != null) && (this.getFirstName() != null) && (this.getFamilyName() != null) && (this.getStreet() != null) && (this.getHouseNumber() != null) && (this.getZipCode() != null) && (this.getCity() != null));
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.user;
+
+import java.io.Serializable;
+import org.mxchange.jcontacts.contact.gender.Gender;
+
+/**
+ * An interface for user beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface UserWebController extends Serializable {
+
+ /**
+ * Creates an instance from all properties
+ * <p>
+ * @return A Customer instance
+ */
+ public User createCustomerInstance ();
+
+ /**
+ * Cellphone number
+ * <p>
+ * @return the cellphoneNumber
+ */
+ public String getCellphoneNumber ();
+
+ /**
+ * Cellphone number
+ * <p>
+ * @param cellphoneNumber the cellphoneNumber to set
+ */
+ public void setCellphoneNumber (final String cellphoneNumber);
+
+ /**
+ * City
+ * <p>
+ * @return the city
+ */
+ public String getCity ();
+
+ /**
+ * City
+ * <p>
+ * @param city the city to set
+ */
+ public void setCity (final String city);
+
+ /**
+ * Company name
+ * <p>
+ * @return the companyName
+ */
+ public String getCompanyName ();
+
+ /**
+ * Company name
+ * <p>
+ * @param companyName the companyName to set
+ */
+ public void setCompanyName (final String companyName);
+
+ /**
+ * Country code
+ * <p>
+ * @return the countryCode
+ */
+ public String getCountryCode ();
+
+ /**
+ * Country code
+ * <p>
+ * @param countryCode the countryCode to set
+ */
+ public void setCountryCode (final String countryCode);
+
+ /**
+ * Email address
+ * <p>
+ * @return the emailAddress
+ */
+ public String getEmailAddress ();
+
+ /**
+ * Email address
+ * <p>
+ * @param emailAddress the emailAddress to set
+ */
+ public void setEmailAddress (final String emailAddress);
+
+ /**
+ * Family name
+ * <p>
+ * @return the familyName
+ */
+ public String getFamilyName ();
+
+ /**
+ * Family name
+ * <p>
+ * @param familyName the familyName to set
+ */
+ public void setFamilyName (final String familyName);
+
+ /**
+ * Fax number
+ * <p>
+ * @return the faxNumber
+ */
+ public String getFaxNumber ();
+
+ /**
+ * Fax number
+ * <p>
+ * @param faxNumber the faxNumber to set
+ */
+ public void setFaxNumber (final String faxNumber);
+
+ /**
+ * First name
+ * <p>
+ * @return the first name
+ */
+ public String getFirstName ();
+
+ /**
+ * First name
+ * <p>
+ * @param firstName the first name to set
+ */
+ public void setFirstName (final String firstName);
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @return the gender
+ */
+ public Gender getGender ();
+
+ /**
+ * Gender of the contact
+ * <p>
+ * @param gender the gender to set
+ */
+ public void setGender (final Gender gender);
+
+ /**
+ * House number
+ * <p>
+ * @return the houseNumber
+ */
+ public Short getHouseNumber ();
+
+ /**
+ * House number
+ * <p>
+ * @param houseNumber the houseNumber to set
+ */
+ public void setHouseNumber (final Short houseNumber);
+
+ /**
+ * Phone number
+ * <p>
+ * @return the phoneNumber
+ */
+ public String getPhoneNumber ();
+
+ /**
+ * Phone number
+ * <p>
+ * @param phoneNumber the phoneNumber to set
+ */
+ public void setPhoneNumber (final String phoneNumber);
+
+ /**
+ * Street
+ * <p>
+ * @return the street
+ */
+ public String getStreet ();
+
+ /**
+ * Street
+ * <p>
+ * @param street the street to set
+ */
+ public void setStreet (final String street);
+
+ /**
+ * ZIP code
+ * <p>
+ * @return the zipCode
+ */
+ public Integer getZipCode ();
+
+ /**
+ * ZIP code
+ * <p>
+ * @param zipCode the zipCode to set
+ */
+ public void setZipCode (final Integer zipCode);
+
+ /**
+ * Checks whether all required personal data is set
+ * <p>
+ * @return Whether the required personal data is set
+ */
+ public boolean isRequiredPersonalDataSet ();
+}