Revision 5fd4238e
Added by Andreas Müller almost 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceBase.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.model.common; |
11 | 11 |
|
12 | 12 |
|
13 |
import java.util.HashSet; |
|
14 |
import java.util.Set; |
|
15 |
|
|
13 | 16 |
import javax.persistence.Column; |
14 | 17 |
import javax.persistence.Entity; |
18 |
import javax.persistence.FetchType; |
|
15 | 19 |
import javax.persistence.Inheritance; |
16 | 20 |
import javax.persistence.InheritanceType; |
21 |
import javax.persistence.OneToMany; |
|
17 | 22 |
import javax.validation.constraints.NotNull; |
18 | 23 |
import javax.xml.bind.annotation.XmlAccessType; |
19 | 24 |
import javax.xml.bind.annotation.XmlAccessorType; |
20 | 25 |
import javax.xml.bind.annotation.XmlAttribute; |
21 | 26 |
import javax.xml.bind.annotation.XmlElement; |
27 |
import javax.xml.bind.annotation.XmlElementWrapper; |
|
22 | 28 |
import javax.xml.bind.annotation.XmlRootElement; |
23 | 29 |
import javax.xml.bind.annotation.XmlType; |
24 | 30 |
|
25 | 31 |
import org.apache.commons.lang.StringUtils; |
26 | 32 |
import org.apache.log4j.Logger; |
33 |
import org.hibernate.annotations.Cascade; |
|
34 |
import org.hibernate.annotations.CascadeType; |
|
27 | 35 |
import org.hibernate.annotations.Table; |
28 | 36 |
import org.hibernate.annotations.Type; |
29 | 37 |
import org.hibernate.envers.Audited; |
30 | 38 |
import org.springframework.util.Assert; |
31 | 39 |
|
32 | 40 |
import eu.etaxonomy.cdm.common.CdmUtils; |
41 |
import eu.etaxonomy.cdm.model.media.ExternalLink; |
|
42 |
import eu.etaxonomy.cdm.strategy.merge.Merge; |
|
43 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|
33 | 44 |
|
34 | 45 |
/** |
35 | 46 |
* Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}. |
... | ... | |
78 | 89 |
@XmlElement(name = "IdNamespace") |
79 | 90 |
private String idNamespace; |
80 | 91 |
|
92 |
@XmlElementWrapper(name = "Links", nillable = true) |
|
93 |
@XmlElement(name = "Link") |
|
94 |
@OneToMany(fetch=FetchType.LAZY, orphanRemoval=true) |
|
95 |
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE}) |
|
96 |
@Merge(MergeMode.ADD_CLONE) |
|
97 |
private Set<ExternalLink> links = new HashSet<>(); |
|
98 |
|
|
81 | 99 |
//***************** CONSTRUCTOR ***********************/ |
82 | 100 |
|
83 | 101 |
//for hibernate use only |
... | ... | |
129 | 147 |
this.type = type; |
130 | 148 |
} |
131 | 149 |
|
150 |
//********************** External Links ********************************************** |
|
151 |
|
|
152 |
public Set<ExternalLink> getLinks(){ |
|
153 |
return this.links; |
|
154 |
} |
|
155 |
public void addLink(ExternalLink link){ |
|
156 |
if (link != null){ |
|
157 |
links.add(link); |
|
158 |
} |
|
159 |
} |
|
160 |
public void removeLink(ExternalLink link){ |
|
161 |
if(links.contains(link)) { |
|
162 |
links.remove(link); |
|
163 |
} |
|
164 |
} |
|
132 | 165 |
|
133 | 166 |
//********************** CLONE ************************************************/ |
134 | 167 |
|
Also available in: Unified diff
ref #6588 add externalLink to OriginalSource