jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
- ${file.reference.jcore.jar}:\
- ${libs.jpa20-persistence.classpath}
+ ${file.reference.jcore.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=true
javadoc.splitindex=true
javadoc.use=true
javadoc.version=true
-javadoc.windowtitle=Contacts Library
+javadoc.windowtitle=Contacts EJB Library
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
+++ /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.jcontacts.contact;
-
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import org.mxchange.jcontacts.contact.gender.Gender;
-
-/**
- * A general contact interface
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public interface Contact extends Serializable {
-
- /**
- * Copies all attributes from other contact object to this
- * <p>
- * @param contact Source instance
- */
- public void copyAll (final Contact contact);
-
- /**
- * Birth day
- * <p>
- * @return the birthday
- */
- public Date getBirthday ();
-
- /**
- * Birth day
- * <p>
- * @param birthday the birthday to set
- */
- public void setBirthday (final Date birthday);
-
- /**
- * 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);
-
- /**
- * Comments
- * <p>
- * @return the comment
- */
- public String getComment ();
-
- /**
- * Comments
- * <p>
- * @param comment the comment to set
- */
- public void setComment (final String comment);
-
- /**
- * Company name
- * <p>
- * @return the companyName
- */
- public String getCompanyName ();
-
- /**
- * Company name
- * <p>
- * @param companyName the companyName to set
- */
- public void setCompanyName (final String companyName);
-
- /**
- * Id number
- * <p>
- * @return the contactId
- */
- public Long getContactId ();
-
- /**
- * Id number
- * <p>
- * @param id the contactId to set
- */
- public void setContactId (final Long id);
-
- /**
- * Country code
- * <p>
- * @return the countryCode
- */
- public String getCountryCode ();
-
- /**
- * Country code
- * <p>
- * @param countryCode the countryCode to set
- */
- public void setCountryCode (final String countryCode);
-
- /**
- * Getter for "created" timestamp
- * <p>
- * @return "created" timestamp
- */
- public Calendar getCreated ();
-
- /**
- * Setter for "created" timestamp
- * <p>
- * @param created "created" timestamp
- */
- public void setCreated (final Calendar created);
-
- /**
- * 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);
-
- /**
- * Setter for own contact
- * <p>
- * @param ownContact Own contact
- */
- public void setOwnContact (final Boolean ownContact);
-
- /**
- * 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);
-
- /**
- * Getter for "updated" timestamp
- * <p>
- * @return "updated" timestamp
- */
- public Calendar getUpdated ();
-
- /**
- * Getter for "updated" timestamp
- * <p>
- * @param updated "updated" timestamp
- */
- public void setUpdated (final Calendar updated);
-
- /**
- * ZIP code
- * <p>
- * @return the zipCode
- */
- public Long getZipCode ();
-
- /**
- * ZIP code
- * <p>
- * @param zipCode the zipCode to set
- */
- public void setZipCode (final Long zipCode);
-
- /**
- * Checks whether the contact is user's own data
- * <p>
- * @return Own data?
- */
- public Boolean isOwnContact ();
-}
+++ /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.jcontacts.contact;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import org.mxchange.jcontacts.contact.gender.Gender;
-
-/**
- * A general contact class which should only be extended.
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- * @version 0.0
- */
-@Entity (name = "contacts")
-@Table (name = "contacts")
-public class UserContact implements Contact, Comparable<Contact> {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 58_744_284_981_863L;
-
- /**
- * Birth day
- */
- @Column (name = "birthday")
- @Temporal (TemporalType.DATE)
- private Date birthday;
-
- /**
- * Cellphone number
- */
- @Column (name = "cellphone_number", length = 100)
- private String cellphoneNumber;
-
- /**
- * City
- */
- @Column (name = "city", nullable = false, length = 100)
- private String city;
-
- /**
- * Optional comments
- */
- @Lob
- @Column (name = "comment")
- private String comment;
-
- /**
- * Company name
- */
- @Column (name = "company_name", nullable = false)
- private String companyName;
-
- /**
- * Id number
- */
- @Id
- @GeneratedValue (strategy = GenerationType.IDENTITY)
- @Column (name = "contact_id", length = 20, updatable = false)
- private Long contactId;
-
- /**
- * Country code
- */
- @Column (name = "country_code", length = 2, nullable = false)
- private String countryCode;
-
- /**
- * When the contact has been created
- */
- @Basic (optional = false)
- @Temporal (TemporalType.TIMESTAMP)
- @Column (name = "created", nullable = false)
- private Calendar created;
-
- /**
- * Email address
- */
- @Column (name = "email_address", length = 100, nullable = false)
- private String emailAddress;
-
- /**
- * Family name
- */
- @Basic (optional = false)
- @Column (name = "family_name", length = 100, nullable = false)
- private String familyName;
-
- /**
- * Fax number
- */
- @Column (name = "fax_number", length = 100)
- private String faxNumber;
-
- /**
- * First name
- */
- @Basic (optional = false)
- @Column (name = "first_name", length = 100, nullable = false)
- private String firstName;
-
- /**
- * Gender instance
- */
- @Basic (optional = false)
- @Column (name = "gender", nullable = false)
- @Enumerated (EnumType.STRING)
- private Gender gender;
-
- /**
- * House number
- */
- @Column (name = "house_number", length = 5, nullable = false)
- private Short houseNumber;
-
- /**
- * Flag whether this contact is user's own data
- */
- @Column (name = "own_contact", nullable = false)
- private Boolean ownContact;
-
- /**
- * Phone number
- */
- @Column (name = "phone_number", length = 100)
- private String phoneNumber;
-
- /**
- * Street
- */
- @Column (name = "street", nullable = false)
- private String street;
-
- /**
- * When the contact has been updated
- */
- @Temporal (TemporalType.TIMESTAMP)
- @Column (name = "updated")
- private Calendar updated;
-
- /**
- * ZIP code
- */
- @Column (name = "zip_code", nullable = false, length = 6)
- private Long zipCode;
-
- /**
- * Constructor for gender and names
- * <p>
- * @param gender Gender instance
- * @param firstName First name
- * @param familyName Family name
- * @param companyName Company name
- */
- public UserContact (final Gender gender, final String firstName, final String familyName, final String companyName) {
- // Set all
- this.gender = gender;
- this.firstName = firstName;
- this.familyName = familyName;
- }
-
- /**
- * Default constructor
- */
- public UserContact () {
- }
-
- /**
- * Compares two contacts with each other
- * <p>
- * @param contact Contact comparator
- * @return Comparison value
- */
- @Override
- public int compareTo (final Contact contact) {
- // contact should not be null
- if (null == contact) {
- throw new NullPointerException("contact is null"); //NOI18N
- }
-
- // Is the contactId the same?
- if (Objects.equals(this.getContactId(), contact.getContactId())) {
- // Same contactId, means same contact
- return 0;
- } else if (this.getContactId() > contact.getContactId()) {
- // This contactId is larger than compared to
- return -1;
- }
-
- // The other contactId is larger
- return 1;
- }
-
- @Override
- public void copyAll (final Contact contact) {
- // Copy all:
- // - base data
- this.setFirstName(contact.getFirstName());
- this.setFamilyName(contact.getFamilyName());
- this.setCompanyName(contact.getCompanyName());
- this.setStreet(contact.getStreet());
- this.setZipCode(contact.getZipCode());
- this.setCity(contact.getCity());
- this.setCountryCode(contact.getCountryCode());
-
- // - phone, fax, email
- this.setPhoneNumber(contact.getPhoneNumber());
- this.setFaxNumber(contact.getFaxNumber());
- this.setCellphoneNumber(contact.getCellphoneNumber());
-
- // - other data
- this.setBirthday(contact.getBirthday());
- this.setComment(contact.getComment());
- this.setCreated(contact.getCreated());
- this.setUpdated(contact.getUpdated());
- }
-
- /**
- * Check if contacts are same or throw an exception
- * <p>
- * @param object Other possible contact class
- * @return Whether both contacts are same TODO Needs a lot improvements
- */
- @Override
- public boolean equals (final Object object) {
- // Is it same type?
- if (!(object instanceof UserContact)) {
- // Not equal types
- return false;
- } else if (!(object instanceof Contact)) {
- // Not correct interface
- return false;
- }
-
- // Try to cast
- Contact contact = (Contact) object;
-
- // Now test some data TODO Definedly needs improvement
- return ((this.getGender().equals(contact.getGender()))
- && (this.getFirstName().toLowerCase().equals(contact.getFirstName().toLowerCase()))
- && (this.getFamilyName().toLowerCase().equals(contact.getFamilyName().toLowerCase())));
- }
-
- @Override
- public Date getBirthday () {
- return this.birthday;
- }
-
- @Override
- public void setBirthday (final Date birthday) {
- this.birthday = birthday;
- }
-
- @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 getComment () {
- return this.comment;
- }
-
- @Override
- public void setComment (final String comment) {
- this.comment = comment;
- }
-
- @Override
- public String getCompanyName () {
- return this.companyName;
- }
-
- @Override
- public void setCompanyName (final String companyName) {
- this.companyName = companyName;
- }
-
- @Override
- public Long getContactId () {
- return this.contactId;
- }
-
- @Override
- public void setContactId (final Long contactId) {
- this.contactId = contactId;
- }
-
- @Override
- public String getCountryCode () {
- return this.countryCode;
- }
-
- @Override
- public void setCountryCode (final String countryCode) {
- this.countryCode = countryCode;
- }
-
- @Override
- public Calendar getCreated () {
- return this.created;
- }
-
- @Override
- public void setCreated (final Calendar created) {
- this.created = created;
- }
-
- @Override
- public String getEmailAddress () {
- return this.emailAddress;
- }
-
- @Override
- public void setEmailAddress (final String emailAddress) {
- this.emailAddress = emailAddress;
- }
-
- @Override
- public String getFamilyName () {
- //* NOISY-DEBUG: */ this.getLogger().logTrace("CALLED!");
- 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 void setOwnContact (final Boolean ownContact) {
- this.ownContact = ownContact;
- }
-
- @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 Calendar getUpdated () {
- return this.updated;
- }
-
- @Override
- public void setUpdated (final Calendar updated) {
- this.updated = updated;
- }
-
- @Override
- public Long getZipCode () {
- return this.zipCode;
- }
-
- @Override
- public void setZipCode (final Long zipCode) {
- this.zipCode = zipCode;
- }
-
- @Override
- public int hashCode () {
- // Validate gender instance
- assert (this.getGender() instanceof Gender) : "gender is not set."; //NOI18N
-
- int hash = 7;
- hash = 79 * hash + Objects.hashCode(this.getFamilyName());
- hash = 79 * hash + this.getGender().hashCode();
- hash = 79 * hash + Objects.hashCode(this.getFirstName());
- return hash;
- }
-
- /**
- * Initialization with fake gender UNKNOWN
- */
- @PostConstruct
- public void init () {
- // Fake gender
- this.gender = Gender.UNKNOWN;
- }
-
- @Override
- public Boolean isOwnContact () {
- return this.ownContact;
- }
-}
+++ /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.jcontacts.contact.gender;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-
-/**
- * Gender enum
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public enum Gender implements Serializable {
-
- /**
- * Unknown enum
- */
- UNKNOWN('U', "GENDER_UNKNOWN"), //NOI18N
-
- /**
- * Male enum
- */
- MALE('M', "GENDER_MALE"), //NOI18N
-
- /**
- * Female enum
- */
- FEMALE('F', "GENDER_FEMALE"), //NOI18N
-
- /**
- * Company enum
- */
- COMPANY('C', "GENDER_COMPANY"); //NOI18N
-
- /**
- * Cache for valid chars
- */
- private static char[] validChars;
-
- /**
- * Access key being entered by ConsoleClient
- */
- private final char accessChar;
-
- /**
- * Output value (for messages)
- */
- private final String messageKey;
-
- /**
- * Getter for Gender enum from given character
- * <p>
- * @param c Gender character
- * @return Gender enum
- */
- public static Gender fromChar (final char c) {
- // Init variable
- Gender g = null;
-
- // Loop through all
- for (final Gender gender : GenderUtils.selectableGenders()) {
- // Does the char match?
- if (c == gender.getAccessChar()) {
- // Found it
- g = gender;
- break;
- }
- }
-
- // Still null?
- if (null == g) {
- // Didn't found a valid one
- throw new IllegalArgumentException(MessageFormat.format("Gender {0} is invalid.", c)); //NOI18N
- }
-
- // Return it
- //* NOISY-DEBUG: */ System.out.println("gender=" + g.getClass().getName());
- return g;
- }
-
- /**
- * Valid chars (mostly for console client)
- * <p>
- * @return Valid chars
- */
- public static char[] validChars () {
- // Is cache set?
- if (validChars != null) {
- // Return it
- return validChars;
- }
-
- // Init array, only 3 are valid as 'U' is UNKNOWN and is not valid.
- char[] valid = new char[3];
-
- // Get values
- int i = 0;
- for (final Gender gender : GenderUtils.selectableGenders()) {
- // Debug message
- //* NOISY-DEBUG: */ System.out.println("gender=" + gender);
-
- // Debug message
- //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("gender={0} - adding at pos {1} ...", gender, i));
- // Get access key as this is also the access
- valid[i] = gender.getAccessChar();
-
- // Increment index
- i++;
- }
-
- // Set it here
- validChars = valid;
-
- // Return finialized array
- return valid;
- }
-
- /**
- * Constructor
- * <p>
- * @param accessChar Value being entered by ConsoleClient
- * @param messageKey Message key for resource file
- */
- private Gender (final char accessChar, final String messageKey) {
- // Set both
- this.accessChar = accessChar;
- this.messageKey = messageKey;
- }
-
- /**
- * Acces key (console client mostly)
- * <p>
- * @return the accessChar
- */
- public char getAccessChar () {
- return this.accessChar;
- }
-
- /**
- * Output value (for messages)
- * <p>
- * @return the messageKey
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-}
+++ /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.jcontacts.contact.gender;
-
-import java.text.MessageFormat;
-import java.util.LinkedList;
-import java.util.List;
-import org.mxchange.jcore.BaseFrameworkSystem;
-import org.mxchange.jcontacts.contact.Contact;
-
-/**
- * Gender utils class
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-public class GenderUtils extends BaseFrameworkSystem {
-
- /**
- * Translates contact's gender to human-readable
- * <p>
- * @param contact Contact instance
- * @return Translates value (from bundle)
- */
- public static String getTranslatedGender (final Contact contact) {
- // Init instance
- GenderUtils utils = new GenderUtils();
-
- // contact must be set
- if (null == contact) {
- // Abort here
- throw new NullPointerException("contact is null");
- } else if (contact.getGender() == null) {
- // Gender is not set
- throw new NullPointerException(MessageFormat.format("contact {0} has no gender set.", contact));
- }
-
- // Get key from it
- String key = contact.getGender().getMessageKey();
-
- // Translate and return it
- return utils.getMessageStringFromKey(key);
- }
-
- /**
- * Private contructor as this is an utility class
- */
- private GenderUtils () {
- }
-
- /**
- * All selectable genders (not UNKNOWN)
- * <p>
- * @return Selectable genders (not UNKNOWN)
- */
- public static List<Gender> selectableGenders () {
- // Init list
- List<Gender> list = new LinkedList<>();
-
- // Walk through all genders
- for (final Gender gender : Gender.values()) {
- // Is it not UNKNOWN
- if (!gender.equals(Gender.UNKNOWN)) {
- // Add it
- boolean added = list.add(gender);
-
- // Has it been added?
- assert (added) : MessageFormat.format("gender {0} not added.", gender); //NOI18N
- }
- }
-
- // Return it
- return list;
- }
-}