From: Roland Haeder Date: Mon, 5 Oct 2015 12:47:26 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a6928dac04310e41d1f0b22e039f6b7059d1d7e3;p=addressbook-war.git Continued: - 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 --- diff --git a/lib/cdi-api.jar b/lib/cdi-api.jar new file mode 100644 index 00000000..1fa239e3 Binary files /dev/null and b/lib/cdi-api.jar differ diff --git a/lib/gf-client.jar b/lib/gf-client.jar new file mode 100644 index 00000000..2f369f3b Binary files /dev/null and b/lib/gf-client.jar differ diff --git a/lib/jcontacts-business-core.jar b/lib/jcontacts-business-core.jar new file mode 100644 index 00000000..6f1c0963 Binary files /dev/null and b/lib/jcontacts-business-core.jar differ diff --git a/lib/jcontacts-core.jar b/lib/jcontacts-core.jar new file mode 100644 index 00000000..c92ea915 Binary files /dev/null and b/lib/jcontacts-core.jar differ diff --git a/lib/jcontacts-lib.jar b/lib/jcontacts-lib.jar new file mode 100644 index 00000000..7797a5a5 Binary files /dev/null and b/lib/jcontacts-lib.jar differ diff --git a/lib/jcore-logger-lib.jar b/lib/jcore-logger-lib.jar new file mode 100644 index 00000000..52fec3ee Binary files /dev/null and b/lib/jcore-logger-lib.jar differ diff --git a/lib/jcore.jar b/lib/jcore.jar new file mode 100644 index 00000000..2c6f30ef Binary files /dev/null and b/lib/jcore.jar differ diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar new file mode 100644 index 00000000..8fd4a463 Binary files /dev/null and b/lib/jcoreee.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 4fa04c42..0823cda1 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1030,12 +1030,28 @@ exists or setup the property manually. For example like this: + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index b5a11b4c..f9b11ae5 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -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 diff --git a/nbproject/project.properties b/nbproject/project.properties index 9d1fd571..84bb6385 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -33,7 +33,16 @@ dist.dir=dist 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 @@ -48,7 +57,15 @@ j2ee.platform.wsit.classpath= 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 @@ -88,6 +105,12 @@ run.test.classpath=\ # (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 diff --git a/nbproject/project.xml b/nbproject/project.xml index 87a35b3e..97607b30 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -6,10 +6,42 @@ addressbook-war 1.6.5 + + ${file.reference.jcore.jar} + WEB-INF/lib + + + ${file.reference.jcoreee.jar} + WEB-INF/lib + + + ${file.reference.jcore-logger-lib.jar} + WEB-INF/lib + + + ${file.reference.jcontacts-core.jar} + WEB-INF/lib + + + ${file.reference.jcontacts-business-core.jar} + WEB-INF/lib + + + ${file.reference.jcontacts-lib.jar} + WEB-INF/lib + ${reference.addressbook-lib.jar} WEB-INF/lib + + ${file.reference.cdi-api.jar} + WEB-INF/lib + + + ${file.reference.gf-client.jar} + WEB-INF/lib + diff --git a/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java b/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java new file mode 100644 index 00000000..f35f4603 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/gender/GenderWebBean.java @@ -0,0 +1,60 @@ +/* + * 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 . + */ +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 + *

+ * @author Roland Haeder + */ +@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 getSelectableGenders () { + // Init array + // TODO Call EJB here? + List genders = GenderUtils.selectableGenders(); + + // Return it + return genders; + } +} diff --git a/src/java/org/mxchange/addressbook/beans/gender/GenderWebController.java b/src/java/org/mxchange/addressbook/beans/gender/GenderWebController.java new file mode 100644 index 00000000..c3f6c4a8 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/gender/GenderWebController.java @@ -0,0 +1,43 @@ +/* + * 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 . + */ +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 + *

+ * @author Roland Haeder + */ +public interface GenderWebController extends Serializable { + + /** + * Getter for all genders as array + *

+ * @return All genders as array + */ + public Gender[] getAllGenders (); + + /** + * Getter for only selectable genders as array, UNKNOWN is not selectable + *

+ * @return All genders as array + */ + public List getSelectableGenders (); +} diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java new file mode 100644 index 00000000..f79582b0 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -0,0 +1,303 @@ +/* + * 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 . + */ +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) + *

+ * @author Roland Haeder + */ +@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)); + } +} diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java new file mode 100644 index 00000000..deed6be4 --- /dev/null +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -0,0 +1,224 @@ +/* + * 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 . + */ +package org.mxchange.addressbook.beans.user; + +import java.io.Serializable; +import org.mxchange.jcontacts.contact.gender.Gender; + +/** + * An interface for user beans + *

+ * @author Roland Haeder + */ +public interface UserWebController extends Serializable { + + /** + * Creates an instance from all properties + *

+ * @return A Customer instance + */ + public User createCustomerInstance (); + + /** + * Cellphone number + *

+ * @return the cellphoneNumber + */ + public String getCellphoneNumber (); + + /** + * Cellphone number + *

+ * @param cellphoneNumber the cellphoneNumber to set + */ + public void setCellphoneNumber (final String cellphoneNumber); + + /** + * City + *

+ * @return the city + */ + public String getCity (); + + /** + * City + *

+ * @param city the city to set + */ + public void setCity (final String city); + + /** + * Company name + *

+ * @return the companyName + */ + public String getCompanyName (); + + /** + * Company name + *

+ * @param companyName the companyName to set + */ + public void setCompanyName (final String companyName); + + /** + * Country code + *

+ * @return the countryCode + */ + public String getCountryCode (); + + /** + * Country code + *

+ * @param countryCode the countryCode to set + */ + public void setCountryCode (final String countryCode); + + /** + * Email address + *

+ * @return the emailAddress + */ + public String getEmailAddress (); + + /** + * Email address + *

+ * @param emailAddress the emailAddress to set + */ + public void setEmailAddress (final String emailAddress); + + /** + * Family name + *

+ * @return the familyName + */ + public String getFamilyName (); + + /** + * Family name + *

+ * @param familyName the familyName to set + */ + public void setFamilyName (final String familyName); + + /** + * Fax number + *

+ * @return the faxNumber + */ + public String getFaxNumber (); + + /** + * Fax number + *

+ * @param faxNumber the faxNumber to set + */ + public void setFaxNumber (final String faxNumber); + + /** + * First name + *

+ * @return the first name + */ + public String getFirstName (); + + /** + * First name + *

+ * @param firstName the first name to set + */ + public void setFirstName (final String firstName); + + /** + * Gender of the contact + *

+ * @return the gender + */ + public Gender getGender (); + + /** + * Gender of the contact + *

+ * @param gender the gender to set + */ + public void setGender (final Gender gender); + + /** + * House number + *

+ * @return the houseNumber + */ + public Short getHouseNumber (); + + /** + * House number + *

+ * @param houseNumber the houseNumber to set + */ + public void setHouseNumber (final Short houseNumber); + + /** + * Phone number + *

+ * @return the phoneNumber + */ + public String getPhoneNumber (); + + /** + * Phone number + *

+ * @param phoneNumber the phoneNumber to set + */ + public void setPhoneNumber (final String phoneNumber); + + /** + * Street + *

+ * @return the street + */ + public String getStreet (); + + /** + * Street + *

+ * @param street the street to set + */ + public void setStreet (final String street); + + /** + * ZIP code + *

+ * @return the zipCode + */ + public Integer getZipCode (); + + /** + * ZIP code + *

+ * @param zipCode the zipCode to set + */ + public void setZipCode (final Integer zipCode); + + /** + * Checks whether all required personal data is set + *

+ * @return Whether the required personal data is set + */ + public boolean isRequiredPersonalDataSet (); +}