2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.model.addressbook.entry;
19 import java.util.Calendar;
20 import java.util.List;
21 import javax.persistence.Basic;
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.OneToMany;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33 import javax.persistence.Temporal;
34 import javax.persistence.TemporalType;
35 import org.mxchange.addressbook.model.addressbook.Addressbook;
36 import org.mxchange.addressbook.model.addressbook.UserAddressbook;
37 import org.mxchange.jcontacts.contact.Contact;
38 import org.mxchange.jcontacts.contact.UserContact;
39 import org.mxchange.jcontactsbusiness.BusinessContact;
40 import org.mxchange.jcontactsbusiness.CompanyContact;
41 import org.mxchange.jusercore.model.user.LoginUser;
42 import org.mxchange.jusercore.model.user.User;
45 * A POJO for address book entries
47 * @author Roland Haeder
49 @Entity (name = "addressbook_entries")
50 @Table (name = "addressbook_entries")
51 public class UserAddressbookEntry implements AddressbookEntry, Comparable<AddressbookEntry> {
56 private static final long serialVersionUID = 178_581_768_581_960L;
62 @GeneratedValue (strategy = GenerationType.IDENTITY)
63 @Column (name = "addressbook_entry_id", nullable = false, updatable = false)
64 private Long addressbookEntryId;
67 * When this address book entry has been created
69 @Basic (optional = false)
70 @Temporal (TemporalType.TIMESTAMP)
71 @Column (name = "addressbook_entry_created", nullable = false, updatable = false)
72 private Calendar addressbookEntryCreated;
75 * Connection to table "addressbooks"
77 @JoinColumn (name = "addressbook_id", nullable = false, updatable = false)
78 @OneToOne (targetEntity = UserAddressbook.class, optional = false, cascade = CascadeType.ALL)
79 private Addressbook addressbookId;
82 * Connection to table "users" (who has initially created this entry
84 @JoinColumn (name = "addressbook_entry_origin_user_id", nullable = false, updatable = false)
85 @ManyToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.ALL)
86 private List<User> addressbookEntryUserOriginList;
89 * Connection to table "users" (who has added this entry)
91 @JoinColumn (name = "addressbook_entry_added_user_id", updatable = false)
92 @OneToMany (targetEntity = LoginUser.class, cascade = CascadeType.ALL)
93 private List<User> addressbookEntryUserAddedList;
96 * Connection to table "contacts" (private contacts)
98 @JoinColumn (name = "addressbook_entry_private_contact_id", updatable = false)
99 @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL)
100 private Contact addressbookEntryPrivateContact;
103 * Connection to table "business_contacts" (commercial contacts)
105 @JoinColumn (name = "addressbook_entry_business_contact_id", updatable = false)
106 @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.ALL)
107 private BusinessContact addressbookEntryBusinessContact;
110 public int compareTo (final AddressbookEntry addressbookEntry) {
111 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
115 public BusinessContact getAddressbookEntryBusinessContact () {
116 return this.addressbookEntryBusinessContact;
120 public void setAddressbookEntryBusinessContact (final BusinessContact addressbookEntryBusinessContact) {
121 this.addressbookEntryBusinessContact = addressbookEntryBusinessContact;
125 public Calendar getAddressbookEntryCreated () {
126 return this.addressbookEntryCreated;
130 public void setAddressbookEntryCreated (final Calendar addressbookEntryCreated) {
131 this.addressbookEntryCreated = addressbookEntryCreated;
135 public Long getAddressbookEntryId () {
136 return this.addressbookEntryId;
140 public void setAddressbookEntryId (final Long addressbookEntryId) {
141 this.addressbookEntryId = addressbookEntryId;
145 public Contact getAddressbookEntryPrivateContact () {
146 return this.addressbookEntryPrivateContact;
150 public void setAddressbookEntryPrivateContact (final Contact addressbookEntryPrivateContact) {
151 this.addressbookEntryPrivateContact = addressbookEntryPrivateContact;
155 public List<User> getAddressbookEntryUserAddedList () {
156 return this.addressbookEntryUserAddedList;
160 public void setAddressbookEntryUserAddedList (final List<User> addressbookEntryUserAddedList) {
161 this.addressbookEntryUserAddedList = addressbookEntryUserAddedList;
165 public List<User> getAddressbookEntryUserOriginList () {
166 return this.addressbookEntryUserOriginList;
170 public void setAddressbookEntryUserOriginList (final List<User> addressbookEntryUserOriginList) {
171 this.addressbookEntryUserOriginList = addressbookEntryUserOriginList;
175 public Addressbook getAddressbookId () {
176 return this.addressbookId;
180 public void setAddressbookId (final Addressbook addressbookId) {
181 this.addressbookId = addressbookId;