(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameRelationshipType.java
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.name;
11
12
13 import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
14 import eu.etaxonomy.cdm.model.location.Continent;
15
16 import org.apache.log4j.Logger;
17 import java.util.*;
18
19 import javax.persistence.*;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlType;
23
24 /**
25 * http://rs.tdwg.org/ontology/voc/TaxonName.rdf#NomenclaturalNoteTypeTerm
26 * The relationship are to be understood as 'is .... of'. For instance
27 * Linum radiola L. is a replaced synonym of Radiola linoides Roth
28 * or Astragalus rhizanthus Boiss. is a later homonym of
29 * Astragalus rhizanthus Royle.
30 *
31 * @author m.doering
32 * @version 1.0
33 * @created 08-Nov-2007 13:06:38
34 */
35 @XmlAccessorType(XmlAccessType.FIELD)
36 @XmlType(name = "")
37 @Entity
38 public class NameRelationshipType extends RelationshipTermBase<NameRelationshipType> {
39 static Logger logger = Logger.getLogger(NameRelationshipType.class);
40
41 private static final UUID uuidOrthographicVariant = UUID.fromString("eeaea868-c4c1-497f-b9fe-52c9fc4aca53");
42 private static final UUID uuidLaterHomonym = UUID.fromString("80f06f65-58e0-4209-b811-cb40ad7220a6");
43 private static final UUID uuidTreatedAsLaterHomonym = UUID.fromString("2990a884-3302-4c8b-90b2-dfd31aaa2778");
44 private static final UUID uuidAlternativeName = UUID.fromString("049c6358-1094-4765-9fae-c9972a0e7780");
45 private static final UUID uuidBasionym = UUID.fromString("25792738-98de-4762-bac1-8c156faded4a");
46 private static final UUID uuidReplacedSynonym = UUID.fromString("71c67c38-d162-445b-b0c2-7aba56106696");
47 private static final UUID uuidConservedAgainst = UUID.fromString("e6439f95-bcac-4ebb-a8b5-69fa5ce79e6a");
48 private static final UUID uuidValidatedByName = UUID.fromString("a176c9ad-b4c2-4c57-addd-90373f8270eb");
49 private static final UUID uuidLaterValidatedByName = UUID.fromString("a25ee4c1-863a-4dab-9499-290bf9b89639");
50 private static final UUID uuidBlockingNameFor = UUID.fromString("1dab357f-2e12-4511-97a4-e5153589e6a6");
51
52 public NameRelationshipType() {
53 super();
54 }
55
56 public NameRelationshipType(String term, String label, String labelAbbrev, boolean symmetric, boolean transitive) {
57 super(term, label, labelAbbrev, symmetric, transitive);
58 }
59
60
61 public static final NameRelationshipType getByUuid(UUID uuid){
62 return (NameRelationshipType)findByUuid(uuid);
63 }
64
65 @Transient
66 public boolean isInvalidType(){
67 if (this.equals(VALIDATED_BY_NAME()) ||
68 this.equals(LATER_VALIDATED_BY_NAME())
69 ){
70 return true;
71 }else{
72 return false;
73 }
74 }
75
76 @Transient
77 public boolean isLegitimateType(){
78 if (this.equals(BASIONYM()) ||
79 this.equals(REPLACED_SYNONYM()) ||
80 this.equals(ALTERNATIVE_NAME()) ||
81 this.equals(CONSERVED_AGAINST())
82 ){
83 return true;
84 }else{
85 return false;
86 }
87 }
88
89 @Transient
90 public boolean isIllegitimateType(){
91 //TODO: implement isX method. Maybe as persistent class attribute?
92 //TODO: RejectedInFavour,
93 if (this.equals(LATER_HOMONYM()) ||
94 this.equals(TREATED_AS_LATER_HOMONYM())
95 ){
96 return true;
97 }else{
98 return false;
99 }
100 }
101
102
103 public static final NameRelationshipType ORTHOGRAPHIC_VARIANT(){
104 return getByUuid(uuidOrthographicVariant);
105 }
106 public static final NameRelationshipType LATER_HOMONYM(){
107 return getByUuid(uuidLaterHomonym);
108 }
109 public static final NameRelationshipType TREATED_AS_LATER_HOMONYM(){
110 return getByUuid(uuidTreatedAsLaterHomonym);
111 }
112 public static final NameRelationshipType ALTERNATIVE_NAME(){
113 return getByUuid(uuidAlternativeName);
114 }
115 public static final NameRelationshipType BASIONYM(){
116 return getByUuid(uuidBasionym);
117 }
118 public static final NameRelationshipType REPLACED_SYNONYM(){
119 return getByUuid(uuidReplacedSynonym);
120 }
121 public static final NameRelationshipType CONSERVED_AGAINST(){
122 return getByUuid(uuidConservedAgainst);
123 }
124 public static final NameRelationshipType VALIDATED_BY_NAME(){
125 return getByUuid(uuidValidatedByName);
126 }
127 public static final NameRelationshipType LATER_VALIDATED_BY_NAME(){
128 return getByUuid(uuidLaterValidatedByName);
129 }
130 public static final NameRelationshipType BLOCKING_NAME_FOR(){
131 return getByUuid(uuidBlockingNameFor);
132 }
133
134 }