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 * @since 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")}
71 private OriginalSourceType type
;
73 //The object's ID in the source, where the alternative string comes from
74 @XmlElement(name
= "IdInSource")
75 private String idInSource
;
77 @XmlElement(name
= "IdNamespace")
78 private String idNamespace
;
80 //***************** CONSTRUCTOR ***********************/
82 //for hibernate use only
83 protected OriginalSourceBase() {
91 protected OriginalSourceBase(OriginalSourceType type
){
93 throw new IllegalArgumentException("OriginalSourceType must not be null");
98 //**************** GETTER / SETTER *******************************/
102 public String
getIdInSource(){
103 return this.idInSource
;
106 public void setIdInSource(String idInSource
){
107 this.idInSource
= idInSource
;
112 public String
getIdNamespace() {
116 public void setIdNamespace(String idNamespace
) {
117 this.idNamespace
= idNamespace
;
122 public OriginalSourceType
getType() {
126 public void setType(OriginalSourceType type
) {
127 Assert
.notNull(type
, "OriginalSourceType must not be null");
132 //********************** CLONE ************************************************/
135 public Object
clone() throws CloneNotSupportedException
{
136 OriginalSourceBase
<?
> result
= (OriginalSourceBase
<?
>)super.clone();
138 //no changes to: idInSource
143 //************************ toString ***************************************/
145 public String
toString(){
146 if (StringUtils
.isNotBlank(idInSource
) || StringUtils
.isNotBlank(idNamespace
) ){
147 return "OriginalSource:" + CdmUtils
.concat(":", idNamespace
, idInSource
);
149 return super.toString();
153 //*********************************** EQUALS *********************************************************/
159 public boolean equalsByShallowCompare(ReferencedEntityBase other
) {
161 if(!super.equalsByShallowCompare(other
)) {
164 OriginalSourceBase
<T
> theOther
= (OriginalSourceBase
<T
>)other
;
165 if(!StringUtils
.equals(this.getIdInSource(), theOther
.getIdInSource())
166 || !StringUtils
.equals(this.getIdNamespace(), theOther
.getIdNamespace())) {