Project

General

Profile

« Previous | Next » 

Revision c5e9236a

Added by Andreas Müller almost 2 years ago

ref #10067 update java-doc for and remove protected access to model constructors where possible in occurrence

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/Collection.java
24 24
import javax.xml.bind.annotation.XmlType;
25 25

  
26 26
import org.apache.commons.lang3.StringUtils;
27
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
27
import org.apache.logging.log4j.LogManager;
28
import org.apache.logging.log4j.Logger;
28 29
import org.hibernate.annotations.Cascade;
29 30
import org.hibernate.annotations.CascadeType;
30 31
import org.hibernate.envers.Audited;
......
127 128

  
128 129
// ******************** CONSTRUCTOR *************************/
129 130

  
130
	protected Collection() {
131
    //*packet* private required by bytebuddy
132
	Collection() {
131 133
		super();
132 134
	}
133 135

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivationEvent.java
26 26
import javax.xml.bind.annotation.XmlSchemaType;
27 27
import javax.xml.bind.annotation.XmlType;
28 28

  
29
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
29
import org.apache.logging.log4j.LogManager;
30
import org.apache.logging.log4j.Logger;
30 31
import org.hibernate.annotations.Cascade;
31 32
import org.hibernate.annotations.CascadeType;
32 33
import org.hibernate.envers.Audited;
......
92 93

  
93 94
	/**
94 95
	 * Factory method
95
	 * @deprecated Use {@link #NewInstance(DerivationEventType)} or any other
96
	 * factory method instead to make sure,
97
	 * the derivation event type is always set.
98
	 */
99
	@Deprecated
100
	public static DerivationEvent NewInstance(){
101
		return new DerivationEvent();
102
	}
103

  
104
	// ********************* FACTORY  ****************************/
105

  
106
	/**
107
	 * Factory method
108
	 * @return
109 96
	 */
110 97
	public static DerivationEvent NewInstance(DerivationEventType type){
111 98
		DerivationEvent result = new DerivationEvent();
......
126 113

  
127 114
// ************************* CONSTRUCTOR ****************************/
128 115

  
129
	/**
130
	 * Constructor
131
	 */
132
	protected DerivationEvent() {
116
    //for hibernate use only, *packet* private required by bytebuddy
117
	DerivationEvent() {
133 118
		super();
134 119
	}
135 120

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivationEventType.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.occurrence;
11 10

  
12 11
import java.util.HashMap;
......
19 18
import javax.xml.bind.annotation.XmlRootElement;
20 19
import javax.xml.bind.annotation.XmlType;
21 20

  
22
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
21
import org.apache.logging.log4j.LogManager;
22
import org.apache.logging.log4j.Logger;
23 23
import org.hibernate.envers.Audited;
24 24

  
25 25
import eu.etaxonomy.cdm.model.description.DescriptionBase;
......
39 39
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
40 40
@Audited
41 41
public class DerivationEventType extends DefinedTermBase<DerivationEventType> {
42

  
42 43
	private static final long serialVersionUID = 6895093454763415279L;
43 44
	@SuppressWarnings("unused")
44 45
	private static final Logger logger = LogManager.getLogger(DerivationEventType.class);
......
59 60

  
60 61
	protected static Map<UUID, DerivationEventType> termMap = null;
61 62

  
62

  
63
//*********************** FACTORY ***********************************************/
63 64

  
64 65
	/**
65 66
	 * Factory method
66
	 * @return
67 67
	 */
68 68
	public static DerivationEventType NewInstance(){
69 69
		return new DerivationEventType();
70 70
	}
71 71

  
72

  
73 72
	/**
74 73
	 * Factory method
75
	 * @return
76 74
	 */
77 75
	public static DerivationEventType NewInstance(String term, String label, String labelAbbrev){
78 76
		return new DerivationEventType(term, label, labelAbbrev);
......
80 78

  
81 79
//********************************** Constructor *********************************/
82 80

  
83
  	//for hibernate use only
84
  	@Deprecated
85
  	protected DerivationEventType() {
81
    //*packet* private required by bytebuddy
82
  	DerivationEventType() {
86 83
		super(TermType.DerivationEventType);
87 84
	}
88 85

  
89

  
90 86
	private DerivationEventType(String term, String label, String labelAbbrev) {
91 87
		super(TermType.DerivationEventType, term, label, labelAbbrev);
92 88
	}
93 89

  
94

  
95 90
//************************** METHODS ********************************
96 91

  
97

  
98 92
	@Override
99 93
	public void resetTerms(){
100 94
		termMap = null;
101 95
	}
102 96

  
103

  
104 97
	protected static DerivationEventType getTermByUuid(UUID uuid){
105 98
	    if (termMap == null || termMap.isEmpty()){
106 99
            return getTermByClassAndUUID(DerivationEventType.class, uuid);
......
111 104

  
112 105
	/**
113 106
	 * TODO distinguish from {@link #DUPLICATE_SEGREGATEION()}
114
	 * @return
115 107
	 */
116 108
	public static final DerivationEventType DUPLICATE(){
117 109
		return getTermByUuid(uuidDuplicate);
118 110
	}
111

  
119 112
	public static final DerivationEventType GATHERING_IN_SITU(){
120 113
		return getTermByUuid(uuidGatheringInSitu);
121 114
	}
115

  
122 116
	public static final DerivationEventType TISSUE_SAMPLING(){
123 117
		return getTermByUuid(uuidTissueSampling);
124 118
	}
119

  
125 120
	public static final DerivationEventType DNA_EXTRACTION(){
126 121
		return getTermByUuid(uuidDnaExtraction);
127 122
	}
123

  
128 124
	public static final DerivationEventType VEGETATIVE_PROPAGATION(){
129 125
		return getTermByUuid(uuidVegetativPropagation);
130 126
	}
127

  
131 128
	/**
132 129
	 * TODO distinguish from {@link #DUPLICATE()}
133
	 * @return
134 130
	 */
135 131
	public static final DerivationEventType DUPLICATE_SEGREGATEION(){
136 132
		return getTermByUuid(uuidDuplicateSegregation);
137 133
	}
134

  
138 135
	/**
139 136
	 * The accessioning in a collection which usually results in an accession number.
140 137
	 * @return
......
183 180
	/**
184 181
	 * The preparation of e.g. a living culture into a preparation which can be stored in a collection
185 182
	 * (using certain preparation methods)
186
	 * @return
187 183
	 */
188 184
	public static final DerivationEventType PREPARATION(){
189 185
		return getTermByUuid(uuidPreparation);
190 186
	}
191 187
	/**
192 188
	 * Ex-situ cultivation.
193
	 * @return
194 189
	 */
195 190
	public static final DerivationEventType CULTIVATION_EX_SITU(){
196 191
		return getTermByUuid(uuidCultivationExSitu);
197 192
	}
198 193

  
199

  
200 194
	@Override
201 195
	protected void setDefaultTerms(TermVocabulary<DerivationEventType> termVocabulary) {
202 196
		termMap = new HashMap<>();
......
204 198
			termMap.put(term.getUuid(), term);
205 199
		}
206 200
	}
207

  
208
}
201
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivedUnit.java
28 28
import javax.xml.bind.annotation.XmlSchemaType;
29 29
import javax.xml.bind.annotation.XmlType;
30 30

  
31
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
31
import org.apache.logging.log4j.LogManager;
32
import org.apache.logging.log4j.Logger;
32 33
import org.hibernate.annotations.Cascade;
33 34
import org.hibernate.annotations.CascadeType;
34 35
import org.hibernate.envers.Audited;
......
202 203

  
203 204
//************************** CONSTRUCTOR *********************************/
204 205

  
205
	//Constructor: For hibernate use only
206
	@SuppressWarnings("deprecation")
206
    //for hibernate use only, protected required by subclass
207
	@Deprecated
207 208
    protected DerivedUnit() {
208
	    super();
209 209
        initDefaultCacheStrategy();
210 210
	}
211 211

  
......
218 218
        initDefaultCacheStrategy();
219 219
	}
220 220

  
221

  
222 221
	/**
223 222
	 * Create new unit derived from an existing field unit
224 223
	 * @param fieldUnit existing field unit from where this unit is derived
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DeterminationEvent.java
25 25
import javax.xml.bind.annotation.XmlSchemaType;
26 26
import javax.xml.bind.annotation.XmlType;
27 27

  
28
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
28
import org.apache.logging.log4j.LogManager;
29
import org.apache.logging.log4j.Logger;
29 30
import org.hibernate.annotations.Cascade;
30 31
import org.hibernate.annotations.CascadeType;
31 32
import org.hibernate.envers.Audited;
......
129 130

  
130 131
//*********************** CONSTRUCTOR ********************************/
131 132

  
132
	protected DeterminationEvent() {
133
    //for hibernate use only, *packet* private required by bytebuddy
134
	DeterminationEvent() {
133 135
		super();
134 136
	}
135 137

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/FieldUnit.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.occurrence;
11 10

  
12

  
13 11
import java.beans.PropertyChangeEvent;
14 12
import java.beans.PropertyChangeListener;
15 13

  
......
26 24
import javax.xml.bind.annotation.XmlSchemaType;
27 25
import javax.xml.bind.annotation.XmlType;
28 26

  
29
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
27
import org.apache.logging.log4j.LogManager;
28
import org.apache.logging.log4j.Logger;
30 29
import org.hibernate.annotations.Cascade;
31 30
import org.hibernate.annotations.CascadeType;
32 31
import org.hibernate.envers.Audited;
......
108 107

  
109 108
//****************************** CONSTRUCTOR **************************************/
110 109

  
111
	/**
112
	 * Constructor
113
	 */
114
	protected FieldUnit(){
110
    //*packet* private required by bytebuddy
111
	FieldUnit(){
115 112
		super(SpecimenOrObservationType.FieldUnit);
116 113
        initDefaultCacheStrategy();
117 114
	}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/GatheringEvent.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.occurrence;
11 10

  
12 11
import java.util.Calendar;
......
31 30
import javax.xml.bind.annotation.XmlSchemaType;
32 31
import javax.xml.bind.annotation.XmlType;
33 32

  
34
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
33
import org.apache.logging.log4j.LogManager;
34
import org.apache.logging.log4j.Logger;
35 35
import org.hibernate.annotations.Cascade;
36 36
import org.hibernate.annotations.CascadeType;
37 37
import org.hibernate.envers.Audited;
......
157 157
	@NumericField
158 158
	private Double distanceToGroundMax;
159 159

  
160

  
161 160
	/**
162 161
	 * Distance to ground (e.g. when sample is taken from a tree) as text.
163 162
	 * If min/max value exists together with distanceToGroundText
......
196 195
    @Column(length=30)
197 196
	private String distanceToWaterSurfaceText;
198 197

  
198
//*********************** FACTORY ****************************************/
199 199

  
200 200
	/**
201 201
	 * Factory method
202
	 * @return
203 202
	 */
204 203
	public static GatheringEvent NewInstance(){
205 204
		return new GatheringEvent();
206 205
	}
207 206

  
208
	/**
209
	 * Constructor
210
	 */
211
	protected GatheringEvent() {
207
//**************************** CONSTRUCTOR ************************************/
208

  
209
    //for hibernate use only, *packet* private required by bytebuddy
210
	GatheringEvent() {
212 211
		super();
213 212
	}
214 213

  
214
//********************* GETTER /SETTER *************************************/
215

  
215 216
	public Point getExactLocation(){
216 217
		return this.exactLocation;
217 218
	}
......
219 220
		this.exactLocation = exactLocation;
220 221
	}
221 222

  
222

  
223

  
224 223
	public NamedArea getCountry() {
225 224
		return country;
226 225
	}
227

  
228 226
	public void setCountry(NamedArea country) {
229 227
		this.country = country;
230 228
	}
231 229

  
232 230
	/**
233 231
	 * Further collecting areas. Should not include #getCountry()
234
	 * @return
235 232
	 */
236 233
	public Set<NamedArea> getCollectingAreas(){
237 234
		if(collectingAreas == null) {
238
			this.collectingAreas = new HashSet<NamedArea>();
235
			this.collectingAreas = new HashSet<>();
239 236
		}
240 237
		return this.collectingAreas;
241 238
	}
242 239

  
243

  
244
	 /**
245
	  * Further collecting areas. Should not include #getCountry()
246
	  * @param area
240
	/**
241
	 * Further collecting areas. Should not include #getCountry()
242
	 * @param area
247 243
	 */
248 244
	public void addCollectingArea(NamedArea area){
249 245
		if (this.collectingAreas == null) {
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/MaterialOrMethodEvent.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
package eu.etaxonomy.cdm.model.occurrence;
10

  
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.Inheritance;
14
import javax.persistence.InheritanceType;
15
import javax.persistence.ManyToOne;
16
import javax.persistence.Transient;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
19
import javax.xml.bind.annotation.XmlElement;
20
import javax.xml.bind.annotation.XmlIDREF;
21
import javax.xml.bind.annotation.XmlRootElement;
22
import javax.xml.bind.annotation.XmlSchemaType;
23
import javax.xml.bind.annotation.XmlType;
24

  
25
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
26
import org.hibernate.envers.Audited;
27
import org.hibernate.search.annotations.IndexedEmbedded;
28

  
29
import eu.etaxonomy.cdm.model.common.EventBase;
30
import eu.etaxonomy.cdm.model.molecular.Cloning;
31
import eu.etaxonomy.cdm.model.term.DefinedTerm;
32
import eu.etaxonomy.cdm.model.term.TermType;
33
import eu.etaxonomy.cdm.model.term.TermVocabulary;
34

  
35
/**
36
 * A material or method event handles data on materials or methods used for handling specimen or derived units
37
 * in general. It stores information on what material or method was used, who used it and when it was used.
38
 * For reusable data on materials or methods it is best practice to define these first as {@link DefinedTerm
39
 * defined terms} of type {@link TermType#MaterialOrMethod} TODO and then use this term as {@link #getDefinedMaterialOrMethod()
40
 * material or method term}. If this is not possible or if additional data needs to be added one may also
41
 * use {@link #getDescription() freetext} field inherited from {@link EventBase}. Actor and Date information
42
 * are also handled via {@link EventBase} fields.
43
 * This class may be extended by more specific classes which require structured handling of additional parameters.
44
 *
45
 * In general material or method data is not considered to be CDM core data. Therefore the decision was made to handle
46
 * all the data with a common base class which is {@link MaterialOrMethodEvent} to reduce the number of tables required
47
 * in the underlying databases.
48
 *
49
 * @author a.mueller
50
 * @since 2013-07-08
51
 *
52
 */
53
@XmlAccessorType(XmlAccessType.FIELD)
54
@XmlType(name = "MaterialOrMethod", propOrder = {
55
	"definedMaterialOrMethod"
56
})
57
@XmlRootElement(name = "MaterialOrMethod")
58
@Entity
59
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
60
@Audited
61
public class MaterialOrMethodEvent extends EventBase {
62

  
63
    private static final long serialVersionUID = -4799205199942053585L;
64
	private static final Logger logger = LogManager.getLogger(MaterialOrMethodEvent.class);
65

  
66
    @XmlElement(name = "DefinedMaterialOrMethod")
67
    @XmlIDREF
68
    @XmlSchemaType(name = "IDREF")
69
    @ManyToOne(fetch=FetchType.LAZY)
70
    @IndexedEmbedded // no depth for terms
71
	private DefinedTerm definedMaterialOrMethod;
72

  
73
	//TODO citation / link
74

  
75

  
76
// ******************** FACTORY METHOD ******************/
77

  
78
    public static MaterialOrMethodEvent NewInstance(){
79
    	return new MaterialOrMethodEvent();
80
    }
81

  
82
    public static MaterialOrMethodEvent NewInstance(DefinedTerm definedMaterialOrMethod, String methodText){
83
    	return new MaterialOrMethodEvent(definedMaterialOrMethod, methodText);
84
    }
85

  
86
// ********************* CONSTRUCTOR ********************/
87

  
88
    protected MaterialOrMethodEvent(){};
89

  
90
    protected MaterialOrMethodEvent(DefinedTerm definedMaterialOrMethod, String methodText){
91
    	this.definedMaterialOrMethod = definedMaterialOrMethod;
92
    	this.setDescription(methodText);
93
    }
94

  
95

  
96
// ********************* GETTER / SETTER ********************/
97

  
98

  
99
	/**
100
	 * The {@link #getDescription()} method is inherited from {@link EventBase}.
101
	 * In this class it is used as freetext describing the material or method used
102
	 * or if a {@link #getDefinedMaterialOrMethod() defined method} is given as
103
	 * an additional information about how this defined method was used.
104
	 *
105
	 * @see #getMaterialMethodText()
106
	 */
107
    @Override
108
	public String getDescription() {
109
		return super.getDescription();
110
	}
111

  
112

  
113
	/**
114
	 * @see #getDescription()
115
	 * @see #setMaterialMethodText(String)
116
	 */
117
    @Override
118
	public void setDescription(String materialMethodText) {
119
		super.setDescription(materialMethodText);
120
	}
121

  
122

  
123

  
124
	/**
125
	 * A freetext describing the material or method or if
126
	 * a {@link #getDefinedMaterialOrMethod() defined method} is given
127
	 * an additional information about how this method was used.
128
	 * In future this method could be removed to decrease the number
129
	 * of transient getters in the CDM.
130
	 */
131
	@Transient
132
    public String getMaterialMethodText() {
133
		return this.getDescription();
134
	}
135

  
136

  
137
	/**
138
	 * @see #getMaterialMethodText()
139
	 */
140
	public void setMaterialMethodText(String materialMethodText) {
141
		this.setDescription(materialMethodText);
142
	}
143

  
144

  
145
	/**
146
	 * A defined material or method given as a defined term in a materialOrMethod
147
	 * {@link TermVocabulary term vocabulary}. If such a defined material or method is used
148
	 * the {@link #getDescription() description} should primarily focus on describing
149
	 * deviation from this method rather then repeating it.
150
	 *
151
	 * @see #getDescription()
152
	 * @see #getMaterialMethodText()
153
	 * @return the material or method term
154
	 */
155
	public DefinedTerm getDefinedMaterialOrMethod() {
156
		return definedMaterialOrMethod;
157
	}
158

  
159
	/**
160
	 * @see #getDefinedMaterialOrMethod()
161
	 * @param materialMethodTerm
162
	 */
163
	public void setDefinedMaterialOrMethod(DefinedTerm definedMaterialOrMethod) {
164
		this.definedMaterialOrMethod = definedMaterialOrMethod;
165
	}
166

  
167
// ********************* CLONE ********************/
168
	/**
169
	 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
170
	 * a new instance that differs only slightly from <i>this</i> cloning by
171
	 * modifying only some of the attributes.<BR><BR>
172
	 *
173
	 * @see EventBase#clone()
174
	 * @see java.lang.Object#clone()
175
	 */
176
	@Override
177
	public MaterialOrMethodEvent clone()  {
178
		try{
179
			MaterialOrMethodEvent result = (MaterialOrMethodEvent)super.clone();
180

  
181
			//don't change materialMethodTerm
182
			return result;
183
		}catch (CloneNotSupportedException e) {
184
			logger.warn("Object does not implement cloneable");
185
			e.printStackTrace();
186
			return null;
187
		}
188
	}
189
}
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
package eu.etaxonomy.cdm.model.occurrence;
10

  
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.Inheritance;
14
import javax.persistence.InheritanceType;
15
import javax.persistence.ManyToOne;
16
import javax.persistence.Transient;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
19
import javax.xml.bind.annotation.XmlElement;
20
import javax.xml.bind.annotation.XmlIDREF;
21
import javax.xml.bind.annotation.XmlRootElement;
22
import javax.xml.bind.annotation.XmlSchemaType;
23
import javax.xml.bind.annotation.XmlType;
24

  
25
import org.apache.logging.log4j.LogManager;
26
import org.apache.logging.log4j.Logger;
27
import org.hibernate.envers.Audited;
28
import org.hibernate.search.annotations.IndexedEmbedded;
29

  
30
import eu.etaxonomy.cdm.model.common.EventBase;
31
import eu.etaxonomy.cdm.model.molecular.Cloning;
32
import eu.etaxonomy.cdm.model.term.DefinedTerm;
33
import eu.etaxonomy.cdm.model.term.TermType;
34
import eu.etaxonomy.cdm.model.term.TermVocabulary;
35

  
36
/**
37
 * A material or method event handles data on materials or methods used for handling specimen or derived units
38
 * in general. It stores information on what material or method was used, who used it and when it was used.
39
 * For reusable data on materials or methods it is best practice to define these first as {@link DefinedTerm
40
 * defined terms} of type {@link TermType#MaterialOrMethod} TODO and then use this term as {@link #getDefinedMaterialOrMethod()
41
 * material or method term}. If this is not possible or if additional data needs to be added one may also
42
 * use {@link #getDescription() freetext} field inherited from {@link EventBase}. Actor and Date information
43
 * are also handled via {@link EventBase} fields.
44
 * This class may be extended by more specific classes which require structured handling of additional parameters.
45
 *
46
 * In general material or method data is not considered to be CDM core data. Therefore the decision was made to handle
47
 * all the data with a common base class which is {@link MaterialOrMethodEvent} to reduce the number of tables required
48
 * in the underlying databases.
49
 *
50
 * @author a.mueller
51
 * @since 2013-07-08
52
 *
53
 */
54
@XmlAccessorType(XmlAccessType.FIELD)
55
@XmlType(name = "MaterialOrMethod", propOrder = {
56
	"definedMaterialOrMethod"
57
})
58
@XmlRootElement(name = "MaterialOrMethod")
59
@Entity
60
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
61
@Audited
62
public class MaterialOrMethodEvent extends EventBase {
63

  
64
    private static final long serialVersionUID = -4799205199942053585L;
65
	private static final Logger logger = LogManager.getLogger(MaterialOrMethodEvent.class);
66

  
67
    @XmlElement(name = "DefinedMaterialOrMethod")
68
    @XmlIDREF
69
    @XmlSchemaType(name = "IDREF")
70
    @ManyToOne(fetch=FetchType.LAZY)
71
    @IndexedEmbedded // no depth for terms
72
	private DefinedTerm definedMaterialOrMethod;
73

  
74
	//TODO citation / link
75

  
76
// ******************** FACTORY METHOD ******************/
77

  
78
    public static MaterialOrMethodEvent NewInstance(){
79
    	return new MaterialOrMethodEvent();
80
    }
81

  
82
    public static MaterialOrMethodEvent NewInstance(DefinedTerm definedMaterialOrMethod, String methodText){
83
    	return new MaterialOrMethodEvent(definedMaterialOrMethod, methodText);
84
    }
85

  
86
// ********************* CONSTRUCTOR ********************/
87

  
88
    //for hibernate use only, *packet* private required by bytebuddy
89
    MaterialOrMethodEvent(){}
90

  
91
    protected MaterialOrMethodEvent(DefinedTerm definedMaterialOrMethod, String methodText){
92
    	this.definedMaterialOrMethod = definedMaterialOrMethod;
93
    	this.setDescription(methodText);
94
    }
95

  
96
// ********************* GETTER / SETTER ********************/
97

  
98
	/**
99
	 * The {@link #getDescription()} method is inherited from {@link EventBase}.
100
	 * In this class it is used as freetext describing the material or method used
101
	 * or if a {@link #getDefinedMaterialOrMethod() defined method} is given as
102
	 * an additional information about how this defined method was used.
103
	 *
104
	 * @see #getMaterialMethodText()
105
	 */
106
    @Override
107
	public String getDescription() {
108
		return super.getDescription();
109
	}
110

  
111

  
112
	/**
113
	 * @see #getDescription()
114
	 * @see #setMaterialMethodText(String)
115
	 */
116
    @Override
117
	public void setDescription(String materialMethodText) {
118
		super.setDescription(materialMethodText);
119
	}
120

  
121

  
122

  
123
	/**
124
	 * A freetext describing the material or method or if
125
	 * a {@link #getDefinedMaterialOrMethod() defined method} is given
126
	 * an additional information about how this method was used.
127
	 * In future this method could be removed to decrease the number
128
	 * of transient getters in the CDM.
129
	 */
130
	@Transient
131
    public String getMaterialMethodText() {
132
		return this.getDescription();
133
	}
134

  
135

  
136
	/**
137
	 * @see #getMaterialMethodText()
138
	 */
139
	public void setMaterialMethodText(String materialMethodText) {
140
		this.setDescription(materialMethodText);
141
	}
142

  
143

  
144
	/**
145
	 * A defined material or method given as a defined term in a materialOrMethod
146
	 * {@link TermVocabulary term vocabulary}. If such a defined material or method is used
147
	 * the {@link #getDescription() description} should primarily focus on describing
148
	 * deviation from this method rather then repeating it.
149
	 *
150
	 * @see #getDescription()
151
	 * @see #getMaterialMethodText()
152
	 * @return the material or method term
153
	 */
154
	public DefinedTerm getDefinedMaterialOrMethod() {
155
		return definedMaterialOrMethod;
156
	}
157

  
158
	/**
159
	 * @see #getDefinedMaterialOrMethod()
160
	 * @param materialMethodTerm
161
	 */
162
	public void setDefinedMaterialOrMethod(DefinedTerm definedMaterialOrMethod) {
163
		this.definedMaterialOrMethod = definedMaterialOrMethod;
164
	}
165

  
166
// ********************* CLONE ********************/
167
	/**
168
	 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
169
	 * a new instance that differs only slightly from <i>this</i> cloning by
170
	 * modifying only some of the attributes.<BR><BR>
171
	 *
172
	 * @see EventBase#clone()
173
	 * @see java.lang.Object#clone()
174
	 */
175
	@Override
176
	public MaterialOrMethodEvent clone()  {
177
		try{
178
			MaterialOrMethodEvent result = (MaterialOrMethodEvent)super.clone();
179

  
180
			//don't change materialMethodTerm
181
			return result;
182
		}catch (CloneNotSupportedException e) {
183
			logger.warn("Object does not implement cloneable");
184
			e.printStackTrace();
185
			return null;
186
		}
187
	}
188
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/MediaSpecimen.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.occurrence;
11 10

  
12

  
13 11
import javax.persistence.Entity;
14 12
import javax.persistence.FetchType;
15 13
import javax.persistence.ManyToOne;
......
21 19
import javax.xml.bind.annotation.XmlSchemaType;
22 20
import javax.xml.bind.annotation.XmlType;
23 21

  
24
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
22
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.Logger;
25 24
import org.hibernate.annotations.Cascade;
26 25
import org.hibernate.annotations.CascadeType;
27 26
import org.hibernate.envers.Audited;
......
56 55
	@SuppressWarnings("unused")
57 56
	private static final Logger logger = LogManager.getLogger(MediaSpecimen.class);
58 57

  
59
// ****************** FACTORY METHOD *****************/
60

  
61
	/**
62
	 * Factory method.
63
	 * @param type must be {@link SpecimenOrObservationType#Media} or a subtype of it.
64
	 * @return
65
	 */
66
	public static MediaSpecimen NewInstance(SpecimenOrObservationType type){
67
		return new MediaSpecimen(type);
68
	}
69 58

  
70 59
// ************** ATTRIBUTES ****************************/
71 60

  
......
76 65
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
77 66
	private Media mediaSpecimen;
78 67

  
68
// ****************** FACTORY METHOD *****************/
69

  
70
    /**
71
     * Factory method.
72
     * @param type must be {@link SpecimenOrObservationType#Media} or a subtype of it.
73
     */
74
    public static MediaSpecimen NewInstance(SpecimenOrObservationType type){
75
        return new MediaSpecimen(type);
76
    }
77

  
79 78
// ******************* CONSTRUCTOR *************************/
80 79

  
81
	private MediaSpecimen() {
80
    private MediaSpecimen() {
82 81
		this(SpecimenOrObservationType.Media);
83 82
	}
84 83

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/OccurrenceStatus.java
18 18
import javax.xml.bind.annotation.XmlSchemaType;
19 19
import javax.xml.bind.annotation.XmlType;
20 20

  
21
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
21
import org.apache.logging.log4j.LogManager;
22
import org.apache.logging.log4j.Logger;
22 23
import org.hibernate.envers.Audited;
23 24

  
24 25
import eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase;
......
87 88

  
88 89
// ************************ CONSTRUCTOR *************************/
89 90

  
90
	protected OccurrenceStatus() {
91
    //*packet* private required by bytebuddy
92
	OccurrenceStatus() {
91 93
        super();
92 94
    }
93 95

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/PreservationMethod.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
package eu.etaxonomy.cdm.model.occurrence;
10

  
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
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.XmlIDREF;
18
import javax.xml.bind.annotation.XmlRootElement;
19
import javax.xml.bind.annotation.XmlSchemaType;
20
import javax.xml.bind.annotation.XmlType;
21

  
22
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.Analyze;
25
import org.hibernate.search.annotations.Field;
26
import org.hibernate.search.annotations.IndexedEmbedded;
27
import org.hibernate.search.annotations.NumericField;
28

  
29
import eu.etaxonomy.cdm.model.common.EventBase;
30
import eu.etaxonomy.cdm.model.molecular.Cloning;
31
import eu.etaxonomy.cdm.model.term.DefinedTerm;
32
import eu.etaxonomy.cdm.model.term.TermType;
33

  
34
/**
35
 * This class is a specialization of {@link MaterialOrMethodEvent} which allows to
36
 * specifically store temperature and XXX which are common parameters for preparation.
37
 *
38
 * {@link #getDefinedMaterialOrMethod() Defined methods} taken to describe a Preservation Method
39
 * should be taken from a vocabulary of type {@link TermType#PreservationMethod}
40
 *
41
 * http://rs.tdwg.org/ontology/voc/Collection.rdf#SpecimenPreservationMethodTypeTerm
42
 *
43
 * @author a.mueller
44
 * @since 2013-09-11
45
 *
46
 */
47
@XmlAccessorType(XmlAccessType.FIELD)
48
@XmlType(name = "PreservationMethod", propOrder = {
49
	"medium",
50
	"temperature"
51
})
52
@XmlRootElement(name = "PreservationMethod")
53
@Entity
54
//TODO @Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
55
@Audited
56
public class PreservationMethod extends MaterialOrMethodEvent implements Cloneable {
57
	private static final long serialVersionUID = 2366116167028862401L;
58
	@SuppressWarnings("unused")
59
	private static final Logger logger = LogManager.getLogger(PreservationMethod.class);
60

  
61
    @XmlElement(name = "Medium")
62
    @XmlIDREF
63
    @XmlSchemaType(name = "IDREF")
64
    @ManyToOne(fetch = FetchType.LAZY)
65
    @IndexedEmbedded // no depth for terms
66
    private DefinedTerm medium;
67

  
68
	@XmlElement(name = "Temperature")
69
	@Field(analyze = Analyze.NO)
70
	@NumericField
71
	private Double temperature;
72

  
73
	// ******************** FACTORY METHOD ******************/
74

  
75
	public static PreservationMethod NewInstance(){
76
		return new PreservationMethod();
77
	}
78

  
79
    public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText){
80
    	return new PreservationMethod(definedMaterialOrMethod, methodText, null, null);
81
    }
82

  
83
	public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm preservationMedium, Double temperature){
84
		return new PreservationMethod(definedMaterialOrMethod, methodText, preservationMedium, temperature);
85
	}
86

  
87
	// ********************* CONSTRUCTOR ********************/
88

  
89
	//for hibernate use only
90
	protected PreservationMethod(){};
91

  
92
    private PreservationMethod(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm medium, Double temperature){
93
    	super(definedMaterialOrMethod, methodText);
94
    	this.medium = medium;
95
    	this.temperature = temperature;
96
    }
97

  
98
	// ********************* GETTER / SETTER ********************/
99

  
100
	public DefinedTerm getMedium() {
101
		return medium;
102
	}
103
	public void setMedium(DefinedTerm medium) {
104
		this.medium = medium;
105
	}
106

  
107
	public Double getTemperature() {
108
		return temperature;
109
	}
110
	public void setTemperature(Double temperature) {
111
		this.temperature = temperature;
112
	}
113

  
114
// ************************** CLONE ********************/
115

  
116
	/**
117
	 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
118
	 * a new instance that differs only slightly from <i>this</i> cloning by
119
	 * modifying only some of the attributes.<BR><BR>
120
	 *
121
	 * @see EventBase#clone()
122
	 * @see java.lang.Object#clone()
123
	 */
124
	@Override
125
	public PreservationMethod clone()  {
126
		PreservationMethod result = (PreservationMethod)super.clone();
127

  
128
		//don't change medium, temperature
129
		return result;
130
	}
131
}
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
package eu.etaxonomy.cdm.model.occurrence;
10

  
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
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.XmlIDREF;
18
import javax.xml.bind.annotation.XmlRootElement;
19
import javax.xml.bind.annotation.XmlSchemaType;
20
import javax.xml.bind.annotation.XmlType;
21

  
22
import org.apache.logging.log4j.LogManager;
23
import org.apache.logging.log4j.Logger;
24
import org.hibernate.envers.Audited;
25
import org.hibernate.search.annotations.Analyze;
26
import org.hibernate.search.annotations.Field;
27
import org.hibernate.search.annotations.IndexedEmbedded;
28
import org.hibernate.search.annotations.NumericField;
29

  
30
import eu.etaxonomy.cdm.model.common.EventBase;
31
import eu.etaxonomy.cdm.model.molecular.Cloning;
32
import eu.etaxonomy.cdm.model.term.DefinedTerm;
33
import eu.etaxonomy.cdm.model.term.TermType;
34

  
35
/**
36
 * This class is a specialization of {@link MaterialOrMethodEvent} which allows to
37
 * specifically store temperature and XXX which are common parameters for preparation.
38
 *
39
 * {@link #getDefinedMaterialOrMethod() Defined methods} taken to describe a Preservation Method
40
 * should be taken from a vocabulary of type {@link TermType#PreservationMethod}
41
 *
42
 * http://rs.tdwg.org/ontology/voc/Collection.rdf#SpecimenPreservationMethodTypeTerm
43
 *
44
 * @author a.mueller
45
 * @since 2013-09-11
46
 */
47
@XmlAccessorType(XmlAccessType.FIELD)
48
@XmlType(name = "PreservationMethod", propOrder = {
49
	"medium",
50
	"temperature"
51
})
52
@XmlRootElement(name = "PreservationMethod")
53
@Entity
54
//TODO @Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
55
@Audited
56
public class PreservationMethod extends MaterialOrMethodEvent {
57

  
58
	private static final long serialVersionUID = 2366116167028862401L;
59
	@SuppressWarnings("unused")
60
	private static final Logger logger = LogManager.getLogger(PreservationMethod.class);
61

  
62
    @XmlElement(name = "Medium")
63
    @XmlIDREF
64
    @XmlSchemaType(name = "IDREF")
65
    @ManyToOne(fetch = FetchType.LAZY)
66
    @IndexedEmbedded // no depth for terms
67
    private DefinedTerm medium;
68

  
69
	@XmlElement(name = "Temperature")
70
	@Field(analyze = Analyze.NO)
71
	@NumericField
72
	private Double temperature;
73

  
74
	// ******************** FACTORY METHOD ******************/
75

  
76
	public static PreservationMethod NewInstance(){
77
		return new PreservationMethod();
78
	}
79

  
80
    public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText){
81
    	return new PreservationMethod(definedMaterialOrMethod, methodText, null, null);
82
    }
83

  
84
	public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm preservationMedium, Double temperature){
85
		return new PreservationMethod(definedMaterialOrMethod, methodText, preservationMedium, temperature);
86
	}
87

  
88
	// ********************* CONSTRUCTOR ********************/
89

  
90
    //for hibernate use only, *packet* private required by bytebuddy
91
	PreservationMethod(){}
92

  
93
    private PreservationMethod(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm medium, Double temperature){
94
    	super(definedMaterialOrMethod, methodText);
95
    	this.medium = medium;
96
    	this.temperature = temperature;
97
    }
98

  
99
	// ********************* GETTER / SETTER ********************/
100

  
101
	public DefinedTerm getMedium() {
102
		return medium;
103
	}
104
	public void setMedium(DefinedTerm medium) {
105
		this.medium = medium;
106
	}
107

  
108
	public Double getTemperature() {
109
		return temperature;
110
	}
111
	public void setTemperature(Double temperature) {
112
		this.temperature = temperature;
113
	}
114

  
115
// ************************** CLONE ********************/
116

  
117
	/**
118
	 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
119
	 * a new instance that differs only slightly from <i>this</i> cloning by
120
	 * modifying only some of the attributes.<BR><BR>
121
	 *
122
	 * @see EventBase#clone()
123
	 * @see java.lang.Object#clone()
124
	 */
125
	@Override
126
	public PreservationMethod clone()  {
127
		PreservationMethod result = (PreservationMethod)super.clone();
128

  
129
		//don't change medium, temperature
130
		return result;
131
	}
132
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationBase.java
39 39
import javax.xml.bind.annotation.XmlType;
40 40
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
41 41

  
42
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
42
import org.apache.logging.log4j.LogManager;
43
import org.apache.logging.log4j.Logger;
43 44
import org.hibernate.annotations.Cascade;
44 45
import org.hibernate.annotations.CascadeType;
45 46
import org.hibernate.annotations.Type;
......
235 236
    @XmlElement(name = "ProtectedIdentityCache")
236 237
    private boolean protectedIdentityCache;
237 238

  
238

  
239 239
//********************************** CONSTRUCTOR *********************************/
240 240

  
241
    //for hibernate use only
242
    @Deprecated
243
    protected SpecimenOrObservationBase(){
244
        super();
245
    }
241
    //for hibernate use only, *packet* private required by bytebuddy and subclass
242
    SpecimenOrObservationBase(){}
246 243

  
247 244
    protected SpecimenOrObservationBase(SpecimenOrObservationType recordBasis) {
248
        super();
249 245
        if (recordBasis == null){ throw new IllegalArgumentException("RecordBasis must not be null");}
250 246
        this.recordBasis = recordBasis;
251 247
    }
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationType.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.model.occurrence;
11 10

  
12 11
import java.util.Set;
......
15 14
import javax.xml.bind.annotation.XmlEnum;
16 15
import javax.xml.bind.annotation.XmlEnumValue;
17 16

  
18
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
17
import org.apache.logging.log4j.LogManager;
18
import org.apache.logging.log4j.Logger;
19 19

  
20 20
import eu.etaxonomy.cdm.model.common.Language;
21 21
import eu.etaxonomy.cdm.model.description.Feature;
......
23 23
import eu.etaxonomy.cdm.model.term.EnumeratedTermVoc;
24 24
import eu.etaxonomy.cdm.model.term.IEnumTerm;
25 25

  
26

  
27 26
/**
28 27
 * The specimen or observation type is used to define what a {@link SpecimenOrObservationBase specimen or observation}
29 28
 * instance describes, may it be a {@link FieldUnit field unit} or a

Also available in: Unified diff