Project

General

Profile

Download (3.35 KB) Statistics
| Branch: | Tag: | Revision:
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 org.apache.log4j.Logger;
14
import org.hibernate.envers.Audited;
15
import org.hibernate.search.annotations.Field;
16
import org.hibernate.search.annotations.Index;
17
import org.hibernate.search.annotations.Indexed;
18

    
19
import javax.persistence.*;
20
import javax.xml.bind.annotation.XmlAccessType;
21
import javax.xml.bind.annotation.XmlAccessorType;
22
import javax.xml.bind.annotation.XmlElement;
23
import javax.xml.bind.annotation.XmlRootElement;
24
import javax.xml.bind.annotation.XmlType;
25

    
26
/**
27
 * workaround for enumerations
28
 * @author m.doering
29
 * @version 1.0
30
 * @created 08-Nov-2007 13:06:49
31
 */
32

    
33
@XmlAccessorType(XmlAccessType.FIELD)
34
@XmlType(name = "Representation", propOrder = {
35
    "label",
36
    "abbreviatedLabel"
37
})
38
@XmlRootElement(name = "Representation")
39
@Entity
40
@Indexed(index = "eu.etaxonomy.cdm.model.common.Representation")
41
@Audited
42
public class Representation extends LanguageStringBase {
43
	private static final long serialVersionUID = -4202420199587324532L;
44
	@SuppressWarnings("unused")
45
	private static final Logger logger = Logger.getLogger(Representation.class);
46

    
47
    @XmlElement(name = "Label")
48
    @Field(index=Index.TOKENIZED)
49
	private String label;
50
    
51
    @XmlElement(name = "AbbreviatedLabel")
52
    @Field(index=Index.TOKENIZED)
53
	private String abbreviatedLabel;
54

    
55
	/**
56
	 * @param text
57
	 * @param label
58
	 * @param lang
59
	 * @return
60
	 */
61
	public static Representation NewInstance(String text, String label, String abbreviatedLabel, Language lang){
62
		return new Representation(text, label, abbreviatedLabel, lang);
63
	}
64
	
65
	public Representation() {
66
		super();
67
	}	
68

    
69
	/**
70
	 * text represents an explanation/declaration ('The name is illegitimate according to ICBN'); label a string identifier ('illegitimate name');
71
	 * abbreviatedLabel a shortened string for the label ('nom. illeg.') 
72
	 */
73
	public Representation(String text, String label, String abbreviatedLabel, Language language) {
74
		super(text, language);
75
		this.label = label;
76
		this.abbreviatedLabel = abbreviatedLabel;
77
	}
78

    
79
	
80
	public String getLabel(){
81
		return this.label;
82
	}
83
	public void setLabel(String label){
84
		this.label = label;
85
	}
86

    
87
	public String getAbbreviatedLabel(){
88
		return this.abbreviatedLabel;
89
	}
90
	public void setAbbreviatedLabel(String abbreviatedLabel){
91
		this.abbreviatedLabel = abbreviatedLabel;
92
	}
93
	
94
	/**
95
	 * Returns the description of this representation
96
	 * see {@link #getText()}
97
	 * @return
98
	 */
99
	@Transient
100
	public String getDescription(){
101
		return getText();
102
	}
103
	
104
	protected void setDescription(String text) {
105
		super.setText(text);
106
	}
107
	
108
	
109
	/* 
110
	 * Overrides super.getText() only to document that here the Text attribute
111
	 * should be used for a larger description of the label.
112
	 */
113
	/**
114
	 * Returns the description of this representation.
115
	 * @see #getDescription()
116
	 */
117
	@Transient
118
	@Override
119
	public String getText(){
120
		return super.getText();
121
	}
122
	
123
	
124
	@Override
125
	public String toString(){
126
		// we dont need the language returned too, do we? 
127
		return getLabel();
128
//		if(getLanguage()==null || getLanguage().getLabel()==null){
129
//			return getLabel();
130
//		}else{
131
//			return getLabel()+"("+ getLanguage().getLabel()+")";
132
//		}
133
	}
134
}
(49-49/62)