root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivationEventType.java

Revision 10455, 4.2 kB (checked in by a.mueller, 20 months ago)

reset for defined terms

  • Property svn:keywords set to Id
Line 
1/**
2* Copyright (C) 2009 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
10package eu.etaxonomy.cdm.model.occurrence;
11
12import java.util.HashMap;
13import java.util.Map;
14import java.util.UUID;
15
16import javax.persistence.Entity;
17import javax.xml.bind.annotation.XmlAccessType;
18import javax.xml.bind.annotation.XmlAccessorType;
19import javax.xml.bind.annotation.XmlRootElement;
20import javax.xml.bind.annotation.XmlType;
21
22import org.apache.log4j.Logger;
23import org.hibernate.envers.Audited;
24import org.hibernate.search.annotations.Indexed;
25
26import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27import eu.etaxonomy.cdm.model.common.TermVocabulary;
28
29@XmlAccessorType(XmlAccessType.FIELD)
30@XmlType(name = "DerivationEventType")
31@XmlRootElement(name = "DerivationEventType")
32@Entity
33@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
34@Audited
35public class DerivationEventType extends DefinedTermBase<DerivationEventType> {
36        private static final long serialVersionUID = 6895093454763415279L;
37        @SuppressWarnings("unused")
38        private static final Logger logger = Logger.getLogger(DerivationEventType.class);
39
40        private static final UUID uuidDuplicate = UUID.fromString("8f54c7cc-eb5e-4652-a6e4-3a4ba429b327");
41        private static final UUID uuidGatheringInSitu = UUID.fromString("1cb2bd40-5c9c-459b-89c7-4d9c2fca7432");
42        private static final UUID uuidTissueSampling = UUID.fromString("9dc1df08-1f31-4008-a4e2-1ddf7c9115da");
43        private static final UUID uuidDnaExtraction = UUID.fromString("f9f957b6-88c0-4531-9a7f-b5fb1c9daf66");
44        private static final UUID uuidVegetativPropagation = UUID.fromString("a4a8e4ce-0e58-462a-be67-a7f567d96da1");
45        private static final UUID uuidDuplicateSegregation = UUID.fromString("661e7292-6bcb-495d-a3cc-140024ae3471");
46        private static final UUID uuidAccessioning = UUID.fromString("3c7c0929-0528-493e-9e5f-15e0d9585fa1");
47        private static final UUID uuidSexualReproduction = UUID.fromString("aa79baac-165d-47ad-9e80-52a03776d8ae");
48
49        protected static Map<UUID, DerivationEventType> termMap = null;         
50       
51
52       
53        /**
54         * Factory method
55         * @return
56         */
57        public static DerivationEventType NewInstance(){
58                return new DerivationEventType();
59        }
60       
61       
62        /**
63         * Factory method
64         * @return
65         */
66        public static DerivationEventType NewInstance(String term, String label, String labelAbbrev){
67                return new DerivationEventType(term, label, labelAbbrev);
68        }
69       
70        /**
71         * Constructor
72         */
73        public DerivationEventType() {
74        }
75       
76       
77        /**
78         * Constructor
79         */
80        public DerivationEventType(String term, String label, String labelAbbrev) {
81                super(term, label, labelAbbrev);
82        }
83
84
85//************************** METHODS ********************************
86       
87       
88        @Override
89        public void resetTerms(){
90                termMap = null;
91        }
92
93       
94        protected static DerivationEventType getTermByUuid(UUID uuid){
95                if (termMap == null){
96                        return null;  //better return null then initialize the termMap in an unwanted way
97                }
98                return (DerivationEventType)termMap.get(uuid);
99        }
100       
101        public static final DerivationEventType DUPLICATE(){
102                return getTermByUuid(uuidDuplicate);
103        }
104        public static final DerivationEventType GATHERING_IN_SITU(){
105                return getTermByUuid(uuidGatheringInSitu);
106        }
107        public static final DerivationEventType TISSUE_SAMPLING(){
108                return getTermByUuid(uuidTissueSampling);
109        }
110        public static final DerivationEventType DNA_EXTRACTION(){
111                return getTermByUuid(uuidDnaExtraction);
112        }
113        public static final DerivationEventType VEGETATIVE_PROPAGATION(){
114                return getTermByUuid(uuidVegetativPropagation);
115        }
116        public static final DerivationEventType DUPLICATE_SEGREGATEION(){
117                return getTermByUuid(uuidDuplicateSegregation);
118        }
119        public static final DerivationEventType ACCESSIONING(){
120                return getTermByUuid(uuidAccessioning);
121        }
122        public static final DerivationEventType SEXUAL_REPRODUCTION(){
123                return getTermByUuid(uuidSexualReproduction);
124        }
125
126        @Override
127        protected void setDefaultTerms(TermVocabulary<DerivationEventType> termVocabulary) {
128                termMap = new HashMap<UUID, DerivationEventType>();
129                for (DerivationEventType term : termVocabulary.getTerms()){
130                        termMap.put(term.getUuid(), (DerivationEventType)term);
131                }       
132        }
133       
134}
Note: See TracBrowser for help on using the browser.