Project

General

Profile

Download (3.02 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.media;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14
import java.util.UUID;
15

    
16
import javax.persistence.Entity;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.log4j.Logger;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.Indexed;
25

    
26
import eu.etaxonomy.cdm.model.common.AnnotationType;
27
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
28
import eu.etaxonomy.cdm.model.common.TermVocabulary;
29

    
30
/**
31
 * @author m.doering
32
 * @version 1.0
33
 * @created 08-Nov-2007 13:06:50
34
 */
35
@XmlAccessorType(XmlAccessType.FIELD)
36
@XmlType(name = "RightsTerm")
37
@XmlRootElement(name = "RightsTerm")
38
@Entity
39
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
40
@Audited
41
public class RightsTerm extends DefinedTermBase<RightsTerm> {
42
	private static final long serialVersionUID = -5823263624000932116L;
43
	private static final Logger logger = Logger.getLogger(RightsTerm.class);
44

    
45
	protected static Map<UUID, RightsTerm> termMap = null;		
46

    
47
	
48
	/**
49
	 * Factory method
50
	 * @return
51
	 */
52
	public static RightsTerm NewInstance(){
53
		logger.debug("NewInstance");
54
		return new RightsTerm();
55
	}
56

    
57
	/**
58
	 * Factory method
59
	 * @return
60
	 */
61
	public static RightsTerm NewInstance(String text, String label, String labelAbbrev){
62
		return new RightsTerm(text, label, labelAbbrev);
63
	}
64
	
65
	/**
66
	 * Default Constructor
67
	 */
68
	public RightsTerm() {
69
	}
70

    
71
	/**
72
	 * Constructor
73
	 */
74
	public RightsTerm(String term, String label, String labelAbbrev) {
75
		super(term, label, labelAbbrev);
76
	}
77

    
78
	
79
//************************** METHODS ********************************
80
	
81
	protected static RightsTerm getTermByUuid(UUID uuid){
82
		if (termMap == null){
83
			return null;  //better return null then initialize the termMap in an unwanted way 
84
		}
85
		return (RightsTerm)termMap.get(uuid);
86
	}
87
	
88
	/**
89
	 * http://purl.org/dc/terms/accessRights
90
	 */
91
	public static final RightsTerm ACCESS_RIGHTS(){
92
		return getTermByUuid(uuidAccessRights);
93
	}
94

    
95
	public static final RightsTerm COPYRIGHT(){
96
		return getTermByUuid(uuidCopyright);
97
	}
98

    
99
	public static final RightsTerm LICENSE(){
100
		return getTermByUuid(uuidLicense);
101
	}
102
	
103
	private static final UUID uuidLicense = UUID.fromString("67c0d47e-8985-1014-8845-c84599f9992c");
104
	private static final UUID uuidCopyright = UUID.fromString("d1ef838e-b195-4f28-b8eb-0d3be080bd37");
105
	private static final UUID uuidAccessRights = UUID.fromString("a50b4def-b3ac-4508-b50a-e0f249e3a1d7");
106

    
107

    
108
	@Override
109
	protected void setDefaultTerms(TermVocabulary<RightsTerm> termVocabulary) {
110
		termMap = new HashMap<UUID, RightsTerm>();
111
		for (RightsTerm term : termVocabulary.getTerms()){
112
			termMap.put(term.getUuid(), (RightsTerm)term);
113
		}	
114
	}
115

    
116
}
(13-13/14)