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
.CdmBase
;
26 public abstract class DbImportMultiAttributeMapperBase
<CDMBASE
extends CdmBase
, STATE
extends DbImportStateBase
<?
,?
>> extends MultipleAttributeMapperBase
<CdmSingleAttributeMapperBase
> implements IDbImportMapper
<STATE
, CDMBASE
>{
27 @SuppressWarnings("unused")
28 private static final Logger logger
= Logger
.getLogger(DbImportMultiAttributeMapperBase
.class);
30 //**************************** ATTRIBUTES ****************************************************
32 protected DbImportMapperBase
<STATE
> importMapperHelper
= new DbImportMapperBase
<STATE
>();
35 * @see eu.etaxonomy.cdm.io.common.mapping.IDbImportMapper#initialize(eu.etaxonomy.cdm.io.common.DbImportStateBase, java.lang.Class)
37 public void initialize(STATE state
, Class
<?
extends CdmBase
> destinationClass
) {
38 importMapperHelper
.initialize(state
, destinationClass
);
41 protected STATE
getState(){
42 return importMapperHelper
.getState();
47 * Retrieves a related object from the state's related object map. Needs casting.
52 protected CdmBase
getRelatedObject(String namespace
, String foreignKey
) {
53 STATE state
= importMapperHelper
.getState();
54 CdmBase result
= state
.getRelatedObject(namespace
, foreignKey
);
59 * Retrieves a related object from the state's related object map. Needs casting.
63 * @throws SQLException
65 protected CdmBase
getRelatedObject(ResultSet rs
, String namespace
, String fkAttribute
) throws SQLException
{
66 STATE state
= importMapperHelper
.getState();
67 String foreignKey
= getForeignKey(rs
, fkAttribute
);
68 CdmBase result
= state
.getRelatedObject(namespace
, foreignKey
);
74 * @param dbReferenceFkAttribute2
76 * @throws SQLException
78 protected String
getForeignKey(ResultSet rs
, String fkAttribute
) throws SQLException
{
79 Object oForeignKey
= rs
.getObject(fkAttribute
);
80 String result
= String
.valueOf(oForeignKey
);