1 |
1c313fd1
|
Andreas Müller
|
/**
|
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 |
951c829f
|
Andreas Müller
|
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 |
1c313fd1
|
Andreas Müller
|
import org.apache.log4j.Logger;
|
23 |
951c829f
|
Andreas Müller
|
import org.hibernate.envers.Audited;
|
24 |
|
|
|
25 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
26 |
1c313fd1
|
Andreas Müller
|
|
27 |
|
|
/**
|
28 |
951c829f
|
Andreas Müller
|
* Class which creates a relation between 2 {@link DefinedTermBase defined terms}.
|
29 |
1c313fd1
|
Andreas Müller
|
*
|
30 |
951c829f
|
Andreas Müller
|
* @author a.mueller
|
31 |
|
|
* @since 06.03.2019
|
32 |
1c313fd1
|
Andreas Müller
|
*/
|
33 |
951c829f
|
Andreas Müller
|
@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 |
11df83d8
|
Andreas Müller
|
extends TermRelationBase<T, TermRelation<T>, TermGraph<T>> {
|
42 |
1c313fd1
|
Andreas Müller
|
|
43 |
|
|
private static final long serialVersionUID = -7835146268318871033L;
|
44 |
|
|
|
45 |
|
|
@SuppressWarnings("unused")
|
46 |
|
|
private static final Logger logger = Logger.getLogger(TermRelation.class);
|
47 |
|
|
|
48 |
|
|
|
49 |
951c829f
|
Andreas Müller
|
@XmlElement(name = "ToTerm")
|
50 |
|
|
@XmlIDREF
|
51 |
|
|
@XmlSchemaType(name = "IDREF")
|
52 |
|
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity=DefinedTermBase.class)
|
53 |
|
|
private T toTerm;
|
54 |
|
|
|
55 |
1c313fd1
|
Andreas Müller
|
// ******************** CONSTRUCTOR ***************************************/
|
56 |
|
|
|
57 |
|
|
protected TermRelation(){}
|
58 |
|
|
|
59 |
951c829f
|
Andreas Müller
|
//** ********************** 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 |
1c313fd1
|
Andreas Müller
|
|
73 |
951c829f
|
Andreas Müller
|
// ********************** CLONE **************************//
|
74 |
1c313fd1
|
Andreas Müller
|
|
75 |
951c829f
|
Andreas Müller
|
@Override
|
76 |
ee0b6690
|
Andreas Müller
|
public TermRelation<T> clone() throws CloneNotSupportedException{
|
77 |
|
|
TermRelation<T> result = (TermRelation<T>)super.clone();
|
78 |
951c829f
|
Andreas Müller
|
return result;
|
79 |
|
|
}
|
80 |
1c313fd1
|
Andreas Müller
|
}
|