]> git.mxchange.org Git - jfinancials-lib.git/blob - src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
Continued:
[jfinancials-lib.git] / src / org / mxchange / addressbook / model / addressbook / UserAddressbook.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.addressbook.model.addressbook;
18
19 import java.util.Calendar;
20 import javax.persistence.Basic;
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.EnumType;
25 import javax.persistence.Enumerated;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.NamedQueries;
31 import javax.persistence.NamedQuery;
32 import javax.persistence.OneToOne;
33 import javax.persistence.Table;
34 import javax.persistence.Temporal;
35 import javax.persistence.TemporalType;
36 import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus;
37 import org.mxchange.jusercore.model.user.LoginUser;
38 import org.mxchange.jusercore.model.user.User;
39
40 /**
41  * A POJO for user addressbooks
42  * <p>
43  * @author Roland Haeder
44  */
45 @Entity (name = "addressbooks")
46 @Table (name = "addressbooks")
47 @NamedQueries (
48                 {
49                         @NamedQuery (name = "AllUsersAddressbooks", query = "SELECT a FROM addressbooks AS a WHERE a.addressbookUser = :param ORDER BY a.addressbookId ASC")
50                 }
51 )
52 public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
53
54         /**
55          * Serial number
56          */
57         private static final long serialVersionUID = 176_573_148_678_169L;
58
59         /**
60          * Id number
61          */
62         @Id
63         @GeneratedValue (strategy = GenerationType.IDENTITY)
64         @Column (name = "addressbook_id", length = 20, nullable = false, updatable = false)
65         private Long addressbookId;
66
67         /**
68          * Connection to "users" table
69          */
70         @JoinColumn (name = "addressbook_user_id", nullable = false)
71         @OneToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.ALL)
72         private User addressbookUser;
73
74         /**
75          * When this address book has been created
76          */
77         @Basic (optional = false)
78         @Temporal (TemporalType.TIMESTAMP)
79         @Column (name = "addressbook_created", nullable = false, updatable = false)
80         private Calendar addressbookCreated;
81
82         /**
83          * Adress book status
84          */
85         @Basic (optional = false)
86         @Enumerated (EnumType.STRING)
87         @Column (name = "addressbook_status", nullable = false, length = 10)
88         private AddressbokStatus addressbookStatus;
89
90         /**
91          * Name for this address book
92          */
93         @Basic (optional = false)
94         @Column (name = "addressbook_name", length = 50, nullable = false)
95         private String addressbookName;
96
97         @Override
98         public int compareTo (final Addressbook addressbook) {
99                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
100         }
101
102         @Override
103         public Calendar getAddressbookCreated () {
104                 return this.addressbookCreated;
105         }
106
107         @Override
108         public void setAddressbookCreated (final Calendar addressbookCreated) {
109                 this.addressbookCreated = addressbookCreated;
110         }
111
112         @Override
113         public Long getAddressbookId () {
114                 return this.addressbookId;
115         }
116
117         @Override
118         public void setAddressbookId (final Long addressbookId) {
119                 this.addressbookId = addressbookId;
120         }
121
122         @Override
123         public String getAddressbookName () {
124                 return this.addressbookName;
125         }
126
127         @Override
128         public void setAddressbookName (final String addressbookName) {
129                 this.addressbookName = addressbookName;
130         }
131
132         @Override
133         public AddressbokStatus getAddressbookStatus () {
134                 return this.addressbookStatus;
135         }
136
137         @Override
138         public void setAddressbookStatus (final AddressbokStatus addressbookStatus) {
139                 this.addressbookStatus = addressbookStatus;
140         }
141
142         @Override
143         public User getAddressbookUser () {
144                 return this.addressbookUser;
145         }
146
147         @Override
148         public void setAddressbookUser (final User addressbookUser) {
149                 this.addressbookUser = addressbookUser;
150         }
151 }