Project

General

Profile

Download (4.15 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
import java.util.HashMap;
13
import java.util.List;
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.XmlSeeAlso;
22
import javax.xml.bind.annotation.XmlType;
23

    
24
import org.apache.log4j.Logger;
25
import org.hibernate.envers.Audited;
26

    
27
import eu.etaxonomy.cdm.common.CdmUtils;
28
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
29
import eu.etaxonomy.cdm.model.common.ILoadableTerm;
30
import eu.etaxonomy.cdm.model.common.Language;
31
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
32
import eu.etaxonomy.cdm.model.common.TermVocabulary;
33
import eu.etaxonomy.cdm.model.location.NamedArea;
34
import eu.etaxonomy.cdm.model.taxon.Taxon;
35

    
36
/**
37
 * This (abstract) class represents terms describing the {@link AbsenceTerm absence}
38
 * (like "extinct") or the {@link PresenceTerm presence} (like "cultivated") of a {@link Taxon taxon}
39
 * in a {@link NamedArea named area}. Splitting the terms in two subclasses allows to
40
 * assign them automatically to absent or present status. These terms are only
41
 * used for {@link Distribution distributions}. 
42

    
43
 * 
44
 * @author m.doering
45
 * @version 1.0
46
 * @created 08-Nov-2007 13:06:44
47
 */
48
@XmlAccessorType(XmlAccessType.FIELD)
49
@XmlType(name = "PresenceAbsenceTermBase")
50
@XmlSeeAlso({
51
	AbsenceTerm.class,
52
	PresenceTerm.class
53
})
54
@Entity
55
@Audited
56
public abstract class PresenceAbsenceTermBase<T extends PresenceAbsenceTermBase<?>> extends OrderedTermBase<T> {
57
	private static final long serialVersionUID = 1596291470042068880L;
58
	private static final Logger logger = Logger.getLogger(PresenceAbsenceTermBase.class);
59

    
60
	private static Map<String, UUID> map = new HashMap<String, UUID>();
61
	private String defaultColor = "000000";
62
	
63

    
64
	/** 
65
	 * Class constructor: creates a new empty presence or absence term.
66
	 * 
67
	 * @see #PresenceAbsenceTermBase(String, String, String)
68
	 */
69
	protected PresenceAbsenceTermBase() {
70
	}
71

    
72
	/** 
73
	 * Class constructor: creates a new presence or absence term with a description
74
	 * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
75
	 * 
76
	 * @param	term  		 the string (in the default language) describing the
77
	 * 						 new presence or absence term to be created 
78
	 * @param	label  		 the string identifying the new presence or absence term to be created
79
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
80
	 * 						 new presence or absence term to be created
81
	 * @see 				 #PresenceAbsenceTermBase()
82
	 */
83
	protected PresenceAbsenceTermBase(String term, String label, String labelAbbrev) {
84
		super(term, label, labelAbbrev);
85
	}
86
	
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(java.util.List)
89
	 */
90
	@Override
91
	public T readCsvLine(Class<T> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
92
		T newInstance = super.readCsvLine(termClass, csvLine, terms);
93
		String abbreviatedLabel = (String)csvLine.get(4);
94
//		String uuid = (String)csvLine.get(0);
95
//		map.put(abbreviatedLabel, UUID.fromString(uuid));
96
		String color = (String)csvLine.get(5);
97
		newInstance.setDefaultColor(color);
98
		newInstance.getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(abbreviatedLabel);
99
		return newInstance;
100
	}
101
	
102
//	public PresenceTerm getPresenceAbsenceTermByAbbreviation(String abbrev){
103
//		UUID uuid = map.get(abbrev);
104
//		if (uuid == null){
105
//			logger.warn("Unknown Abbreviation for PresenceAbsenceTerm: " + CdmUtils.Nz(abbrev));
106
//			return null;
107
//		}
108
//		return (uuid);
109
//	}
110

    
111
	
112
	/**
113
	 * @return the defaultColor
114
	 */
115
	public String getDefaultColor() {
116
		return defaultColor;
117
	}
118

    
119
	/**
120
	 * @param defaultColor the defaultColor to set
121
	 */
122
	//TODO check RGB length 6 and between 000000 and FFFFFF
123
	public void setDefaultColor(String defaultColor) {
124
		this.defaultColor = defaultColor;
125
	}
126

    
127
}
(18-18/36)