Project

General

Profile

Download (3.65 KB) Statistics
| Branch: | Tag: | Revision:
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
    @SuppressWarnings("deprecation")
75
    protected TermCollection(){}
76

    
77
    protected TermCollection(TermType type){
78
        super(type);
79
    }
80

    
81
    protected TermCollection(TermType type, String term, String label, String labelAbbrev, Language lang) {
82
        super(type, term, label, labelAbbrev, lang);
83
    }
84

    
85
    protected TermCollection(TermType type, String term, String label, String labelAbbrev) {
86
        super(type, term, label, labelAbbrev, null);
87
    }
88
// ****************** GETTER / SETTER **********************************/
89

    
90
    public boolean isAllowDuplicates() {
91
        return allowDuplicates;
92
    }
93
    public void setAllowDuplicates(boolean allowDuplicates) {
94
        this.allowDuplicates = allowDuplicates;
95
    }
96

    
97
    public boolean isOrderRelevant() {
98
        return orderRelevant;
99
    }
100
    public void setOrderRelevant(boolean orderRelevant) {
101
        this.orderRelevant = orderRelevant;
102
    }
103

    
104
    public boolean isFlat() {
105
        return isFlat;
106
    }
107
    public void setFlat(boolean isFlat) {
108
        this.isFlat = isFlat;
109
    }
110

    
111
    /**
112
     * @Deprecated for use by defined subclasses only
113
     */
114
    @Deprecated
115
    protected Set<REL> termRelations() {
116
        return termRelations;
117
    }
118
    /**
119
     * @Deprecated for use by defined subclasses only
120
     */
121
    @Deprecated
122
    protected void termRelations(Set<REL> termRelations) {
123
        this.termRelations = termRelations;
124
    }
125

    
126
}
(19-19/30)