Project

General

Profile

Download (30 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

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

    
83

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

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

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

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

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

    
111

    
112

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

    
117

    
118
//********************************** CONSTRUCTOR *********************************/
119

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

    
149

    
150
//************************** METHODS ********************************
151

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

    
157

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

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

    
180
    /**
181
     * <code>true</code> if this relationship type is any
182
     * of the misapplied name relationships such as
183
     * {@link #MISAPPLIED_NAME_FOR()} or {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()}
184
     *
185
     * @see #isMisappliedNameOrInvalidDesignation()
186
     */
187
    public boolean isAnyMisappliedName(){
188
        return (allMisappliedNameTypes().contains(this));
189
    }
190

    
191
    /**
192
     * <code>true</code> if this relationship type is any
193
     * of the {@link #isAnyMisappliedName() misapplied name relationships} or
194
     * any of the {@link #isAnySynonym() (pro parte) synonym relationships}
195
     */
196
    public boolean isAnySynonymOrMisappliedName(){
197
        return (allMisappliedNameTypes().contains(this) || allSynonymTypes().contains(this));
198
    }
199

    
200

    
201
    /**
202
     * <code>true</code> if this relationship type is any
203
     * of the pro parte or partial synonym relationship types
204
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PARTIAL_SYNONYM_FOR()}
205
     *
206
     * @see #isAnyMisappliedName()
207
     */
208
    public boolean isAnySynonym(){
209
        return (allSynonymTypes().contains(this));
210
    }
211

    
212
    /**
213
     * <code>true</code> if this relationship type is either
214
     * a pro parte synonym or a pro parte misapplied name relationship type
215
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PRO_PARTE_MISAPPLIED_NAME_FOR}
216
     */
217
    public boolean isProParte(){
218
        return (allProParteTypes().contains(this));
219
    }
220

    
221
    /**
222
     * <code>true</code> if this relationship type is either
223
     * a partial synonym or a partial misapplied name relationship type
224
     * {@link #PARTIAL_SYNONYM_FOR()} or {@link #PARTIAL_MISAPPLIED_NAME_FOR}
225
     *
226
     * @see #isProParte()
227
     */
228
    public boolean isPartial(){
229
        return (allPartialTypes().contains(this));
230
    }
231

    
232
    /**
233
     * Returns a list of all misapplied name relationship
234
     * types such as "misapplied name for" and
235
     * "pro parte misapplied name for".
236
     *
237
     * @see #MISAPPLIED_NAME_FOR()
238
     * @see #PRO_PARTE_MISAPPLIED_NAME_FOR()
239
     */
240
    public static Set<TaxonRelationshipType> allMisappliedNameTypes(){
241
        Set<TaxonRelationshipType> result = new HashSet<>();
242
        result.add(MISAPPLIED_NAME_FOR());
243
        result.add(PRO_PARTE_MISAPPLIED_NAME_FOR());
244
        result.add(PARTIAL_MISAPPLIED_NAME_FOR());
245
        return result;
246
    }
247

    
248
    public static Set<TaxonRelationshipType> allSynonymTypes(){
249
        Set<TaxonRelationshipType> result = new HashSet<>();
250
        result.add(PRO_PARTE_SYNONYM_FOR());
251
        result.add(PARTIAL_SYNONYM_FOR());
252
        return result;
253
    }
254

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

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

    
269

    
270
	/**
271
	 * Returns <code>true</code>, if this relationship type is not a <i>misapplied name for<i>
272
	 * and also no <i>taxonomically included in</i> relationship.<BR>
273
	 * It assumes that all other relationships are concept relationships.
274
	 * @return
275
	 */
276
	public boolean isConceptRelationship(){
277
		if (this.isMisappliedName()){
278
			return false;
279
        }else if (this.equals(TAXONOMICALLY_INCLUDED_IN())){
280
			return false;
281
		}
282
		return true;
283
	}
284

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

    
377
	/**
378
	 * Returns the (concept) taxon relationship type "is impossible"
379
	 * (contradiction). This is a concept relationship type which means that the
380
	 * circumscriptions (the set of organisms/specimens that belong to a {@link Taxon taxon}
381
	 * according to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
382
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
383
	 * beeing compared. In a concept relationship the concept references of the
384
	 * involved taxa must be distinct. <BR>
385
	 * The "is impossible" (contradiction) taxon relationship type arises
386
	 * logically if two or more incompatible (concept) taxon relationships
387
	 * between the two taxa already exist (for instance with the types
388
	 * "is congruent to" and "excludes").<BR>
389
	 * This type is symmetric but not transitive.
390
	 */
391
	public static final TaxonRelationshipType CONTRADICTION(){
392
		return getTermByUuid(uuidContradiction);
393
	}
394

    
395
	/**
396
	 * Returns the (concept) taxon relationship type "is congruent to".
397
	 * This is a concept relationship type which means that the circumscriptions
398
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
399
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
400
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
401
	 * beeing compared. In a concept relationship the concept references of the
402
	 * involved taxa must be distinct. <BR>
403
	 * The "is congruent to" taxon relationship type indicates that the
404
	 * circumscriptions of both taxa involved in the taxon relationship are
405
	 * identical.<BR>
406
	 * This type is symmetric and transitive.
407
	 */
408
	public static final TaxonRelationshipType CONGRUENT_TO(){
409
		return getTermByUuid(uuidCongruentTo);
410
	}
411

    
412
	/**
413
	 * Returns the (concept) taxon relationship type "includes".
414
	 * This is a concept relationship type which means that the circumscriptions
415
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
416
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
417
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
418
	 * beeing compared. In a concept relationship the concept references of the
419
	 * involved taxa must be distinct. <BR>
420
	 * The "includes" taxon relationship type indicates that each element
421
	 * belonging to the circumscription of the target taxon involved in the
422
	 * taxon relationship belongs to the circumscription of the source taxon,
423
	 * but that some elements belonging to the circumscription of the source
424
	 * taxon do not belong to the circumscription of the target taxon.<BR>
425
	 * This type is not symmetric but transitive.
426
	 */
427
	public static final TaxonRelationshipType INCLUDES(){
428
		return getTermByUuid(uuidIncludes);
429
	}
430

    
431
	/**
432
	 * Returns the (concept) taxon relationship type "overlaps".
433
	 * This is a concept relationship type which means that the circumscriptions
434
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
435
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
436
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
437
	 * beeing compared. In a concept relationship the concept references of the
438
	 * involved taxa must be distinct. <BR>
439
	 * The "overlaps" taxon relationship type indicates that both
440
	 * circumscriptions have common elements but that some elements belonging
441
	 * to the circumscription of the source taxon do not belong to the
442
	 * circumscription of the target taxon and vice-versa.<BR>
443
	 * This type is symmetric but not transitive.
444
	 */
445
	public static final TaxonRelationshipType OVERLAPS(){
446
		return getTermByUuid(uuidOverlaps);
447
	}
448

    
449
	/**
450
	 * Returns the (concept) taxon relationship type "excludes".
451
	 * This is a concept relationship type which means that the circumscriptions
452
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
453
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
454
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
455
	 * beeing compared. In a concept relationship the concept references of the
456
	 * involved taxa must be distinct. <BR>
457
	 * The "excludes" taxon relationship type indicates that both
458
	 * circumscriptions have no common elements.<BR>
459
	 * This type is symmetric but not transitive.
460
	 */
461
	public static final TaxonRelationshipType EXCLUDES(){
462
		return getTermByUuid(uuidExcludes);
463
	}
464

    
465
	/**
466
	 * Returns the (concept) taxon relationship type "does not exclude".
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 "does not exclude" taxon relationship type indicates that both
474
	 * circumscriptions have common elements. This type is a generalisation of
475
	 * {@link #CONGRUENT_TO() "is congruent to"}, {@link #INCLUDES() "includes"} and {@link #OVERLAPS() "overlaps"}.<BR>
476
	 * This type is symmetric but not transitive.
477
	 *
478
	 * @see		#EXCLUDES()
479
	 */
480
	public static final TaxonRelationshipType DOES_NOT_EXCLUDE(){
481
		return getTermByUuid(uuidDoesNotExclude);
482
	}
483
	/**
484
	 * Returns the (concept) taxon relationship type "does not overlap".
485
	 * This is a concept relationship type which means that the circumscriptions
486
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
487
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
488
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
489
	 * beeing compared. In a concept relationship the concept references of the
490
	 * involved taxa must be distinct. <BR>
491
	 * The "does not overlap" taxon relationship type is a generalisation of
492
	 * {@link #CONGRUENT_TO() "is congruent to"}, {@link #INCLUDES() "includes"} and {@link #EXCLUDES() "excludes"}.<BR>
493
	 * This type is symmetric but not transitive.
494
	 *
495
	 * @see		#OVERLAPS()
496
	 */
497
	public static final TaxonRelationshipType DOES_NOT_OVERLAP(){
498
		return getTermByUuid(uuidDoesNotOverlap);
499
	}
500
	/**
501
	 * Returns the (concept) taxon relationship type "is not included in".
502
	 * This is a concept relationship type which means that the circumscriptions
503
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
504
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
505
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
506
	 * beeing compared. In a concept relationship the concept references of the
507
	 * involved taxa must be distinct. <BR>
508
	 * The "is not included in" taxon relationship type indicates that at least
509
	 * one element belonging to the circumscription of the source taxon involved
510
	 * in the taxon relationship does not belong to the circumscription of the
511
	 * target taxon. <BR>
512
	 * This type is neither symmetric nor transitive.
513
	 *
514
	 * @see		#INCLUDES()
515
	 */
516
	public static final TaxonRelationshipType NOT_INCLUDED_IN(){
517
		return getTermByUuid(uuidNotIncludedIn);
518
	}
519
	/**
520
	 * Returns the (concept) taxon relationship type "is not congruent to".
521
	 * This is a concept relationship type which means that the circumscriptions
522
	 * (the set of organisms/specimens that belong to a {@link Taxon taxon} according
523
	 * to the -maybe implicit- opinion of the {@link TaxonBase#getSec() concept reference})
524
	 * of both taxa involved in such a {@link TaxonRelationship taxon relationship} are
525
	 * beeing compared. In a concept relationship the concept references of the
526
	 * involved taxa must be distinct. <BR>
527
	 * The "is not congruent to" taxon relationship type indicates that at least
528
	 * one element belonging to one of both circumscriptions does not belong to
529
	 * the other circumscription. This type is a generalisation of
530
	 * {@link #INCLUDES() "includes"}, {@link #OVERLAPS() "overlaps"} and {@link #EXCLUDES() "excludes"}.<BR>
531
	 * This type is symmetric but not transitive.
532
	 *
533
	 * @see		#CONGRUENT_TO()
534
	 */
535
	public static final TaxonRelationshipType NOT_CONGRUENT_TO(){
536
		return getTermByUuid(uuidNotCongruentTo);
537
	}
538

    
539
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES(){
540
		return getTermByUuid(uuidCongruentToOrIncludes);
541
	}
542
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES(){
543
		return getTermByUuid(uuidIncludedInOrIncludes);
544
	}
545
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDED_OR_INCLUDES(){
546
		return getTermByUuid(uuidCongruentIncludedInOrIncludes);
547
	}
548
	public static final TaxonRelationshipType CONGRUENT_OR_OVERLAPS(){
549
		return getTermByUuid(uuidCongruentToOrOverlaps);
550
	}
551

    
552
	public static final TaxonRelationshipType INCLUDES_OR_OVERLAPS(){
553
		return getTermByUuid(uuidIncludesOrOverlaps);
554
	}
555

    
556
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES_OR_EXCLUDES(){
557
		return getTermByUuid(uuidCongruentToOrIncludesOrExcludes);
558
	}
559

    
560
	public static final TaxonRelationshipType INCLUDES_OR_EXCLUDES(){
561
		return getTermByUuid(uuidIncludesOrExcludes);
562
	}
563

    
564
	public static final TaxonRelationshipType CONGRUENT_OR_EXCLUDES(){
565
		return getTermByUuid(uuidCongruentToOrExcludes);
566
	}
567

    
568
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES_OR_OVERLAPS(){
569
		return getTermByUuid(uuidIncludedInOrIncludesOrOverlaps);
570
	}
571

    
572
	public static final TaxonRelationshipType CONGRUENT_OR_INCLUDES_OR_OVERLAPS(){
573
		return getTermByUuid(uuidCongruentToOrIncludesOrOverlaps);
574
	}
575

    
576
	public static final TaxonRelationshipType INCLUDES_OR_OVERLAPS_OR_EXCLUDES(){
577
		return getTermByUuid(uuidIncludesOrOverlapsOrExcludes);
578
	}
579

    
580
	public static final TaxonRelationshipType CONGRUENT_OR_OVERLAPS_OR_EXCLUDES(){
581
		return getTermByUuid(uuidCongruentToOrOverlapsOrExcludes);
582
	}
583

    
584
	public static final TaxonRelationshipType OVERLAPS_OR_EXCLUDES(){
585
		return getTermByUuid(uuidOverlapsOrExcludes);
586
	}
587

    
588
	public static final TaxonRelationshipType INCLUDED_OR_INCLUDES_OR_EXCLUDES(){
589
		return getTermByUuid(uuidIncludedInOrIncludesOrExcludes);
590
	}
591

    
592
	public static final TaxonRelationshipType UNCLEAR(){
593
	    return getTermByUuid(uuidUnclear);
594
	}
595

    
596
    public static final TaxonRelationshipType NOT_YET_WORKED_ON(){
597
        return getTermByUuid(uuidNotYetWorkedOn);
598
    }
599

    
600

    
601
	@Override
602
    protected void setDefaultTerms(TermVocabulary<TaxonRelationshipType> termVocabulary) {
603
		termMap = new HashMap<>();
604
		for (TaxonRelationshipType term : termVocabulary.getTerms()){
605
			termMap.put(term.getUuid(), term);
606
		}
607
	}
608

    
609
	//TODO other relationshipTypes
610

    
611
	public static final TaxonRelationshipType ALL_RELATIONSHIPS(){
612
		return getTermByUuid(uuidAllRelationships);
613
	}
614

    
615
    @Override
616
    public TaxonRelationshipType readCsvLine(Class<TaxonRelationshipType> termClass, List<String> csvLine, TermType termType,
617
            Map<UUID,DefinedTermBase> terms, boolean abbrevAsId) {
618
        TaxonRelationshipType newInstance = super.readCsvLine(termClass, csvLine, termType, terms, abbrevAsId);
619

    
620
        newInstance.setSymbol(newInstance.getIdInVocabulary());
621
        String inverseLabelAbbrev = csvLine.get(7).trim();
622
        newInstance.setInverseSymbol(inverseLabelAbbrev);
623
        return newInstance;
624
    }
625

    
626
    /**
627
     * @return a set containing all UUIDs of relationship types representing
628
     * a pro parte or partial synonym relationship (e.g.
629
     * {@link #PRO_PARTE_SYNONYM_FOR()} or {@link #PARTIAL_SYNONYM_FOR()}
630
     */
631
    public static Set<UUID> proParteOrPartialSynonymUuids() {
632
        Set<UUID> result = new HashSet<>();
633
        result.add(uuidProParteSynonymFor);
634
        result.add(uuidPartialSynonymFor);
635
        return result;
636
    }
637

    
638
    /**
639
     * @return a set containing all UUIDs of relationship types representing
640
     * a misapplied name relationship (e.g. {@link #MISAPPLIED_NAME_FOR()},
641
     * {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()} and {@link #PARTIAL_MISAPPLIED_NAME_FOR()}
642
     */
643
    public static Set<UUID> misappliedNameUuids() {
644
        Set<UUID> result = new HashSet<>();
645
        result.add(uuidMisappliedNameFor);
646
        result.add(uuidProParteMisappliedNameFor);
647
        result.add(uuidPartialMisappliedNameFor);
648
        return result;
649
    }
650

    
651

    
652
    /**
653
     * @return a set containing all UUIDs of relationship types representing
654
     * a partial relationship (e.g. {@link #PARTIAL_SYNONYM_FOR()} and
655
     * {@link #PARTIAL_MISAPPLIED_NAME_FOR()})
656
     */
657
    public static Set<UUID> partialUuids() {
658
        Set<UUID> result = new HashSet<>();
659
        result.add(uuidPartialSynonymFor);
660
        result.add(uuidPartialSynonymFor);
661
        return result;
662
    }
663

    
664
    /**
665
     * @return a set containing all UUIDs of relationship types representing
666
     * a pro parte relationship (e.g. {@link #PRO_PARTE_SYNONYM_FOR()} and
667
     * {@link #PRO_PARTE_MISAPPLIED_NAME_FOR()})
668
     */
669
    public static Set<UUID> proParteUuids() {
670
        Set<UUID> result = new HashSet<>();
671
        result.add(uuidProParteSynonymFor);
672
        result.add(uuidProParteMisappliedNameFor);
673
        return result;
674
    }
675

    
676
    /**
677
     * @return a set containing all UUIDs of relationship types representing
678
     * a pseudo taxon relationship (a synonym relationship expressed as
679
     * taxon relationship as the synonym side for some reason must be
680
     * handled as pseudo accepted taxon, e.g. because factual data
681
     * is attached from an import)
682
     */
683
    public static Set<UUID> pseudoTaxonUuids() {
684
        Set<UUID> result = new HashSet<>();
685
        result.add(uuidHomotypicSynonymTaxonRelationship);
686
        result.add(uuidHeterotypicSynonymTaxonRelationship);
687
        result.add(uuidSynonymOfTaxonRelationship);
688
        return result;
689
    }
690

    
691
}
(19-19/21)