| 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.List; |
|---|
| 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.XmlSeeAlso; |
|---|
| 20 | import javax.xml.bind.annotation.XmlType; |
|---|
| 21 | |
|---|
| 22 | import org.apache.log4j.Logger; |
|---|
| 23 | import org.hibernate.envers.Audited; |
|---|
| 24 | |
|---|
| 25 | import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|---|
| 26 | import eu.etaxonomy.cdm.model.common.Language; |
|---|
| 27 | import eu.etaxonomy.cdm.model.common.OrderedTermBase; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | /** |
|---|
| 31 | * This (abstract) class represents terms describing the {@link AbsenceTerm absence} |
|---|
| 32 | * (like "extinct") or the {@link PresenceTerm presence} (like "cultivated") of a {@link Taxon taxon} |
|---|
| 33 | * in a {@link NamedArea named area}. Splitting the terms in two subclasses allows to |
|---|
| 34 | * assign them automatically to absent or present status. These terms are only |
|---|
| 35 | * used for {@link Distribution distributions}. |
|---|
| 36 | |
|---|
| 37 | * |
|---|
| 38 | * @author m.doering |
|---|
| 39 | * @version 1.0 |
|---|
| 40 | * @created 08-Nov-2007 13:06:44 |
|---|
| 41 | */ |
|---|
| 42 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 43 | @XmlType(name = "PresenceAbsenceTermBase") |
|---|
| 44 | @XmlSeeAlso({ |
|---|
| 45 | AbsenceTerm.class, |
|---|
| 46 | PresenceTerm.class |
|---|
| 47 | }) |
|---|
| 48 | @Entity |
|---|
| 49 | @Audited |
|---|
| 50 | public abstract class PresenceAbsenceTermBase<T extends PresenceAbsenceTermBase<?>> extends OrderedTermBase<T> { |
|---|
| 51 | private static final long serialVersionUID = 1596291470042068880L; |
|---|
| 52 | @SuppressWarnings("unused") |
|---|
| 53 | private static final Logger logger = Logger.getLogger(PresenceAbsenceTermBase.class); |
|---|
| 54 | |
|---|
| 55 | private String defaultColor = "000000"; |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | /** |
|---|
| 59 | * Class constructor: creates a new empty presence or absence term. |
|---|
| 60 | * |
|---|
| 61 | * @see #PresenceAbsenceTermBase(String, String, String) |
|---|
| 62 | */ |
|---|
| 63 | protected PresenceAbsenceTermBase() { |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | /** |
|---|
| 67 | * Class constructor: creates a new presence or absence term with a description |
|---|
| 68 | * (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation. |
|---|
| 69 | * |
|---|
| 70 | * @param term the string (in the default language) describing the |
|---|
| 71 | * new presence or absence term to be created |
|---|
| 72 | * @param label the string identifying the new presence or absence term to be created |
|---|
| 73 | * @param labelAbbrev the string identifying (in abbreviated form) the |
|---|
| 74 | * new presence or absence term to be created |
|---|
| 75 | * @see #PresenceAbsenceTermBase() |
|---|
| 76 | */ |
|---|
| 77 | protected PresenceAbsenceTermBase(String term, String label, String labelAbbrev) { |
|---|
| 78 | super(term, label, labelAbbrev); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /* (non-Javadoc) |
|---|
| 82 | * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(java.util.List) |
|---|
| 83 | */ |
|---|
| 84 | @Override |
|---|
| 85 | public T readCsvLine(Class<T> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) { |
|---|
| 86 | T newInstance = super.readCsvLine(termClass, csvLine, terms); |
|---|
| 87 | String abbreviatedLabel = (String)csvLine.get(4); |
|---|
| 88 | // String uuid = (String)csvLine.get(0); |
|---|
| 89 | // map.put(abbreviatedLabel, UUID.fromString(uuid)); |
|---|
| 90 | String color = (String)csvLine.get(5); |
|---|
| 91 | newInstance.setDefaultColor(color); |
|---|
| 92 | newInstance.getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(abbreviatedLabel); |
|---|
| 93 | return newInstance; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | /** |
|---|
| 97 | * @return the defaultColor |
|---|
| 98 | */ |
|---|
| 99 | public String getDefaultColor() { |
|---|
| 100 | return defaultColor; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | /** |
|---|
| 104 | * @param defaultColor the defaultColor to set |
|---|
| 105 | */ |
|---|
| 106 | //TODO check RGB length 6 and between 000000 and FFFFFF |
|---|
| 107 | public void setDefaultColor(String defaultColor) { |
|---|
| 108 | this.defaultColor = defaultColor; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | } |
|---|