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
;
28 import org
.hibernate
.annotations
.Table
;
29 import org
.hibernate
.annotations
.Type
;
30 import org
.hibernate
.envers
.Audited
;
31 import org
.springframework
.util
.Assert
;
33 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
36 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
37 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
41 * @created 08-Nov-2007 13:06:22
44 @XmlAccessorType(XmlAccessType
.FIELD
)
45 @XmlType(name
= "OriginalSource", propOrder
= {
50 @XmlRootElement(name
= "OriginalSource")
53 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
54 @Table(appliesTo
="OriginalSourceBase")
55 public abstract class OriginalSourceBase
<T
extends ISourceable
> extends ReferencedEntityBase
implements IOriginalSource
<T
>, Cloneable
{
56 private static final long serialVersionUID
= -1972959999261181462L;
57 @SuppressWarnings("unused")
58 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 @Type(type
= "eu.etaxonomy.cdm.hibernate.EnumUserType",
69 parameters
= {@org.hibernate
.annotations
.Parameter(name
="enumClass", value
="eu.etaxonomy.cdm.model.common.OriginalSourceType")}
72 private OriginalSourceType type
;
74 //The object's ID in the source, where the alternative string comes from
75 @XmlElement(name
= "IdInSource")
76 private String idInSource
;
78 @XmlElement(name
= "IdNamespace")
79 private String idNamespace
;
81 //***************** CONSTRUCTOR ***********************/
83 //for hibernate use only
84 protected OriginalSourceBase() {
92 protected OriginalSourceBase(OriginalSourceType type
){
94 throw new IllegalArgumentException("OriginalSourceType must not be null");
99 //**************** GETTER / SETTER *******************************/
103 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
105 public String
getIdInSource(){
106 return this.idInSource
;
109 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
111 public void setIdInSource(String idInSource
){
112 this.idInSource
= idInSource
;
117 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
119 public String
getIdNamespace() {
124 * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
126 public void setIdNamespace(String idNamespace
) {
127 this.idNamespace
= idNamespace
;
131 public OriginalSourceType
getType() {
135 public void setType(OriginalSourceType type
) {
136 Assert
.notNull(type
, "OriginalSourceType must not be null");
141 //********************** CLONE ************************************************/
144 * @see java.lang.Object#clone()
147 public Object
clone() throws CloneNotSupportedException
{
148 OriginalSourceBase
<?
> result
= (OriginalSourceBase
<?
>)super.clone();
150 //no changes to: idInSource, sourcedObj
155 //************************ toString ***************************************/
157 public String
toString(){
158 if (StringUtils
.isNotBlank(idInSource
) || StringUtils
.isNotBlank(idNamespace
) ){
159 return "OriginalSource:" + CdmUtils
.concat(":", idNamespace
, idInSource
);
161 return super.toString();