dfe3722a8c72270c2b30c890c19a537eb7818a6c
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / common / mapping / out / DbExportNotYetImplementedMapper.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.out;
12
13 import java.sql.PreparedStatement;
14 import java.sql.SQLException;
15
16 import org.apache.commons.lang.StringUtils;
17 import org.apache.log4j.Logger;
18
19 import eu.etaxonomy.cdm.io.common.DbExportStateBase;
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 needs to be mapped but is not yet mapped.
25 * @author a.mueller
26 * @created 25.02.2010
27 * @version 1.0
28 */
29 public class DbExportNotYetImplementedMapper extends DbSingleAttributeExportMapperBase<DbExportStateBase> {
30 private static final Logger logger = Logger.getLogger(DbExportNotYetImplementedMapper.class);
31
32 public static DbExportNotYetImplementedMapper NewInstance(String dbAttributeToIgnore){
33 return new DbExportNotYetImplementedMapper(dbAttributeToIgnore, null, null, null);
34 }
35
36 public static DbExportNotYetImplementedMapper NewInstance(String dbAttributeToIgnore, String reason){
37 return new DbExportNotYetImplementedMapper(dbAttributeToIgnore, null, null, reason);
38 }
39
40 //*************************** VARIABLES ***************************************************************//
41 private String unimplementedReason;
42
43 //*************************** CONSTRUCTOR ***************************************************************//
44
45 /**
46 * @param dbAttributString
47 * @param cdmAttributeString
48 * @param defaultValue
49 */
50 protected DbExportNotYetImplementedMapper(String dbAttributString, String cdmAttributeString, Object defaultValue, String unimplementedReason) {
51 super(dbAttributString, cdmAttributeString, defaultValue);
52 this.unimplementedReason = unimplementedReason;
53 }
54
55 @Override
56 public void initialize(PreparedStatement stmt, IndexCounter index, DbExportStateBase state, String tableName) {
57 String attributeName = this.getSourceAttribute();
58 String localReason = "";
59 if (StringUtils.isNotBlank(unimplementedReason)){
60 localReason = " (" + unimplementedReason +")";
61 }
62 logger.warn(attributeName + " not yet implemented . " + localReason);
63 exportMapperHelper.initializeNull(stmt, state, tableName);
64 }
65
66 @Override
67 protected boolean doInvoke(CdmBase cdmBase) throws SQLException {
68 return true; // do nothing
69 }
70
71
72 /* (non-Javadoc)
73 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
74 */
75 @Override
76 public Class getTypeClass() {
77 return null; //not needed
78 }
79
80
81 @Override
82 protected int getSqlType() {
83 return -1; // not needed
84 }
85
86
87
88
89 }