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
;
17 import org
.apache
.log4j
.Logger
;
19 import eu
.etaxonomy
.cdm
.io
.common
.DbImportStateBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
23 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
24 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
33 public class DbImportImageCreationMapper
extends DbImportDescriptionElementCreationMapperBase
<TextData
, DbImportStateBase
<?
,?
>> {
34 @SuppressWarnings("unused")
35 private static final Logger logger
= Logger
.getLogger(DbImportImageCreationMapper
.class);
37 // ************************** FACTORY ***********************************************************/
39 public static DbImportImageCreationMapper
NewInstance(String dbIdAttribute
, String objectToCreateNamespace
, String dbTaxonFkAttribute
, String taxonNamespace
, boolean isOneTextData
){
40 return new DbImportImageCreationMapper(dbIdAttribute
, objectToCreateNamespace
, dbTaxonFkAttribute
, taxonNamespace
, isOneTextData
);
44 // ************************** ATTRIBUTES ***********************************************************/
45 private boolean isOneTextData
;
47 //********************************* CONSTRUCTOR ***************************************************/
50 * @param dbIdAttribute
51 * @param objectToCreateNamespace
52 * @param dbTaxonFkAttribute
53 * @param taxonNamespace
55 protected DbImportImageCreationMapper(String dbIdAttribute
, String objectToCreateNamespace
, String dbTaxonFkAttribute
, String taxonNamespace
, boolean isOneTextData
) {
56 super(dbIdAttribute
, objectToCreateNamespace
, dbTaxonFkAttribute
, taxonNamespace
);
57 this.isImageGallery
= true;
58 this.isOneTextData
= isOneTextData
;
61 // ********************************** METHODS ***********************************************************
64 * @see eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapperBase#createObject(java.sql.ResultSet)
67 protected TextData
createObject(ResultSet rs
) throws SQLException
{
68 TextData textData
= TextData
.NewInstance(Feature
.IMAGE());
73 * @see eu.etaxonomy.cdm.io.common.mapping.DbImportDescriptionElementCreationMapperBase#addDescriptionElement(eu.etaxonomy.cdm.model.taxon.Taxon, eu.etaxonomy.cdm.model.description.DescriptionElementBase)
76 protected TextData
addDescriptionElement(Taxon taxon
, TextData element
) {
80 TaxonDescription description
= getTaxonDescription(taxon
, isImageGallery
);
81 if (isOneTextData
== true){
83 Set
<DescriptionElementBase
> elements
= description
.getElements();
84 for (DescriptionElementBase descElement
: elements
){
85 if (descElement
.isInstanceOf(TextData
.class) && descElement
.getFeature().equals(Feature
.IMAGE()) ){
86 element
= CdmBase
.deproxy(descElement
, TextData
.class);
90 description
.addElement(element
);