Project

General

Profile

Download (6.46 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.DefinedTerm;
27
import eu.etaxonomy.cdm.model.common.Language;
28
import eu.etaxonomy.cdm.model.common.TermType;
29

    
30
/**
31
 * A subclass of the Feature class that is meant for handling
32
 * Features/Characters for descriptions in the narrow sense of describing
33
 * an object.
34
 *
35
 * @author a.mueller
36
 * @since 04.05.2017
37
 */
38

    
39
@XmlAccessorType(XmlAccessType.PROPERTY)
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 FeatureNode 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 FeatureNode property;
78

    
79
    //#8120
80
    /**
81
     * @deprecated experimental, may be removed in future
82
     */
83
    @Deprecated
84
    @XmlElement(name = "PropertyModifier")
85
    @XmlIDREF
86
    @XmlSchemaType(name = "IDREF")
87
    @ManyToOne(fetch = FetchType.LAZY)
88
    @IndexedEmbedded
89
    private DefinedTerm propertyModifier;
90

    
91
/* ***************** CONSTRUCTOR AND FACTORY METHODS **********************************/
92

    
93

    
94

    
95

    
96
    public static Character NewInstance() {
97
        return new Character();
98
    }
99

    
100

    
101
    /**
102
     * Class constructor: creates a new character instance associated with
103
     * the given structure and property node
104
     *
105
     * @param structure The structure feature node for this character
106
     * @param property The property feature node for this character
107
     * @see #Feature()
108
     */
109
    public static Character NewInstance(FeatureNode structure, FeatureNode property){
110
        return new Character(structure, property, null, null, null);
111
    }
112

    
113

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

    
136

    
137
    //for hibernate use only
138
    @Deprecated
139
    protected Character() {
140
        super();
141
        this.setTermType(TermType.Character);
142
    }
143

    
144

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

    
170
 // ****************** GETTER / SETTER *********************************************/
171

    
172
    public FeatureNode getStructure() {
173
        return structure;
174
    }
175
    public void setStructure(FeatureNode structure) {
176
        this.structure = structure;
177
    }
178

    
179
    public FeatureNode getProperty() {
180
        return property;
181
    }
182
    public void setProperty(FeatureNode property) {
183
        this.property = property;
184
    }
185

    
186
    public DefinedTerm getStructureModifier() {
187
        return structureModifier;
188
    }
189
    public void setStructureModifier(DefinedTerm structureModifier) {
190
        this.structureModifier = structureModifier;
191
    }
192

    
193
    /**
194
     * @return
195
     * @deprecated experimental, may be removed in future
196
     */
197
    @Deprecated
198
    public DefinedTerm getPropertyModifier() {
199
        return propertyModifier;
200
    }
201
    /**
202
     * @param propertyModifier
203
     * @deprecated experimental, may be removed in future
204
     */
205
    @Deprecated
206
    public void setPropertyModifier(DefinedTerm propertyModifier) {
207
        this.propertyModifier = propertyModifier;
208
    }
209

    
210
}
(2-2/37)