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