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
.common
.CdmUtils
;
19 import eu
.etaxonomy
.cdm
.io
.common
.DbImportStateBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
23 * This mapper does not change any import object, but keeps the information that a database
24 * attribute does not need to be mapped.
29 public class DbIgnoreMapper
extends DbSingleAttributeImportMapperBase
<DbImportStateBase
<?
,?
>, CdmBase
> {
30 private static final Logger logger
= Logger
.getLogger(DbIgnoreMapper
.class);
32 //*************************** FACTORY ***************************************************************//
34 public static DbIgnoreMapper
NewInstance(String dbAttributeToIgnore
){
35 return new DbIgnoreMapper(dbAttributeToIgnore
, null, null, null);
38 public static DbIgnoreMapper
NewInstance(String dbAttributeToIgnore
, String ignoreReason
){
39 return new DbIgnoreMapper(dbAttributeToIgnore
, null, null, ignoreReason
);
42 //*************************** VARIABLES ***************************************************************//
43 private String ignoreReason
;
45 //*************************** CONSTRUCTOR ***************************************************************//
48 * @param dbAttributString
49 * @param cdmAttributeString
52 protected DbIgnoreMapper(String dbAttributString
, String cdmAttributeString
, Object defaultValue
, String ignoreReason
) {
53 super(dbAttributString
, cdmAttributeString
, defaultValue
);
54 this.ignoreReason
= ignoreReason
;
58 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#invoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.CdmBase)
61 public CdmBase
invoke(ResultSet rs
, CdmBase cdmBase
) throws SQLException
{
62 return cdmBase
; //do nothing
67 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
70 public Class
getTypeClass() {
71 return null; //not needed
75 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#initialize(eu.etaxonomy.cdm.io.common.DbImportStateBase, java.lang.Class)
78 public void initialize(DbImportStateBase
<?
,?
> state
, Class
<?
extends CdmBase
> destinationClass
) {
79 String localIgnoreReason
= "";
80 if (CdmUtils
.isNotEmpty(ignoreReason
)){
81 localIgnoreReason
= "(" + ignoreReason
+")";
83 logger
.warn(this.getSourceAttribute() + " ignored" + localIgnoreReason
);