Project

General

Profile

« Previous | Next » 

Revision 52c34f45

Added by Andreas Müller almost 8 years ago

Remove bidirectionality for supplemental data #5743

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/Annotation.java
14 14
import java.util.HashSet;
15 15
import java.util.Set;
16 16

  
17
import javax.persistence.Column;
18 17
import javax.persistence.Entity;
19 18
import javax.persistence.FetchType;
20
import javax.persistence.JoinColumn;
21 19
import javax.persistence.ManyToOne;
22 20
import javax.persistence.OneToMany;
23 21
import javax.xml.bind.annotation.XmlAccessType;
......
30 28

  
31 29
import org.apache.commons.lang.StringUtils;
32 30
import org.apache.log4j.Logger;
33
import org.hibernate.annotations.Any;
34 31
import org.hibernate.annotations.Cascade;
35 32
import org.hibernate.annotations.CascadeType;
36 33
import org.hibernate.annotations.Type;
37 34
import org.hibernate.envers.Audited;
38
import org.hibernate.envers.NotAudited;
39 35

  
40 36
import eu.etaxonomy.cdm.model.agent.Person;
41 37

  
42 38
/**
43 39
 * @author m.doering
44
 * @version 1.0
45 40
 * @created 08-Nov-2007 13:06:10
46 41
 */
47 42
@XmlAccessorType(XmlAccessType.FIELD)
48 43
@XmlType(name = "Annotation", propOrder = {
49 44
    "commentator",
50
    "annotatedObj",
51 45
    "annotationType",
52 46
    "linkbackUri",
53 47
    "intextReferences"
......
59 53
	@SuppressWarnings("unused")
60 54
	private static final Logger logger = Logger.getLogger(Annotation.class);
61 55

  
62
	//TODO do we need to add it to JAXB? #4706
63
	@XmlElementWrapper(name = "IntextReferences", nillable = true)
64
	@XmlElement(name = "IntextReference")
65
	@OneToMany(mappedBy="languageString", fetch=FetchType.LAZY, orphanRemoval=true)
66
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
67
//	@Merge(MergeMode.ADD_CLONE)
68
    private Set<IntextReference> intextReferences = new HashSet<IntextReference>();
69

  
70 56
	/**
71 57
	 * Factory method.
72 58
	 * @param text
......
93 79
	}
94 80

  
95 81

  
82
    //TODO do we need to add it to JAXB? #4706
83
    @XmlElementWrapper(name = "IntextReferences", nillable = true)
84
    @XmlElement(name = "IntextReference")
85
    @OneToMany(mappedBy="languageString", fetch=FetchType.LAZY, orphanRemoval=true)
86
    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
87
//  @Merge(MergeMode.ADD_CLONE)
88
    private Set<IntextReference> intextReferences = new HashSet<IntextReference>();
89

  
96 90
	//Human annotation
97 91
	@XmlElement(name = "Commentator")
98 92
    @XmlIDREF
......
101 95
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
102 96
	private Person commentator;
103 97

  
104
	@XmlElement(name = "AnnotatedObject")
105
    @XmlIDREF
106
    @XmlSchemaType(name = "IDREF")
107
    @Any(metaDef = "CdmBase",
108
	    	 metaColumn=@Column(name = "annotatedObj_type"),
109
	    	 fetch = FetchType.EAGER,
110
	    	 optional = false)
111
	@JoinColumn(name = "annotatedObj_id")
112
	@NotAudited
113
	private AnnotatableEntity annotatedObj;
114

  
115 98
    @XmlElement(name = "AnnotationType")
116 99
    @XmlIDREF
117 100
    @XmlSchemaType(name = "IDREF")
......
144 127
//******************** GETTER /SETTER *************************/
145 128

  
146 129

  
147
	/**
148
	 * Currently envers does not support @Any
149
	 * @return
150
	 */
151
	public AnnotatableEntity getAnnotatedObj() {
152
		return annotatedObj;
153
	}
154

  
155
	//TODO make not public, but TaxonTaoHibernateImpl.delete has to be changed then
156
	/**
157
	 *
158
	 * @param newAnnotatedObj
159
	 * @deprecated should not be used, is only public for internal reasons
160
	 */
161
	@Deprecated
162
	public void setAnnotatedObj(AnnotatableEntity newAnnotatedObj) {
163
		this.annotatedObj = newAnnotatedObj;
164
	}
165

  
166 130
	public AnnotationType getAnnotationType() {
167 131
		return annotationType;
168 132
	}
......
252 216
		return result;
253 217
	}
254 218

  
255

  
256
	/**
257
	 * Clones this annotation and sets the clone's annotated object to 'annotatedObject'
258
	 * @see java.lang.Object#clone()
259
	 */
260
	public Annotation clone(AnnotatableEntity annotatedObject) throws CloneNotSupportedException{
261
		Annotation result = (Annotation)clone();
262
		result.setAnnotatedObj(annotatedObject);
263

  
264
		return result;
265
	}
266 219
}

Also available in: Unified diff