Project

General

Profile

Download (6.93 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.description;
10

    
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
14
import javax.xml.bind.annotation.XmlAccessType;
15
import javax.xml.bind.annotation.XmlAccessorType;
16
import javax.xml.bind.annotation.XmlElement;
17
import javax.xml.bind.annotation.XmlIDREF;
18
import javax.xml.bind.annotation.XmlRootElement;
19
import javax.xml.bind.annotation.XmlSchemaType;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.log4j.Logger;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.IndexedEmbedded;
25

    
26
import eu.etaxonomy.cdm.model.common.Language;
27
import eu.etaxonomy.cdm.model.term.DefinedTerm;
28
import eu.etaxonomy.cdm.model.term.TermNode;
29
import eu.etaxonomy.cdm.model.term.TermType;
30

    
31
/**
32
 * A subclass of the Feature class that is meant for handling
33
 * Features/Characters for descriptions in the narrow sense of describing
34
 * an object.
35
 *
36
 * @author a.mueller
37
 * @since 04.05.2017
38
 */
39
@XmlAccessorType(XmlAccessType.FIELD)
40
@XmlType(name="Feature", factoryMethod="NewInstance", propOrder = {
41
        "structure",
42
        "structureModifier",
43
        "property",
44
        "propertyModifier"
45
})
46
@XmlRootElement(name = "Character")
47
@Entity
48
@Audited
49
public class Character extends Feature {
50

    
51
    private static final long serialVersionUID = -5631282599057455256L;
52
    @SuppressWarnings("unused")
53
    private static final Logger logger = Logger.getLogger(Feature.class);
54

    
55
    @XmlElement(name = "Structure")
56
    @XmlIDREF
57
    @XmlSchemaType(name = "IDREF")
58
    @ManyToOne(fetch = FetchType.LAZY)
59
    @IndexedEmbedded
60
//    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
61
    private TermNode<DefinedTerm> structure;
62

    
63
    //#8120
64
    @XmlElement(name = "StructureModifier")
65
    @XmlIDREF
66
    @XmlSchemaType(name = "IDREF")
67
    @ManyToOne(fetch = FetchType.LAZY)
68
    @IndexedEmbedded
69
    private DefinedTerm structureModifier;
70

    
71
    @XmlElement(name = "Property")
72
    @XmlIDREF
73
    @XmlSchemaType(name = "IDREF")
74
    @ManyToOne(fetch = FetchType.LAZY)
75
    @IndexedEmbedded
76
//    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
77
    private TermNode<DefinedTerm> property;
78

    
79
    //#9507
80
    @XmlElement(name = "RatioToStructure")
81
    @XmlIDREF
82
    @XmlSchemaType(name = "IDREF")
83
    @ManyToOne(fetch = FetchType.LAZY)
84
    @IndexedEmbedded
85
    private TermNode<DefinedTerm> ratioToStructure;
86

    
87
    //#8120
88
    /**
89
     * @deprecated experimental, may be removed in future
90
     */
91
    @Deprecated
92
    @XmlElement(name = "PropertyModifier")
93
    @XmlIDREF
94
    @XmlSchemaType(name = "IDREF")
95
    @ManyToOne(fetch = FetchType.LAZY)
96
    @IndexedEmbedded
97
    private DefinedTerm propertyModifier;
98

    
99
/* ***************** CONSTRUCTOR AND FACTORY METHODS **********************************/
100

    
101

    
102

    
103

    
104
    public static Character NewInstance() {
105
        return new Character();
106
    }
107

    
108

    
109
    /**
110
     * Class constructor: creates a new character instance associated with
111
     * the given structure and property node
112
     *
113
     * @param structure The structure feature node for this character
114
     * @param property The property feature node for this character
115
     * @see #Feature()
116
     */
117
    public static Character NewInstance(TermNode structure, TermNode property){
118
        return new Character(structure, property, null, null, null);
119
    }
120

    
121

    
122
    /**
123
     * Class constructor: creates a new character instance associated with
124
     * the given structure and property node with a description
125
     * (in the {@link Language#DEFAULT() default language}), a label and a label
126
     * abbreviation.
127
     *
128
     * @param structure The structure feature node for this character
129
     * @param property The property feature node for this character
130
     * @param term
131
     *            the string (in the default language) describing the new
132
     *            feature to be created
133
     * @param label
134
     *            the string identifying the new feature to be created
135
     * @param labelAbbrev
136
     *            the string identifying (in abbreviated form) the new feature
137
     *            to be created
138
     * @see #Feature()
139
     */
140
    public static Character NewInstance(TermNode structure, TermNode property, String term, String label, String labelAbbrev){
141
        return new Character(structure, property, term, label, labelAbbrev);
142
    }
143

    
144

    
145
    //for hibernate use only
146
    @Deprecated
147
    protected Character() {
148
        super();
149
        this.setTermType(TermType.Character);
150
    }
151

    
152

    
153
    /**
154
     * Class constructor: creates a new character instance associated with
155
     * the given structure and property node with a description
156
     * (in the {@link Language#DEFAULT() default language}), a label and a label
157
     * abbreviation.
158
     *
159
     * @param structure The structure feature node for this character
160
     * @param property The property feature node for this character
161
     * @param term
162
     *            the string (in the default language) describing the new
163
     *            feature to be created
164
     * @param label
165
     *            the string identifying the new feature to be created
166
     * @param labelAbbrev
167
     *            the string identifying (in abbreviated form) the new feature
168
     *            to be created
169
     * @see #Feature()
170
     */
171
    protected Character(TermNode structure, TermNode property, String term, String label, String labelAbbrev) {
172
        super(term, label, labelAbbrev);
173
        this.setTermType(TermType.Character);
174
        this.structure = structure;
175
        this.property = property;
176
    }
177

    
178
 // ****************** GETTER / SETTER *********************************************/
179

    
180
    public TermNode getStructure() {
181
        return structure;
182
    }
183
    public void setStructure(TermNode structure) {
184
        this.structure = structure;
185
    }
186

    
187
    public TermNode<DefinedTerm> getRatioToStructure() {
188
        return ratioToStructure;
189
    }
190
    public void setRatioToStructure(TermNode<DefinedTerm> ratioToStructure) {
191
        this.ratioToStructure = ratioToStructure;
192
    }
193

    
194
    public TermNode getProperty() {
195
        return property;
196
    }
197
    public void setProperty(TermNode property) {
198
        this.property = property;
199
    }
200

    
201
    public DefinedTerm getStructureModifier() {
202
        return structureModifier;
203
    }
204
    public void setStructureModifier(DefinedTerm structureModifier) {
205
        this.structureModifier = structureModifier;
206
    }
207

    
208
    /**
209
     * @return
210
     * @deprecated experimental, may be removed in future
211
     */
212
    @Deprecated
213
    public DefinedTerm getPropertyModifier() {
214
        return propertyModifier;
215
    }
216
    /**
217
     * @param propertyModifier
218
     * @deprecated experimental, may be removed in future
219
     */
220
    @Deprecated
221
    public void setPropertyModifier(DefinedTerm propertyModifier) {
222
        this.propertyModifier = propertyModifier;
223
    }
224

    
225
}
(2-2/38)