started replacing ArrayLists with Sets. Adding get/set/add/remove methods to all...
[cdmlib.git] / cdmlibrary / src / main / java / eu / etaxonomy / cdm / model / common / VersionableEntity.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.model.common;
11
12
13 import eu.etaxonomy.cdm.model.agent.Person;
14 import eu.etaxonomy.cdm.model.view.View;
15 import org.apache.log4j.Logger;
16 import eu.etaxonomy.cdm.model.Description;
17 import java.util.*;
18 import javax.persistence.*;
19
20 /**
21 * @author m.doering
22 * @version 1.0
23 * @created 08-Nov-2007 13:07:01
24 */
25 @MappedSuperclass
26 public abstract class VersionableEntity extends CdmBase {
27 public VersionableEntity() {
28 super();
29 this.uuid = UUID.randomUUID().toString();
30 this.created = Calendar.getInstance();
31 }
32
33 static Logger logger = Logger.getLogger(VersionableEntity.class);
34 private int id;
35 //the globally unique identifier
36 private String uuid;
37 private Calendar created;
38 private Person createdBy;
39 //time of last update for this object
40 private Calendar updated;
41 private Person updatedBy;
42 private VersionableEntity nextVersion;
43 private VersionableEntity previousVersion;
44
45 public VersionableEntity getNextVersion(){
46 return this.nextVersion;
47 }
48
49 /**
50 *
51 * @param nextVersion nextVersion
52 */
53 public void setNextVersion(VersionableEntity nextVersion){
54 this.nextVersion = nextVersion;
55 }
56
57 public VersionableEntity getPreviousVersion(){
58 return this.previousVersion;
59 }
60
61 /**
62 *
63 * @param previousVersion previousVersion
64 */
65 public void setPreviousVersion(VersionableEntity previousVersion){
66 this.previousVersion = previousVersion;
67 }
68
69 @ManyToOne
70 public Person getUpdatedBy(){
71 return this.updatedBy;
72 }
73
74 /**
75 *
76 * @param updatedBy updatedBy
77 */
78 public void setUpdatedBy(Person updatedBy){
79 this.updatedBy = updatedBy;
80 }
81
82 @ManyToOne
83 public Person getCreatedBy(){
84 return this.createdBy;
85 }
86
87 /**
88 *
89 * @param createdBy createdBy
90 */
91 public void setCreatedBy(Person createdBy){
92 this.createdBy = createdBy;
93 }
94
95 @Id @GeneratedValue(generator="system-increment")
96 public int getId(){
97 return this.id;
98 }
99 /**
100 *
101 * @param id id
102 */
103 public void setId(int id){
104 this.id = id;
105 }
106
107 public String getUuid(){
108 return this.uuid;
109 }
110 /**
111 *
112 * @param uuid uuid
113 */
114 public void setUuid(String uuid){
115 this.uuid = uuid;
116 }
117
118 @Temporal(TemporalType.TIMESTAMP)
119 public Calendar getCreated(){
120 return this.created;
121 }
122 /**
123 *
124 * @param created created
125 */
126 public void setCreated(Calendar created){
127 this.created = created;
128 }
129
130 @Temporal(TemporalType.TIMESTAMP)
131 public Calendar getUpdated(){
132 return this.updated;
133 }
134
135 /**
136 *
137 * @param updated updated
138 */
139 public void setUpdated(Calendar updated){
140 this.updated = updated;
141 }
142
143 /**
144 * based on created
145 */
146 @Transient
147 public Calendar getValidFrom(){
148 return null;
149 }
150
151 /**
152 * based on updated
153 */
154 @Transient
155 public Calendar getValidTo(){
156 return null;
157 }
158
159 }