root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceBase.java

Revision 10019, 3.8 kB (checked in by a.kohlbecker, 21 months ago)

reintegrating sru service wrapper branch (basic implementation)

  • Property svn:keywords set to Id
Line 
1/**
2* Copyright (C) 2007 EDIT
3* European Distributed Institute of Taxonomy
4* http://www.e-taxonomy.eu
5*
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.
8*/
9
10package eu.etaxonomy.cdm.model.common;
11
12
13import javax.persistence.Column;
14import javax.persistence.Entity;
15import javax.persistence.FetchType;
16import javax.persistence.Inheritance;
17import javax.persistence.InheritanceType;
18import javax.persistence.JoinColumn;
19import javax.xml.bind.annotation.XmlAccessType;
20import javax.xml.bind.annotation.XmlAccessorType;
21import javax.xml.bind.annotation.XmlElement;
22import javax.xml.bind.annotation.XmlIDREF;
23import javax.xml.bind.annotation.XmlRootElement;
24import javax.xml.bind.annotation.XmlSchemaType;
25import javax.xml.bind.annotation.XmlType;
26
27import org.apache.commons.lang.StringUtils;
28import org.apache.log4j.Logger;
29import org.hibernate.annotations.Any;
30import org.hibernate.annotations.Table;
31import org.hibernate.envers.Audited;
32import org.hibernate.envers.NotAudited;
33
34import eu.etaxonomy.cdm.common.CdmUtils;
35
36/**
37 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
38 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
39 *
40 * @author m.doering
41 * @version 1.0
42 * @created 08-Nov-2007 13:06:22
43 */
44
45@XmlAccessorType(XmlAccessType.FIELD)
46@XmlType(name = "OriginalSource", propOrder = {
47    "idInSource",
48    "idNamespace"
49})
50@XmlRootElement(name = "OriginalSource")
51@Entity
52@Audited
53@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
54@Table(appliesTo="OriginalSourceBase")
55public abstract class OriginalSourceBase<T extends ISourceable> extends ReferencedEntityBase implements Cloneable, IOriginalSource<T> {
56        private static final long serialVersionUID = -1972959999261181462L;
57        @SuppressWarnings("unused")
58        private static final Logger logger = Logger.getLogger(OriginalSourceBase.class);
59       
60        //The object's ID in the source, where the alternative string comes from
61        @XmlElement(name = "IdInSource")
62        private String idInSource;
63       
64        @XmlElement(name = "IdNamespace")
65        private String idNamespace;
66
67        /*@XmlElement(name = "SourcedObject")
68    @XmlIDREF
69    @XmlSchemaType(name = "IDREF")
70        @Any(metaDef = "CdmBase",
71                 metaColumn=@Column(name = "sourcedObj_type"),
72                 fetch = FetchType.LAZY,
73                 optional = false)
74        @JoinColumn(name = "sourcedObj_id")
75        @NotAudited
76        protected IdentifiableEntity sourcedObj;*/
77
78        /**
79         * Constructor
80         */
81        protected OriginalSourceBase(){
82                super();
83        }
84
85        /* (non-Javadoc)
86         * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdInSource()
87         */
88        public String getIdInSource(){
89                return this.idInSource;
90        }
91        /* (non-Javadoc)
92         * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdInSource(java.lang.String)
93         */
94        public void setIdInSource(String idInSource){
95                this.idInSource = idInSource;
96        }
97
98
99        /* (non-Javadoc)
100         * @see eu.etaxonomy.cdm.model.common.IOriginalSource#getIdNamespace()
101         */
102        public String getIdNamespace() {
103                return idNamespace;
104        }
105
106        /* (non-Javadoc)
107         * @see eu.etaxonomy.cdm.model.common.IOriginalSource#setIdNamespace(java.lang.String)
108         */
109        public void setIdNamespace(String idNamespace) {
110                this.idNamespace = idNamespace;
111        }
112
113       
114//********************** CLONE ************************************************/
115         
116        /* (non-Javadoc)
117         * @see java.lang.Object#clone()
118         */
119        @Override
120        public Object clone() throws CloneNotSupportedException{
121                OriginalSourceBase result = (OriginalSourceBase)super.clone();
122               
123                //no changes to: idInSource, sourcedObj
124                return result;
125        }
126
127       
128//************************ toString ***************************************/
129        @Override
130        public String toString(){
131                if (StringUtils.isNotBlank(idInSource) || StringUtils.isNotBlank(idNamespace) ){
132                        return "OriginalSource:" + CdmUtils.concat(":", idNamespace, idInSource);
133                }else{
134                        return super.toString();
135                }
136        }
137}
Note: See TracBrowser for help on using the browser.