Project

General

Profile

Download (3.28 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.description;
11

    
12

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

    
17
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
18
import eu.etaxonomy.cdm.model.common.Language;
19
import eu.etaxonomy.cdm.model.common.TermType;
20
import eu.etaxonomy.cdm.model.common.TermVocabulary;
21

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

    
26
import javax.persistence.*;
27
import javax.xml.bind.annotation.XmlAccessType;
28
import javax.xml.bind.annotation.XmlAccessorType;
29
import javax.xml.bind.annotation.XmlRootElement;
30
import javax.xml.bind.annotation.XmlType;
31

    
32
/**
33
 * This class represents measurement units such as "centimeter" or "degree
34
 * Celsius".
35
 * 
36
 * @author m.doering
37
 * @created 08-Nov-2007 13:06:34
38
 */
39
@XmlAccessorType(XmlAccessType.FIELD)
40
@XmlType(name = "MeasurementUnit")
41
@XmlRootElement(name = "MeasurementUnit")
42
@Entity
43
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
44
@Audited
45
public class MeasurementUnit extends DefinedTermBase<MeasurementUnit> {
46
	private static final long serialVersionUID = 4904519152652248312L;
47
	@SuppressWarnings("unused")
48
	private static final Logger logger = Logger.getLogger(MeasurementUnit.class);
49
	
50
	protected static Map<UUID, MeasurementUnit> termMap = null;		
51

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

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

    
60
	/** 
61
	 * Creates a new measurement unit with a description
62
	 * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
63
	 * 
64
	 * @param	term  		 the string (in the default language) describing the
65
	 * 						 new measurement unit to be created 
66
	 * @param	label  		 the string identifying the new measurement unit
67
	 * 						 to be created
68
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
69
	 * 						 new measurement unit to be created
70
	 * @see 				 #NewInstance()
71
	 */
72
	private MeasurementUnit(String term, String label, String labelAbbrev) {
73
		super(TermType.MeasurementUnit, term, label, labelAbbrev);
74
	}
75

    
76
	
77
	/** 
78
	 * Creates a new empty measurement unit instance.
79
	 * 
80
	 * @see #MeasurementUnit(String, String, String)
81
	 */
82
	public static MeasurementUnit NewInstance(){
83
		return new MeasurementUnit();
84
	}
85
	
86
	/** 
87
	 * Creates a new empty measurement unit instance.
88
	 * 
89
	 * @see #MeasurementUnit(String, String, String)
90
	 */
91
	public static MeasurementUnit NewInstance(String term, String label, String labelAbbrev){
92
		return new MeasurementUnit(term, label, labelAbbrev);
93
	}
94

    
95
	
96
	/* (non-Javadoc)
97
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
98
	 */
99
	@Override
100
	public void resetTerms(){
101
		termMap = null;
102
	}
103

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

    
115
}
(16-16/36)