cleanup
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / common / mapping / DbIgnoreMapper.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.cdm.io.common.mapping;
12
13 import java.sql.ResultSet;
14 import java.sql.SQLException;
15
16 import org.apache.log4j.Logger;
17
18 import eu.etaxonomy.cdm.common.CdmUtils;
19 import eu.etaxonomy.cdm.io.common.DbImportStateBase;
20 import eu.etaxonomy.cdm.model.common.CdmBase;
21
22 /**
23 * This mapper does not change any import object, but keeps the information that a database
24 * attribute does not need to be mapped.
25 * @author a.mueller
26 * @created 25.02.2010
27 * @version 1.0
28 */
29 public class DbIgnoreMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase> {
30 private static final Logger logger = Logger.getLogger(DbIgnoreMapper.class);
31
32 //*************************** FACTORY ***************************************************************//
33
34 public static DbIgnoreMapper NewInstance(String dbAttributeToIgnore){
35 return new DbIgnoreMapper(dbAttributeToIgnore, null, null, null);
36 }
37
38 public static DbIgnoreMapper NewInstance(String dbAttributeToIgnore, String ignoreReason){
39 return new DbIgnoreMapper(dbAttributeToIgnore, null, null, ignoreReason);
40 }
41
42 //*************************** VARIABLES ***************************************************************//
43 private String ignoreReason;
44
45 //*************************** CONSTRUCTOR ***************************************************************//
46
47 /**
48 * @param dbAttributString
49 * @param cdmAttributeString
50 * @param defaultValue
51 */
52 protected DbIgnoreMapper(String dbAttributString, String cdmAttributeString, Object defaultValue, String ignoreReason) {
53 super(dbAttributString, cdmAttributeString, defaultValue);
54 this.ignoreReason = ignoreReason;
55 }
56
57 /* (non-Javadoc)
58 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#invoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.CdmBase)
59 */
60 @Override
61 public CdmBase invoke(ResultSet rs, CdmBase cdmBase) throws SQLException {
62 return cdmBase; //do nothing
63 }
64
65
66 /* (non-Javadoc)
67 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
68 */
69 @Override
70 public Class getTypeClass() {
71 return null; //not needed
72 }
73
74 /* (non-Javadoc)
75 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#initialize(eu.etaxonomy.cdm.io.common.DbImportStateBase, java.lang.Class)
76 */
77 @Override
78 public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) {
79 String localIgnoreReason = "";
80 if (CdmUtils.isNotEmpty(ignoreReason)){
81 localIgnoreReason = "(" + ignoreReason +")";
82 }
83 logger.warn(this.getSourceAttribute() + " ignored" + localIgnoreReason);
84 }
85
86
87
88 }