1 package eu
.etaxonomy
.cdm
.model
.common
;
3 import java
.util
.HashSet
;
6 import javax
.persistence
.Entity
;
7 import javax
.persistence
.Inheritance
;
8 import javax
.persistence
.InheritanceType
;
9 import javax
.persistence
.MappedSuperclass
;
10 import javax
.persistence
.OneToMany
;
11 import javax
.persistence
.Transient
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.hibernate
.annotations
.Cascade
;
15 import org
.hibernate
.annotations
.CascadeType
;
18 public abstract class RelationshipTermBase
extends OrderedTermBase
{
19 static Logger logger
= Logger
.getLogger(RelationshipTermBase
.class);
21 private boolean symmetric
;
22 private boolean transitive
;
23 private Set
<Representation
> inverseRepresentations
= new HashSet();
25 public RelationshipTermBase() {
28 public RelationshipTermBase(String term
, String label
, boolean symmetric
, boolean transitive
) {
30 setSymmetric(symmetric
);
31 setTransitive(transitive
);
35 public boolean isSymmetric() {
38 public void setSymmetric(boolean symmetric
) {
39 this.symmetric
= symmetric
;
42 public boolean isTransitive() {
45 public void setTransitive(boolean transitive
) {
46 this.transitive
= transitive
;
51 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE
})
52 public Set
<Representation
> getInverseRepresentations() {
53 return inverseRepresentations
;
55 protected void setInverseRepresentations(
56 Set
<Representation
> inverseRepresentations
) {
57 this.inverseRepresentations
= inverseRepresentations
;
59 public void addRepresentation(Representation representation
) {
60 this.inverseRepresentations
.add(representation
);
62 public void removeRepresentation(Representation representation
) {
63 this.inverseRepresentations
.remove(representation
);
67 public Representation
getInverseRepresentation(Language lang
) {
68 Representation result
= null;
69 if (this.isSymmetric()){
70 for (Representation repr
: this.getRepresentations()){
71 if (repr
.getLanguage() == lang
){
76 for (Representation repr
: this.getInverseRepresentations()){
77 if (repr
.getLanguage() == lang
){