Update script for termtype and some other, remove InstitutionType and COntinent,...
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / occurrence / PreservationMethod.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.occurrence;
11
12 import java.util.HashMap;
13 import java.util.Map;
14 import java.util.UUID;
15
16 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
17 import eu.etaxonomy.cdm.model.common.TermType;
18 import eu.etaxonomy.cdm.model.common.TermVocabulary;
19
20 import org.apache.log4j.Logger;
21 import org.hibernate.envers.Audited;
22 import org.hibernate.search.annotations.Indexed;
23
24 import javax.persistence.*;
25 import javax.xml.bind.annotation.XmlAccessType;
26 import javax.xml.bind.annotation.XmlAccessorType;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30 /**
31 * http://rs.tdwg.org/ontology/voc/Collection.rdf#SpecimenPreservationMethodTypeTerm
32 * @author m.doering
33 * @created 08-Nov-2007 13:06:44
34 */
35 @XmlAccessorType(XmlAccessType.FIELD)
36 @XmlType(name = "PreservationMethod")
37 @XmlRootElement(name = "PreservationMethod")
38 @Entity
39 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
40 @Audited
41 public class PreservationMethod extends DefinedTermBase<PreservationMethod> {
42 private static final long serialVersionUID = -6597303767771121540L;
43 @SuppressWarnings("unused")
44 private static final Logger logger = Logger.getLogger(PreservationMethod.class);
45
46 protected static Map<UUID, PreservationMethod> termMap = null;
47
48
49 //********************************** FACTORY METHOD *********************************/
50
51 /**
52 * Factory method
53 * @return
54 */
55 public static PreservationMethod NewInstance(){
56 return new PreservationMethod();
57 }
58
59 /**
60 * Factory method
61 * @return
62 */
63 public static PreservationMethod NewInstance(String term, String label, String labelAbbrev) {
64 return new PreservationMethod(term, label, labelAbbrev);
65 }
66
67 //********************************** CONSTRUCTOR *********************************/
68
69 //for hibernate use only
70 @Deprecated
71 protected PreservationMethod() {
72 super(TermType.PreservationMethod);
73 }
74
75
76 /**
77 * Constructor
78 */
79 protected PreservationMethod(String term, String label, String labelAbbrev) {
80 super(TermType.PreservationMethod, term, label, labelAbbrev);
81 }
82
83 // *************************** METHODS ******************************************************/
84
85 /* (non-Javadoc)
86 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
87 */
88 @Override
89 public void resetTerms(){
90 termMap = null;
91 }
92
93
94 @Override
95 protected void setDefaultTerms(TermVocabulary<PreservationMethod> termVocabulary){
96 termMap = new HashMap<UUID, PreservationMethod>();
97 for (PreservationMethod term : termVocabulary.getTerms()){
98 termMap.put(term.getUuid(), term);
99 }
100 }
101 }