more tests and features for #476: Implement free-text search methods for TaxonBase...
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / description / Modifier.java
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 import org.hibernate.search.annotations.Indexed;
26
27 import eu.etaxonomy.cdm.model.common.Language;
28 import eu.etaxonomy.cdm.model.common.OrderedTermBase;
29 import eu.etaxonomy.cdm.model.common.TermVocabulary;
30
31 /**
32 * This class represents possible modulations for the validity of
33 * information pieces ({@link DescriptionElementBase} description elements).
34 * It can cover probability ("perhaps"), frequency ("often") intensity ("very"),
35 * timing ("spring") and other domains. Its instances can be grouped to build
36 * different controlled {@link TermVocabulary term vocabularies}.
37 * <P>
38 * This class corresponds to GeneralModifierNLDType according to
39 * the SDD schema.
40 *
41 * @author m.doering
42 * @version 1.0
43 * @created 08-Nov-2007 13:06:35
44 */
45 @XmlAccessorType(XmlAccessType.FIELD)
46 @XmlType(name = "Modifier")
47 @XmlRootElement(name = "Modifier")
48 @Entity
49 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
50 @Audited
51 public class Modifier extends OrderedTermBase<Modifier> {
52 private static final long serialVersionUID = -2491833848163461951L;
53 @SuppressWarnings("unused")
54 private static final Logger logger = Logger.getLogger(Modifier.class);
55
56 protected static Map<UUID, Modifier> termMap = null;
57
58
59 /**
60 * Creates a new empty modifier instance.
61 *
62 * @see #Modifier(String, String, String)
63 */
64 public static Modifier NewInstance(){
65 return new Modifier();
66 }
67
68 public static Modifier NewInstance(String term, String label, String labelAbbrev){
69 return new Modifier(term, label, labelAbbrev);
70 }
71
72 /**
73 * Class constructor: creates a new empty modifier instance.
74 *
75 * @see #Modifier(String, String, String)
76 */
77 public Modifier(){
78 }
79
80
81 /**
82 * Class constructor: creates a new modifier with a description
83 * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
84 *
85 * @param term the string (in the default language) describing the
86 * new modifier to be created
87 * @param label the string identifying the new modifier to be created
88 * @param labelAbbrev the string identifying (in abbreviated form) the
89 * new modifier to be created
90 * @see #Modifier()
91 */
92 public Modifier(String term, String label, String labelAbbrev) {
93 super(term, label, labelAbbrev);
94 }
95
96
97 //************************** METHODS ********************************
98
99 /* (non-Javadoc)
100 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
101 */
102 @Override
103 public void resetTerms(){
104 termMap = null;
105 }
106
107
108
109 @Override
110 protected void setDefaultTerms(TermVocabulary<Modifier> termVocabulary) {
111 termMap = new HashMap<UUID, Modifier>();
112 for (Modifier term : termVocabulary.getTerms()){
113 termMap.put(term.getUuid(), term);
114 }
115 }
116
117 }