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
.FetchType
;
16 import javax
.persistence
.JoinColumn
;
17 import javax
.persistence
.ManyToOne
;
18 import javax
.persistence
.Transient
;
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
.XmlSchemaType
;
24 import javax
.xml
.bind
.annotation
.XmlType
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Any
;
28 import org
.hibernate
.envers
.Audited
;
29 import org
.hibernate
.envers
.NotAudited
;
32 * This class aims to make available more "attributes" for identifiable entities
33 * in a flexible way. Application developers (and even users) can define their own
34 * "attributes" as an ExtensionType and add data to Identifiable instances via
35 * Extension instances.
38 * @created 08-Nov-2007 13:06:23
40 @XmlAccessorType(XmlAccessType
.FIELD
)
41 @XmlType(name
= "Extension", propOrder
= {
48 public class Extension
extends VersionableEntity
implements Cloneable
{
49 private static final long serialVersionUID
= -857207737641432202L;
50 @SuppressWarnings("unused")
51 private static final Logger logger
= Logger
.getLogger(Extension
.class);
53 @XmlElement(name
= "Value")
56 @XmlElement(name
= "ExtensionType")
58 @XmlSchemaType(name
= "IDREF")
59 @ManyToOne(fetch
= FetchType
.LAZY
)
60 private ExtensionType type
;
62 @XmlElement(name
= "ExtendedObject")
64 @XmlSchemaType(name
= "IDREF")
65 @Any(metaDef
= "CdmBase",
66 metaColumn
=@Column(name
= "extendedObj_type"),
67 fetch
= FetchType
.LAZY
,
69 @JoinColumn(name
= "extendedObj_id")
71 private IdentifiableEntity extendedObj
;
73 public static Extension
NewInstance(){
74 return new Extension();
78 * TODO should not be private but throws error in persistence/io test
81 protected Extension(){
85 public IdentifiableEntity
getExtendedObj() {
88 public void setExtendedObj(IdentifiableEntity extendedObj
) {
89 this.extendedObj
= extendedObj
;
93 public ExtensionType
getType(){
101 public void setType(ExtensionType type
){
105 public String
getValue(){
113 public void setValue(String value
){
117 //****************** CLONE ************************************************/
120 * @see java.lang.Object#clone()
123 public Object
clone() throws CloneNotSupportedException
{
124 Extension result
= (Extension
)super.clone();
125 //no changes to: type, value
130 * Clones this extension and sets the clone's extended object to 'extendedObject'
131 * @see java.lang.Object#clone()
133 public Extension
clone(IdentifiableEntity extendedObject
) throws CloneNotSupportedException
{
134 Extension result
= (Extension
)clone();
135 result
.setExtendedObj(extendedObject
);