excludes=
file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
+file.reference.jcoreee.jar=lib/jcoreee.jar
file.reference.juser-core.jar=lib/juser-core.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.juser-core.jar}:\
- ${file.reference.jcontacts-core.jar}:\
${file.reference.jcontacts-business-core.jar}:\
+ ${file.reference.jcontacts-core.jar}:\
+ ${file.reference.jcoreee.jar}:\
${libs.jpa20-persistence.classpath}
# Space-separated list of extra javac options
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
source.encoding=UTF-8
source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
source.reference.jcontacts-core.jar=../jcontacts-core/src/
+source.reference.jcoreee.jar=../jcoreee/src/
source.reference.juser-core.jar=../juser-core/src/
src.dir=src
test.src.dir=test
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface Addressbook extends Serializable {
+public interface Addressbook extends Comparable<Addressbook>, Serializable {
/**
* Getter for id number
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.mxchange.jaddressbook.model.addressbook.status.AddressbokStatus;
+import org.mxchange.jcoreee.utils.Comparables;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
/**
- * A POJO for user addressbooks
+ * A POJO for user address books
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
@Table (name = "addressbooks")
@NamedQueries (
{
+ @NamedQuery (name = "AllAddressbooks", query = "SELECT a FROM addressbooks AS a ORDER BY a.addressbookId ASC"),
@NamedQuery (name = "AllUsersAddressbooks", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :param ORDER BY a.addressbookId ASC"),
- @NamedQuery (name = "SearchUserAddressbookName", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :user AND LOWER(a.addressbookName) LIKE LOWER(:name)"),
+ @NamedQuery (name = "SearchUserAddressbookName", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :user AND LOWER(a.addressbookName) LIKE LOWER(:name)")
}
)
@SuppressWarnings ("PersistenceUnitPresent")
private String addressbookName;
/**
- * Adress book status
+ * Address book status
*/
@Basic (optional = false)
@Enumerated (EnumType.STRING)
* Default constructor
*/
public UserAddressbook () {
- // Set status to UNLOCKED
- this.addressbookStatus = AddressbokStatus.UNLOCKED;
+ }
+
+ @Override
+ public int compareTo (final Addressbook addressbook) {
+ // Checkparameter and return 0 if equal
+ if (null == addressbook) {
+ // Should not happen
+ throw new NullPointerException("addressbook is null"); //NOI18N
+ } else if (Objects.equals(this, addressbook)) {
+ // Same object
+ return 0;
+ }
+
+ // All comparators
+ final int comparators[] = {
+ // First name ...
+ this.getAddressbookName().compareToIgnoreCase(addressbook.getAddressbookName()),
+ // ... status
+ this.getAddressbookStatus().compareTo(addressbook.getAddressbookStatus()),
+ // .. then user
+ this.getAddressbookUser().compareTo(addressbook.getAddressbookUser())
+ };
+
+ // Check all values
+ final int comparison = Comparables.checkAll(comparators);
+
+ // Return value
+ return comparison;
}
@Override
}
@Override
- public int hashCode () {
- int hash = 7;
- hash = 59 * hash + Objects.hashCode(this.getAddressbookName());
- hash = 59 * hash + Objects.hashCode(this.getAddressbookUser());
- return hash;
- }
-
- @Override
+ @SuppressWarnings ("ReturnOfDateField")
public Date getAddressbookCreated () {
return this.addressbookCreated;
}
@Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
public void setAddressbookCreated (final Date addressbookCreated) {
this.addressbookCreated = addressbookCreated;
}
}
@Override
+ @SuppressWarnings ("ReturnOfDateField")
public Date getAddressbookLastLocked () {
return this.addressbookLastLocked;
}
@Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
public void setAddressbookLastLocked (final Date addressbookLastLocked) {
this.addressbookLastLocked = addressbookLastLocked;
}
this.addressbookUser = addressbookUser;
}
+ @Override
+ public int hashCode () {
+ int hash = 7;
+
+ hash = 59 * hash + Objects.hashCode(this.getAddressbookName());
+ hash = 59 * hash + Objects.hashCode(this.getAddressbookUser());
+
+ return hash;
+ }
+
}
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
-public interface AddressbookEntry extends Serializable {
+public interface AddressbookEntry extends Comparable<AddressbookEntry>, Serializable {
/**
* Getter for id number
* <p>
* @return Business contact
*/
- BasicData getAddressbookEntryBusinessContact ();
+ BasicData getAddressbookEntryBusinessBasicData ();
/**
* Setter for business contact
* <p>
* @param addressbookEntryBusinessContact Business contact
*/
- void setAddressbookEntryBusinessContact (final BasicData addressbookEntryBusinessContact);
+ void setAddressbookEntryBusinessBasicData (final BasicData addressbookEntryBusinessContact);
/**
* Getter for entry created timestamp
* <p>
* @return Address book
*/
- Addressbook getAddressbookId ();
+ Addressbook getEntryAddressbook ();
/**
* Setter for address book
* <p>
* @param addressbookId Address book
*/
- void setAddressbookId (final Addressbook addressbookId);
+ void setEntryAddressbook (final Addressbook addressbookId);
@Override
boolean equals (final Object object);
import org.mxchange.jcontacts.model.contact.UserContact;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
+import org.mxchange.jcoreee.utils.Comparables;
/**
* A POJO for address book entries
@Table (name = "addressbook_entries")
@NamedQueries (
{
- @NamedQuery (
- name = "SearchUsersAddressbookEntries",
- query = "SELECT e FROM addressbook_entries AS e INNER JOIN addressbooks AS a ON e.addressbookId = a WHERE e.addressbookId = :addressbook AND a.addressbookUser = :owner ORDER BY e.addressbookEntryId ASC"
- )
+ @NamedQuery (name = "AllAddressBookEntries", query = "SELECT e FROM addressbook_entries AS e ORDER BY e.addressbookEntryId ASC")
}
)
@SuppressWarnings ("PersistenceUnitPresent")
*/
@JoinColumn (name = "entry_business_contact_id", updatable = false)
@OneToOne (targetEntity = BusinessBasicData.class, cascade = CascadeType.REFRESH)
- private BasicData addressbookEntryBusinessContact;
+ private BasicData addressbookEntryBusinessBasicData;
/**
* When this address book entry has been created
private Contact addressbookEntryPrivateContact;
/**
- * Connection to table "addressbooks"
+ * Connection to table "address books"
*/
@JoinColumn (name = "entry_addressbook_id", nullable = false, updatable = false)
@OneToOne (targetEntity = UserAddressbook.class, cascade = CascadeType.REFRESH, optional = false)
- private Addressbook addressbookId;
+ private Addressbook entryAddressbook;
+
+ @Override
+ public int compareTo (final AddressbookEntry addressbookEntry) {
+ // For performance reasons
+ if (null == addressbookEntry) {
+ // Should not happen
+ throw new NullPointerException("addressbookEntry is null"); //NOI18N
+ } else if (Objects.equals(this, addressbookEntry)) {
+ // Same object
+ return 0;
+ }
+
+ // Init comparitors
+ final int comparitors[] = {
+ // First compare address books
+ this.getEntryAddressbook().compareTo(addressbookEntry.getEntryAddressbook()),
+ // ... then business address
+ this.getAddressbookEntryBusinessBasicData().compareTo(addressbookEntry.getAddressbookEntryBusinessBasicData()),
+ // ... then private contact
+ this.getAddressbookEntryPrivateContact().compareTo(addressbookEntry.getAddressbookEntryPrivateContact())
+ };
+
+ // Check all vaules
+ final int comparison = Comparables.checkAll(comparitors);
+
+ // Return value
+ return comparison;
+ }
@Override
public boolean equals (final Object object) {
final AddressbookEntry other = (AddressbookEntry) object;
- if (!Objects.equals(this.getAddressbookEntryBusinessContact(), other.getAddressbookEntryBusinessContact())) {
+ if (!Objects.equals(this.getAddressbookEntryBusinessBasicData(), other.getAddressbookEntryBusinessBasicData())) {
return false;
} else if (!Objects.equals(this.getAddressbookEntryPrivateContact(), other.getAddressbookEntryPrivateContact())) {
return false;
- } else if (!Objects.equals(this.getAddressbookId(), other.getAddressbookId())) {
+ } else if (!Objects.equals(this.getEntryAddressbook(), other.getEntryAddressbook())) {
return false;
}
}
@Override
- public int hashCode () {
- int hash = 3;
-
- hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessContact());
- hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
- hash = 19 * hash + Objects.hashCode(this.getAddressbookId());
-
- return hash;
+ public BasicData getAddressbookEntryBusinessBasicData () {
+ return this.addressbookEntryBusinessBasicData;
}
@Override
- public BasicData getAddressbookEntryBusinessContact () {
- return this.addressbookEntryBusinessContact;
- }
-
- @Override
- public void setAddressbookEntryBusinessContact (final BasicData addressbookEntryBusinessContact) {
- this.addressbookEntryBusinessContact = addressbookEntryBusinessContact;
+ public void setAddressbookEntryBusinessBasicData (final BasicData addressbookEntryBusinessBasicData) {
+ this.addressbookEntryBusinessBasicData = addressbookEntryBusinessBasicData;
}
@Override
}
@Override
- public Addressbook getAddressbookId () {
- return this.addressbookId;
+ public Addressbook getEntryAddressbook () {
+ return this.entryAddressbook;
+ }
+
+ @Override
+ public void setEntryAddressbook (final Addressbook entryAddressbook) {
+ this.entryAddressbook = entryAddressbook;
}
@Override
- public void setAddressbookId (final Addressbook addressbookId) {
- this.addressbookId = addressbookId;
+ public int hashCode () {
+ int hash = 3;
+
+ hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryBusinessBasicData());
+ hash = 19 * hash + Objects.hashCode(this.getAddressbookEntryPrivateContact());
+ hash = 19 * hash + Objects.hashCode(this.getEntryAddressbook());
+
+ return hash;
}
}