3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.io
.common
.mapping
;
13 import java
.sql
.ResultSet
;
14 import java
.sql
.SQLException
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.io
.common
.DbImportStateBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
21 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
22 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
23 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
24 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
28 * Object creation mapper which creates a marker.
34 public class DbImportAnnotationCreationMapper
extends DbImportSupplementCreationMapperBase
<Annotation
, AnnotatableEntity
, DbImportStateBase
<?
, ?
>> {
35 private static final Logger logger
= Logger
.getLogger(DbImportAnnotationCreationMapper
.class);
37 //************************** FACTORY METHODS ***************************************************************/
41 * @param dbAnnotatedObjectAttribute
42 * @param annotatedObjectNamespace
45 public static DbImportAnnotationCreationMapper
NewInstance(String dbAnnotatedObjectAttribute
, String annotatedObjectNamespace
){
46 return new DbImportAnnotationCreationMapper(dbAnnotatedObjectAttribute
, annotatedObjectNamespace
, null, null, null, null);
50 * Creates an annotation mapper which creates an annotation and sets the annotation text,
51 * the annotation language and annotation (added to this annotation) holding the original
53 * If one of the attribute is null the according value is not set.
55 * @param dbAnnotatedObjectAttribute - obligatory
56 * @param annotatedObjectNamespace - obligatory
57 * @param dbAnnotationTextAttribute
59 * @param dbIdAttribute
60 * @param annotationType
63 public static DbImportAnnotationCreationMapper
NewInstance(String dbAnnotatedObjectAttribute
, String annotatedObjectNamespace
, String dbAnnotationTextAttribute
, Language language
, String dbIdAttribute
, MarkerType annotationType
){
64 return new DbImportAnnotationCreationMapper(dbAnnotatedObjectAttribute
, annotatedObjectNamespace
, dbAnnotationTextAttribute
, language
, dbIdAttribute
, annotationType
);
67 // ******************************* VARIABLES ****************************************/
69 protected Language language
;
71 //********************************* CONSTRUCTOR ****************************************/
74 * @param dbSupplementValueAttribute
75 * @param dbSupplementedObjectAttribute
76 * @param dbIdAttribute
77 * @param supplementedObjectNamespace
78 * @param supplementType
80 protected DbImportAnnotationCreationMapper(String dbSupplementedObjectAttribute
, String supplementedObjectNamespace
, String dbSupplementValueAttribute
, Language language
, String dbIdAttribute
, DefinedTermBase supplementType
) {
81 super(dbSupplementValueAttribute
, dbSupplementedObjectAttribute
, dbIdAttribute
, supplementedObjectNamespace
, supplementType
);
82 this.language
= language
;
85 //************************************ METHODS *******************************************/
88 * @see eu.etaxonomy.cdm.io.common.mapping.DbImportSupplementCreationMapperBase#addSupplement(eu.etaxonomy.cdm.model.common.AnnotatableEntity, java.lang.String, eu.etaxonomy.cdm.model.common.AnnotatableEntity)
91 protected boolean addSupplement(Annotation annotation
, AnnotatableEntity annotatableEntity
, String id
) {
92 if (annotatableEntity
!= null){
93 annotatableEntity
.addAnnotation(annotation
);
96 String warning
= "Annotatable entity (" + id
+ ") for annotation not found. Annotation not created.";
103 * @see eu.etaxonomy.cdm.io.common.mapping.DbImportSupplementCreationMapperBase#setSupplementValue(java.lang.Object)
106 protected void setSupplementValue(ResultSet rs
, Annotation annotation
) throws SQLException
{
107 String value
= rs
.getString(dbSupplementValueAttribute
);
108 annotation
.setText(value
);
113 * @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#createObject(java.sql.ResultSet)
116 protected Annotation
createObject(ResultSet rs
) throws SQLException
{
117 Annotation annotation
= Annotation
.NewInstance(null, null);
118 if (language
!= null){
119 annotation
.setLanguage(language
);