Project

General

Profile

Download (2.97 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.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
24
import org.hibernate.envers.Audited;
25

    
26
import eu.etaxonomy.cdm.model.term.TermType;
27
import eu.etaxonomy.cdm.model.term.TermVocabulary;
28

    
29
/**
30
 * Annotation types ...
31
 * @author a.mueller
32
 * @since 12-Nov-2008 15:37:33
33
 */
34
@XmlAccessorType(XmlAccessType.FIELD)
35
@XmlType(name = "AnnotationType")
36
@XmlRootElement(name = "AnnotationType")
37
@Entity
38
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
39
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
40
@Audited
41
public class AnnotationType extends AvailableForIdentifiableBase<AnnotationType> {
42

    
43
	private static final long serialVersionUID = 49629121282854575L;
44
	@SuppressWarnings("unused")
45
	private static final Logger logger = LogManager.getLogger(AnnotationType.class);
46

    
47
	protected static Map<UUID, AnnotationType> termMap = null;
48

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

    
52
	public static AnnotationType NewInstance(String term, String label, String labelAbbrev){
53
		return new AnnotationType(term, label, labelAbbrev);
54
	}
55

    
56
//********************************** Constructor *******************************************************************/
57

    
58
	//for hibernate use only
59
	@Deprecated
60
	protected AnnotationType() {
61
		super(TermType.AnnotationType);
62
	}
63

    
64
	/**
65
	 * Constructor
66
	 */
67
	protected AnnotationType(String term, String label, String labelAbbrev) {
68
		super(TermType.AnnotationType , term, label, labelAbbrev);
69
	}
70

    
71
//************************** METHODS ********************************
72

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

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

    
86

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

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

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

    
103
}
(3-3/58)