]> git.mxchange.org Git - jfinancials-lib.git/blob - src/org/mxchange/addressbook/model/addressbook/UserAddressbook.java
b2d8ee4e36e4fbd0eba91e3aaf1cfde9520909e4
[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.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.mxchange.addressbook.model.addressbook.status.AddressbokStatus;
35 import org.mxchange.jusercore.model.user.LoginUser;
36 import org.mxchange.jusercore.model.user.User;
37
38 /**
39  * A POJO for user addressbooks
40  * <p>
41  * @author Roland Haeder
42  */
43 @Entity (name = "addressbooks")
44 @Table (name = "addressbooks")
45 public class UserAddressbook implements Addressbook, Comparable<Addressbook> {
46
47         /**
48          * Serial number
49          */
50         private static final long serialVersionUID = 176_573_148_678_169L;
51
52         /**
53          * Id number
54          */
55         @Id
56         @GeneratedValue (strategy = GenerationType.IDENTITY)
57         @Column (name = "addressbook_id", length = 20, nullable = false, updatable = false)
58         private Long addressbookId;
59
60         /**
61          * Connection to "users" table
62          */
63         @JoinColumn (name = "addressbook_user_id", nullable = false)
64         @OneToOne (targetEntity = LoginUser.class, optional = false, cascade = CascadeType.ALL)
65         private User addressbookUser;
66
67         /**
68          * When this address book has been created
69          */
70         @Basic (optional = false)
71         @Temporal (TemporalType.TIMESTAMP)
72         @Column (name = "addressbook_created", nullable = false, updatable = false)
73         private Calendar addressbookCreated;
74
75         /**
76          * Adress book status
77          */
78         @Basic (optional = false)
79         @Enumerated (EnumType.STRING)
80         @Column (name = "addressbook_status", nullable = false, length = 10)
81         private AddressbokStatus addressbookStatus;
82
83         /**
84          * Name for this address book
85          */
86         @Basic (optional = false)
87         @Column (name = "addressbook_name", length = 50, nullable = false)
88         private String addressbookName;
89
90         @Override
91         public int compareTo (final Addressbook addressbook) {
92                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
93         }
94
95         @Override
96         public Long getAddressbookId () {
97                 return this.addressbookId;
98         }
99
100         @Override
101         public void setAddressbookId (final Long addressbookId) {
102                 this.addressbookId = addressbookId;
103         }
104
105 }