root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AnnotationType.java

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

reset for defined terms

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.common;
11
12
13import java.util.HashMap;
14import java.util.Map;
15import java.util.UUID;
16
17import javax.persistence.Entity;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlRootElement;
21import javax.xml.bind.annotation.XmlType;
22
23import org.apache.log4j.Logger;
24import org.hibernate.envers.Audited;
25import org.hibernate.search.annotations.Indexed;
26import org.springframework.util.Assert;
27
28/**
29 * Annotation types ...
30 * @author a.mueller
31 * @version 1.0
32 * @created 12-Nov-2008 15:37:33
33 */
34@XmlAccessorType(XmlAccessType.FIELD)
35@XmlType(name = "AnnotationType")
36@XmlRootElement(name = "AnnotationType")
37@Entity
38@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
39@Audited
40public class AnnotationType extends DefinedTermBase<AnnotationType> {
41        private static final long serialVersionUID = 49629121282854575L;
42        @SuppressWarnings("unused")
43        private static final Logger logger = Logger.getLogger(AnnotationType.class);
44
45        protected static Map<UUID, AnnotationType> termMap = null;             
46       
47        private static final UUID uuidTechnical = UUID.fromString("6a5f9ea4-1bdd-4906-89ad-6e669f982d69");
48        private static final UUID uuidEditorial = UUID.fromString("e780d5fd-abfc-4025-938a-46deb751d808");
49
50        public static AnnotationType NewInstance(String term, String label, String labelAbbrev){
51                return new AnnotationType(term, label, labelAbbrev);
52        }
53       
54        /**
55         * Constructor
56         * @param term
57         * @param label
58         */
59        public AnnotationType() {
60        }
61       
62        /**
63         * Constructor
64         * @param term
65         * @param label
66         */
67        protected AnnotationType(String term, String label, String labelAbbrev) {
68                super(term, label, labelAbbrev);
69        }
70
71       
72//************************** METHODS ********************************
73       
74        /* (non-Javadoc)
75         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
76         */
77        @Override
78        public void resetTerms(){
79                termMap = null;
80        }
81       
82        protected static AnnotationType getTermByUuid(UUID uuid){
83                if (termMap == null){
84                        return null;  //better return null then initialize the termMap in an unwanted way
85                }
86                return (AnnotationType)termMap.get(uuid);
87        }
88       
89       
90        public static final AnnotationType TECHNICAL(){
91                return getTermByUuid(uuidTechnical);
92        }
93
94        public static final AnnotationType EDITORIAL(){
95                return getTermByUuid(uuidEditorial);
96        }
97
98        protected void setDefaultTerms(TermVocabulary<AnnotationType> termVocabulary) {
99                termMap = new HashMap<UUID, AnnotationType>();
100                for (AnnotationType term : termVocabulary.getTerms()){
101                        termMap.put(term.getUuid(), (AnnotationType)term);
102                }       
103        }
104
105}
Note: See TracBrowser for help on using the browser.