1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.io.common.mapping;
|
10
|
|
11
|
import java.sql.ResultSet;
|
12
|
import java.sql.SQLException;
|
13
|
|
14
|
import org.apache.commons.lang3.StringUtils;
|
15
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
|
18
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
19
|
|
20
|
/**
|
21
|
* This mapper does not change any import object, but keeps the information that a database
|
22
|
* attribute does not need to be mapped.
|
23
|
*
|
24
|
* @author a.mueller
|
25
|
* @since 25.02.2010
|
26
|
*/
|
27
|
public class DbIgnoreMapper
|
28
|
extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase> {
|
29
|
|
30
|
private static final Logger logger = LogManager.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
|
|
44
|
private String ignoreReason;
|
45
|
|
46
|
//*************************** CONSTRUCTOR ***************************************************************//
|
47
|
|
48
|
protected DbIgnoreMapper(String dbAttributString, String cdmAttributeString, Object defaultValue, String ignoreReason) {
|
49
|
super(dbAttributString, cdmAttributeString, defaultValue);
|
50
|
this.ignoreReason = ignoreReason;
|
51
|
}
|
52
|
|
53
|
@Override
|
54
|
public CdmBase invoke(ResultSet rs, CdmBase cdmBase) throws SQLException {
|
55
|
return cdmBase; //do nothing
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public Class getTypeClass() {
|
60
|
return null; //not needed
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) {
|
65
|
String localIgnoreReason = "";
|
66
|
if (StringUtils.isNotBlank(ignoreReason)){
|
67
|
localIgnoreReason = "(" + ignoreReason +")";
|
68
|
}
|
69
|
logger.warn(this.getSourceAttribute() + " ignored" + localIgnoreReason);
|
70
|
}
|
71
|
}
|