Project

General

Profile

Download (3.04 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.AvailableForIdentifiableBase;
27
import eu.etaxonomy.cdm.model.term.TermType;
28
import eu.etaxonomy.cdm.model.term.TermVocabulary;
29

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

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

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

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

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

    
57
//********************************** Constructor *******************************************************************/
58

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

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

    
72
//************************** METHODS ********************************
73

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

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

    
87

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

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

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

    
104
}
(3-3/56)