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 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
|
|
25
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
26
|
|
27
|
/**
|
28
|
* Class which creates a relation between 2 {@link DefinedTermBase defined terms}.
|
29
|
*
|
30
|
* @author a.mueller
|
31
|
* @since 06.03.2019
|
32
|
*/
|
33
|
@XmlAccessorType(XmlAccessType.FIELD)
|
34
|
@XmlType(name = "TermRelation", propOrder = {
|
35
|
"toTerm",
|
36
|
})
|
37
|
@XmlRootElement(name = "TermRelation")
|
38
|
@Entity
|
39
|
@Audited
|
40
|
public abstract class TermRelation<T extends DefinedTermBase>
|
41
|
extends TermRelationBase<T, TermRelation<T>, TermGraph<T>> {
|
42
|
|
43
|
private static final long serialVersionUID = -7835146268318871033L;
|
44
|
|
45
|
@SuppressWarnings("unused")
|
46
|
private static final Logger logger = Logger.getLogger(TermRelation.class);
|
47
|
|
48
|
|
49
|
@XmlElement(name = "ToTerm")
|
50
|
@XmlIDREF
|
51
|
@XmlSchemaType(name = "IDREF")
|
52
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity=DefinedTermBase.class)
|
53
|
private T toTerm;
|
54
|
|
55
|
// ******************** CONSTRUCTOR ***************************************/
|
56
|
|
57
|
protected TermRelation(){}
|
58
|
|
59
|
//** ********************** To Term ******************************/
|
60
|
|
61
|
/**
|
62
|
* Returns the {@link DefinedTermBase term} <i>this</i> term tree node is based on.
|
63
|
*/
|
64
|
public T getToTerm() {
|
65
|
return CdmBase.deproxy(toTerm);
|
66
|
}
|
67
|
|
68
|
public void setToTerm(T toTerm) {
|
69
|
checkTermType(toTerm);
|
70
|
this.toTerm = toTerm;
|
71
|
}
|
72
|
|
73
|
// ********************** CLONE **************************//
|
74
|
|
75
|
@Override
|
76
|
public TermRelation<T> clone() throws CloneNotSupportedException{
|
77
|
TermRelation<T> result = (TermRelation<T>)super.clone();
|
78
|
return result;
|
79
|
}
|
80
|
}
|