Project

General

Profile

Download (2.61 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
import org.hibernate.search.annotations.Indexed;
26

    
27
/**
28
 * Annotation types ...
29
 * @author a.mueller
30
 * @version 1.0
31
 * @created 12-Nov-2008 15:37:33
32
 */
33
@XmlAccessorType(XmlAccessType.FIELD)
34
@XmlType(name = "AnnotationType")
35
@XmlRootElement(name = "AnnotationType")
36
@Entity
37
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
38
@Audited
39
public class AnnotationType extends DefinedTermBase<AnnotationType> {
40
	private static final long serialVersionUID = 49629121282854575L;
41
	@SuppressWarnings("unused")
42
	private static final Logger logger = Logger.getLogger(AnnotationType.class);
43

    
44
	protected static Map<UUID, AnnotationType> termMap = null;		
45
	
46
	private static final UUID uuidTechnical = UUID.fromString("6a5f9ea4-1bdd-4906-89ad-6e669f982d69");
47
	private static final UUID uuidEditorial = UUID.fromString("e780d5fd-abfc-4025-938a-46deb751d808");
48

    
49
	public static AnnotationType NewInstance(String term, String label, String labelAbbrev){
50
		return new AnnotationType(term, label, labelAbbrev);
51
	}
52
	
53
	/**
54
	 * Constructor
55
	 * @param term
56
	 * @param label
57
	 */
58
	public AnnotationType() {
59
	}
60
	
61
	/**
62
	 * Constructor
63
	 * @param term
64
	 * @param label
65
	 */
66
	protected AnnotationType(String term, String label, String labelAbbrev) {
67
		super(term, label, labelAbbrev);
68
	}
69

    
70
	
71
//************************** METHODS ********************************
72
	
73
	protected static AnnotationType getTermByUuid(UUID uuid){
74
		if (termMap == null){
75
			return null;  //better return null then initialize the termMap in an unwanted way 
76
		}
77
		return (AnnotationType)termMap.get(uuid);
78
	}
79
	
80
	
81
	public static final AnnotationType TECHNICAL(){
82
		return getTermByUuid(uuidTechnical);
83
	}
84

    
85
	public static final AnnotationType EDITORIAL(){
86
		return getTermByUuid(uuidEditorial);
87
	}
88

    
89
	protected void setDefaultTerms(TermVocabulary<AnnotationType> termVocabulary) {
90
		termMap = new HashMap<UUID, AnnotationType>();
91
		for (AnnotationType term : termVocabulary.getTerms()){
92
			termMap.put(term.getUuid(), (AnnotationType)term);
93
		}	
94
	}
95

    
96
}
(3-3/62)