Revision 93ad7e54
Added by Andreas Müller over 4 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/OriginalSourceBase.java | ||
---|---|---|
19 | 19 |
import javax.persistence.Inheritance; |
20 | 20 |
import javax.persistence.InheritanceType; |
21 | 21 |
import javax.persistence.OneToMany; |
22 |
import javax.persistence.OneToOne; |
|
22 | 23 |
import javax.persistence.Table; |
23 | 24 |
import javax.validation.constraints.NotNull; |
24 | 25 |
import javax.xml.bind.annotation.XmlAccessType; |
... | ... | |
26 | 27 |
import javax.xml.bind.annotation.XmlAttribute; |
27 | 28 |
import javax.xml.bind.annotation.XmlElement; |
28 | 29 |
import javax.xml.bind.annotation.XmlElementWrapper; |
30 |
import javax.xml.bind.annotation.XmlIDREF; |
|
29 | 31 |
import javax.xml.bind.annotation.XmlRootElement; |
32 |
import javax.xml.bind.annotation.XmlSchemaType; |
|
30 | 33 |
import javax.xml.bind.annotation.XmlType; |
31 | 34 |
|
32 | 35 |
import org.apache.commons.lang.StringUtils; |
... | ... | |
57 | 60 |
"type", |
58 | 61 |
"idInSource", |
59 | 62 |
"idNamespace", |
63 |
"cdmSource", |
|
60 | 64 |
"links" |
61 | 65 |
}) |
62 | 66 |
@XmlRootElement(name = "OriginalSource") |
... | ... | |
66 | 70 |
@Table(name="OriginalSourceBase") |
67 | 71 |
public abstract class OriginalSourceBase<T extends ISourceable> |
68 | 72 |
extends ReferencedEntityBase |
69 |
implements IOriginalSource<T>, IIntextReferenceTarget,Cloneable {
|
|
73 |
implements IOriginalSource<T>, IIntextReferenceTarget { |
|
70 | 74 |
|
71 | 75 |
private static final long serialVersionUID = -1972959999261181462L; |
72 | 76 |
@SuppressWarnings("unused") |
... | ... | |
93 | 97 |
@XmlElement(name = "IdNamespace") |
94 | 98 |
private String idNamespace; |
95 | 99 |
|
100 |
@XmlElement(name = "CdmSource") |
|
101 |
@XmlIDREF |
|
102 |
@XmlSchemaType(name = "IDREF") |
|
103 |
@OneToOne(fetch = FetchType.LAZY) |
|
104 |
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE}) |
|
105 |
private CdmLinkSource cdmSource; |
|
106 |
|
|
96 | 107 |
@XmlElementWrapper(name = "Links", nillable = true) |
97 | 108 |
@XmlElement(name = "Link") |
98 | 109 |
@OneToMany(fetch=FetchType.LAZY, orphanRemoval=true) |
... | ... | |
151 | 162 |
this.type = type; |
152 | 163 |
} |
153 | 164 |
|
165 |
@Override |
|
166 |
public CdmLinkSource getCdmSource() { |
|
167 |
return cdmSource; |
|
168 |
} |
|
169 |
@Override |
|
170 |
public void setCdmSource(CdmLinkSource cdmSource) { |
|
171 |
this.cdmSource = cdmSource; |
|
172 |
} |
|
173 |
@Override |
|
174 |
public void setCdmSource(ICdmTarget cdmTarget){ |
|
175 |
if (cdmTarget != null){ |
|
176 |
this.cdmSource = CdmLinkSource.NewInstance(cdmTarget); |
|
177 |
}else{ |
|
178 |
this.cdmSource = null; |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
154 | 182 |
//********************** External Links ********************************************** |
155 | 183 |
|
184 |
|
|
156 | 185 |
public Set<ExternalLink> getLinks(){ |
157 | 186 |
return this.links; |
158 | 187 |
} |
... | ... | |
182 | 211 |
result.addLink((ExternalLink)link.clone()); |
183 | 212 |
} |
184 | 213 |
|
214 |
if (this.cdmSource != null){ |
|
215 |
result.setCdmSource((CdmLinkSource)this.cdmSource.clone()); |
|
216 |
} |
|
217 |
|
|
185 | 218 |
//no changes to: idInSource |
186 | 219 |
return result; |
187 | 220 |
} |
... | ... | |
190 | 223 |
//************************ toString ***************************************/ |
191 | 224 |
@Override |
192 | 225 |
public String toString(){ |
193 |
if (StringUtils.isNotBlank(idInSource) || StringUtils.isNotBlank(idNamespace) ){
|
|
226 |
if (isNotBlank(idInSource) || isNotBlank(idNamespace) ){
|
|
194 | 227 |
return "OriginalSource:" + CdmUtils.concat(":", idNamespace, idInSource); |
195 | 228 |
}else{ |
196 | 229 |
return super.toString(); |
... | ... | |
199 | 232 |
|
200 | 233 |
//*********************************** EQUALS *********************************************************/ |
201 | 234 |
|
202 |
/** |
|
203 |
* {@inheritDoc} |
|
204 |
*/ |
|
205 | 235 |
@Override |
206 | 236 |
public boolean equalsByShallowCompare(ReferencedEntityBase other) { |
207 | 237 |
|
Also available in: Unified diff
fix #8673 Add CdmLinkSource to OriginalSourceBase