| 1 | package eu.etaxonomy.cdm.model.description; |
|---|
| 2 | |
|---|
| 3 | import java.util.Map; |
|---|
| 4 | import java.util.UUID; |
|---|
| 5 | |
|---|
| 6 | import javax.persistence.Entity; |
|---|
| 7 | import javax.xml.bind.annotation.XmlAccessType; |
|---|
| 8 | import javax.xml.bind.annotation.XmlAccessorType; |
|---|
| 9 | import javax.xml.bind.annotation.XmlElement; |
|---|
| 10 | import javax.xml.bind.annotation.XmlIDREF; |
|---|
| 11 | import javax.xml.bind.annotation.XmlRootElement; |
|---|
| 12 | import javax.xml.bind.annotation.XmlSchemaType; |
|---|
| 13 | import javax.xml.bind.annotation.XmlType; |
|---|
| 14 | |
|---|
| 15 | import org.apache.log4j.Logger; |
|---|
| 16 | import org.hibernate.envers.Audited; |
|---|
| 17 | import org.hibernate.search.annotations.Indexed; |
|---|
| 18 | |
|---|
| 19 | import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|---|
| 20 | import eu.etaxonomy.cdm.model.common.Language; |
|---|
| 21 | import eu.etaxonomy.cdm.model.common.Representation; |
|---|
| 22 | import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|---|
| 23 | |
|---|
| 24 | @XmlAccessorType(XmlAccessType.PROPERTY) |
|---|
| 25 | @XmlType(name="NaturalLanguageTerm") |
|---|
| 26 | @XmlRootElement(name = "NaturalLanguageTerm") |
|---|
| 27 | @Entity |
|---|
| 28 | @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase") |
|---|
| 29 | @Audited |
|---|
| 30 | public class NaturalLanguageTerm extends DefinedTermBase<NaturalLanguageTerm> { |
|---|
| 31 | private static final long serialVersionUID = 6754598791831848705L; |
|---|
| 32 | @SuppressWarnings("unused") |
|---|
| 33 | private static final Logger logger = Logger.getLogger(NaturalLanguageTerm.class); |
|---|
| 34 | |
|---|
| 35 | protected static Map<UUID, NaturalLanguageTerm> termMap = null; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | private static NaturalLanguageTerm FROM = new NaturalLanguageTerm(); |
|---|
| 39 | private static NaturalLanguageTerm TO = new NaturalLanguageTerm(); |
|---|
| 40 | private static NaturalLanguageTerm UP_TO = new NaturalLanguageTerm(); |
|---|
| 41 | private static NaturalLanguageTerm MOST_FREQUENTLY = new NaturalLanguageTerm(); |
|---|
| 42 | private static NaturalLanguageTerm ON_AVERAGE = new NaturalLanguageTerm(); |
|---|
| 43 | private static NaturalLanguageTerm MORE_OR_LESS = new NaturalLanguageTerm(); |
|---|
| 44 | |
|---|
| 45 | private static final UUID uuidTo = UUID.fromString("9087cdcd-8b08-4082-a1de-34c9ba9fb494"); |
|---|
| 46 | |
|---|
| 47 | @Override |
|---|
| 48 | protected void setDefaultTerms( |
|---|
| 49 | TermVocabulary<NaturalLanguageTerm> termVocabulary) { |
|---|
| 50 | //NaturalLanguageTerm.TO = termVocabulary.findTermByUuid(NaturalLanguageTerm.uuidTo); |
|---|
| 51 | //NaturalLanguageTerm.TO.setLabel("eip"); |
|---|
| 52 | |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | public NaturalLanguageTerm() { |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | public NaturalLanguageTerm(String term, String label, String labelAbbrev) { |
|---|
| 59 | super(term, label, labelAbbrev); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | /* (non-Javadoc) |
|---|
| 64 | * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms() |
|---|
| 65 | */ |
|---|
| 66 | @Override |
|---|
| 67 | public void resetTerms(){ |
|---|
| 68 | termMap = null; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | @XmlElement(name = "KindOf", namespace = "http://etaxonomy.eu/cdm/model/common/1.0") |
|---|
| 73 | @XmlIDREF |
|---|
| 74 | @XmlSchemaType(name = "IDREF") |
|---|
| 75 | @Override |
|---|
| 76 | public NaturalLanguageTerm getKindOf(){ |
|---|
| 77 | return super.getKindOf(); |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | public void setKindOf(NaturalLanguageTerm kindOf){ |
|---|
| 81 | super.setKindOf(kindOf); |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | /** |
|---|
| 85 | * Returns the "from" term. |
|---|
| 86 | */ |
|---|
| 87 | public static final NaturalLanguageTerm FROM(){ |
|---|
| 88 | NaturalLanguageTerm nlt = FROM; |
|---|
| 89 | Representation representation = Representation.NewInstance("", "from", "", Language.ENGLISH()); |
|---|
| 90 | Representation representation2 = Representation.NewInstance("", "de", "", Language.FRENCH()); |
|---|
| 91 | Representation representation3 = Representation.NewInstance("", "von", "", Language.GERMAN()); |
|---|
| 92 | nlt.addRepresentation(representation); |
|---|
| 93 | nlt.addRepresentation(representation2); |
|---|
| 94 | nlt.addRepresentation(representation3); |
|---|
| 95 | return nlt; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | /** |
|---|
| 99 | * Returns the "to" term. |
|---|
| 100 | */ |
|---|
| 101 | public static final NaturalLanguageTerm TO(){ |
|---|
| 102 | NaturalLanguageTerm nlt = TO; |
|---|
| 103 | Representation representation = Representation.NewInstance("", "to", "", Language.ENGLISH()); |
|---|
| 104 | Representation representation2 = Representation.NewInstance("", "�", "", Language.FRENCH()); |
|---|
| 105 | nlt.addRepresentation(representation); |
|---|
| 106 | nlt.addRepresentation(representation2); |
|---|
| 107 | return nlt; |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | public static final NaturalLanguageTerm UP_TO(){ |
|---|
| 111 | NaturalLanguageTerm nlt = UP_TO; |
|---|
| 112 | Representation representation = Representation.NewInstance("", "up to", "", Language.ENGLISH()); |
|---|
| 113 | Representation representation2 = Representation.NewInstance("", "jusqu'�", "", Language.FRENCH()); |
|---|
| 114 | nlt.addRepresentation(representation); |
|---|
| 115 | nlt.addRepresentation(representation2); |
|---|
| 116 | return nlt; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | public static final NaturalLanguageTerm MOST_FREQUENTLY(){ |
|---|
| 120 | NaturalLanguageTerm nlt = MOST_FREQUENTLY; |
|---|
| 121 | Representation representation = Representation.NewInstance("", "most frequently", "", Language.ENGLISH()); |
|---|
| 122 | Representation representation2 = Representation.NewInstance("", "plus fr�quemment", "", Language.FRENCH()); |
|---|
| 123 | nlt.addRepresentation(representation); |
|---|
| 124 | nlt.addRepresentation(representation2); |
|---|
| 125 | return nlt; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | public static final NaturalLanguageTerm ON_AVERAGE(){ |
|---|
| 129 | NaturalLanguageTerm nlt = ON_AVERAGE; |
|---|
| 130 | Representation representation = Representation.NewInstance("", "on average", "", Language.ENGLISH()); |
|---|
| 131 | Representation representation2 = Representation.NewInstance("", "en moyenne", "", Language.FRENCH()); |
|---|
| 132 | nlt.addRepresentation(representation); |
|---|
| 133 | nlt.addRepresentation(representation2); |
|---|
| 134 | return nlt; |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | public static final NaturalLanguageTerm MORE_OR_LESS(){ |
|---|
| 138 | NaturalLanguageTerm nlt = MORE_OR_LESS; |
|---|
| 139 | Representation representation = Representation.NewInstance("", "+/-", "", Language.ENGLISH()); |
|---|
| 140 | nlt.addRepresentation(representation); |
|---|
| 141 | return nlt; |
|---|
| 142 | } |
|---|
| 143 | } |
|---|