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
.Column
;
14 import javax
.persistence
.Entity
;
15 import javax
.persistence
.Inheritance
;
16 import javax
.persistence
.InheritanceType
;
17 import javax
.validation
.constraints
.NotNull
;
18 import javax
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlAttribute
;
21 import javax
.xml
.bind
.annotation
.XmlElement
;
22 import javax
.xml
.bind
.annotation
.XmlRootElement
;
23 import javax
.xml
.bind
.annotation
.XmlType
;
25 import org
.apache
.commons
.lang
.StringUtils
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Table
;
28 import org
.hibernate
.envers
.Audited
;
29 import org
.springframework
.util
.Assert
;
31 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
34 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
35 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
39 * @created 08-Nov-2007 13:06:22
42 @XmlAccessorType(XmlAccessType
.FIELD
)
43 @XmlType(name
= "OriginalSource", propOrder
= {
48 @XmlRootElement(name
= "OriginalSource")
51 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
52 @Table(appliesTo
="OriginalSourceBase")
53 public abstract class OriginalSourceBase
<T
extends ISourceable
> extends ReferencedEntityBase
implements Cloneable
, IOriginalSource
<T
> {
54 private static final long serialVersionUID
= -1972959999261181462L;
55 @SuppressWarnings("unused")
56 private static final Logger logger
= Logger
.getLogger(OriginalSourceBase
.class);
59 @XmlAttribute(name
="type")
60 @Column(name
="refType")
62 private OriginalSourceType type
;
64 //The object's ID in the source, where the alternative string comes from
65 @XmlElement(name
= "IdInSource")
66 private String idInSource
;
68 @XmlElement(name
= "IdNamespace")
69 private String idNamespace
;
71 //***************** CONSTRUCTOR ***********************/
77 protected OriginalSourceBase(OriginalSourceType type
){
78 Assert
.notNull(type
, "OriginalSourceType must not be null");
81 //**************** GETTER / SETTER *******************************/
84 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
86 public String
getIdInSource(){
87 return this.idInSource
;
90 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
92 public void setIdInSource(String idInSource
){
93 this.idInSource
= idInSource
;
98 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
100 public String
getIdNamespace() {
105 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
107 public void setIdNamespace(String idNamespace
) {
108 this.idNamespace
= idNamespace
;
112 public OriginalSourceType
getType() {
116 public void setType(OriginalSourceType type
) {
117 Assert
.notNull(type
, "OriginalSourceType must not be null");
122 //********************** CLONE ************************************************/
125 * @see java.lang.Object#clone()
128 public Object
clone() throws CloneNotSupportedException
{
129 OriginalSourceBase
<?
> result
= (OriginalSourceBase
<?
>)super.clone();
131 //no changes to: idInSource, sourcedObj
136 //************************ toString ***************************************/
138 public String
toString(){
139 if (StringUtils
.isNotBlank(idInSource
) || StringUtils
.isNotBlank(idNamespace
) ){
140 return "OriginalSource:" + CdmUtils
.concat(":", idNamespace
, idInSource
);
142 return super.toString();