| 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.occurrence; |
|---|
| 11 | |
|---|
| 12 | import java.util.HashMap; |
|---|
| 13 | import java.util.Map; |
|---|
| 14 | import java.util.UUID; |
|---|
| 15 | |
|---|
| 16 | import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|---|
| 17 | import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|---|
| 18 | |
|---|
| 19 | import org.apache.log4j.Logger; |
|---|
| 20 | import org.hibernate.envers.Audited; |
|---|
| 21 | import org.hibernate.search.annotations.Indexed; |
|---|
| 22 | |
|---|
| 23 | import javax.persistence.*; |
|---|
| 24 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 25 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 26 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 27 | import javax.xml.bind.annotation.XmlType; |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * http://rs.tdwg.org/ontology/voc/Collection.rdf#SpecimenPreservationMethodTypeTerm |
|---|
| 31 | * @author m.doering |
|---|
| 32 | * @version 1.0 |
|---|
| 33 | * @created 08-Nov-2007 13:06:44 |
|---|
| 34 | */ |
|---|
| 35 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 36 | @XmlType(name = "PreservationMethod") |
|---|
| 37 | @XmlRootElement(name = "PreservationMethod") |
|---|
| 38 | @Entity |
|---|
| 39 | @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase") |
|---|
| 40 | @Audited |
|---|
| 41 | public class PreservationMethod extends DefinedTermBase<PreservationMethod> { |
|---|
| 42 | private static final long serialVersionUID = -6597303767771121540L; |
|---|
| 43 | @SuppressWarnings("unused") |
|---|
| 44 | private static final Logger logger = Logger.getLogger(PreservationMethod.class); |
|---|
| 45 | |
|---|
| 46 | protected static Map<UUID, PreservationMethod> termMap = null; |
|---|
| 47 | |
|---|
| 48 | /** |
|---|
| 49 | * Factory method |
|---|
| 50 | * @return |
|---|
| 51 | */ |
|---|
| 52 | public static PreservationMethod NewInstance(){ |
|---|
| 53 | return new PreservationMethod(); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | /** |
|---|
| 57 | * Constructor |
|---|
| 58 | */ |
|---|
| 59 | public PreservationMethod() { |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| 63 | * Factory method |
|---|
| 64 | * @return |
|---|
| 65 | */ |
|---|
| 66 | public static PreservationMethod NewInstance(String term, String label, String labelAbbrev) { |
|---|
| 67 | return new PreservationMethod(term, label, labelAbbrev); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | /** |
|---|
| 71 | * Constructor |
|---|
| 72 | */ |
|---|
| 73 | protected PreservationMethod(String term, String label, String labelAbbrev) { |
|---|
| 74 | super(term, label, labelAbbrev); |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | // *************************** METHODS ******************************************************/ |
|---|
| 78 | |
|---|
| 79 | /* (non-Javadoc) |
|---|
| 80 | * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms() |
|---|
| 81 | */ |
|---|
| 82 | @Override |
|---|
| 83 | public void resetTerms(){ |
|---|
| 84 | termMap = null; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | @Override |
|---|
| 89 | protected void setDefaultTerms(TermVocabulary<PreservationMethod> termVocabulary){ |
|---|
| 90 | termMap = new HashMap<UUID, PreservationMethod>(); |
|---|
| 91 | for (PreservationMethod term : termVocabulary.getTerms()){ |
|---|
| 92 | termMap.put(term.getUuid(), term); |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | } |
|---|