1
|
/**
|
2
|
* Copyright (C) 2009 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
|
import java.util.UUID;
|
13
|
|
14
|
import javax.persistence.Transient;
|
15
|
import javax.validation.GroupSequence;
|
16
|
import javax.validation.groups.Default;
|
17
|
|
18
|
import org.joda.time.DateTime;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.permission.User;
|
21
|
import eu.etaxonomy.cdm.validation.Level2;
|
22
|
import eu.etaxonomy.cdm.validation.Level3;
|
23
|
|
24
|
@GroupSequence({Default.class, Level2.class, Level3.class})
|
25
|
public interface ICdmBase {
|
26
|
|
27
|
/**
|
28
|
* Returns local unique identifier for the concrete subclass
|
29
|
* @return
|
30
|
*/
|
31
|
public int getId();
|
32
|
|
33
|
/**
|
34
|
* Assigns a unique local ID to this object.
|
35
|
* Because of the EJB3 @Id and @GeneratedValue annotation this id will be
|
36
|
* set automatically by the persistence framework when object is saved.
|
37
|
* @param id
|
38
|
*/
|
39
|
public void setId(int id);
|
40
|
|
41
|
public UUID getUuid();
|
42
|
|
43
|
public void setUuid(UUID uuid);
|
44
|
|
45
|
public DateTime getCreated();
|
46
|
|
47
|
/**
|
48
|
* Sets the timestamp this object was created.
|
49
|
* Most databases cannot store milliseconds, so they are removed by this method.
|
50
|
* Caution: We are planning to replace the Calendar class with a different datetime representation which is more suitable for hibernate
|
51
|
* see {@link https://dev.e-taxonomy.eu/redmine/issues/247 TRAC ticket}
|
52
|
*
|
53
|
* @param created
|
54
|
*/
|
55
|
public void setCreated(DateTime created);
|
56
|
|
57
|
/**
|
58
|
* @return The {@link User} who was authenticated when the entity was created.
|
59
|
* Can be <code>null</code> if the entity has been created without any user authentication present.
|
60
|
*/
|
61
|
public User getCreatedBy();
|
62
|
|
63
|
public void setCreatedBy(User createdBy);
|
64
|
|
65
|
/**
|
66
|
* Tests if the object is assignable from the type
|
67
|
* defined as parameter <code>clazz</code>, regardless
|
68
|
* whether it is an actual entity or hibernate proxy.
|
69
|
*/
|
70
|
public boolean isInstanceOf(Class<? extends CdmBase> clazz);
|
71
|
|
72
|
/**
|
73
|
* Reports the persistend state of the cdm entity. If this method returns <code>true</code> it does not
|
74
|
* necessarily mean that there is a database record already but
|
75
|
* maybe the object was only saved to a persistence session, which still needs to be flushed to the storage engine.
|
76
|
*
|
77
|
* @return if and only if the instance has been saved to the persistent storage.
|
78
|
* For new and un-persisted entities this method returns false.
|
79
|
*/
|
80
|
@Transient
|
81
|
public boolean isPersited();
|
82
|
|
83
|
}
|