1
|
/**
|
2
|
* Copyright (C) 2019 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
|
package eu.etaxonomy.cdm.model.term;
|
10
|
|
11
|
import java.util.HashSet;
|
12
|
import java.util.Set;
|
13
|
|
14
|
import javax.persistence.Entity;
|
15
|
import javax.persistence.FetchType;
|
16
|
import javax.persistence.Inheritance;
|
17
|
import javax.persistence.InheritanceType;
|
18
|
import javax.persistence.OneToMany;
|
19
|
import javax.persistence.Table;
|
20
|
import javax.xml.bind.annotation.XmlAccessType;
|
21
|
import javax.xml.bind.annotation.XmlAccessorType;
|
22
|
import javax.xml.bind.annotation.XmlElement;
|
23
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
24
|
import javax.xml.bind.annotation.XmlIDREF;
|
25
|
import javax.xml.bind.annotation.XmlSchemaType;
|
26
|
import javax.xml.bind.annotation.XmlType;
|
27
|
|
28
|
import org.hibernate.annotations.Cascade;
|
29
|
import org.hibernate.annotations.CascadeType;
|
30
|
import org.hibernate.envers.Audited;
|
31
|
import org.hibernate.search.annotations.IndexedEmbedded;
|
32
|
|
33
|
import eu.etaxonomy.cdm.model.common.Language;
|
34
|
|
35
|
/**
|
36
|
* @author a.mueller
|
37
|
* @since 06.03.2019
|
38
|
*/
|
39
|
@XmlAccessorType(XmlAccessType.FIELD)
|
40
|
@XmlType(name = "TermCollection", propOrder = {
|
41
|
"termRelations",
|
42
|
"allowDuplicates",
|
43
|
"orderRelevant",
|
44
|
"isFlat"
|
45
|
})
|
46
|
@Entity
|
47
|
@Audited
|
48
|
@Table(name="TermCollection")
|
49
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
50
|
public abstract class TermCollection<TERM extends DefinedTermBase, REL extends TermRelationBase>
|
51
|
extends TermBase{
|
52
|
|
53
|
private static final long serialVersionUID = 6102175902060054329L;
|
54
|
|
55
|
@XmlElementWrapper(name = "TermRelations")
|
56
|
@XmlElement(name = "TermRelation")
|
57
|
@XmlIDREF
|
58
|
@XmlSchemaType(name = "IDREF")
|
59
|
@OneToMany(mappedBy="graph", fetch=FetchType.LAZY, targetEntity = TermRelationBase.class)
|
60
|
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
|
61
|
@IndexedEmbedded(depth = 2)
|
62
|
private Set<REL> termRelations = new HashSet<>();
|
63
|
|
64
|
//#7372 indicates if this tree/graph allows duplicated terms/features
|
65
|
private boolean allowDuplicates = false;
|
66
|
|
67
|
private boolean orderRelevant = true;
|
68
|
|
69
|
private boolean isFlat = false;
|
70
|
|
71
|
|
72
|
//*************************** CONSTRUCTOR *************************************/
|
73
|
|
74
|
//for hibernate use only, *packet* private required by bytebuddy
|
75
|
@Deprecated
|
76
|
TermCollection(){}
|
77
|
|
78
|
protected TermCollection(TermType type){
|
79
|
super(type);
|
80
|
}
|
81
|
|
82
|
protected TermCollection(TermType type, String term, String label, String labelAbbrev, Language lang) {
|
83
|
super(type, term, label, labelAbbrev, lang);
|
84
|
}
|
85
|
|
86
|
protected TermCollection(TermType type, String term, String label, String labelAbbrev) {
|
87
|
super(type, term, label, labelAbbrev, null);
|
88
|
}
|
89
|
// ****************** GETTER / SETTER **********************************/
|
90
|
|
91
|
public boolean isAllowDuplicates() {
|
92
|
return allowDuplicates;
|
93
|
}
|
94
|
public void setAllowDuplicates(boolean allowDuplicates) {
|
95
|
this.allowDuplicates = allowDuplicates;
|
96
|
}
|
97
|
|
98
|
public boolean isOrderRelevant() {
|
99
|
return orderRelevant;
|
100
|
}
|
101
|
public void setOrderRelevant(boolean orderRelevant) {
|
102
|
this.orderRelevant = orderRelevant;
|
103
|
}
|
104
|
|
105
|
public boolean isFlat() {
|
106
|
return isFlat;
|
107
|
}
|
108
|
public void setFlat(boolean isFlat) {
|
109
|
this.isFlat = isFlat;
|
110
|
}
|
111
|
|
112
|
/**
|
113
|
* @Deprecated for use by defined subclasses only
|
114
|
*/
|
115
|
@Deprecated
|
116
|
protected Set<REL> termRelations() {
|
117
|
return termRelations;
|
118
|
}
|
119
|
/**
|
120
|
* @Deprecated for use by defined subclasses only
|
121
|
*/
|
122
|
@Deprecated
|
123
|
protected void termRelations(Set<REL> termRelations) {
|
124
|
this.termRelations = termRelations;
|
125
|
}
|
126
|
|
127
|
}
|