(no commit message)
[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 //the globally unique identifier
35 private String uuid;
36 private Calendar created;
37 private Person createdBy;
38 //time of last update for this object
39 private Calendar updated;
40 private Person updatedBy;
41 private VersionableEntity nextVersion;
42 private VersionableEntity previousVersion;
43
44 @Transient
45 public VersionableEntity getNextVersion(){
46 return this.nextVersion;
47 }
48 public void setNextVersion(VersionableEntity nextVersion){
49 this.nextVersion = nextVersion;
50 }
51
52 @Transient
53 public VersionableEntity getPreviousVersion(){
54 return this.previousVersion;
55 }
56 public void setPreviousVersion(VersionableEntity previousVersion){
57 this.previousVersion = previousVersion;
58 }
59
60
61 @ManyToOne
62 public Person getUpdatedBy(){
63 return this.updatedBy;
64 }
65
66 /**
67 *
68 * @param updatedBy updatedBy
69 */
70 public void setUpdatedBy(Person updatedBy){
71 this.updatedBy = updatedBy;
72 }
73
74 @ManyToOne
75 public Person getCreatedBy(){
76 return this.createdBy;
77 }
78
79 /**
80 *
81 * @param createdBy createdBy
82 */
83 public void setCreatedBy(Person createdBy){
84 this.createdBy = createdBy;
85 }
86
87 public String getUuid(){
88 return this.uuid;
89 }
90 /**
91 *
92 * @param uuid uuid
93 */
94 public void setUuid(String uuid){
95 this.uuid = uuid;
96 }
97
98 @Temporal(TemporalType.TIMESTAMP)
99 public Calendar getCreated(){
100 return this.created;
101 }
102 /**
103 *
104 * @param created created
105 */
106 public void setCreated(Calendar created){
107 this.created = created;
108 }
109
110 @Temporal(TemporalType.TIMESTAMP)
111 public Calendar getUpdated(){
112 return this.updated;
113 }
114
115 /**
116 *
117 * @param updated updated
118 */
119 public void setUpdated(Calendar updated){
120 this.updated = updated;
121 }
122
123 /**
124 * based on created
125 */
126 @Transient
127 public Calendar getValidFrom(){
128 return null;
129 }
130
131 /**
132 * based on updated
133 */
134 @Transient
135 public Calendar getValidTo(){
136 return null;
137 }
138
139 }