Project

General

Profile

Revision 4e36de56

ID4e36de564e6a36dbcff9fd761d1c5a8fc0837839
Parent 73a78654
Child abe8cce6

Added by Andreas Müller about 1 year ago

ref #8441 FeatureState classes added and TermNode adapted

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/FeatureState.java
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.description;
10

  
11
import javax.persistence.Entity;
12
import javax.xml.bind.annotation.XmlAccessType;
13
import javax.xml.bind.annotation.XmlAccessorType;
14
import javax.xml.bind.annotation.XmlRootElement;
15
import javax.xml.bind.annotation.XmlType;
16

  
17
import org.apache.log4j.Logger;
18
import org.hibernate.envers.Audited;
19

  
20
import eu.etaxonomy.cdm.model.common.CdmBase;
21
import eu.etaxonomy.cdm.model.term.TermNode;
22

  
23
/**
24
 * A class representing a state for a given feature. As instances of {@link State state}
25
 * are reusable they may represent multiple states in e.g. a given feature tree.
26
 * By handling them as a pair with feature it is expected to be explicit within a certain
27
 * feature tree branch and therefore can be used to define values like {@link TermNode#getInapplicableIf()}
28
 * or {@link TermNode#getOnlyApplicableIf()}.
29
 *
30
 * @author a.mueller
31
 * @since 08.08.2019
32
 */
33
@XmlAccessorType(XmlAccessType.PROPERTY)
34
@XmlType(name="FeatureState", factoryMethod="NewInstance", propOrder = {
35
        "feature",
36
        "state"
37
})
38
@XmlRootElement(name = "FeatureState")
39
@Entity
40
@Audited
41
public class FeatureState extends CdmBase {
42

  
43
    private static final long serialVersionUID = -421832597710084356L;
44
    private static final Logger logger = Logger.getLogger(FeatureState.class);
45

  
46
    private Feature feature;
47

  
48
    private State state;
49
    /* ***************** CONSTRUCTOR AND FACTORY METHODS **********************************/
50

  
51
    public static FeatureState NewInstance() {
52
        return new FeatureState();
53
    }
54

  
55
    public static FeatureState NewInstance(Feature feature, State state){
56
        return new FeatureState(feature, state);
57
    }
58

  
59

  
60
    //for hibernate use only
61
    @Deprecated
62
    protected FeatureState() {}
63

  
64
    protected FeatureState(Feature feature, State state) {
65
        this.feature = feature;
66
        this.state = state;
67
    }
68

  
69

  
70
/* *************************************************************************************/
71

  
72
    public Feature getFeature() {
73
        return feature;
74
    }
75
    public void setFeature(Feature feature) {
76
        this.feature = feature;
77
    }
78

  
79
    public State getState() {
80
        return state;
81
    }
82
    public void setState(State state) {
83
        this.state = state;
84
    }
85

  
86

  
87
//*********************************** CLONE *********************************************************/
88

  
89
    @Override
90
    public Object clone() throws CloneNotSupportedException {
91
        FeatureState result = (FeatureState)super.clone();
92

  
93
        //no changes to: feature, state
94
        return result;
95
    }
96

  
97
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermNode.java
45 45
import eu.etaxonomy.cdm.model.common.ITreeNode;
46 46
import eu.etaxonomy.cdm.model.description.CategoricalData;
47 47
import eu.etaxonomy.cdm.model.description.Feature;
48
import eu.etaxonomy.cdm.model.description.FeatureState;
48 49
import eu.etaxonomy.cdm.model.description.State;
49 50

  
50 51
/**
......
103 104
    //see https://dev.e-taxonomy.eu/trac/ticket/3722
104 105
    private Integer sortIndex;
105 106

  
106
	@XmlElementWrapper(name = "OnlyApplicableIf")
107
	@XmlElementWrapper(name = "OnlyApplicableIf_old")
107 108
	@XmlElement(name = "OnlyApplicableIf")
108 109
	@XmlIDREF
109 110
	@XmlSchemaType(name="IDREF")
110 111
	@ManyToMany(fetch = FetchType.LAZY)
111 112
//	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})  remove cascade #5755
112
	@JoinTable(name="TermNode_DefinedTermBase_OnlyApplicable")
113
	private final Set<State> onlyApplicableIf = new HashSet<>();
113
	@JoinTable(name="TermNode_DefinedTermBase_OnlyApplicable_old")
114
	private final Set<State> onlyApplicableIf_old = new HashSet<>();
114 115

  
115
	@XmlElementWrapper(name = "InapplicableIf")
116
	@XmlElementWrapper(name = "InapplicableIf_old")
116 117
	@XmlElement(name = "InapplicableIf")
117 118
	@XmlIDREF
118 119
	@XmlSchemaType(name="IDREF")
119 120
	@ManyToMany(fetch = FetchType.LAZY)
120 121
//	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})  remove cascade #5755
121
	@JoinTable(name="TermNode_DefinedTermBase_InapplicableIf")
122
	private final Set<State> inapplicableIf = new HashSet<>();
122
	@JoinTable(name="TermNode_DefinedTermBase_InapplicableIf_old")
123
	private final Set<State> inapplicableIf_old = new HashSet<>();
124

  
125
    @XmlElementWrapper(name = "OnlyApplicableIf")
126
    @XmlElement(name = "OnlyApplicableIf")
127
    @XmlIDREF
128
    @XmlSchemaType(name="IDREF")
129
    @ManyToMany(fetch = FetchType.LAZY)
130
    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
131
    private final Set<FeatureState> onlyApplicableIf = new HashSet<>();
132

  
133
    @XmlElementWrapper(name = "InapplicableIf")
134
    @XmlElement(name = "InapplicableIf")
135
    @XmlIDREF
136
    @XmlSchemaType(name="IDREF")
137
    @ManyToMany(fetch = FetchType.LAZY)
138
    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
139
    private final Set<FeatureState> inapplicableIf = new HashSet<>();
123 140

  
124 141
// ***************************** FACTORY *********************************/
125 142

  
......
416 433
	}
417 434

  
418 435
	/**
419
	 * Returns the set of {@link State states} implying rendering the
436
	 * Returns the set of {@link FeatureState feature states} implying rendering the
420 437
	 * concerned {@link Feature feature} applicable.
421 438
	 * If at least one state is present in this set, in a given description
422 439
	 * the {@link Feature feature} in <i>this</i> feature node is inapplicable
......
430 447
	 * @see    #addApplicableState(State)
431 448
	 * @see    #removeApplicableState(State)
432 449
	 */
433
	public Set<State> getOnlyApplicableIf() {
450
	public Set<FeatureState> getOnlyApplicableIf() {
434 451
		return onlyApplicableIf;
435 452
	}
436 453

  
......
442 459
	 * @param applicableState	the applicable state to be added to <i>this</i> feature node
443 460
	 * @see    	   								#getApplicableState()
444 461
	 */
445
	public void addApplicableState(State applicableState) {
462
	public void addApplicableState(FeatureState applicableState) {
446 463
		this.onlyApplicableIf.add(applicableState);
447 464
	}
448 465

  
......
473 490
	 * @see    #addInapplicableState(State)
474 491
	 * @see    #removeInapplicableState(State)
475 492
	 */
476
	public Set<State> getInapplicableIf() {
493
	public Set<FeatureState> getInapplicableIf() {
477 494
		return inapplicableIf;
478 495
	}
479 496

  
......
485 502
	 * @param inapplicableState	the inapplicable state to be added to <i>this</i> feature node
486 503
	 * @see    	   								#getInapplicableState()
487 504
	 */
488
	public void addInapplicableState(State inapplicableState) {
505
	public void addInapplicableState(FeatureState inapplicableState) {
489 506
		this.inapplicableIf.add(inapplicableState);
490 507
	}
491 508

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)