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 needs to be mapped but is not yet mapped.
|
23
|
*
|
24
|
* @author a.mueller
|
25
|
* @since 25.02.2010
|
26
|
*/
|
27
|
public class DbNotYetImplementedMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase> {
|
28
|
private static final Logger logger = LogManager.getLogger(DbNotYetImplementedMapper.class);
|
29
|
|
30
|
public static DbNotYetImplementedMapper NewInstance(String dbAttributeToIgnore){
|
31
|
return new DbNotYetImplementedMapper(dbAttributeToIgnore, null, null, null);
|
32
|
}
|
33
|
|
34
|
public static DbNotYetImplementedMapper NewInstance(String dbAttributeToIgnore, String reason){
|
35
|
return new DbNotYetImplementedMapper(dbAttributeToIgnore, null, null, reason);
|
36
|
}
|
37
|
|
38
|
//*************************** VARIABLES ***************************************************************//
|
39
|
|
40
|
private String unimplementedReason;
|
41
|
|
42
|
//*************************** CONSTRUCTOR ***************************************************************//
|
43
|
|
44
|
protected DbNotYetImplementedMapper(String dbAttributString, String cdmAttributeString, Object defaultValue, String unimplementedReason) {
|
45
|
super(dbAttributString, cdmAttributeString, defaultValue);
|
46
|
this.unimplementedReason = unimplementedReason;
|
47
|
}
|
48
|
|
49
|
@Override
|
50
|
public CdmBase invoke(ResultSet rs, CdmBase cdmBase) throws SQLException {
|
51
|
return cdmBase; //do nothing
|
52
|
}
|
53
|
|
54
|
@Override
|
55
|
public Class getTypeClass() {
|
56
|
return null; //not needed
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) {
|
61
|
String attributeName = this.getSourceAttribute();
|
62
|
String localReason = "";
|
63
|
if (StringUtils.isNotBlank(unimplementedReason)){
|
64
|
localReason = " (" + unimplementedReason +")";
|
65
|
}
|
66
|
logger.warn(attributeName + " not yet implemented for class " + destinationClass.getSimpleName() + localReason);
|
67
|
}
|
68
|
}
|