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
.annotations
.Type
;
29 import org
.hibernate
.envers
.Audited
;
30 import org
.springframework
.util
.Assert
;
32 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
35 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
36 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
40 * @created 08-Nov-2007 13:06:22
43 @XmlAccessorType(XmlAccessType
.FIELD
)
44 @XmlType(name
= "OriginalSource", propOrder
= {
49 @XmlRootElement(name
= "OriginalSource")
52 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
53 @Table(appliesTo
="OriginalSourceBase")
54 public abstract class OriginalSourceBase
<T
extends ISourceable
> extends ReferencedEntityBase
implements IOriginalSource
<T
>, Cloneable
{
55 private static final long serialVersionUID
= -1972959999261181462L;
56 @SuppressWarnings("unused")
57 private static final Logger logger
= Logger
.getLogger(OriginalSourceBase
.class);
60 * The {@link OriginalSourceType type} of this source. According to PROV the type has to be thought as
61 * an activity that leads from the source entity to the current entity. It is not a property of the
64 @XmlAttribute(name
="type")
65 @Column(name
="sourceType")
67 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
68 parameters
= {@org.hibernate
.annotations
.Parameter(name
="enumClass", value
="eu.etaxonomy.cdm.model.common.OriginalSourceType")}
70 private OriginalSourceType type
;
72 //The object's ID in the source, where the alternative string comes from
73 @XmlElement(name
= "IdInSource")
74 private String idInSource
;
76 @XmlElement(name
= "IdNamespace")
77 private String idNamespace
;
79 //***************** CONSTRUCTOR ***********************/
81 //for hibernate use only
82 protected OriginalSourceBase() {
90 protected OriginalSourceBase(OriginalSourceType type
){
92 throw new IllegalArgumentException("OriginalSourceType must not be null");
97 //**************** GETTER / SETTER *******************************/
101 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
103 public String
getIdInSource(){
104 return this.idInSource
;
107 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
109 public void setIdInSource(String idInSource
){
110 this.idInSource
= idInSource
;
115 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
117 public String
getIdNamespace() {
122 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
124 public void setIdNamespace(String idNamespace
) {
125 this.idNamespace
= idNamespace
;
129 public OriginalSourceType
getType() {
133 public void setType(OriginalSourceType type
) {
134 Assert
.notNull(type
, "OriginalSourceType must not be null");
139 //********************** CLONE ************************************************/
142 * @see java.lang.Object#clone()
145 public Object
clone() throws CloneNotSupportedException
{
146 OriginalSourceBase
<?
> result
= (OriginalSourceBase
<?
>)super.clone();
148 //no changes to: idInSource, sourcedObj
153 //************************ toString ***************************************/
155 public String
toString(){
156 if (StringUtils
.isNotBlank(idInSource
) || StringUtils
.isNotBlank(idNamespace
) ){
157 return "OriginalSource:" + CdmUtils
.concat(":", idNamespace
, idInSource
);
159 return super.toString();