Revision 52c34f45
Added by Andreas Müller almost 8 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/DbImportDescriptionElementSourceCreationMapper.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.io.common.mapping; |
|
12 |
|
|
13 |
import java.sql.ResultSet; |
|
14 |
import java.sql.SQLException; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
19 |
import eu.etaxonomy.cdm.io.common.DbImportStateBase; |
|
20 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
22 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
24 |
|
|
25 |
/** |
|
26 |
* This mapper creates an description element source that is added to the according description element. |
|
27 |
* It adds the reference and the microReference. |
|
28 |
* @author a.mueller |
|
29 |
* @created 11.03.2010 |
|
30 |
* @version 1.0 |
|
31 |
*/ |
|
32 |
public class DbImportDescriptionElementSourceCreationMapper extends DbImportObjectCreationMapperBase<DescriptionElementSource, DbImportStateBase<?,?>> { |
|
33 |
@SuppressWarnings("unused") |
|
34 |
private static final Logger logger = Logger.getLogger(DbImportDescriptionElementSourceCreationMapper.class); |
|
35 |
|
|
36 |
//**************************** FACTORY METHOD ***********************************************/ |
|
37 |
|
|
38 |
/** |
|
39 |
* Returns an description element source creation mapper. |
|
40 |
* @param dbDescriptionElementFkAttribute |
|
41 |
* @param descriptionElementNamespace |
|
42 |
* @param dbReferenceFkAttribute |
|
43 |
* @param referenceNamespace |
|
44 |
* @return |
|
45 |
*/ |
|
46 |
public static DbImportDescriptionElementSourceCreationMapper NewInstance(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace){ |
|
47 |
String dbMicroReferenceAttribute = null; |
|
48 |
return new DbImportDescriptionElementSourceCreationMapper(dbDescriptionElementFkAttribute, descriptionElementNamespace, dbReferenceFkAttribute, referenceNamespace, dbMicroReferenceAttribute); |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* Returns an description element source creation mapper. |
|
54 |
* @param dbDescriptionElementFkAttribute |
|
55 |
* @param descriptionElementNamespace |
|
56 |
* @param dbReferenceFkAttribute |
|
57 |
* @param referenceNamespace |
|
58 |
* @param dbMicroReferenceAttribute |
|
59 |
* @return |
|
60 |
*/ |
|
61 |
public static DbImportDescriptionElementSourceCreationMapper NewInstance(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace, String dbMicroReferenceAttribute){ |
|
62 |
return new DbImportDescriptionElementSourceCreationMapper(dbDescriptionElementFkAttribute, descriptionElementNamespace, dbReferenceFkAttribute, referenceNamespace, dbMicroReferenceAttribute); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
//******************************* VARIABLES ***********************************************/ |
|
67 |
|
|
68 |
protected String descriptionElementNamespace; |
|
69 |
protected String dbDescriptionElementFkAttribute; |
|
70 |
protected String referenceNamespace; |
|
71 |
protected String dbReferenceFkAttribute; |
|
72 |
protected String dbMicroReferenceAttribute; |
|
73 |
|
|
74 |
|
|
75 |
//******************************* CONSTRUCTOR ***********************************************/ |
|
76 |
|
|
77 |
/** |
|
78 |
* @param dbIdAttribute |
|
79 |
* @param objectToCreateNamespace |
|
80 |
*/ |
|
81 |
protected DbImportDescriptionElementSourceCreationMapper(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace, String dbMicroReferenceAttribute) { |
|
82 |
super(null, null); // idAttribute and objectToCreateNamespace not needed |
|
83 |
this.descriptionElementNamespace = descriptionElementNamespace; |
|
84 |
this.dbDescriptionElementFkAttribute = dbDescriptionElementFkAttribute; |
|
85 |
this.dbReferenceFkAttribute = dbReferenceFkAttribute; |
|
86 |
this.referenceNamespace = referenceNamespace; |
|
87 |
this.dbMicroReferenceAttribute = dbMicroReferenceAttribute; |
|
88 |
} |
|
89 |
|
|
90 |
//******************************* METHODS ***********************************************/ |
|
91 |
|
|
92 |
/* (non-Javadoc) |
|
93 |
* @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#createObject(java.sql.ResultSet) |
|
94 |
*/ |
|
95 |
@Override |
|
96 |
protected DescriptionElementSource createObject(ResultSet rs)throws SQLException { |
|
97 |
DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource); |
|
98 |
return source; |
|
99 |
} |
|
100 |
|
|
101 |
/* (non-Javadoc) |
|
102 |
* @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#doInvoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.VersionableEntity) |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
protected DescriptionElementSource doInvoke(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
106 |
addCitation(rs, source); |
|
107 |
addMicroCitation(rs, source); |
|
108 |
setDescriptionElement(rs, source); |
|
109 |
return source; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* @param rs |
|
114 |
* @param source |
|
115 |
* @throws SQLException |
|
116 |
*/ |
|
117 |
private void setDescriptionElement(ResultSet rs, |
|
118 |
DescriptionElementSource source) throws SQLException { |
|
119 |
DescriptionElementBase descriptionElement = (DescriptionElementBase)getRelatedObject(rs, descriptionElementNamespace, dbDescriptionElementFkAttribute); |
|
120 |
source.setSourcedObj(descriptionElement); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* @param rs |
|
125 |
* @param source |
|
126 |
* @throws SQLException |
|
127 |
*/ |
|
128 |
private void addMicroCitation(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
129 |
String microReference = null; |
|
130 |
if (CdmUtils.isNotEmpty(dbMicroReferenceAttribute)){ |
|
131 |
microReference = rs.getString(dbMicroReferenceAttribute); |
|
132 |
} |
|
133 |
source.setCitationMicroReference(microReference); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* @param rs |
|
138 |
* @param source |
|
139 |
* @throws SQLException |
|
140 |
*/ |
|
141 |
private void addCitation(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
142 |
Reference citation = (Reference)getRelatedObject(rs, referenceNamespace, dbReferenceFkAttribute); |
|
143 |
source.setCitation(citation); |
|
144 |
} |
|
145 |
|
|
146 |
} |
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.io.common.mapping; |
|
12 |
|
|
13 |
import java.sql.ResultSet; |
|
14 |
import java.sql.SQLException; |
|
15 |
|
|
16 |
import org.apache.commons.lang.StringUtils; |
|
17 |
import org.apache.log4j.Logger; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.io.common.DbImportStateBase; |
|
20 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
|
22 |
import eu.etaxonomy.cdm.model.description.DescriptionElementSource; |
|
23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
24 |
|
|
25 |
/** |
|
26 |
* This mapper creates an description element source that is added to the according description element. |
|
27 |
* It adds the reference and the microReference. |
|
28 |
* @author a.mueller |
|
29 |
* @created 11.03.2010 |
|
30 |
* @version 1.0 |
|
31 |
*/ |
|
32 |
public class DbImportDescriptionElementSourceCreationMapper extends DbImportObjectCreationMapperBase<DescriptionElementSource, DbImportStateBase<?,?>> { |
|
33 |
@SuppressWarnings("unused") |
|
34 |
private static final Logger logger = Logger.getLogger(DbImportDescriptionElementSourceCreationMapper.class); |
|
35 |
|
|
36 |
//**************************** FACTORY METHOD ***********************************************/ |
|
37 |
|
|
38 |
/** |
|
39 |
* Returns an description element source creation mapper. |
|
40 |
* @param dbDescriptionElementFkAttribute |
|
41 |
* @param descriptionElementNamespace |
|
42 |
* @param dbReferenceFkAttribute |
|
43 |
* @param referenceNamespace |
|
44 |
* @return |
|
45 |
*/ |
|
46 |
public static DbImportDescriptionElementSourceCreationMapper NewInstance(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace){ |
|
47 |
String dbMicroReferenceAttribute = null; |
|
48 |
return new DbImportDescriptionElementSourceCreationMapper(dbDescriptionElementFkAttribute, descriptionElementNamespace, dbReferenceFkAttribute, referenceNamespace, dbMicroReferenceAttribute); |
|
49 |
} |
|
50 |
|
|
51 |
|
|
52 |
/** |
|
53 |
* Returns an description element source creation mapper. |
|
54 |
* @param dbDescriptionElementFkAttribute |
|
55 |
* @param descriptionElementNamespace |
|
56 |
* @param dbReferenceFkAttribute |
|
57 |
* @param referenceNamespace |
|
58 |
* @param dbMicroReferenceAttribute |
|
59 |
* @return |
|
60 |
*/ |
|
61 |
public static DbImportDescriptionElementSourceCreationMapper NewInstance(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace, String dbMicroReferenceAttribute){ |
|
62 |
return new DbImportDescriptionElementSourceCreationMapper(dbDescriptionElementFkAttribute, descriptionElementNamespace, dbReferenceFkAttribute, referenceNamespace, dbMicroReferenceAttribute); |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
//******************************* VARIABLES ***********************************************/ |
|
67 |
|
|
68 |
protected String descriptionElementNamespace; |
|
69 |
protected String dbDescriptionElementFkAttribute; |
|
70 |
protected String referenceNamespace; |
|
71 |
protected String dbReferenceFkAttribute; |
|
72 |
protected String dbMicroReferenceAttribute; |
|
73 |
|
|
74 |
|
|
75 |
//******************************* CONSTRUCTOR ***********************************************/ |
|
76 |
|
|
77 |
/** |
|
78 |
* @param dbIdAttribute |
|
79 |
* @param objectToCreateNamespace |
|
80 |
*/ |
|
81 |
protected DbImportDescriptionElementSourceCreationMapper(String dbDescriptionElementFkAttribute, String descriptionElementNamespace, String dbReferenceFkAttribute, String referenceNamespace, String dbMicroReferenceAttribute) { |
|
82 |
super(null, null); // idAttribute and objectToCreateNamespace not needed |
|
83 |
this.descriptionElementNamespace = descriptionElementNamespace; |
|
84 |
this.dbDescriptionElementFkAttribute = dbDescriptionElementFkAttribute; |
|
85 |
this.dbReferenceFkAttribute = dbReferenceFkAttribute; |
|
86 |
this.referenceNamespace = referenceNamespace; |
|
87 |
this.dbMicroReferenceAttribute = dbMicroReferenceAttribute; |
|
88 |
} |
|
89 |
|
|
90 |
//******************************* METHODS ***********************************************/ |
|
91 |
|
|
92 |
/* (non-Javadoc) |
|
93 |
* @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#createObject(java.sql.ResultSet) |
|
94 |
*/ |
|
95 |
@Override |
|
96 |
protected DescriptionElementSource createObject(ResultSet rs)throws SQLException { |
|
97 |
DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource); |
|
98 |
return source; |
|
99 |
} |
|
100 |
|
|
101 |
/* (non-Javadoc) |
|
102 |
* @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#doInvoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.VersionableEntity) |
|
103 |
*/ |
|
104 |
@Override |
|
105 |
protected DescriptionElementSource doInvoke(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
106 |
addCitation(rs, source); |
|
107 |
addMicroCitation(rs, source); |
|
108 |
setDescriptionElement(rs, source); |
|
109 |
return source; |
|
110 |
} |
|
111 |
|
|
112 |
/** |
|
113 |
* @param rs |
|
114 |
* @param source |
|
115 |
* @throws SQLException |
|
116 |
*/ |
|
117 |
private void setDescriptionElement(ResultSet rs, |
|
118 |
DescriptionElementSource source) throws SQLException { |
|
119 |
DescriptionElementBase descriptionElement = (DescriptionElementBase)getRelatedObject(rs, descriptionElementNamespace, dbDescriptionElementFkAttribute); |
|
120 |
descriptionElement.addSource(source); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* @param rs |
|
125 |
* @param source |
|
126 |
* @throws SQLException |
|
127 |
*/ |
|
128 |
private void addMicroCitation(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
129 |
String microReference = null; |
|
130 |
if (StringUtils.isNotBlank(dbMicroReferenceAttribute)){ |
|
131 |
microReference = rs.getString(dbMicroReferenceAttribute); |
|
132 |
} |
|
133 |
source.setCitationMicroReference(microReference); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* @param rs |
|
138 |
* @param source |
|
139 |
* @throws SQLException |
|
140 |
*/ |
|
141 |
private void addCitation(ResultSet rs, DescriptionElementSource source) throws SQLException { |
|
142 |
Reference citation = (Reference)getRelatedObject(rs, referenceNamespace, dbReferenceFkAttribute); |
|
143 |
source.setCitation(citation); |
|
144 |
} |
|
145 |
|
|
146 |
} |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/markup/MarkupSpecimenImport.java | ||
---|---|---|
33 | 33 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
34 | 34 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
35 | 35 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
36 |
import eu.etaxonomy.cdm.model.common.Identifier; |
|
37 | 36 |
import eu.etaxonomy.cdm.model.common.Language; |
38 | 37 |
import eu.etaxonomy.cdm.model.common.Marker; |
39 | 38 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
... | ... | |
667 | 666 |
//for now we do not handle annotation and typeNotes |
668 | 667 |
String altFieldNum = getCData(state, reader, parent, false).trim(); |
669 | 668 |
DefinedTerm type = this.getIdentifierType(state, MarkupTransformer.uuidIdentTypeAlternativeFieldNumber, "Alternative field number", "Alternative field number", "alt. field no.", null); |
670 |
Identifier<?> identifier = Identifier.NewInstance(fieldUnit, altFieldNum, type);
|
|
669 |
fieldUnit.addIdentifier(altFieldNum, type);
|
|
671 | 670 |
if (doubtful){ |
672 | 671 |
fireWarningEvent("Marking alternative field numbers as doubtful not yet possible, see #4673", parent,4); |
673 | 672 |
// Marker.NewInstance(identifier, "true", MarkerType.IS_DOUBTFUL()); |
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/molecular/AbcdDnaParser.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.io.specimen.abcd206.in.AbcdPersonParser; |
24 | 24 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
25 | 25 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
26 |
import eu.etaxonomy.cdm.model.common.Identifier; |
|
27 | 26 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
28 | 27 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
29 | 28 |
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent; |
... | ... | |
121 | 120 |
private void parseSampleDesignations(Element item, DnaSample dnaSample) { |
122 | 121 |
NodeList sampleDesignationList = item.getElementsByTagName(prefix+"sampleDesignation"); |
123 | 122 |
for(int i=0;i<sampleDesignationList.getLength();i++){ |
124 |
Identifier.NewInstance(dnaSample, sampleDesignationList.item(i).getTextContent(), (DefinedTerm)cdmAppController.getTermService().find(UUID.fromString("fadeba12-1be3-4bc7-9ff5-361b088d86fc")));
|
|
123 |
dnaSample.addIdentifier(sampleDesignationList.item(i).getTextContent(), (DefinedTerm)cdmAppController.getTermService().find(UUID.fromString("fadeba12-1be3-4bc7-9ff5-361b088d86fc")));
|
|
125 | 124 |
} |
126 | 125 |
|
127 | 126 |
} |
cdmlib-io/src/main/resources/schema/cdm/common.xsd | ||
---|---|---|
333 | 333 |
<xs:sequence> |
334 | 334 |
<xs:element name="Value" type="xs:string" minOccurs="0"/> |
335 | 335 |
<xs:element name="ExtensionType" type="xs:IDREF" minOccurs="0"/> |
336 |
<xs:element name="ExtendedObject" type="xs:IDREF" minOccurs="0"/> |
|
337 | 336 |
</xs:sequence> |
338 | 337 |
</xs:extension> |
339 | 338 |
</xs:complexContent> |
cdmlib-io/src/test/java/eu/etaxonomy/cdm/io/jaxb/AnnotationTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2009 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 |
package eu.etaxonomy.cdm.io.jaxb; |
|
10 |
|
|
11 |
import static org.junit.Assert.assertEquals; |
|
12 |
import static org.junit.Assert.assertNotNull; |
|
13 |
|
|
14 |
import java.io.InputStreamReader; |
|
15 |
import java.net.URI; |
|
16 |
|
|
17 |
import org.junit.Test; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
|
20 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
21 |
|
|
22 |
public class AnnotationTest { |
|
23 |
|
|
24 |
private String resource = "/eu/etaxonomy/cdm/io/jaxb/AnnotationTest.xml"; |
|
25 |
|
|
26 |
@Test |
|
27 |
public void testUnmarshalAnnotations() throws Exception { |
|
28 |
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder(); |
|
29 |
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString())); |
|
30 |
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString()); |
|
31 |
|
|
32 |
AnnotatableEntity annotatableEntity = (AnnotatableEntity)dataSet.getTaxonBases().get(0); |
|
33 |
assertNotNull("annotatableEntity must exist",annotatableEntity); |
|
34 |
|
|
35 |
assertNotNull("annotatableEntity must have annotations",annotatableEntity.getAnnotations()); |
|
36 |
assertEquals("There should be one annotation",1,annotatableEntity.getAnnotations().size()); |
|
37 |
|
|
38 |
Annotation annotation = annotatableEntity.getAnnotations().iterator().next(); |
|
39 |
assertEquals("object must also be the annotated object",annotatableEntity,annotation.getAnnotatedObj()); |
|
40 |
assertNotNull("Annotation must have annotations",annotation.getAnnotations()); |
|
41 |
assertEquals("There should be one annotation",1,annotation.getAnnotations().size()); |
|
42 |
Annotation annotationTwo = annotation.getAnnotations().iterator().next(); |
|
43 |
assertEquals("Annotation should be the annotated object",annotation,annotationTwo.getAnnotatedObj()); |
|
44 |
} |
|
45 |
} |
|
1 |
/** |
|
2 |
* Copyright (C) 2009 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 |
package eu.etaxonomy.cdm.io.jaxb; |
|
10 |
|
|
11 |
import static org.junit.Assert.assertEquals; |
|
12 |
import static org.junit.Assert.assertNotNull; |
|
13 |
|
|
14 |
import java.io.InputStreamReader; |
|
15 |
import java.net.URI; |
|
16 |
|
|
17 |
import org.junit.Test; |
|
18 |
|
|
19 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
|
20 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
21 |
|
|
22 |
public class AnnotationTest { |
|
23 |
|
|
24 |
private String resource = "/eu/etaxonomy/cdm/io/jaxb/AnnotationTest.xml"; |
|
25 |
|
|
26 |
@Test |
|
27 |
public void testUnmarshalAnnotations() throws Exception { |
|
28 |
CdmDocumentBuilder cdmDocumentBuilder = new CdmDocumentBuilder(); |
|
29 |
URI uri = new URI(URIEncoder.encode(this.getClass().getResource(resource).toString())); |
|
30 |
DataSet dataSet = cdmDocumentBuilder.unmarshal(DataSet.class, new InputStreamReader(this.getClass().getResourceAsStream(resource)),uri.toString()); |
|
31 |
|
|
32 |
AnnotatableEntity annotatableEntity = dataSet.getTaxonBases().get(0); |
|
33 |
assertNotNull("annotatableEntity must exist",annotatableEntity); |
|
34 |
|
|
35 |
assertNotNull("annotatableEntity must have annotations",annotatableEntity.getAnnotations()); |
|
36 |
assertEquals("There should be one annotation",1,annotatableEntity.getAnnotations().size()); |
|
37 |
|
|
38 |
Annotation annotation = annotatableEntity.getAnnotations().iterator().next(); |
|
39 |
// assertEquals("object must also be the annotated object",annotatableEntity,annotation.getAnnotatedObj()); |
|
40 |
assertNotNull("Annotation must have annotations",annotation.getAnnotations()); |
|
41 |
assertEquals("There should be one annotation",1,annotation.getAnnotations().size()); |
|
42 |
Annotation annotationTwo = annotation.getAnnotations().iterator().next(); |
|
43 |
// assertEquals("Annotation should be the annotated object",annotation,annotationTwo.getAnnotatedObj()); |
|
44 |
} |
|
45 |
} |
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/jaxb/AnnotationTest.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<DataSet |
|
3 |
xmlns="http://etaxonomy.eu/cdm/model/1.0" |
|
4 |
xmlns:agent="http://etaxonomy.eu/cdm/model/agent/1.0" |
|
5 |
xmlns:common="http://etaxonomy.eu/cdm/model/common/1.0" |
|
6 |
xmlns:name="http://etaxonomy.eu/cdm/model/name/1.0" |
|
7 |
xmlns:taxon="http://etaxonomy.eu/cdm/model/taxon/1.0" |
|
8 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
9 |
xsi:schemaLocation="http://etaxonomy.eu/cdm/model/1.0 |
|
10 |
../../../../../../classes/schema/cdm/cdm.xsd"> |
|
11 |
<Terms> |
|
12 |
<common:Language id="1" uuid="urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d" iso639_1="en" iso639_2="eng"/> |
|
13 |
</Terms> |
|
14 |
<Agents> |
|
15 |
<agent:Person id="1" uuid="urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66"> |
|
16 |
<common:TitleCache>Person Name</common:TitleCache> |
|
17 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
18 |
</agent:Person> |
|
19 |
</Agents> |
|
20 |
|
|
21 |
<TaxonomicNames> |
|
22 |
<name:ZoologicalName id="1" uuid="urn-uuid-57db34b2-1130-4d42-afe1-cf2d8f1f2a3e" hasProblem="false" problemStarts="-1" problemEnds="-1"> |
|
23 |
<common:TitleCache>Aus aus L., 1758</common:TitleCache> |
|
24 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
25 |
<name:ProtectedFullTitleCache>false</name:ProtectedFullTitleCache> |
|
26 |
<name:NameCache>Aus aus</name:NameCache> |
|
27 |
<name:AuthorshipCache>L., 1758</name:AuthorshipCache> |
|
28 |
<name:ProtectedAuthorshipCache>false</name:ProtectedAuthorshipCache> |
|
29 |
<name:ProtectedNameCache>false</name:ProtectedNameCache> |
|
30 |
</name:ZoologicalName> |
|
31 |
</TaxonomicNames> |
|
32 |
<TaxonBases> |
|
33 |
<taxon:Taxon id="1" uuid="urn-uuid-2c980a17-4a96-4ea1-b688-90396c0771d9" isDoubtful="false"> |
|
34 |
<common:Annotations> |
|
35 |
<common:Annotation id="1" uuid="urn-uuid-775f5099-0908-4b8b-a59e-4398800a2e1c"> |
|
36 |
<common:Created>2007-04-21T00:00:00Z</common:Created> |
|
37 |
<common:CreatedBy>urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66</common:CreatedBy> |
|
38 |
<common:Annotations> |
|
39 |
<common:Annotation id="2" uuid="urn-uuid-f2efd210-0889-4a0e-9d71-ff1bfcd6c090"> |
|
40 |
<common:Created>2007-05-22T00:00:00Z</common:Created> |
|
41 |
<common:CreatedBy>urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66</common:CreatedBy> |
|
42 |
<common:Text>What a load of old rubbish</common:Text> |
|
43 |
<common:Language>urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d</common:Language> |
|
44 |
<common:AnnotatedObject>urn-uuid-775f5099-0908-4b8b-a59e-4398800a2e1c</common:AnnotatedObject> |
|
45 |
</common:Annotation> |
|
46 |
</common:Annotations> |
|
47 |
<common:Text>Bibbly bobbly BOING</common:Text> |
|
48 |
<common:Language>urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d</common:Language> |
|
49 |
<common:AnnotatedObject>urn-uuid-2c980a17-4a96-4ea1-b688-90396c0771d9</common:AnnotatedObject> |
|
50 |
</common:Annotation> |
|
51 |
</common:Annotations> |
|
52 |
<common:TitleCache>Aus aus L., 1758 sec CATE 2008</common:TitleCache> |
|
53 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
54 |
<taxon:Name>urn-uuid-57db34b2-1130-4d42-afe1-cf2d8f1f2a3e</taxon:Name> |
|
55 |
<taxon:TaxonomicChildrenCount>0</taxon:TaxonomicChildrenCount> |
|
56 |
</taxon:Taxon> |
|
57 |
</TaxonBases> |
|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<DataSet |
|
3 |
xmlns="http://etaxonomy.eu/cdm/model/1.0" |
|
4 |
xmlns:agent="http://etaxonomy.eu/cdm/model/agent/1.0" |
|
5 |
xmlns:common="http://etaxonomy.eu/cdm/model/common/1.0" |
|
6 |
xmlns:name="http://etaxonomy.eu/cdm/model/name/1.0" |
|
7 |
xmlns:taxon="http://etaxonomy.eu/cdm/model/taxon/1.0" |
|
8 |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
9 |
xsi:schemaLocation="http://etaxonomy.eu/cdm/model/1.0 |
|
10 |
../../../../../../classes/schema/cdm/cdm.xsd"> |
|
11 |
<Terms> |
|
12 |
<common:Language id="1" uuid="urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d" iso639_1="en" iso639_2="eng"/> |
|
13 |
</Terms> |
|
14 |
<Agents> |
|
15 |
<agent:Person id="1" uuid="urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66"> |
|
16 |
<common:TitleCache>Person Name</common:TitleCache> |
|
17 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
18 |
</agent:Person> |
|
19 |
</Agents> |
|
20 |
|
|
21 |
<TaxonomicNames> |
|
22 |
<name:ZoologicalName id="1" uuid="urn-uuid-57db34b2-1130-4d42-afe1-cf2d8f1f2a3e" hasProblem="false" problemStarts="-1" problemEnds="-1"> |
|
23 |
<common:TitleCache>Aus aus L., 1758</common:TitleCache> |
|
24 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
25 |
<name:ProtectedFullTitleCache>false</name:ProtectedFullTitleCache> |
|
26 |
<name:NameCache>Aus aus</name:NameCache> |
|
27 |
<name:AuthorshipCache>L., 1758</name:AuthorshipCache> |
|
28 |
<name:ProtectedAuthorshipCache>false</name:ProtectedAuthorshipCache> |
|
29 |
<name:ProtectedNameCache>false</name:ProtectedNameCache> |
|
30 |
</name:ZoologicalName> |
|
31 |
</TaxonomicNames> |
|
32 |
<TaxonBases> |
|
33 |
<taxon:Taxon id="1" uuid="urn-uuid-2c980a17-4a96-4ea1-b688-90396c0771d9" isDoubtful="false"> |
|
34 |
<common:Annotations> |
|
35 |
<common:Annotation id="1" uuid="urn-uuid-775f5099-0908-4b8b-a59e-4398800a2e1c"> |
|
36 |
<common:Created>2007-04-21T00:00:00Z</common:Created> |
|
37 |
<common:CreatedBy>urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66</common:CreatedBy> |
|
38 |
<common:Annotations> |
|
39 |
<common:Annotation id="2" uuid="urn-uuid-f2efd210-0889-4a0e-9d71-ff1bfcd6c090"> |
|
40 |
<common:Created>2007-05-22T00:00:00Z</common:Created> |
|
41 |
<common:CreatedBy>urn-uuid-cb0a8800-5900-11dd-ae16-0800200c9a66</common:CreatedBy> |
|
42 |
<common:Text>What a load of old rubbish</common:Text> |
|
43 |
<common:Language>urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d</common:Language> |
|
44 |
</common:Annotation> |
|
45 |
</common:Annotations> |
|
46 |
<common:Text>Bibbly bobbly BOING</common:Text> |
|
47 |
<common:Language>urn-uuid-09f563bd-a65f-4b4a-968e-d4fb953e1a8d</common:Language> |
|
48 |
</common:Annotation> |
|
49 |
</common:Annotations> |
|
50 |
<common:TitleCache>Aus aus L., 1758 sec CATE 2008</common:TitleCache> |
|
51 |
<common:ProtectedTitleCache>false</common:ProtectedTitleCache> |
|
52 |
<taxon:Name>urn-uuid-57db34b2-1130-4d42-afe1-cf2d8f1f2a3e</taxon:Name> |
|
53 |
<taxon:TaxonomicChildrenCount>0</taxon:TaxonomicChildrenCount> |
|
54 |
</taxon:Taxon> |
|
55 |
</TaxonBases> |
|
58 | 56 |
</DataSet> |
cdmlib-io/src/test/resources/eu/etaxonomy/cdm/io/specimen/excel/in/ExcelSpecimenImportExampleTest.testResultSet-result.xml | ||
---|---|---|
29 | 29 |
<DESCRIPTIONELEMENTBASE DTYPE="IndividualsAssociation" FEATURE_ID="935" /> <!-- ASSOCIATEDSPECIMENOROBSERVATION_ID="5000" --> |
30 | 30 |
<DESCRIPTIONELEMENTBASE DTYPE="IndividualsAssociation" FEATURE_ID="935" /> <!-- ASSOCIATEDSPECIMENOROBSERVATION_ID="5002" --> |
31 | 31 |
<DESCRIPTIONELEMENTBASE DTYPE="IndividualsAssociation" FEATURE_ID="935" /> <!-- ASSOCIATEDSPECIMENOROBSERVATION_ID="5004" --> |
32 |
<EXTENSION EXTENDEDOBJ_TYPE="DerivedUnit" VALUE="Label name: Vaccinium stanleyi Schweinf. ::"/>
|
|
33 |
<EXTENSION EXTENDEDOBJ_TYPE="DerivedUnit" VALUE="Label name: Philippia johnstonii engl. :: Det. as: Erica mannii (Hook.f.) Beentje by Geerinck D. (BR) in: Nov 2007. (Verification # 57888):: Det. as: Erica johnstonii (Schweinf. ex Engl.) Dorr by : Geerinck D. (BR) in Aug 2007. (Verification #"/>
|
|
34 |
<EXTENSION EXTENDEDOBJ_TYPE="DerivedUnit" VALUE="Label name: Erica arborea ::"/>
|
|
32 |
<EXTENSION VALUE="Label name: Vaccinium stanleyi Schweinf. ::"/> |
|
33 |
<EXTENSION VALUE="Label name: Philippia johnstonii engl. :: Det. as: Erica mannii (Hook.f.) Beentje by Geerinck D. (BR) in: Nov 2007. (Verification # 57888):: Det. as: Erica johnstonii (Schweinf. ex Engl.) Dorr by : Geerinck D. (BR) in Aug 2007. (Verification #"/> |
|
34 |
<EXTENSION VALUE="Label name: Erica arborea ::"/> |
|
35 | 35 |
<GATHERINGEVENT TIMEPERIOD_FREETEXT="[null]" TIMEPERIOD_START="19590306" TIMEPERIOD_END="[null]" ABSOLUTEELEVATION="1300" EXACTLOCATION_REFERENCESYSTEM_ID="2039"/> |
36 | 36 |
<GATHERINGEVENT TIMEPERIOD_FREETEXT="[null]" TIMEPERIOD_START="19800407" TIMEPERIOD_END="19800506" ABSOLUTEELEVATION="1400" EXACTLOCATION_REFERENCESYSTEM_ID="2053"/> |
37 | 37 |
<GATHERINGEVENT TIMEPERIOD_FREETEXT="[null]" TIMEPERIOD_START="18740110" TIMEPERIOD_END="[null]" ABSOLUTEELEVATION="2100" EXACTLOCATION_REFERENCESYSTEM_ID="2054"/> |
... | ... | |
43 | 43 |
<LANGUAGESTRING ID="15" TEXT="rien d'ecology" LANGUAGE_ID="124"/> |
44 | 44 |
<LANGUAGESTRING ID="16" TEXT="A place somewhere out there" LANGUAGE_ID="124"/> |
45 | 45 |
<LANGUAGESTRING ID="17" TEXT="Buisson de 2 m de hauteur. Fleurs roses" LANGUAGE_ID="124"/--> |
46 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="777526" SOURCEDOBJ_TYPE="DerivedUnit"/>
|
|
47 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="222" SOURCEDOBJ_TYPE="DerivedUnit"/>
|
|
48 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="479998" SOURCEDOBJ_TYPE="DerivedUnit"/>
|
|
46 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="777526" /> |
|
47 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="222" /> |
|
48 |
<ORIGINALSOURCEBASE DTYPE="IdentifiableSource" IDINSOURCE="479998"/> |
|
49 | 49 |
<REFERENCE PROTECTEDTITLECACHE="true" TITLECACHE="My first source" REFTYPE="GEN" PROTECTEDABBREVTITLECACHE="false" ABBREVTITLECACHE="Sp. Pl." ABBREVTITLE="Sp. Pl." NOMENCLATURALLYRELEVANT="false"/> |
50 | 50 |
<REFERENCE PROTECTEDTITLECACHE="true" TITLECACHE="My nice source" REFTYPE="GEN" PROTECTEDABBREVTITLECACHE="false" ABBREVTITLECACHE="My nice source" ABBREVTITLE="[null]" NOMENCLATURALLYRELEVANT="false"/> |
51 | 51 |
<REFERENCE PROTECTEDTITLECACHE="true" TITLECACHE="Another source" REFTYPE="GEN" PROTECTEDABBREVTITLECACHE="false" ABBREVTITLECACHE="Another source" ABBREVTITLE="[null]" NOMENCLATURALLYRELEVANT="false"/> |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/AnnotatableEntity.java | ||
---|---|---|
77 | 77 |
@Override |
78 | 78 |
public void addMarker(Marker marker){ |
79 | 79 |
if (marker != null){ |
80 |
marker.setMarkedObj(this); |
|
81 | 80 |
getMarkers().add(marker); |
82 | 81 |
} |
83 | 82 |
} |
... | ... | |
85 | 84 |
public void removeMarker(Marker marker){ |
86 | 85 |
if(getMarkers().contains(marker)) { |
87 | 86 |
getMarkers().remove(marker); |
88 |
marker.setMarkedObj(null); |
|
89 | 87 |
} |
90 | 88 |
} |
91 | 89 |
|
... | ... | |
115 | 113 |
@Override |
116 | 114 |
public void addAnnotation(Annotation annotation){ |
117 | 115 |
if (annotation != null){ |
118 |
annotation.setAnnotatedObj(this); |
|
119 | 116 |
getAnnotations().add(annotation); |
120 | 117 |
} |
121 | 118 |
} |
... | ... | |
124 | 121 |
public void removeAnnotation(Annotation annotation){ |
125 | 122 |
if(getAnnotations().contains(annotation)) { |
126 | 123 |
getAnnotations().remove(annotation); |
127 |
annotation.setAnnotatedObj(null); |
|
128 | 124 |
} |
129 | 125 |
} |
130 | 126 |
|
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 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/Extension.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 |
*/ |
... | ... | |
10 | 10 |
package eu.etaxonomy.cdm.model.common; |
11 | 11 |
|
12 | 12 |
|
13 |
import javax.persistence.Column; |
|
14 | 13 |
import javax.persistence.Entity; |
15 | 14 |
import javax.persistence.FetchType; |
16 |
import javax.persistence.JoinColumn; |
|
17 | 15 |
import javax.persistence.Lob; |
18 | 16 |
import javax.persistence.ManyToOne; |
19 | 17 |
import javax.xml.bind.annotation.XmlAccessType; |
... | ... | |
25 | 23 |
|
26 | 24 |
import org.apache.commons.lang.StringUtils; |
27 | 25 |
import org.apache.log4j.Logger; |
28 |
import org.hibernate.annotations.Any; |
|
29 | 26 |
import org.hibernate.envers.Audited; |
30 |
import org.hibernate.envers.NotAudited; |
|
31 | 27 |
|
32 | 28 |
/** |
33 | 29 |
* This class aims to make available more "attributes" for identifiable entities |
... | ... | |
41 | 37 |
@XmlAccessorType(XmlAccessType.FIELD) |
42 | 38 |
@XmlType(name = "Extension", propOrder = { |
43 | 39 |
"value", |
44 |
"type", |
|
45 |
"extendedObj" |
|
40 |
"type" |
|
46 | 41 |
}) |
47 | 42 |
@Entity |
48 | 43 |
@Audited |
... | ... | |
50 | 45 |
private static final long serialVersionUID = -857207737641432202L; |
51 | 46 |
@SuppressWarnings("unused") |
52 | 47 |
private static final Logger logger = Logger.getLogger(Extension.class); |
53 |
|
|
48 |
|
|
54 | 49 |
@XmlElement(name = "Value") |
55 | 50 |
@Lob |
56 | 51 |
private String value; |
57 |
|
|
52 |
|
|
58 | 53 |
@XmlElement(name = "ExtensionType") |
59 | 54 |
@XmlIDREF |
60 | 55 |
@XmlSchemaType(name = "IDREF") |
61 | 56 |
@ManyToOne(fetch = FetchType.LAZY) |
62 | 57 |
private ExtensionType type; |
63 |
|
|
64 |
@XmlElement(name = "ExtendedObject") |
|
65 |
@XmlIDREF |
|
66 |
@XmlSchemaType(name = "IDREF") |
|
67 |
@Any(metaDef = "CdmBase", |
|
68 |
metaColumn=@Column(name = "extendedObj_type"), |
|
69 |
fetch = FetchType.LAZY, |
|
70 |
optional = false) |
|
71 |
@JoinColumn(name = "extendedObj_id") |
|
72 |
@NotAudited |
|
73 |
private IdentifiableEntity extendedObj; |
|
74 |
|
|
58 |
|
|
75 | 59 |
public static Extension NewInstance(){ |
76 | 60 |
return new Extension(); |
77 | 61 |
} |
78 |
|
|
62 |
|
|
79 | 63 |
/** |
80 | 64 |
* Creates a new extension and adds it to the extended object. |
81 | 65 |
* @param extendedObject |
... | ... | |
90 | 74 |
extendedObject.addExtension(extension); |
91 | 75 |
return extension; |
92 | 76 |
} |
93 |
|
|
94 |
/** |
|
95 |
* TODO should not be private but throws error in persistence/io test |
|
96 |
* Constructor |
|
97 |
*/ |
|
98 |
protected Extension(){ |
|
99 |
} |
|
100 |
|
|
101 |
public IdentifiableEntity getExtendedObj() { |
|
102 |
return extendedObj; |
|
103 |
} |
|
104 |
protected void setExtendedObj(IdentifiableEntity extendedObj) { |
|
105 |
this.extendedObj = extendedObj; |
|
106 |
} |
|
107 | 77 |
|
108 |
|
|
78 |
// *************************** GETTER / SETTER ********************************/ |
|
79 |
|
|
80 |
//type |
|
109 | 81 |
public ExtensionType getType(){ |
110 | 82 |
return this.type; |
111 | 83 |
} |
112 |
|
|
113 |
/** |
|
114 |
* |
|
115 |
* @param type type |
|
116 |
*/ |
|
117 | 84 |
public void setType(ExtensionType type){ |
118 | 85 |
this.type = type; |
119 | 86 |
} |
120 | 87 |
|
88 |
//value |
|
121 | 89 |
public String getValue(){ |
122 | 90 |
return this.value; |
123 | 91 |
} |
124 |
|
|
125 |
/** |
|
126 |
* |
|
127 |
* @param value value |
|
128 |
*/ |
|
129 | 92 |
public void setValue(String value){ |
130 | 93 |
this.value = value; |
131 | 94 |
} |
132 | 95 |
|
133 | 96 |
//***************************** TO STRING *********************************** |
134 |
|
|
97 |
|
|
135 | 98 |
@Override |
136 | 99 |
public String toString() { |
137 | 100 |
if (StringUtils.isNotBlank(this.value)){ |
... | ... | |
140 | 103 |
return super.toString(); |
141 | 104 |
} |
142 | 105 |
} |
143 |
|
|
144 |
|
|
106 |
|
|
107 |
|
|
145 | 108 |
//****************** CLONE ************************************************/ |
146 |
|
|
109 |
|
|
147 | 110 |
@Override |
148 | 111 |
public Object clone() throws CloneNotSupportedException{ |
149 |
Extension result = (Extension)super.clone();
|
|
112 |
Extension result = (Extension)super.clone(); |
|
150 | 113 |
//no changes to: type, value |
151 | 114 |
return result; |
152 | 115 |
} |
153 |
|
|
154 |
/** |
|
155 |
* Clones this extension and sets the clone's extended object to 'extendedObject' |
|
156 |
* @see java.lang.Object#clone() |
|
157 |
*/ |
|
158 |
public Extension clone(IdentifiableEntity extendedObject) throws CloneNotSupportedException{ |
|
159 |
Extension result = (Extension)clone(); |
|
160 |
result.setExtendedObj(extendedObject); |
|
161 |
return result; |
|
162 |
} |
|
163 | 116 |
|
164 | 117 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IOriginalSource.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.model.common; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
14 |
|
|
15 |
/** |
|
16 |
* An original source can be used in different ways.<BR> |
|
17 |
* 1.) As a referencing system. The original source holds all information about the reference, |
|
18 |
* the microReference (page, figure, ...), the identifier used in the source for the referenced object in the |
|
19 |
* reference, a namespace that makes this identifier unique, the original name string that in |
|
20 |
* general stores the representation of the referenced object within the source (if the string representation |
|
21 |
* in the source differs from that one unsed in the CDM object) |
|
22 |
* |
|
23 |
* 2.) Dataprovenance: When importing data from another datasource important information like the identifier |
|
24 |
* and it's namespace (e.g. tablename) as well as the datasource itself maybe stored in an original source. |
|
25 |
* E.g. when importing SDD data here you may store the filename and the id used in the SDD file here. |
|
26 |
* |
|
27 |
* Starting with v3.3 we started to let this class be influenced by the PROV Ontology |
|
28 |
* (http://www.w3.org/TR/2013/NOTE-prov-overview-20130430/). It may move further in this direction in |
|
29 |
* future. |
|
30 |
* The above mentioned ways to use the Original Source are now related to different activity types |
|
31 |
* (http://www.w3.org/TR/2013/REC-prov-dm-20130430/#term-Activity) in PROV. |
|
32 |
* |
|
33 |
* |
|
34 |
* @author a.mueller |
|
35 |
* @created 18.09.2009 |
|
36 |
*/ |
|
37 |
public interface IOriginalSource<T extends ISourceable> { |
|
38 |
|
|
39 |
/*************** GETTER /SETTER ************************************/ |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* Returns the {@link OriginalSourceType type} of the source. The type defines the relationship |
|
44 |
* between the current data and the original data. |
|
45 |
* @see OriginalSourceType |
|
46 |
* @return the type of the source |
|
47 |
*/ |
|
48 |
public OriginalSourceType getType(); |
|
49 |
|
|
50 |
/** |
|
51 |
* @see #getType() |
|
52 |
* @param type the type to be set |
|
53 |
*/ |
|
54 |
public void setType(OriginalSourceType type); |
|
55 |
|
|
56 |
/** |
|
57 |
* Returns the (unique) identifier used in the source. |
|
58 |
* If the identifier is not unique, {@link #getIdNamespace() namespace} should be defined. |
|
59 |
* The namespace together with the identifier should be unique. |
|
60 |
* @return the identifier used in the source. |
|
61 |
*/ |
|
62 |
public String getIdInSource(); |
|
63 |
|
|
64 |
/** |
|
65 |
* @see #getIdInSource() |
|
66 |
* @param idInSource |
|
67 |
*/ |
|
68 |
public void setIdInSource(String idInSource); |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns the id namespace. The id namespace is a String that further defines the origin of |
|
72 |
* the original record. In the combination with the id it should be unique within one a source. |
|
73 |
* E.g. if a record comes from table ABC and has the id 345, 'ABC' is a suitable namespace and the |
|
74 |
* combination of 'ABC' and 345 is a unique id for this source. |
|
75 |
* The namespace is meant to distinguish import records that come from two different tables, elements, objects, ... |
|
76 |
* and end up in the same CDM class. In this case the id may not be enough to identify the original record. |
|
77 |
* @return the idNamespace |
|
78 |
*/ |
|
79 |
public String getIdNamespace(); |
|
80 |
|
|
81 |
/** |
|
82 |
* @see #getIdNamespace() |
|
83 |
* @param idNamespace the idNamespace to set |
|
84 |
*/ |
|
85 |
public void setIdNamespace(String idNamespace); |
|
86 |
|
|
87 |
/** |
|
88 |
* The object this original source is the source for |
|
89 |
* @return |
|
90 |
*/ |
|
91 |
public T getSourcedObj(); |
|
92 |
|
|
93 |
/** |
|
94 |
* @see #getSourcedObj() |
|
95 |
* @param sourcedObj |
|
96 |
*/ |
|
97 |
public void setSourcedObj(T sourcedObj); |
|
98 |
|
|
99 |
/** |
|
100 |
* Returns the micro citation of the according citation. This may be a String |
|
101 |
* defining a page or a page range, a figure in a citation, etc. |
|
102 |
* Examples: 'p.345', 'pp.345-367', 'fig. 3a', ... |
|
103 |
* @return |
|
104 |
*/ |
|
105 |
public String getCitationMicroReference(); |
|
106 |
|
|
107 |
/** |
|
108 |
* @see #getCitationMicroReference() |
|
109 |
* @param microCitation |
|
110 |
*/ |
|
111 |
public void setCitationMicroReference(String microCitation); |
|
112 |
|
|
113 |
|
|
114 |
/** |
|
115 |
* Returns the citation. |
|
116 |
* @return |
|
117 |
*/ |
|
118 |
public Reference getCitation(); |
|
119 |
|
|
120 |
/** |
|
121 |
* @see #getCitation() |
|
122 |
* @param citation |
|
123 |
*/ |
|
124 |
public void setCitation(Reference citation); |
|
125 |
|
|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.model.common; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
14 |
|
|
15 |
/** |
|
16 |
* An original source can be used in different ways.<BR> |
|
17 |
* 1.) As a referencing system. The original source holds all information about the reference, |
|
18 |
* the microReference (page, figure, ...), the identifier used in the source for the referenced object in the |
|
19 |
* reference, a namespace that makes this identifier unique, the original name string that in |
|
20 |
* general stores the representation of the referenced object within the source (if the string representation |
|
21 |
* in the source differs from that one unsed in the CDM object) |
|
22 |
* |
|
23 |
* 2.) Dataprovenance: When importing data from another datasource important information like the identifier |
|
24 |
* and it's namespace (e.g. tablename) as well as the datasource itself maybe stored in an original source. |
|
25 |
* E.g. when importing SDD data here you may store the filename and the id used in the SDD file here. |
|
26 |
* |
|
27 |
* Starting with v3.3 we started to let this class be influenced by the PROV Ontology |
|
28 |
* (http://www.w3.org/TR/2013/NOTE-prov-overview-20130430/). It may move further in this direction in |
|
29 |
* future. |
|
30 |
* The above mentioned ways to use the Original Source are now related to different activity types |
|
31 |
* (http://www.w3.org/TR/2013/REC-prov-dm-20130430/#term-Activity) in PROV. |
|
32 |
* |
|
33 |
* |
|
34 |
* @author a.mueller |
|
35 |
* @created 18.09.2009 |
|
36 |
*/ |
|
37 |
public interface IOriginalSource<T extends ISourceable> { |
|
38 |
|
|
39 |
/*************** GETTER /SETTER ************************************/ |
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* Returns the {@link OriginalSourceType type} of the source. The type defines the relationship |
|
44 |
* between the current data and the original data. |
|
45 |
* @see OriginalSourceType |
|
46 |
* @return the type of the source |
|
47 |
*/ |
|
48 |
public OriginalSourceType getType(); |
|
49 |
|
|
50 |
/** |
|
51 |
* @see #getType() |
|
52 |
* @param type the type to be set |
|
53 |
*/ |
|
54 |
public void setType(OriginalSourceType type); |
|
55 |
|
|
56 |
/** |
|
57 |
* Returns the (unique) identifier used in the source. |
|
58 |
* If the identifier is not unique, {@link #getIdNamespace() namespace} should be defined. |
|
59 |
* The namespace together with the identifier should be unique. |
|
60 |
* @return the identifier used in the source. |
|
61 |
*/ |
|
62 |
public String getIdInSource(); |
|
63 |
|
|
64 |
/** |
|
65 |
* @see #getIdInSource() |
|
66 |
* @param idInSource |
|
67 |
*/ |
|
68 |
public void setIdInSource(String idInSource); |
|
69 |
|
|
70 |
/** |
|
71 |
* Returns the id namespace. The id namespace is a String that further defines the origin of |
|
72 |
* the original record. In the combination with the id it should be unique within one a source. |
|
73 |
* E.g. if a record comes from table ABC and has the id 345, 'ABC' is a suitable namespace and the |
|
74 |
* combination of 'ABC' and 345 is a unique id for this source. |
|
75 |
* The namespace is meant to distinguish import records that come from two different tables, elements, objects, ... |
|
76 |
* and end up in the same CDM class. In this case the id may not be enough to identify the original record. |
|
77 |
* @return the idNamespace |
|
78 |
*/ |
|
79 |
public String getIdNamespace(); |
|
80 |
|
|
81 |
/** |
|
82 |
* @see #getIdNamespace() |
|
83 |
* @param idNamespace the idNamespace to set |
|
84 |
*/ |
|
85 |
public void setIdNamespace(String idNamespace); |
|
86 |
|
|
87 |
/** |
|
88 |
* Returns the micro citation of the according citation. This may be a String |
|
89 |
* defining a page or a page range, a figure in a citation, etc. |
|
90 |
* Examples: 'p.345', 'pp.345-367', 'fig. 3a', ... |
|
91 |
* @return |
|
92 |
*/ |
|
93 |
public String getCitationMicroReference(); |
|
94 |
|
|
95 |
/** |
|
96 |
* @see #getCitationMicroReference() |
|
97 |
* @param microCitation |
|
98 |
*/ |
|
99 |
public void setCitationMicroReference(String microCitation); |
|
100 |
|
|
101 |
|
|
102 |
/** |
|
103 |
* Returns the citation. |
|
104 |
* @return |
|
105 |
*/ |
|
106 |
public Reference getCitation(); |
|
107 |
|
|
108 |
/** |
|
109 |
* @see #getCitation() |
|
110 |
* @param citation |
|
111 |
*/ |
|
112 |
public void setCitation(Reference citation); |
|
113 |
|
|
126 | 114 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java | ||
---|---|---|
244 | 244 |
return cache; |
245 | 245 |
} |
246 | 246 |
|
247 |
|
|
248 |
@Override |
|
249 |
public boolean isProtectedTitleCache() { |
|
250 |
return protectedTitleCache; |
|
251 |
} |
|
252 |
|
|
253 |
@Override |
|
254 |
public void setProtectedTitleCache(boolean protectedTitleCache) { |
|
255 |
this.protectedTitleCache = protectedTitleCache; |
|
256 |
} |
|
257 |
|
|
247 | 258 |
//************************************************************************************** |
248 | 259 |
|
249 | 260 |
@Override |
... | ... | |
332 | 343 |
*/ |
333 | 344 |
public Set<String> getIdentifiers(UUID identifierTypeUuid){ |
334 | 345 |
Set<String> result = new HashSet<String>(); |
335 |
for (Identifier identifier : getIdentifiers()){ |
|
346 |
for (Identifier<?> identifier : getIdentifiers()){
|
|
336 | 347 |
if (identifier.getType().getUuid().equals(identifierTypeUuid)){ |
337 | 348 |
result.add(identifier.getIdentifier()); |
338 | 349 |
} |
... | ... | |
342 | 353 |
|
343 | 354 |
@Override |
344 | 355 |
public Identifier addIdentifier(String identifier, DefinedTerm identifierType){ |
345 |
Identifier result = Identifier.NewInstance(this, identifier, identifierType); |
|
356 |
Identifier<?> result = Identifier.NewInstance(identifier, identifierType); |
|
357 |
addIdentifier(result); |
|
346 | 358 |
return result; |
347 | 359 |
} |
348 | 360 |
|
349 | 361 |
@Override |
350 | 362 |
public void addIdentifier(int index, Identifier identifier){ |
351 | 363 |
if (identifier != null){ |
352 |
if (identifier.getIdentifiedObj() != null && ! identifier.getIdentifiedObj().equals(this)){ |
|
353 |
identifier.getIdentifiedObj().removeIdentifier(identifier); |
|
354 |
} |
|
355 |
identifier.setIdentifiedObj(this); |
|
356 | 364 |
//deduplication |
357 | 365 |
int oldIndex = getIdentifiers().indexOf(identifier); |
358 | 366 |
if(oldIndex > -1){ |
... | ... | |
373 | 381 |
@Override |
374 | 382 |
public void removeIdentifier(Identifier identifier){ |
375 | 383 |
if (identifier != null){ |
376 |
identifier.setIdentifiedObj(null); |
|
377 | 384 |
getIdentifiers().remove(identifier); |
378 | 385 |
} |
379 | 386 |
} |
... | ... | |
423 | 430 |
@Override |
424 | 431 |
public void addExtension(Extension extension){ |
425 | 432 |
if (extension != null){ |
426 |
extension.setExtendedObj(this); |
|
427 | 433 |
getExtensions().add(extension); |
428 | 434 |
} |
429 | 435 |
} |
430 | 436 |
@Override |
431 | 437 |
public void removeExtension(Extension extension){ |
432 | 438 |
if (extension != null){ |
433 |
extension.setExtendedObj(null); |
|
434 | 439 |
getExtensions().remove(extension); |
435 | 440 |
} |
436 | 441 |
} |
437 | 442 |
|
438 |
@Override |
|
439 |
public boolean isProtectedTitleCache() { |
|
440 |
return protectedTitleCache; |
|
441 |
} |
|
442 |
|
|
443 |
@Override |
|
444 |
public void setProtectedTitleCache(boolean protectedTitleCache) { |
|
445 |
this.protectedTitleCache = protectedTitleCache; |
|
446 |
} |
|
447 | 443 |
|
448 | 444 |
@Override |
449 | 445 |
public Set<IdentifiableSource> getSources() { |
... | ... | |
456 | 452 |
@Override |
457 | 453 |
public void addSource(IdentifiableSource source) { |
458 | 454 |
if (source != null){ |
459 |
IdentifiableEntity<?> oldSourcedObj = source.getSourcedObj(); |
|
460 |
if (oldSourcedObj != null && oldSourcedObj != this){ |
|
461 |
oldSourcedObj.getSources().remove(source); |
|
462 |
} |
|
463 | 455 |
getSources().add(source); |
464 |
source.setSourcedObj(this); |
|
465 | 456 |
} |
466 | 457 |
} |
467 | 458 |
|
... | ... | |
469 | 460 |
public void addSources(Set<IdentifiableSource> sources) { |
470 | 461 |
if (sources != null){ |
471 | 462 |
for (IdentifiableSource source: sources){ |
472 |
IdentifiableEntity<?> oldSourcedObj = source.getSourcedObj(); |
|
473 |
if (oldSourcedObj != null && oldSourcedObj != this){ |
|
474 |
oldSourcedObj.getSources().remove(source); |
|
475 |
} |
|
476 | 463 |
getSources().add(source); |
477 |
source.setSourcedObj(this); |
|
478 | 464 |
} |
479 | 465 |
} |
480 | 466 |
} |
... | ... | |
513 | 499 |
|
514 | 500 |
//******************************** TO STRING *****************************************************/ |
515 | 501 |
|
516 |
/* (non-Javadoc) |
|
517 |
* @see eu.etaxonomy.cdm.model.common.IIdentifiableEntity#toString() |
|
518 |
*/ |
|
519 |
@Override |
|
502 |
@Override |
|
520 | 503 |
public String toString() { |
521 | 504 |
String result; |
522 | 505 |
if (titleCache == null){ |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableSource.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
package eu.etaxonomy.cdm.model.common; |
12 | 12 |
|
13 |
import javax.persistence.Column; |
|
14 | 13 |
import javax.persistence.Entity; |
15 |
import javax.persistence.FetchType; |
|
16 |
import javax.persistence.JoinColumn; |
|
17 |
import javax.xml.bind.annotation.XmlElement; |
|
18 |
import javax.xml.bind.annotation.XmlIDREF; |
|
19 |
import javax.xml.bind.annotation.XmlSchemaType; |
|
20 | 14 |
import javax.xml.bind.annotation.XmlType; |
21 | 15 |
|
22 | 16 |
import org.apache.log4j.Logger; |
23 |
import org.hibernate.annotations.Any; |
|
24 | 17 |
import org.hibernate.envers.Audited; |
25 |
import org.hibernate.envers.NotAudited; |
|
26 | 18 |
|
27 | 19 |
import eu.etaxonomy.cdm.model.reference.Reference; |
28 | 20 |
|
... | ... | |
34 | 26 |
* |
35 | 27 |
* @author a.mueller |
36 | 28 |
* @created 18.09.2009 |
37 |
* @version 1.0 |
|
38 | 29 |
*/ |
39 | 30 |
@XmlType(name = "IdentifiableSource", propOrder = { |
40 |
"sourcedObj" |
|
41 | 31 |
}) |
42 | 32 |
@Entity |
43 | 33 |
@Audited |
... | ... | |
88 | 78 |
|
89 | 79 |
// ******************************** FIELDS ************************************/ |
90 | 80 |
|
91 |
@XmlElement(name = "SourcedObject") |
|
92 |
@XmlIDREF |
|
93 |
@XmlSchemaType(name = "IDREF") |
|
94 |
@Any(metaDef = "CdmBase", |
|
95 |
metaColumn=@Column(name = "sourcedObj_type"), |
|
96 |
fetch = FetchType.LAZY, |
|
97 |
optional = false) |
|
98 |
@JoinColumn(name = "sourcedObj_id") |
|
99 |
@NotAudited |
|
100 |
|
|
101 |
// @org.hibernate.annotations.AnyMetaDef(name = "OriginalSource" , |
|
102 |
// metaType="string", |
|
103 |
// idType="integer", |
|
104 |
// metaValues={ |
|
105 |
// @MetaValue(value = "eu.etaxonomy.cdm.model.common.IdentifiableEntity", targetEntity = IdentifiableEntity.class), |
|
106 |
// @MetaValue(value = "eu.etaxonomy.cdm.model.description.DescriptionElementBase", targetEntity = DescriptionElementBase.class), |
|
107 |
// }) |
|
108 |
private IdentifiableEntity<?> sourcedObj; |
|
81 |
|
|
109 | 82 |
|
110 | 83 |
// ****************** CONSTRUCTOR ********************************/ |
111 | 84 |
|
... | ... | |
119 | 92 |
|
120 | 93 |
// ********************** GETTER /SETTER *****************************/ |
121 | 94 |
|
122 |
@Override |
|
123 |
public IdentifiableEntity getSourcedObj() { |
|
124 |
return sourcedObj; |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public void setSourcedObj(IdentifiableEntity sourcedObj) { |
|
129 |
this.sourcedObj = sourcedObj; |
|
130 |
} |
|
131 | 95 |
|
132 | 96 |
//*********************************** CLONE *********************************************************/ |
133 | 97 |
|
134 |
/** |
|
135 |
* Clones this original source and sets the clones sourced object to 'sourceObj' |
|
136 |
* @see java.lang.Object#clone() |
|
137 |
*/ |
|
138 |
public IdentifiableSource clone(IdentifiableEntity sourcedObj) throws CloneNotSupportedException{ |
|
139 |
IdentifiableSource result = (IdentifiableSource)clone(); |
|
140 |
result.setSourcedObj(sourcedObj); |
|
141 |
return result; |
|
142 |
} |
|
143 | 98 |
|
144 | 99 |
@Override |
145 | 100 |
public Object clone() throws CloneNotSupportedException{ |
146 | 101 |
IdentifiableSource result = (IdentifiableSource)super.clone(); |
147 | 102 |
|
148 |
//no changes to: sourcedObj
|
|
103 |
//no changes |
|
149 | 104 |
return result; |
150 | 105 |
} |
151 | 106 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/Identifier.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.model.common; |
|
11 |
|
|
12 |
import javax.persistence.Column; |
|
13 |
import javax.persistence.Entity; |
|
14 |
import javax.persistence.FetchType; |
|
15 |
import javax.persistence.JoinColumn; |
|
16 |
import javax.persistence.ManyToOne; |
|
17 |
import javax.xml.bind.annotation.XmlAccessType; |
|
18 |
import javax.xml.bind.annotation.XmlAccessorType; |
|
19 |
import javax.xml.bind.annotation.XmlElement; |
|
20 |
import javax.xml.bind.annotation.XmlIDREF; |
|
21 |
import javax.xml.bind.annotation.XmlSchemaType; |
|
22 |
import javax.xml.bind.annotation.XmlType; |
|
23 |
|
|
24 |
import org.apache.commons.lang.StringUtils; |
|
25 |
import org.apache.log4j.Logger; |
|
26 |
import org.hibernate.annotations.Any; |
|
27 |
import org.hibernate.annotations.Index; |
|
28 |
import org.hibernate.annotations.Table; |
|
29 |
import org.hibernate.envers.Audited; |
|
30 |
import org.hibernate.envers.NotAudited; |
|
31 |
import org.hibernate.search.annotations.Field; |
|
32 |
|
|
33 |
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty; |
|
34 |
|
|
35 |
/** |
|
36 |
* @author a.mueller |
|
37 |
* @date 2014-06-30 |
|
38 |
*/ |
|
39 |
|
|
40 |
@XmlAccessorType(XmlAccessType.FIELD) |
|
41 |
@XmlType(name = "Identifier", propOrder = { |
|
42 |
"identifier", |
|
43 |
"type", |
|
44 |
"identifiedObj" |
|
45 |
}) |
|
46 |
@Entity |
|
47 |
@Audited |
|
48 |
@Table(appliesTo="Identifier", indexes = { @Index(name = "identifierIndex", columnNames = { "identifier" }) }) |
|
49 |
public class Identifier<T extends IdentifiableEntity<?>> extends AnnotatableEntity implements Cloneable { |
|
50 |
private static final long serialVersionUID = 3337567049024506936L; |
|
51 |
@SuppressWarnings("unused") |
|
52 |
private static final Logger logger = Logger.getLogger(Identifier.class); |
|
53 |
|
|
54 |
|
|
55 |
@XmlElement(name ="Identifier" ) |
|
56 |
@Column(length=800, name="identifier") |
|
57 |
@Field |
|
58 |
@NullOrNotEmpty |
|
59 |
private String identifier; |
|
60 |
|
|
61 |
@XmlElement(name = "Type") |
|
62 |
@XmlIDREF |
|
63 |
@XmlSchemaType(name = "IDREF") |
|
64 |
@ManyToOne(fetch = FetchType.LAZY) |
|
65 |
private DefinedTerm type; |
|
66 |
|
|
67 |
@XmlElement(name = "IdentifiedObject") |
|
68 |
@XmlIDREF |
|
69 |
@XmlSchemaType(name = "IDREF") |
|
70 |
@Any(metaDef = "CdmBase", |
|
71 |
metaColumn=@Column(name = "identifiedObj_type"), |
|
72 |
fetch = FetchType.LAZY, |
|
73 |
optional = false) |
|
74 |
@JoinColumn(name = "identifiedObj_id") |
|
75 |
@NotAudited |
|
76 |
private T identifiedObj; |
|
77 |
|
|
78 |
// **************************** FACTORY ******************************/ |
|
79 |
|
|
80 |
public static <T extends IdentifiableEntity<?>> Identifier<T> NewInstance(T entity, String identifier, DefinedTerm type){ |
|
81 |
return new Identifier<T>(entity, identifier, type); |
|
82 |
} |
|
83 |
|
|
84 |
// ************************* CONSTRUCTOR ************************************ |
|
85 |
|
|
86 |
@Deprecated //for hibernate use only |
|
87 |
protected Identifier(){}; |
|
88 |
|
|
89 |
public Identifier (T entity, String identifier, DefinedTerm type){ |
|
90 |
this.identifier = identifier; |
|
91 |
this.type = type; |
|
92 |
// logger.warn("Identified object not yet implemented"); |
|
93 |
this.identifiedObj = entity; |
|
94 |
identifiedObj.addIdentifier(this); |
Also available in: Unified diff
Remove bidirectionality for supplemental data #5743