Project

General

Profile

Download (3.73 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.term.OrderedTermBase;
28
import eu.etaxonomy.cdm.model.term.TermType;
29
import eu.etaxonomy.cdm.model.term.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
 * @since 08-Nov-2007 13:06:53
38
 */
39
@XmlAccessorType(XmlAccessType.FIELD)
40
@XmlType(name = "State")
41
@XmlRootElement(name = "State")
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.term.DefinedTermBase")
45
@Audited
46
public class State extends OrderedTermBase<State> {
47
	private static final long serialVersionUID = -4816292463790262516L;
48
	@SuppressWarnings("unused")
49
	private static final Logger logger = Logger.getLogger(State.class);
50

    
51
	public static final UUID uuidPresent = UUID.fromString("4f90d908-2061-4627-b251-0683c55b9c2e");
52
	public static final UUID uuidAbsent = UUID.fromString("f193112f-68b2-4c74-bb82-05791892d2c4");
53

    
54

    
55
	protected static Map<UUID, State> termMap = null;
56

    
57

    
58
//********************************** Constructor *******************************************************************/
59

    
60
	//for hibernate use only
61
	@Deprecated
62
	protected State() {
63
		super(TermType.State);
64
	}
65

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

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

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

    
106
//************************** METHODS ********************************
107

    
108
	@Override
109
	public void resetTerms(){
110
		termMap = null;
111
	}
112

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

    
121
}
(27-27/38)