Project

General

Profile

Download (3.67 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.description;
11

    
12

    
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.UUID;
16

    
17
import javax.persistence.Entity;
18
import javax.xml.bind.annotation.XmlAccessType;
19
import javax.xml.bind.annotation.XmlAccessorType;
20
import javax.xml.bind.annotation.XmlRootElement;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.log4j.Logger;
24
import org.hibernate.envers.Audited;
25

    
26
import eu.etaxonomy.cdm.model.common.Language;
27
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
28
import eu.etaxonomy.cdm.model.common.TermType;
29
import eu.etaxonomy.cdm.model.common.TermVocabulary;
30

    
31
/**
32
 * This class represents terms describing different states (like "oval" or
33
 * "triangular") for {@link Feature features} that can be described with
34
 * categorical values (like for instance shapes).
35
 *
36
 * @author m.doering
37
 * @version 1.0
38
 * @created 08-Nov-2007 13:06:53
39
 */
40
@XmlAccessorType(XmlAccessType.FIELD)
41
@XmlType(name = "State")
42
@XmlRootElement(name = "State")
43
@Entity
44
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
45
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
46
@Audited
47
public class State extends OrderedTermBase<State> {
48
	private static final long serialVersionUID = -4816292463790262516L;
49
	@SuppressWarnings("unused")
50
	private static final Logger logger = Logger.getLogger(State.class);
51

    
52
	protected static Map<UUID, State> termMap = null;
53

    
54

    
55
//********************************** Constructor *******************************************************************/
56

    
57
	//for hibernate use only
58
	@Deprecated
59
	protected State() {
60
		super(TermType.State);
61
	}
62

    
63
	/**
64
	 * Class constructor: creates a new state with a description (in the {@link Language#DEFAULT() default language}),
65
	 * a label and a label abbreviation.
66
	 *
67
	 * @param	term  		 the string (in the default language) describing the
68
	 * 						 new state to be created
69
	 * @param	label  		 the string identifying the new state to be created
70
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
71
	 * 						 new state to be created
72
	 * @see 				 #State()
73
	 */
74
	private State(String term, String label, String labelAbbrev) {
75
		super(TermType.State, term, label, labelAbbrev);
76
	}
77

    
78
	//********* METHODS **************************************/
79
	/**
80
	 * Creates a new empty state.
81
	 *
82
	 * @see #NewInstance(String, String, String)
83
	 */
84
	public static State NewInstance(){
85
		return new State();
86
	}
87

    
88
	/**
89
	 * Creates a new state with a description (in the {@link Language#DEFAULT() default language}),
90
	 * a label and a label abbreviation.
91
	 *
92
	 * @param	term  		 the string (in the default language) describing the
93
	 * 						 new state to be created
94
	 * @param	label  		 the string identifying the new state to be created
95
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
96
	 * 						 new state to be created
97
	 * @see 				 #NewInstance()
98
	 */
99
	public static State NewInstance(String term, String label, String labelAbbrev){
100
		return new State(term, label, labelAbbrev);
101
	}
102

    
103
//************************** METHODS ********************************
104

    
105
	/* (non-Javadoc)
106
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
107
	 */
108
	@Override
109
	public void resetTerms(){
110
		termMap = null;
111
	}
112

    
113

    
114
	@Override
115
	protected void setDefaultTerms(TermVocabulary<State> termVocabulary){
116
		termMap = new HashMap<UUID, State>();
117
		for (State term : termVocabulary.getTerms()){
118
			termMap.put(term.getUuid(), term);
119
		}
120
	}
121

    
122
}
(25-25/36)