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.description;
|
11
|
|
12
|
|
13
|
import javax.persistence.Entity;
|
14
|
import javax.xml.bind.annotation.XmlAccessType;
|
15
|
import javax.xml.bind.annotation.XmlAccessorType;
|
16
|
import javax.xml.bind.annotation.XmlElement;
|
17
|
import javax.xml.bind.annotation.XmlRootElement;
|
18
|
import javax.xml.bind.annotation.XmlType;
|
19
|
|
20
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
21
|
import org.hibernate.envers.Audited;
|
22
|
import org.hibernate.search.annotations.Indexed;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.common.ExtendedTimePeriod;
|
25
|
|
26
|
/**
|
27
|
* This class represents a temporal fact .
|
28
|
* A temporal fact handles facts which primarily define certain time periods
|
29
|
* like seasons.
|
30
|
*
|
31
|
* @author a.mueller
|
32
|
* @since 29-Apr-2020
|
33
|
*/
|
34
|
@XmlAccessorType(XmlAccessType.FIELD)
|
35
|
@XmlType(name = "TemporalData", propOrder = {
|
36
|
"period",
|
37
|
})
|
38
|
@XmlRootElement(name = "TemporalData")
|
39
|
@Entity
|
40
|
@Audited
|
41
|
@Indexed(index = "eu.etaxonomy.cdm.model.description.DescriptionElementBase")
|
42
|
public class TemporalData extends DescriptionElementBase {
|
43
|
|
44
|
private static final long serialVersionUID = -1064249780729501786L;
|
45
|
@SuppressWarnings("unused")
|
46
|
private static final Logger logger = LogManager.getLogger(TemporalData.class);
|
47
|
|
48
|
@XmlElement(name = "Period")
|
49
|
private ExtendedTimePeriod period = ExtendedTimePeriod.NewExtendedInstance();
|
50
|
|
51
|
public static TemporalData NewInstance(){
|
52
|
TemporalData result = new TemporalData();
|
53
|
return result;
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* Creates a temporal fact with the given period.
|
58
|
*/
|
59
|
public static TemporalData NewInstance(ExtendedTimePeriod period){
|
60
|
TemporalData result = new TemporalData();
|
61
|
result.setPeriod(period);
|
62
|
return result;
|
63
|
}
|
64
|
|
65
|
public static TemporalData NewInstance(Feature feature){
|
66
|
TemporalData result = new TemporalData();
|
67
|
result.setFeature(feature);
|
68
|
return result;
|
69
|
}
|
70
|
|
71
|
public static TemporalData NewInstance(Feature feature, ExtendedTimePeriod period){
|
72
|
TemporalData result = new TemporalData();
|
73
|
result.setFeature(feature);
|
74
|
result.setPeriod(period);
|
75
|
return result;
|
76
|
}
|
77
|
|
78
|
// *************************** CONSTRUCTOR *************************************/
|
79
|
|
80
|
/**
|
81
|
* Class constructor: creates a new empty common name instance.
|
82
|
* The corresponding {@link Feature feature} is set to {@link Feature#COMMON_NAME() COMMON_NAME}.
|
83
|
*/
|
84
|
protected TemporalData(){}
|
85
|
|
86
|
// *************************** METHODS *****************************************/
|
87
|
|
88
|
public ExtendedTimePeriod getPeriod() {
|
89
|
return period;
|
90
|
}
|
91
|
public void setPeriod(ExtendedTimePeriod period) {
|
92
|
this.period = period;
|
93
|
}
|
94
|
|
95
|
//*********************************** CLONE *****************************************/
|
96
|
|
97
|
/**
|
98
|
* Clones <i>this</i> common name. This is a shortcut that enables to create
|
99
|
* a new instance that differs only slightly from <i>this</i> common name by
|
100
|
* modifying only some of the attributes.
|
101
|
*
|
102
|
* @see eu.etaxonomy.cdm.model.description.DescriptionElementBase#clone()
|
103
|
* @see java.lang.Object#clone()
|
104
|
*/
|
105
|
@Override
|
106
|
public TemporalData clone() {
|
107
|
|
108
|
TemporalData result = (TemporalData)super.clone();
|
109
|
result.setPeriod(this.period.clone());
|
110
|
//no changes to ...
|
111
|
return result;
|
112
|
}
|
113
|
|
114
|
//*********************************** toString *****************************************/
|
115
|
|
116
|
@Override
|
117
|
public String toString(){
|
118
|
if (period != null){
|
119
|
return period.toString();
|
120
|
}else{
|
121
|
return super.toString();
|
122
|
}
|
123
|
}
|
124
|
}
|