2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.description
;
13 import java
.util
.HashMap
;
15 import java
.util
.UUID
;
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
;
23 import org
.apache
.logging
.log4j
.LogManager
;
24 import org
.apache
.logging
.log4j
.Logger
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
28 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTermBase
;
29 import eu
.etaxonomy
.cdm
.model
.term
.TermType
;
30 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
33 * This class represents terms describing different states (like "oval" or
34 * "triangular") for {@link Feature features} that can be described with
35 * categorical values (like for instance shapes).
38 * @since 08-Nov-2007 13:06:53
40 @XmlAccessorType(XmlAccessType
.FIELD
)
41 @XmlType(name
= "State")
42 @XmlRootElement(name
= "State")
44 //@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
45 //@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
47 public class State
extends DefinedTermBase
<State
> {
49 private static final long serialVersionUID
= -4816292463790262516L;
50 @SuppressWarnings("unused")
51 private static final Logger logger
= LogManager
.getLogger();
53 public static final UUID uuidPresent
= UUID
.fromString("4f90d908-2061-4627-b251-0683c55b9c2e");
54 public static final UUID uuidAbsent
= UUID
.fromString("f193112f-68b2-4c74-bb82-05791892d2c4");
56 protected static Map
<UUID
, State
> termMap
= null;
58 //********************************** Constructor *******************************************************************/
60 //for hibernate use only
63 super(TermType
.State
);
67 * Class constructor: creates a new state with a description (in the {@link Language#DEFAULT() default language}),
68 * a label and a label abbreviation.
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
77 private State(String term
, String label
, String labelAbbrev
) {
78 super(TermType
.State
, term
, label
, labelAbbrev
);
81 //********* METHODS **************************************/
83 * Creates a new empty state.
85 * @see #NewInstance(String, String, String)
87 public static State
NewInstance(){
92 * Creates a new state with a description (in the {@link Language#DEFAULT() default language}),
93 * a label and a label abbreviation.
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()
102 public static State
NewInstance(String term
, String label
, String labelAbbrev
){
103 return new State(term
, label
, labelAbbrev
);
106 public static State
NewInstance(String term
, String label
, String labelAbbrev
, Language language
){
107 State result
= new State(term
, label
, labelAbbrev
);
108 result
.getRepresentations().iterator().next().setLanguage(language
);
112 //************************** METHODS ********************************
115 public void resetTerms(){
120 protected void setDefaultTerms(TermVocabulary
<State
> termVocabulary
){
121 termMap
= new HashMap
<>();
122 for (State term
: termVocabulary
.getTerms()){
123 termMap
.put(term
.getUuid(), term
);