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
|
import javax.persistence.Entity;
|
13
|
import javax.persistence.FetchType;
|
14
|
import javax.persistence.ManyToOne;
|
15
|
import javax.xml.bind.annotation.XmlAccessType;
|
16
|
import javax.xml.bind.annotation.XmlAccessorType;
|
17
|
import javax.xml.bind.annotation.XmlElement;
|
18
|
import javax.xml.bind.annotation.XmlIDREF;
|
19
|
import javax.xml.bind.annotation.XmlRootElement;
|
20
|
import javax.xml.bind.annotation.XmlSchemaType;
|
21
|
import javax.xml.bind.annotation.XmlType;
|
22
|
|
23
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
24
|
import org.hibernate.annotations.Cascade;
|
25
|
import org.hibernate.annotations.CascadeType;
|
26
|
import org.hibernate.envers.Audited;
|
27
|
import org.hibernate.search.annotations.FieldBridge;
|
28
|
import org.springframework.beans.factory.annotation.Configurable;
|
29
|
|
30
|
import eu.etaxonomy.cdm.hibernate.search.NotNullAwareIdBridge;
|
31
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
32
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
33
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
34
|
import eu.etaxonomy.cdm.strategy.cache.description.TaxonNameDescriptionDefaultCacheStrategy;
|
35
|
|
36
|
/**
|
37
|
* This class represents all piece of information (not ruled by a {@link NomenclaturalCode nomenclatural code})
|
38
|
* concerning a {@link TaxonName taxon name} like for instance the content of its first
|
39
|
* publication (protolog) or a picture of this publication.
|
40
|
*
|
41
|
* @author a.mueller
|
42
|
* @since 08-Jul-2008
|
43
|
*/
|
44
|
@XmlAccessorType(XmlAccessType.FIELD)
|
45
|
@XmlType(name = "TaxonNameDescription", propOrder = {
|
46
|
"taxonName"
|
47
|
})
|
48
|
@XmlRootElement(name = "TaxonNameDescription")
|
49
|
@Entity
|
50
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
51
|
//@Indexed(index = "eu.etaxonomy.cdm.model.description.DescriptionBase")
|
52
|
@Audited
|
53
|
@Configurable
|
54
|
public class TaxonNameDescription
|
55
|
extends DescriptionBase<IIdentifiableEntityCacheStrategy<TaxonNameDescription>> {
|
56
|
|
57
|
private static final long serialVersionUID = -7349160369642038687L;
|
58
|
@SuppressWarnings("unused")
|
59
|
private static final Logger logger = LogManager.getLogger(TaxonNameDescription.class);
|
60
|
|
61
|
@XmlElement(name="TaxonName")
|
62
|
@XmlIDREF
|
63
|
@XmlSchemaType(name="IDREF")
|
64
|
@ManyToOne(fetch = FetchType.LAZY)
|
65
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
66
|
@FieldBridge(impl=NotNullAwareIdBridge.class)
|
67
|
private TaxonName taxonName;
|
68
|
|
69
|
//******************* FACTORY ********************************************/
|
70
|
|
71
|
/**
|
72
|
* Creates a new empty taxon name description instance.
|
73
|
*/
|
74
|
public static TaxonNameDescription NewInstance(){
|
75
|
return new TaxonNameDescription();
|
76
|
}
|
77
|
|
78
|
/**
|
79
|
* Creates a new taxon name description instance for the given {@link TaxonName name}.
|
80
|
* The new taxon name description will be also added to the {@link TaxonName#getDescriptions() set of descriptions}
|
81
|
* assigned to the given name.
|
82
|
*
|
83
|
* @see #NewInstance()
|
84
|
*/
|
85
|
public static TaxonNameDescription NewInstance(TaxonName name){
|
86
|
TaxonNameDescription description = new TaxonNameDescription();
|
87
|
name.addDescription(description);
|
88
|
return description;
|
89
|
}
|
90
|
|
91
|
// ********************** CONSTRUCTOR ***************************************/
|
92
|
|
93
|
/**
|
94
|
* Class constructor: creates a new empty taxon name description instance.
|
95
|
*/
|
96
|
private TaxonNameDescription() {
|
97
|
super();
|
98
|
}
|
99
|
|
100
|
@Override
|
101
|
protected void initDefaultCacheStrategy() {
|
102
|
this.cacheStrategy = new TaxonNameDescriptionDefaultCacheStrategy();
|
103
|
}
|
104
|
|
105
|
//************************* GETTER /SETTER ***************************************/
|
106
|
|
107
|
/**
|
108
|
* Returns the {@link TaxonName taxon name} to which <i>this</i> taxon name description
|
109
|
* provides additional information not ruled by a {@link NomenclaturalCode nomenclatural code}.
|
110
|
*/
|
111
|
public TaxonName getTaxonName() {
|
112
|
return taxonName;
|
113
|
}
|
114
|
|
115
|
//*************** METHODS ***********************************************/
|
116
|
|
117
|
@Override
|
118
|
public IDescribable<?> describedEntity(){
|
119
|
return this.taxonName;
|
120
|
}
|
121
|
|
122
|
//*********************** CLONE ********************************************************/
|
123
|
|
124
|
/**
|
125
|
* Clones <i>this</i> taxon name description. This is a shortcut that enables to create
|
126
|
* a new instance that differs only slightly from <i>this</i> taxon name description by
|
127
|
* modifying only some of the attributes.
|
128
|
*
|
129
|
* @see eu.etaxonomy.cdm.model.description.DescriptionBase#clone()
|
130
|
* @see java.lang.Object#clone()
|
131
|
*/
|
132
|
@Override
|
133
|
public TaxonNameDescription clone() {
|
134
|
TaxonNameDescription result;
|
135
|
result = (TaxonNameDescription)super.clone();
|
136
|
//no changes to: taxonName
|
137
|
return result;
|
138
|
}
|
139
|
}
|