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 IOriginalSource
<T
>, Cloneable
{
54 private static final long serialVersionUID
= -1972959999261181462L;
55 @SuppressWarnings("unused")
56 private static final Logger logger
= Logger
.getLogger(OriginalSourceBase
.class);
61 * The {@link OriginalSourceType type} of this source. According to PROV the type has to be thought as
62 * an activity that leads from the source entity to the current entity. It is not a property of the
65 @XmlAttribute(name
="type")
66 @Column(name
="sourceType")
68 private OriginalSourceType type
;
70 //The object's ID in the source, where the alternative string comes from
71 @XmlElement(name
= "IdInSource")
72 private String idInSource
;
74 @XmlElement(name
= "IdNamespace")
75 private String idNamespace
;
77 //***************** CONSTRUCTOR ***********************/
79 //for hibernate use only
80 protected OriginalSourceBase() {
88 protected OriginalSourceBase(OriginalSourceType type
){
89 Assert
.notNull(type
, "OriginalSourceType must not be null");
93 //**************** GETTER / SETTER *******************************/
97 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
99 public String
getIdInSource(){
100 return this.idInSource
;
103 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
105 public void setIdInSource(String idInSource
){
106 this.idInSource
= idInSource
;
111 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
113 public String
getIdNamespace() {
118 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
120 public void setIdNamespace(String idNamespace
) {
121 this.idNamespace
= idNamespace
;
125 public OriginalSourceType
getType() {
129 public void setType(OriginalSourceType type
) {
130 Assert
.notNull(type
, "OriginalSourceType must not be null");
135 //********************** CLONE ************************************************/
138 * @see java.lang.Object#clone()
141 public Object
clone() throws CloneNotSupportedException
{
142 OriginalSourceBase
<?
> result
= (OriginalSourceBase
<?
>)super.clone();
144 //no changes to: idInSource, sourcedObj
149 //************************ toString ***************************************/
151 public String
toString(){
152 if (StringUtils
.isNotBlank(idInSource
) || StringUtils
.isNotBlank(idNamespace
) ){
153 return "OriginalSource:" + CdmUtils
.concat(":", idNamespace
, idInSource
);
155 return super.toString();