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
;
15 import java
.util
.ArrayList
;
16 import java
.util
.HashSet
;
17 import java
.util
.List
;
20 import org
.apache
.log4j
.Logger
;
22 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
31 public abstract class MultipleAttributeMapperBase
<SINGLE_MAPPER
extends CdmSingleAttributeMapperBase
> extends CdmAttributeMapperBase
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= Logger
.getLogger(MultipleAttributeMapperBase
.class);
36 //******************************* ATTRIBUTES ***************************************/
38 protected List
<SINGLE_MAPPER
> singleMappers
= new ArrayList
<SINGLE_MAPPER
>();
42 //********************************* CONSTRUCTOR ****************************************/
47 public MultipleAttributeMapperBase() {
48 singleMappers
= new ArrayList
<SINGLE_MAPPER
>();
52 //************************************ METHODS *******************************************/
55 * @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getDestinationAttributeList()
58 public List
<String
> getDestinationAttributeList() {
59 List
<String
> result
= new ArrayList
<String
>();
60 for (SINGLE_MAPPER singleMapper
: singleMappers
){
61 result
.add(singleMapper
.getDestinationAttribute());
67 * @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getDestinationAttributes()
70 public Set
<String
> getDestinationAttributes() {
71 Set
<String
> result
= new HashSet
<String
>();
72 result
.addAll(getDestinationAttributeList());
77 * @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getSourceAttributeList()
80 public List
<String
> getSourceAttributeList() {
81 List
<String
> result
= new ArrayList
<String
>();
82 for (SINGLE_MAPPER singleMapper
: singleMappers
){
83 result
.add(singleMapper
.getSourceAttribute());
89 * @see eu.etaxonomy.cdm.io.common.CdmAttributeMapperBase#getSourceAttributes()
92 public Set
<String
> getSourceAttributes() {
93 Set
<String
> result
= new HashSet
<String
>();
94 result
.addAll(getSourceAttributeList());
100 * Returns the value of a result set attribute in its String representation.
101 * Better move this to a subclass for DbImportMappers (does not exist yet)
105 * @throws SQLException
107 protected String
getStringDbValue(ResultSet rs
, String attribute
) throws SQLException
{
108 if (CdmUtils
.isEmpty(attribute
)){
111 Object oId
= rs
.getObject(attribute
);
115 String id
= String
.valueOf(oId
);