Project

General

Profile

« Previous | Next » 

Revision c6a0721d

Added by Andreas Müller almost 8 years ago

  • ID c6a0721db1da86894a25afad447639cf60cb78a0
  • Parent ed77d49a

Preliminary changes for FK problem on sourcedObj_id using common base
class #5534, later reverted due to #5743

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceBase.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
12 12

  
13 13
import javax.persistence.Column;
14 14
import javax.persistence.Entity;
15
import javax.persistence.FetchType;
15 16
import javax.persistence.Inheritance;
16 17
import javax.persistence.InheritanceType;
18
import javax.persistence.JoinColumn;
17 19
import javax.validation.constraints.NotNull;
18 20
import javax.xml.bind.annotation.XmlAccessType;
19 21
import javax.xml.bind.annotation.XmlAccessorType;
20 22
import javax.xml.bind.annotation.XmlAttribute;
21 23
import javax.xml.bind.annotation.XmlElement;
24
import javax.xml.bind.annotation.XmlIDREF;
22 25
import javax.xml.bind.annotation.XmlRootElement;
26
import javax.xml.bind.annotation.XmlSchemaType;
23 27
import javax.xml.bind.annotation.XmlType;
24 28

  
25 29
import org.apache.commons.lang.StringUtils;
26 30
import org.apache.log4j.Logger;
27

  
31
import org.hibernate.annotations.Any;
32
import org.hibernate.annotations.Cascade;
33
import org.hibernate.annotations.CascadeType;
28 34
import org.hibernate.annotations.Table;
29 35
import org.hibernate.annotations.Type;
30 36
import org.hibernate.envers.Audited;
37
import org.hibernate.envers.NotAudited;
31 38
import org.springframework.util.Assert;
32 39

  
33 40
import eu.etaxonomy.cdm.common.CdmUtils;
......
35 42
/**
36 43
 * Abstract base class for classes implementing {@link eu.etaxonomy.cdm.model.common.IOriginalSource IOriginalSource}.
37 44
 * @see eu.etaxonomy.cdm.model.common.IOriginalSource
38
 * 
45
 *
39 46
 * @author m.doering
40 47
 * @version 1.0
41 48
 * @created 08-Nov-2007 13:06:22
......
56 63
	private static final long serialVersionUID = -1972959999261181462L;
57 64
	@SuppressWarnings("unused")
58 65
	private static final Logger logger = Logger.getLogger(OriginalSourceBase.class);
59
	
66

  
60 67
	/**
61
	 * The {@link OriginalSourceType type} of this source. According to PROV the type has to be thought as 
68
	 * The {@link OriginalSourceType type} of this source. According to PROV the type has to be thought as
62 69
	 * an activity that leads from the source entity to the current entity. It is not a property of the
63 70
	 * source itself.
64 71
	 */
......
70 77
    )
71 78
	@Audited
72 79
	private OriginalSourceType type;
73
	
80

  
74 81
	//The object's ID in the source, where the alternative string comes from
75 82
	@XmlElement(name = "IdInSource")
76 83
	private String idInSource;
77
	
84

  
78 85
	@XmlElement(name = "IdNamespace")
79 86
	private String idNamespace;
80 87

  
81
//***************** CONSTRUCTOR ***********************/	
88
	@XmlElement(name = "SourcedObject")
89
    @XmlIDREF
90
    @XmlSchemaType(name = "IDREF")
91
    @Any(metaDef = "CdmBase",
92
             metaColumn=@Column(name = "sourcedObj_type"),
93
             fetch = FetchType.LAZY,
94
             optional = false)
95
    @JoinColumn(name = "sourcedObj_id")
96
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
97
    @NotAudited
98
    protected T sourcedObj;
99

  
100
//***************** CONSTRUCTOR ***********************/
82 101

  
83 102
	//for hibernate use only
84 103
	protected OriginalSourceBase() {
85
		
104

  
86 105
	}
87
	
106

  
88 107
	/**
89 108
	 * Constructor
90
	 * @param type2 
109
	 * @param type2
91 110
	 */
92 111
	protected OriginalSourceBase(OriginalSourceType type){
93 112
		if (type == null){
......
117 136
	public void setIdNamespace(String idNamespace) {
118 137
		this.idNamespace = idNamespace;
119 138
	}
120
	
139

  
121 140

  
122 141
	@Override
123 142
	public OriginalSourceType getType() {
......
129 148
		this.type = type;
130 149
	}
131 150

  
132
	
151

  
133 152
//********************** CLONE ************************************************/
134
	 
153

  
135 154
	@Override
136 155
	public Object clone() throws CloneNotSupportedException{
137 156
		OriginalSourceBase<?> result = (OriginalSourceBase<?>)super.clone();
138
		
157

  
139 158
		//no changes to: idInSource, sourcedObj
140 159
		return result;
141 160
	}
142 161

  
143
	
162

  
144 163
//************************ toString ***************************************/
145 164
	@Override
146 165
	public String toString(){

Also available in: Unified diff