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