2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.common
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.Transient
;
15 import javax
.xml
.bind
.annotation
.XmlAccessType
;
16 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
17 import javax
.xml
.bind
.annotation
.XmlElement
;
18 import javax
.xml
.bind
.annotation
.XmlRootElement
;
19 import javax
.xml
.bind
.annotation
.XmlTransient
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.apache
.log4j
.Logger
;
25 * Other names/labels/titles (abreviated or not) for the same object (person,
26 * reference, source, etc.)
29 * @created 08-Nov-2007 13:06:22
32 @XmlAccessorType(XmlAccessType
.FIELD
)
33 @XmlType(name
= "OriginalSource", propOrder
= {
37 @XmlRootElement(name
= "OriginalSource")
39 public class OriginalSource
extends ReferencedEntityBase
implements Cloneable
{
41 static Logger logger
= Logger
.getLogger(OriginalSource
.class);
43 //The object's ID in the source, where the alternative string comes from
44 @XmlElement(name
= "IdInSource")
45 private String idInSource
;
47 @XmlElement(name
= "IdNamespace")
48 private String idNamespace
;
51 private IdentifiableEntity sourcedObj
;
57 public static OriginalSource
NewInstance(){
58 return new OriginalSource();
61 public static OriginalSource
NewInstance(String id
){
62 OriginalSource result
= new OriginalSource();
63 result
.setIdInSource(id
);
67 public static OriginalSource
NewInstance(String id
, String idNamespace
){
68 OriginalSource result
= new OriginalSource();
69 result
.setIdInSource(id
);
70 result
.setIdNamespace(idNamespace
);
78 public OriginalSource(){
82 /*************** GETTER /SETTER ************************************/
84 public String
getIdInSource(){
85 return this.idInSource
;
87 public void setIdInSource(String idInSource
){
88 this.idInSource
= idInSource
;
93 * Returns the id namespace. The id namespace is a String that further defines the origin of
94 * the original record. In the combination with the id it should be unique within one a source.
95 * E.g. if a record comes from table ABC and has the id 345, 'ABC' is a suitable namespace and the
96 * combination of 'ABC' and 345 is a unique id for this source.
97 * The namespace is meant to distinguish import records that come from two different tables, elements, objects, ...
98 * and end up in the same CDM class. In this case the id may not be enough to identify the original record.
99 * @return the idNamespace
101 public String
getIdNamespace() {
106 * @param idNamespace the idNamespace to set
108 public void setIdNamespace(String idNamespace
) {
109 this.idNamespace
= idNamespace
;
114 // @Cascade(CascadeType.SAVE_UPDATE)
115 @Transient //beacause IdentifiableEntity is MappedSuperclass
116 public IdentifiableEntity
getSourcedObj() {
119 public void setSourcedObj(IdentifiableEntity sourcedObj
) {
120 this.sourcedObj
= sourcedObj
;
125 //****************** CLONE ************************************************/
128 * @see java.lang.Object#clone()
131 public Object
clone() throws CloneNotSupportedException
{
132 OriginalSource result
= (OriginalSource
)super.clone();
134 //no changes to: idInSource, sourcedObj
139 * Clones this original source and sets the clones sourced object to 'sourceObj'
140 * @see java.lang.Object#clone()
142 public OriginalSource
clone(IdentifiableEntity sourcedObj
) throws CloneNotSupportedException
{
143 OriginalSource result
= (OriginalSource
)clone();
144 result
.setSourcedObj(sourcedObj
);