Project

General

Profile

Download (31 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.taxon;
11

    
12
import java.util.HashMap;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Map;
16
import java.util.Set;
17
import java.util.UUID;
18

    
19
import javax.persistence.Entity;
20
import javax.xml.bind.annotation.XmlAccessType;
21
import javax.xml.bind.annotation.XmlAccessorType;
22
import javax.xml.bind.annotation.XmlRootElement;
23
import javax.xml.bind.annotation.XmlType;
24

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

    
28
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
29
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
30
import eu.etaxonomy.cdm.model.term.TermType;
31
import eu.etaxonomy.cdm.model.term.TermVocabulary;
32

    
33

    
34
/**
35
 * The class representing categories of {@link TaxonRelationship taxon relationships}
36
 * (like "is congruent to" or "is misapplied name for").
37
 * <P>
38
 * A standard (ordered) list of taxon relationship type instances will be
39
 * automatically created as the project starts. But this class allows to extend
40
 * this standard list by creating new instances of additional taxon
41
 * relationship types if needed.
42
 * <P>
43
 * This class corresponds in part to: <ul>
44
 * <li> TaxonRelationshipTerm according to the TDWG ontology
45
 * <li> RelationshipType according to the TCS
46
 * </ul>
47
 *
48
 * @author m.doering
49
 * @since 08-Nov-2007 13:06:17
50
 */
51
@XmlAccessorType(XmlAccessType.FIELD)
52
@XmlType(name = "TaxonRelationshipType")
53
@XmlRootElement(name = "TaxonRelationshipType")
54
@Entity
55
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
56
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
57
@Audited
58
public class TaxonRelationshipType extends RelationshipTermBase<TaxonRelationshipType> {
59
	private static final long serialVersionUID = 6575652105931691670L;
60
	@SuppressWarnings("unused")
61
	private static final Logger logger = Logger.getLogger(TaxonRelationshipType.class);
62

    
63
	protected static Map<UUID, TaxonRelationshipType> termMap = null;
64

    
65
	private static final UUID uuidTaxonomicallyIncludedIn = UUID.fromString("d13fecdf-eb44-4dd7-9244-26679c05df1c");
66

    
67
	public static final UUID uuidMisappliedNameFor = UUID.fromString("1ed87175-59dd-437e-959e-0d71583d8417");
68
	public static final UUID uuidProParteMisappliedNameFor = UUID.fromString("b59b4bd2-11ff-45d1-bae2-146efdeee206");
69
	public static final UUID uuidPartialMisappliedNameFor = UUID.fromString("859fb615-b0e8-440b-866e-8a19f493cd36");
70
	public static final UUID uuidProParteSynonymFor = UUID.fromString("8a896603-0fa3-44c6-9cd7-df2d8792e577");
71
	public static final UUID uuidPartialSynonymFor = UUID.fromString("9d7a5e56-973c-474c-b6c3-a1cb00833a3c");
72
	private static final UUID uuidInvalidDesignationFor = UUID.fromString("605b1d01-f2b1-4544-b2e0-6f08def3d6ed");
73

    
74
	private static final UUID uuidContradiction = UUID.fromString("a8f03491-2ad6-4fae-a04c-2a4c117a2e9b");
75
	private static final UUID uuidCongruentTo = UUID.fromString("60974c98-64ab-4574-bb5c-c110f6db634d");
76
	private static final UUID uuidIncludes = UUID.fromString("0501c385-cab1-4fbe-b945-fc747419bb13");
77
	private static final UUID uuidOverlaps = UUID.fromString("2046a0fd-4fd6-45a1-b707-2b91547f3ec7");
78
	private static final UUID uuidExcludes = UUID.fromString("4535a63c-4a3f-4d69-9350-7bf02e2c23be");
79
	private static final UUID uuidDoesNotExclude = UUID.fromString("0e5099bb-87c0-400e-abdc-bcfed5b5eece");
80
	private static final UUID uuidDoesNotOverlap = UUID.fromString("ecd2382b-3d94-4169-9dd2-2c4ea1d24605");
81
	private static final UUID uuidNotIncludedIn = UUID.fromString("89dffa4e-e004-4d42-b0d1-ae1827529e43");
82
	private static final UUID uuidNotCongruentTo = UUID.fromString("6c16c33b-cfc5-4a00-92bd-a9f9e448f389");
83

    
84

    
85
	private static final UUID uuidCongruentToOrIncludes = UUID.fromString("b55cb3a2-6e20-4ca3-95bc-12b59d3235b0");
86
	private static final UUID uuidIncludedInOrIncludes = UUID.fromString("c3ed5089-6779-4051-bb24-f5ea0eca80d5");
87
	private static final UUID uuidCongruentIncludedInOrIncludes = UUID.fromString("0170cd83-93ad-43c2-9ad1-7ac879300e2f");
88
	private static final UUID uuidCongruentToOrOverlaps = UUID.fromString("78355cfa-5200-432f-8e00-82b97afad0ed");
89
	private static final UUID uuidIncludesOrOverlaps = UUID.fromString("f1ec567b-3c73-436b-8625-b4fd53588abb");
90

    
91
	private static final UUID uuidCongruentToOrIncludesOrOverlaps = UUID.fromString("2d923b1a-6c0f-414c-ac9b-bbc502e18078");
92
	private static final UUID uuidIncludedInOrIncludesOrOverlaps = UUID.fromString("43466aa9-e431-4f37-8bca-febfd9f63716");
93
	private static final UUID uuidCongruentToOrExcludes = UUID.fromString("758e6cf3-05a0-49ed-9496-d8c4a9fd02ae");
94
	private static final UUID uuidIncludesOrExcludes = UUID.fromString("6ee440bc-fd3d-4da2-ad85-906d35a94731");
95
	private static final UUID uuidCongruentToOrIncludesOrExcludes = UUID.fromString("d5c6953d-aa53-46f8-aafc-ebc6428ad5d0");
96
	private static final UUID uuidIncludedInOrIncludesOrExcludes = UUID.fromString("43d8492c-8bd5-4f38-a633-f1ad910a34dd");
97
	private static final UUID uuidOverlapsOrExcludes = UUID.fromString("623ecdeb-ff1f-471d-a8dc-0d75b2fe8d94");
98
	private static final UUID uuidCongruentToOrOverlapsOrExcludes = UUID.fromString("6fabef72-5264-44f1-bfc0-8e2e141375f2");
99
	private static final UUID uuidIncludesOrOverlapsOrExcludes = UUID.fromString("b7153c89-cc6c-4f8c-bf74-216f10feac46");
100

    
101
	private static final UUID uuidAllRelationships = UUID.fromString("831fcd88-e5c9-49e0-b06e-bbb67d1c05c9");
102

    
103
	private static final UUID uuidUnclear = UUID.fromString("4c48ba25-c1d0-4bdd-9260-c1fa2e42a5d3");
104
    private static final UUID uuidNotYetWorkedOn = UUID.fromString("8d47e59a-790d-428f-8060-01d443519166");
105

    
106
    //currently only used for ERMS import for synonym relationship where the synonym needs to be of class
107
    //Taxon for some reason.
108
    public static final UUID uuidHeterotypicSynonymTaxonRelationship = UUID.fromString("8f1be54b-c693-4d58-ab36-6f389fc9bd1f");
109
    public static final UUID uuidHomotypicSynonymTaxonRelationship = UUID.fromString("bfe114b9-1a25-4199-b8b0-6599eb53ae8a");
110
    public static final UUID uuidSynonymOfTaxonRelationship = UUID.fromString("cc648276-0823-47b1-9deb-fa7c046e4afd");
111

    
112

    
113

    
114
	public static TaxonRelationshipType NewInstance(String term, String label, String labelAbbrev, boolean symmetric, boolean transitive) {
115
		return new TaxonRelationshipType(term, label, labelAbbrev, symmetric, transitive);
116
	}
117

    
118

    
119
//********************************** CONSTRUCTOR *********************************/
120

    
121
  	/**
122
  	 * @deprecated for inner (hibernate) use only
123
  	 */
124
  	@Deprecated
125
  	protected TaxonRelationshipType() {
126
		super(TermType.TaxonRelationshipType);
127
	}
128
	/**
129
	 * Class constructor: creates an additional taxon relationship type
130
	 * instance with a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label,
131
	 * a label abbreviation and the flags indicating whether this new taxon
132
	 * relationship type is symmetric and/or transitive.
133
	 *
134
	 * @param	term  		 the string (in the default language) describing the
135
	 * 						 new taxon relationship type to be created
136
	 * @param	label  		 the string identifying the new taxon relationship
137
	 * 						 type to be created
138
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
139
	 * 						 new taxon relationship type to be created
140
	 * @param	symmetric	 the boolean indicating whether the new taxon
141
	 * 						 relationship type to be created is symmetric
142
	 * @param	transitive	 the boolean indicating whether the new taxon
143
	 * 						 relationship type to be created is transitive
144
	 * @see 				 #TaxonRelationshipType()
145
	 */
146
	private TaxonRelationshipType(String term, String label, String labelAbbrev, boolean symmetric, boolean transitive) {
147
		super(TermType.TaxonRelationshipType, term, label, labelAbbrev, symmetric, transitive);
148
	}
149

    
150

    
151
//************************** METHODS ********************************
152

    
153
	@Override
154
	public void resetTerms(){
155
		termMap = null;
156
	}
157

    
158

    
159
	protected static TaxonRelationshipType getTermByUuid(UUID uuid){
160
	    if (termMap == null || termMap.isEmpty()){
161
            return getTermByClassAndUUID(TaxonRelationshipType.class, uuid);
162
        } else {
163
            return termMap.get(uuid);
164
        }
165
	}
166

    
167
    /**
168
     * <code>true</code> if this relationship type is {@link #isAnyMisappliedName()
169
     * any of the misapplied name relationship types} or an
170
     * {@link #INVALID_DESIGNATION_FOR() invalid designation}
171
     *
172
     * @see #isAnyMisappliedName()()
173
     */
174
	public boolean isMisappliedNameOrInvalidDesignation(){
175
        if (this.isAnyMisappliedName()){
176
            return true;
177
        }else if (isInvalidDesignation()){
178
            return true;
179
        }
180
        return false;
181
    }
182

    
183
    /**
184
     * <code>true</code> if this relationship type is an
185
     * {@link #INVALID_DESIGNATION_FOR() invalid designation}
186
     *
187
     * @see #isAnyMisappliedName()()
188
     */
189
    public boolean isInvalidDesignation(){
190
        if (this.equals(INVALID_DESIGNATION_FOR())){
191
            return true;
192
        }
193
        return false;
194
    }
195

    
196
    /**
197
     * <code>true</code> if this relationship type is any
198
     * of the misapplied name relationships such as
199
     * {@link #MISAPPLIED_NAME_FOR()} or {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()}
200
     *
201
     * @see #isMisappliedNameOrInvalidDesignation()
202
     */
203
    public boolean isAnyMisappliedName(){
204
        return (allMisappliedNameTypes().contains(this));
205
    }
206

    
207

    
208
    /**
209
     * <code>true</code> if this relationship type is any
210
     * of the pro parte or partial synonym relationship types
211
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PARTIAL_SYNONYM_FOR()}
212
     *
213
     * @see #isAnyMisappliedName()
214
     */
215
    public boolean isAnySynonym(){
216
        return (allSynonymTypes().contains(this));
217
    }
218

    
219
    /**
220
     * <code>true</code> if this relationship type is either
221
     * a pro parte synonym or a pro parte misapplied name relationship type
222
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PRO_PARTE_MISAPPLIED_NAME_FOR}
223
     */
224
    public boolean isProParte(){
225
        return (allProParteTypes().contains(this));
226
    }
227

    
228
    /**
229
     * <code>true</code> if this relationship type is either
230
     * a partial synonym or a partial misapplied name relationship type
231
     * {@link #PARTIAL_SYNONYM_FOR()} or {@link #PARTIAL_MISAPPLIED_NAME_FOR}
232
     *
233
     * @see #isProParte()
234
     */
235
    public boolean isPartial(){
236
        return (allPartialTypes().contains(this));
237
    }
238

    
239
    /**
240
     * Returns a list of all misapplied name relationship
241
     * types such as "misapplied name for" and
242
     * "pro parte misapplied name for".
243
     *
244
     * @see #MISAPPLIED_NAME_FOR()
245
     * @see #PRO_PARTE_MISAPPLIED_NAME_FOR()
246
     */
247
    public static Set<TaxonRelationshipType> allMisappliedNameTypes(){
248
        Set<TaxonRelationshipType> result = new HashSet<>();
249
        result.add(MISAPPLIED_NAME_FOR());
250
        result.add(PRO_PARTE_MISAPPLIED_NAME_FOR());
251
        result.add(PARTIAL_MISAPPLIED_NAME_FOR());
252
        return result;
253
    }
254

    
255
    public static Set<TaxonRelationshipType> allSynonymTypes(){
256
        Set<TaxonRelationshipType> result = new HashSet<>();
257
        result.add(PRO_PARTE_SYNONYM_FOR());
258
        result.add(PARTIAL_SYNONYM_FOR());
259
        return result;
260
    }
261

    
262
    public static Set<TaxonRelationshipType> allProParteTypes(){
263
        Set<TaxonRelationshipType> result = new HashSet<>();
264
        result.add(PRO_PARTE_SYNONYM_FOR());
265
        result.add(PRO_PARTE_MISAPPLIED_NAME_FOR());
266
        return result;
267
    }
268

    
269
    public static Set<TaxonRelationshipType> allPartialTypes(){
270
        Set<TaxonRelationshipType> result = new HashSet<>();
271
        result.add(PARTIAL_SYNONYM_FOR());
272
        result.add(PARTIAL_MISAPPLIED_NAME_FOR());
273
        return result;
274
    }
275

    
276

    
277
	/**
278
	 * Returns <code>true</code>, if this relationship type is not a <i>misapplied name for<i>
279
	 * and also no <i>taxonomically included in</i> relationship.<BR>
280
	 * It assumes that all other relationships are concept relationships.
281
	 * @return
282
	 */
283
	public boolean isConceptRelationship(){
284
		if (this.isMisappliedNameOrInvalidDesignation()){
285
			return false;
286
        }else if (this.equals(TAXONOMICALLY_INCLUDED_IN())){
287
			return false;
288
		}
289
		return true;
290
	}
291

    
292
	/**
293
	 * Returns the taxon relationship type "is taxonomically included in". This
294
	 * indicates that the {@link TaxonRelationship#getFromTaxon() source taxon}
295
	 * in such a {@link TaxonRelationship taxon relationship} has the target {@link Taxon taxon}
296
	 * as immediate next higher parent within the classification. Generally
297
	 * the {@link Taxon#getSec() concept reference} of both taxa are the same
298
	 * except if the concept reference follows the taxonomical opinion of
299
	 * another reference.<BR>
300
	 * This type is neither symmetric nor transitive.
301
	 * @deprecated will be removed in version 3.0
302
	 */
303
	@Deprecated
304
	public static final TaxonRelationshipType TAXONOMICALLY_INCLUDED_IN(){
305
		return getTermByUuid(uuidTaxonomicallyIncludedIn);
306
	}
307
	/**
308
	 * Returns the taxon relationship type "is misapplied name for". This
309
	 * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name}
310
	 * of the {@link TaxonRelationship#getFromTaxon() source taxon}
311
	 * in such a {@link TaxonRelationship taxon relationship} has been erroneously used by
312
	 * the {@link TaxonBase#getSec() concept reference} to denominate the same real taxon
313
	 * as the one meant by the target {@link Taxon taxon}.<BR>
314
	 * This type is neither symmetric nor transitive.
315
	 */
316
	public static final TaxonRelationshipType MISAPPLIED_NAME_FOR(){
317
		return getTermByUuid(uuidMisappliedNameFor);
318
	}
319
    /**
320
     * Returns the taxon relationship type "is pro parte misapplied name for". This
321
     * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name} of the
322
     * {@link TaxonRelationship#getFromTaxon() source taxon}
323
     * in such a {@link TaxonRelationship taxon relationship} has been erroneously used by
324
     * the {@link TaxonBase#getSec() concept reference} to (partly) denominate the same real taxon
325
     * as the one meant by the target {@link Taxon taxon}. Additionaly another real taxon
326
     * is (partly) denominated by the given name in the concept reference. Therefore it is called
327
     * pro parte. <BR>
328
     * This type is neither symmetric nor transitive.
329
     *
330
     * @see #MISAPPLIED_NAME_FOR()
331
     * @see #PRO_PARTE_SYNONYM_FOR()
332
     */
333
    public static final TaxonRelationshipType PRO_PARTE_MISAPPLIED_NAME_FOR(){
334
        return getTermByUuid(uuidProParteMisappliedNameFor);
335
    }
336
    /**
337
     * Returns the taxon relationship type "is partial misapplied name for". This
338
     * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name} of the
339
     * {@link TaxonRelationship#getFromTaxon() source taxon}
340
     * in such a {@link TaxonRelationship taxon relationship} has been erroneously used by
341
     * the {@link TaxonBase#getSec() concept reference} to (partly) denominate the same real taxon
342
     * as the one meant by the target {@link Taxon taxon}. In contrary to a
343
     * {@link #PRO_PARTE_MISAPPLIED_NAME_FOR() pro parte misapplied name} no other real taxon
344
     * is (partly) demoninated by the given name in the concept reference. Therefore it is called
345
     * partial.<BR>
346
     * This type is neither symmetric nor transitive.
347
     *
348
     * @see #MISAPPLIED_NAME_FOR()
349
     * @see #PRO_PARTE_MISAPPLIED_NAME_FOR()
350
     * @see #PARTIAL_SYNONYM_FOR()
351
     * @see #INCLUDES()
352
     */
353
    public static final TaxonRelationshipType PARTIAL_MISAPPLIED_NAME_FOR(){
354
        return getTermByUuid(uuidPartialMisappliedNameFor);
355
    }
356
    /**
357
     * Returns the taxon relationship type "is pro parte synonym for". This
358
     * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name} of the
359
     * {@link TaxonRelationship#getFromTaxon() source taxon}
360
     * in such a {@link TaxonRelationship taxon relationship} has been used as a
361
     * pro parte synonym.<BR>
362
     * This type is neither symmetric nor transitive.
363
     *
364
     * @see #PRO_PARTE_MISAPPLIED_NAME_FOR()
365
     */
366
    public static final TaxonRelationshipType PRO_PARTE_SYNONYM_FOR(){
367
        return getTermByUuid(uuidProParteSynonymFor);
368
    }
369
    /**
370
     * Returns the taxon relationship type "is partial synonym for". This
371
     * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name} of the
372
     * {@link TaxonRelationship#getFromTaxon() source taxon}
373
     * in such a {@link TaxonRelationship taxon relationship} has been used as a
374
     * partial synonym.<BR>
375
     * This type is neither symmetric nor transitive.
376
     *
377
     * @see #PRO_PARTE_SYNONYM_FOR()
378
     * @see #PARTIAL_MISAPPLIED_NAME_FOR()
379
     */
380
    public static final TaxonRelationshipType PARTIAL_SYNONYM_FOR(){
381
        return getTermByUuid(uuidPartialSynonymFor);
382
    }
383

    
384
	/**
385
	 * Returns the taxon relationship type "is invalid designation for". This
386
	 * indicates that the {@link eu.etaxonomy.cdm.model.name.TaxonName taxon name} of the {@link TaxonRelationship#getFromTaxon() source taxon}
387
	 * in such a {@link TaxonRelationship taxon relationship} has
388
	 * {@link eu.etaxonomy.cdm.model.name.NomenclaturalStatusType#isInvalidType() not been validly published} but was intended to denominate
389
	 * a real taxon which is the same as the one meant by the target {@link Taxon taxon}.<BR>
390
	 * According to the nomenclature codes a not validly published taxon name is
391
	 * not a taxon name at all.<BR>
392
	 * This type is neither symmetric nor transitive.
393
	 */
394
	public static final TaxonRelationshipType INVALID_DESIGNATION_FOR(){
395
		return getTermByUuid(uuidInvalidDesignationFor);
396
	}
397
	/**
398
	 * Returns the (concept) taxon relationship type "is impossible"
399
	 * (contradiction). This is a concept relationship type which means that the
400
	 * circumscriptions (the set of organisms/specimens that belong to a {@link Taxon taxon}
401
	 * according to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
402
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
403
	 * beeing compared. In a concept relationship the concept references of the
404
	 * involved taxa must be distinct. <BR>
405
	 * The "is impossible" (contradiction) taxon relationship type arises
406
	 * logically if two or more incompatible (concept) taxon relationships
407
	 * between the two taxa already exist (for instance with the types
408
	 * "is congruent to" and "excludes").<BR>
409
	 * This type is symmetric but not transitive.
410
	 */
411
	public static final TaxonRelationshipType CONTRADICTION(){
412
		return getTermByUuid(uuidContradiction);
413
	}
414
	/**
415
	 * Returns the (concept) taxon relationship type "is congruent to".
416
	 * This is a concept relationship type which means that the circumscriptions
417
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
418
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
419
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
420
	 * beeing compared. In a concept relationship the concept references of the
421
	 * involved taxa must be distinct. <BR>
422
	 * The "is congruent to" taxon relationship type indicates that the
423
	 * circumscriptions of both taxa involved in the taxon relationship are
424
	 * identical.<BR>
425
	 * This type is symmetric and transitive.
426
	 */
427
	public static final TaxonRelationshipType CONGRUENT_TO(){
428
		return getTermByUuid(uuidCongruentTo);
429
	}
430
	/**
431
	 * Returns the (concept) taxon relationship type "includes".
432
	 * This is a concept relationship type which means that the circumscriptions
433
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
434
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
435
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
436
	 * beeing compared. In a concept relationship the concept references of the
437
	 * involved taxa must be distinct. <BR>
438
	 * The "includes" taxon relationship type indicates that each element
439
	 * belonging to the circumscription of the target taxon involved in the
440
	 * taxon relationship belongs to the circumscription of the source taxon,
441
	 * but that some elements belonging to the circumscription of the source
442
	 * taxon do not belong to the circumscription of the target taxon.<BR>
443
	 * This type is not symmetric but transitive.
444
	 */
445
	public static final TaxonRelationshipType INCLUDES(){
446
		return getTermByUuid(uuidIncludes);
447
	}
448
	/**
449
	 * Returns the (concept) taxon relationship type "overlaps".
450
	 * This is a concept relationship type which means that the circumscriptions
451
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
452
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
453
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
454
	 * beeing compared. In a concept relationship the concept references of the
455
	 * involved taxa must be distinct. <BR>
456
	 * The "overlaps" taxon relationship type indicates that both
457
	 * circumscriptions have common elements but that some elements belonging
458
	 * to the circumscription of the source taxon do not belong to the
459
	 * circumscription of the target taxon and vice-versa.<BR>
460
	 * This type is symmetric but not transitive.
461
	 */
462
	public static final TaxonRelationshipType OVERLAPS(){
463
		return getTermByUuid(uuidOverlaps);
464
	}
465
	/**
466
	 * Returns the (concept) taxon relationship type "excludes".
467
	 * This is a concept relationship type which means that the circumscriptions
468
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
469
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
470
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
471
	 * beeing compared. In a concept relationship the concept references of the
472
	 * involved taxa must be distinct. <BR>
473
	 * The "excludes" taxon relationship type indicates that both
474
	 * circumscriptions have no common elements.<BR>
475
	 * This type is symmetric but not transitive.
476
	 */
477
	public static final TaxonRelationshipType EXCLUDES(){
478
		return getTermByUuid(uuidExcludes);
479
	}
480
	/**
481
	 * Returns the (concept) taxon relationship type "does not exclude".
482
	 * This is a concept relationship type which means that the circumscriptions
483
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
484
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
485
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
486
	 * beeing compared. In a concept relationship the concept references of the
487
	 * involved taxa must be distinct. <BR>
488
	 * The "does not exclude" taxon relationship type indicates that both
489
	 * circumscriptions have common elements. This type is a generalisation of
490
	 * {@link #CONGRUENT_TO() "is congruent to"}, {@link #INCLUDES() "includes"} and {@link #OVERLAPS() "overlaps"}.<BR>
491
	 * This type is symmetric but not transitive.
492
	 *
493
	 * @see		#EXCLUDES()
494
	 */
495
	public static final TaxonRelationshipType DOES_NOT_EXCLUDE(){
496
		return getTermByUuid(uuidDoesNotExclude);
497
	}
498
	/**
499
	 * Returns the (concept) taxon relationship type "does not overlap".
500
	 * This is a concept relationship type which means that the circumscriptions
501
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
502
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
503
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
504
	 * beeing compared. In a concept relationship the concept references of the
505
	 * involved taxa must be distinct. <BR>
506
	 * The "does not overlap" taxon relationship type is a generalisation of
507
	 * {@link #CONGRUENT_TO() "is congruent to"}, {@link #INCLUDES() "includes"} and {@link #EXCLUDES() "excludes"}.<BR>
508
	 * This type is symmetric but not transitive.
509
	 *
510
	 * @see		#OVERLAPS()
511
	 */
512
	public static final TaxonRelationshipType DOES_NOT_OVERLAP(){
513
		return getTermByUuid(uuidDoesNotOverlap);
514
	}
515
	/**
516
	 * Returns the (concept) taxon relationship type "is not included in".
517
	 * This is a concept relationship type which means that the circumscriptions
518
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
519
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
520
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
521
	 * beeing compared. In a concept relationship the concept references of the
522
	 * involved taxa must be distinct. <BR>
523
	 * The "is not included in" taxon relationship type indicates that at least
524
	 * one element belonging to the circumscription of the source taxon involved
525
	 * in the taxon relationship does not belong to the circumscription of the
526
	 * target taxon. <BR>
527
	 * This type is neither symmetric nor transitive.
528
	 *
529
	 * @see		#INCLUDES()
530
	 */
531
	public static final TaxonRelationshipType NOT_INCLUDED_IN(){
532
		return getTermByUuid(uuidNotIncludedIn);
533
	}
534
	/**
535
	 * Returns the (concept) taxon relationship type "is not congruent to".
536
	 * This is a concept relationship type which means that the circumscriptions
537
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
538
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
539
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
540
	 * beeing compared. In a concept relationship the concept references of the
541
	 * involved taxa must be distinct. <BR>
542
	 * The "is not congruent to" taxon relationship type indicates that at least
543
	 * one element belonging to one of both circumscriptions does not belong to
544
	 * the other circumscription. This type is a generalisation of
545
	 * {@link #INCLUDES() "includes"}, {@link #OVERLAPS() "overlaps"} and {@link #EXCLUDES() "excludes"}.<BR>
546
	 * This type is symmetric but not transitive.
547
	 *
548
	 * @see		#CONGRUENT_TO()
549
	 */
550
	public static final TaxonRelationshipType NOT_CONGRUENT_TO(){
551
		return getTermByUuid(uuidNotCongruentTo);
552
	}
553

    
554
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES(){
555
		return getTermByUuid(uuidCongruentToOrIncludes);
556
	}
557
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES(){
558
		return getTermByUuid(uuidIncludedInOrIncludes);
559
	}
560
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDED_OR_INCLUDES(){
561
		return getTermByUuid(uuidCongruentIncludedInOrIncludes);
562
	}
563
	public static final TaxonRelationshipType CONGRUENT_OR_OVERLAPS(){
564
		return getTermByUuid(uuidCongruentToOrOverlaps);
565
	}
566

    
567
	public static final TaxonRelationshipType INCLUDES_OR_OVERLAPS(){
568
		return getTermByUuid(uuidIncludesOrOverlaps);
569
	}
570

    
571
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES_OR_EXCLUDES(){
572
		return getTermByUuid(uuidCongruentToOrIncludesOrExcludes);
573
	}
574

    
575
	public static final TaxonRelationshipType INCLUDES_OR_EXCLUDES(){
576
		return getTermByUuid(uuidIncludesOrExcludes);
577
	}
578

    
579
	public static final TaxonRelationshipType CONGRUENT_OR_EXCLUDES(){
580
		return getTermByUuid(uuidCongruentToOrExcludes);
581
	}
582

    
583
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES_OR_OVERLAPS(){
584
		return getTermByUuid(uuidIncludedInOrIncludesOrOverlaps);
585
	}
586

    
587
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES_OR_OVERLAPS(){
588
		return getTermByUuid(uuidCongruentToOrIncludesOrOverlaps);
589
	}
590

    
591
	public static final TaxonRelationshipType INCLUDES_OR_OVERLAPS_OR_EXCLUDES(){
592
		return getTermByUuid(uuidIncludesOrOverlapsOrExcludes);
593
	}
594

    
595
	public static final TaxonRelationshipType CONGRUENT_OR_OVERLAPS_OR_EXCLUDES(){
596
		return getTermByUuid(uuidCongruentToOrOverlapsOrExcludes);
597
	}
598

    
599
	public static final TaxonRelationshipType OVERLAPS_OR_EXCLUDES(){
600
		return getTermByUuid(uuidOverlapsOrExcludes);
601
	}
602

    
603
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES_OR_EXCLUDES(){
604
		return getTermByUuid(uuidIncludedInOrIncludesOrExcludes);
605
	}
606

    
607
	public static final TaxonRelationshipType UNCLEAR(){
608
	    return getTermByUuid(uuidUnclear);
609
	}
610

    
611
    public static final TaxonRelationshipType NOT_YET_WORKED_ON(){
612
        return getTermByUuid(uuidNotYetWorkedOn);
613
    }
614

    
615

    
616
	@Override
617
    protected void setDefaultTerms(TermVocabulary<TaxonRelationshipType> termVocabulary) {
618
		termMap = new HashMap<>();
619
		for (TaxonRelationshipType term : termVocabulary.getTerms()){
620
			termMap.put(term.getUuid(), term);
621
		}
622
	}
623

    
624
	//TODO other relationshipTypes
625

    
626
	public static final TaxonRelationshipType ALL_RELATIONSHIPS(){
627
		return getTermByUuid(uuidAllRelationships);
628
	}
629

    
630
    @Override
631
    public TaxonRelationshipType readCsvLine(Class<TaxonRelationshipType> termClass, List<String> csvLine, TermType termType,
632
            Map<UUID,DefinedTermBase> terms, boolean abbrevAsId) {
633
        TaxonRelationshipType newInstance = super.readCsvLine(termClass, csvLine, termType, terms, abbrevAsId);
634

    
635
        newInstance.setSymbol(newInstance.getIdInVocabulary());
636
        String inverseLabelAbbrev = csvLine.get(7).trim();
637
        newInstance.setInverseSymbol(inverseLabelAbbrev);
638
        return newInstance;
639
    }
640

    
641
    /**
642
     * @return a set containing all UUIDs of relationship types representing
643
     * a pro parte or partial synonym relationship (e.g.
644
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PARTIAL_SYNONYM_FOR()}
645
     */
646
    public static Set<UUID> proParteOrPartialSynonymUuids() {
647
        Set<UUID> result = new HashSet<>();
648
        result.add(uuidProParteSynonymFor);
649
        result.add(uuidPartialSynonymFor);
650
        return result;
651
    }
652

    
653
    /**
654
     * @return a set containing all UUIDs of relationship types representing
655
     * a misapplied name relationship (e.g. {@link #MISAPPLIED_NAME_FOR()},
656
     * {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()} and {@link #PARTIAL_MISAPPLIED_NAME_FOR()}
657
     */
658
    public static Set<UUID> misappliedNameUuids() {
659
        Set<UUID> result = new HashSet<>();
660
        result.add(uuidMisappliedNameFor);
661
        result.add(uuidProParteMisappliedNameFor);
662
        result.add(uuidPartialMisappliedNameFor);
663
        return result;
664
    }
665

    
666

    
667
    /**
668
     * @return a set containing all UUIDs of relationship types representing
669
     * a partial relationship (e.g. {@link #PARTIAL_SYNONYM_FOR()} and
670
     * {@link #PARTIAL_MISAPPLIED_NAME_FOR()})
671
     */
672
    public static Set<UUID> partialUuids() {
673
        Set<UUID> result = new HashSet<>();
674
        result.add(uuidPartialSynonymFor);
675
        result.add(uuidPartialSynonymFor);
676
        return result;
677
    }
678

    
679
    /**
680
     * @return a set containing all UUIDs of relationship types representing
681
     * a pro parte relationship (e.g. {@link #PRO_PARTE_SYNONYM_FOR()} and
682
     * {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()})
683
     */
684
    public static Set<UUID> proParteUuids() {
685
        Set<UUID> result = new HashSet<>();
686
        result.add(uuidProParteSynonymFor);
687
        result.add(uuidProParteMisappliedNameFor);
688
        return result;
689
    }
690

    
691
    /**
692
     * @return a set containing all UUIDs of relationship types representing
693
     * a pseudo taxon relationship (a synonym relationship expressed as
694
     * taxon relationship as the synonym side for some reason must be
695
     * handled as pseudo accepted taxon, e.g. because factual data
696
     * is attached from an import)
697
     */
698
    public static Set<UUID> pseudoTaxonUuids() {
699
        Set<UUID> result = new HashSet<>();
700
        result.add(uuidHomotypicSynonymTaxonRelationship);
701
        result.add(uuidHeterotypicSynonymTaxonRelationship);
702
        result.add(uuidSynonymOfTaxonRelationship);
703
        return result;
704
    }
705

    
706
}
(19-19/21)