Project

General

Profile

Download (2.85 KB) Statistics
| Branch: | Tag: | Revision:
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.common;
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

    
26
/**
27
 * Annotation types ...
28
 * @author a.mueller
29
 * @since 12-Nov-2008 15:37:33
30
 */
31
@XmlAccessorType(XmlAccessType.FIELD)
32
@XmlType(name = "AnnotationType")
33
@XmlRootElement(name = "AnnotationType")
34
@Entity
35
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
36
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
37
@Audited
38
public class AnnotationType extends DefinedTermBase<AnnotationType> {
39
	private static final long serialVersionUID = 49629121282854575L;
40
	@SuppressWarnings("unused")
41
	private static final Logger logger = Logger.getLogger(AnnotationType.class);
42

    
43
	protected static Map<UUID, AnnotationType> termMap = null;
44

    
45
	private static final UUID uuidTechnical = UUID.fromString("6a5f9ea4-1bdd-4906-89ad-6e669f982d69");
46
	private static final UUID uuidEditorial = UUID.fromString("e780d5fd-abfc-4025-938a-46deb751d808");
47

    
48
	public static AnnotationType NewInstance(String term, String label, String labelAbbrev){
49
		return new AnnotationType(term, label, labelAbbrev);
50
	}
51

    
52
//********************************** Constructor *******************************************************************/
53

    
54
	//for hibernate use only
55
	@Deprecated
56
	protected AnnotationType() {
57
		super(TermType.AnnotationType);
58
	}
59

    
60
	/**
61
	 * Constructor
62
	 * @param term
63
	 * @param label
64
	 */
65
	protected AnnotationType(String term, String label, String labelAbbrev) {
66
		super(TermType.AnnotationType , term, label, labelAbbrev);
67
	}
68

    
69

    
70
//************************** METHODS ********************************
71

    
72
	@Override
73
	public void resetTerms(){
74
		termMap = null;
75
	}
76

    
77
	protected static AnnotationType getTermByUuid(UUID uuid){
78
	    if (termMap == null || termMap.isEmpty()){
79
            return getTermByClassAndUUID(AnnotationType.class, uuid);
80
        }  else {
81
            return termMap.get(uuid);
82
        }
83
	}
84

    
85

    
86
	public static final AnnotationType TECHNICAL(){
87
		return getTermByUuid(uuidTechnical);
88
	}
89

    
90
	public static final AnnotationType EDITORIAL(){
91
		return getTermByUuid(uuidEditorial);
92
	}
93

    
94
	@Override
95
    protected void setDefaultTerms(TermVocabulary<AnnotationType> termVocabulary) {
96
		termMap = new HashMap<>();
97
		for (AnnotationType term : termVocabulary.getTerms()){
98
			termMap.put(term.getUuid(), term);
99
		}
100
	}
101

    
102
}
(4-4/83)