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.term;
|
11
|
|
12
|
|
13
|
import javax.persistence.Entity;
|
14
|
import javax.persistence.Transient;
|
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.XmlRootElement;
|
19
|
import javax.xml.bind.annotation.XmlType;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.hibernate.envers.Audited;
|
23
|
import org.hibernate.search.annotations.Field;
|
24
|
import org.hibernate.search.annotations.Store;
|
25
|
|
26
|
import eu.etaxonomy.cdm.model.common.Language;
|
27
|
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
|
28
|
|
29
|
/**
|
30
|
* workaround for enumerations
|
31
|
* @author m.doering
|
32
|
* @since 08-Nov-2007 13:06:49
|
33
|
*/
|
34
|
|
35
|
@XmlAccessorType(XmlAccessType.FIELD)
|
36
|
@XmlType(name = "Representation", propOrder = {
|
37
|
"label",
|
38
|
"plural",
|
39
|
"abbreviatedLabel"
|
40
|
})
|
41
|
@XmlRootElement(name = "Representation")
|
42
|
@Entity
|
43
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
44
|
//@Indexed(index = "eu.etaxonomy.cdm.model.common.Representation")
|
45
|
@Audited
|
46
|
public class Representation extends LanguageStringBase {
|
47
|
private static final long serialVersionUID = -4202420199587324532L;
|
48
|
private static final Logger logger = Logger.getLogger(Representation.class);
|
49
|
|
50
|
@XmlElement(name = "Label")
|
51
|
@Field(store=Store.YES)
|
52
|
private String label;
|
53
|
|
54
|
@XmlElement(name = "AbbreviatedLabel")
|
55
|
@Field(store=Store.YES)
|
56
|
private String abbreviatedLabel;
|
57
|
|
58
|
//#8142
|
59
|
@XmlElement(name = "Plural")
|
60
|
@Field(store=Store.YES)
|
61
|
private String plural;
|
62
|
|
63
|
/**
|
64
|
* @param text
|
65
|
* @param label
|
66
|
* @param lang
|
67
|
* @return
|
68
|
*/
|
69
|
public static Representation NewInstance(String description, String label, String abbreviatedLabel, Language lang){
|
70
|
return new Representation(description, label, abbreviatedLabel, lang);
|
71
|
}
|
72
|
|
73
|
public Representation() {
|
74
|
super();
|
75
|
}
|
76
|
|
77
|
/**
|
78
|
* text represents an explanation/declaration ('The name is illegitimate according to ICBN'); label a string identifier ('illegitimate name');
|
79
|
* abbreviatedLabel a shortened string for the label ('nom. illeg.')
|
80
|
*/
|
81
|
public Representation(String description, String label, String abbreviatedLabel, Language language) {
|
82
|
super(description, language);
|
83
|
this.label = label;
|
84
|
this.abbreviatedLabel = abbreviatedLabel;
|
85
|
}
|
86
|
|
87
|
|
88
|
public String getLabel(){
|
89
|
return this.label;
|
90
|
}
|
91
|
public void setLabel(String label){
|
92
|
this.label = label;
|
93
|
}
|
94
|
|
95
|
public String getAbbreviatedLabel(){
|
96
|
return this.abbreviatedLabel;
|
97
|
}
|
98
|
public void setAbbreviatedLabel(String abbreviatedLabel){
|
99
|
this.abbreviatedLabel = abbreviatedLabel;
|
100
|
}
|
101
|
|
102
|
public String getPlural() {
|
103
|
return plural;
|
104
|
}
|
105
|
public void setPlural(String plural) {
|
106
|
this.plural = plural;
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* Returns the description of this representation
|
111
|
* see {@link #getText()}
|
112
|
* @return
|
113
|
*/
|
114
|
@Transient
|
115
|
public String getDescription(){
|
116
|
return getText();
|
117
|
}
|
118
|
|
119
|
protected void setDescription(String text) {
|
120
|
super.setText(text);
|
121
|
}
|
122
|
|
123
|
|
124
|
/*
|
125
|
* Overrides super.getText() only to document that here the Text attribute
|
126
|
* should be used for a larger description of the label.
|
127
|
*/
|
128
|
/**
|
129
|
* Returns the description of this representation.
|
130
|
* @see #getDescription()
|
131
|
*/
|
132
|
@Transient
|
133
|
@Override
|
134
|
public String getText(){
|
135
|
return super.getText();
|
136
|
}
|
137
|
|
138
|
|
139
|
@Override
|
140
|
public String toString(){
|
141
|
// we dont need the language returned too, do we?
|
142
|
return getLabel();
|
143
|
// if(getLanguage()==null || getLanguage().getLabel()==null){
|
144
|
// return getLabel();
|
145
|
// }else{
|
146
|
// return getLabel()+"("+ getLanguage().getLabel()+")";
|
147
|
// }
|
148
|
}
|
149
|
|
150
|
//*********************** CLONE ********************************************************/
|
151
|
|
152
|
/**
|
153
|
* Clones <i>this</i> Representation. This is a shortcut that enables to create
|
154
|
* a new instance that differs only slightly from <i>this</i> Representation by
|
155
|
* modifying only some of the attributes.
|
156
|
*
|
157
|
* @see eu.etaxonomy.cdm.model.common.LanguageStringBase#clone()
|
158
|
* @see java.lang.Object#clone()
|
159
|
*/
|
160
|
@Override
|
161
|
public Object clone() {
|
162
|
try{
|
163
|
Representation result = (Representation) super.clone();
|
164
|
//no changes to abbreviatedLabel and label
|
165
|
return result;
|
166
|
}catch (CloneNotSupportedException e) {
|
167
|
logger.warn("Object does not implement cloneable");
|
168
|
e.printStackTrace();
|
169
|
return null;
|
170
|
}
|
171
|
|
172
|
}
|
173
|
}
|