Project

General

Profile

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

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

    
37
@XmlAccessorType(XmlAccessType.PROPERTY)
38
@XmlType(name="Feature", factoryMethod="NewInstance", propOrder = {
39
        "structure",
40
        "property"
41
})
42
@XmlRootElement(name = "Feature")
43
@Entity
44
@Audited
45
public class Character extends Feature {
46

    
47
    private static final long serialVersionUID = -5631282599057455256L;
48
    @SuppressWarnings("unused")
49
    private static final Logger logger = Logger.getLogger(Feature.class);
50

    
51

    
52
    @XmlElement(name = "Structure")
53
    @XmlIDREF
54
    @XmlSchemaType(name = "IDREF")
55
    @ManyToOne(fetch = FetchType.LAZY)
56
    @IndexedEmbedded
57
//    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
58
    private FeatureNode structure;
59

    
60
    @XmlElement(name = "Property")
61
    @XmlIDREF
62
    @XmlSchemaType(name = "IDREF")
63
    @ManyToOne(fetch = FetchType.LAZY)
64
    @IndexedEmbedded
65
//    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
66
    private FeatureNode property;
67

    
68
/* ***************** CONSTRUCTOR AND FACTORY METHODS **********************************/
69

    
70

    
71
    public static Character NewInstance() {
72
        return new Character();
73
    }
74

    
75

    
76
    /**
77
     * Class constructor: creates a new character instance associated with
78
     * the given structure and property node
79
     *
80
     * @param structure The structure feature node for this character
81
     * @param property The property feature node for this character
82
     * @see #Feature()
83
     */
84
    public static Character NewInstance(FeatureNode structure, FeatureNode property){
85
        return new Character(structure, property, null, null, null);
86
    }
87

    
88

    
89
    /**
90
     * Class constructor: creates a new character instance associated with
91
     * the given structure and property node with a description
92
     * (in the {@link Language#DEFAULT() default language}), a label and a label
93
     * abbreviation.
94
     *
95
     * @param structure The structure feature node for this character
96
     * @param property The property feature node for this character
97
     * @param term
98
     *            the string (in the default language) describing the new
99
     *            feature to be created
100
     * @param label
101
     *            the string identifying the new feature to be created
102
     * @param labelAbbrev
103
     *            the string identifying (in abbreviated form) the new feature
104
     *            to be created
105
     * @see #Feature()
106
     */
107
    public static Character NewInstance(FeatureNode structure, FeatureNode property, String term, String label, String labelAbbrev){
108
        return new Character(structure, property, term, label, labelAbbrev);
109
    }
110

    
111

    
112
    //for hibernate use only
113
    @Deprecated
114
    protected Character() {
115
        super();
116
    }
117

    
118

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

    
143
 // ****************** GETTER / SETTER *********************************************/
144

    
145
    public FeatureNode getStructure() {
146
        return structure;
147
    }
148

    
149
    public FeatureNode getProperty() {
150
        return property;
151
    }
152
}
(2-2/37)