Project

General

Profile

Download (2.99 KB) Statistics
| Branch: | Tag: | Revision:
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

    
10
package eu.etaxonomy.cdm.io.common.mapping;
11

    
12
import java.sql.ResultSet;
13
import java.sql.SQLException;
14

    
15
import org.apache.log4j.Logger;
16

    
17
import eu.etaxonomy.cdm.common.CdmUtils;
18
import eu.etaxonomy.cdm.io.common.DbImportStateBase;
19
import eu.etaxonomy.cdm.model.common.CdmBase;
20

    
21
/**
22
 * This mapper does not change any import object, but keeps the information that a database
23
 * attribute needs to be mapped but is not yet mapped.
24
 * @author a.mueller
25
 * @created 25.02.2010
26
 * @version 1.0
27
 */
28
public class DbNotYetImplementedMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, CdmBase> {
29
	private static final Logger logger = Logger.getLogger(DbNotYetImplementedMapper.class);
30
	
31
	public static DbNotYetImplementedMapper NewInstance(String dbAttributeToIgnore){
32
		return new DbNotYetImplementedMapper(dbAttributeToIgnore, null, null, null);
33
	}
34

    
35
	public static DbNotYetImplementedMapper NewInstance(String dbAttributeToIgnore, String reason){
36
		return new DbNotYetImplementedMapper(dbAttributeToIgnore, null, null, reason);
37
	}
38

    
39
//*************************** VARIABLES ***************************************************************//
40
	private String unimplementedReason;
41
	
42
//*************************** CONSTRUCTOR ***************************************************************//
43
	
44
	/**
45
	 * @param dbAttributString
46
	 * @param cdmAttributeString
47
	 * @param defaultValue
48
	 */
49
	protected DbNotYetImplementedMapper(String dbAttributString, String cdmAttributeString, Object defaultValue, String unimplementedReason) {
50
		super(dbAttributString, cdmAttributeString, defaultValue);
51
		this.unimplementedReason = unimplementedReason;
52
	}
53

    
54
	/* (non-Javadoc)
55
	 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#invoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.CdmBase)
56
	 */
57
	@Override
58
	public CdmBase invoke(ResultSet rs, CdmBase cdmBase) throws SQLException {
59
		return cdmBase; //do nothing
60
	}
61

    
62
	/* (non-Javadoc)
63
	 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
64
	 */
65
	@Override
66
	public Class getTypeClass() {
67
		return null;  //not needed
68
	}
69

    
70
	/* (non-Javadoc)
71
	 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#initialize(eu.etaxonomy.cdm.io.common.DbImportStateBase, java.lang.Class)
72
	 */
73
	@Override
74
	public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) {
75
		String attributeName = this.getSourceAttribute();
76
		String localReason = "";
77
		if (CdmUtils.isNotEmpty(unimplementedReason)){
78
			localReason = " (" + unimplementedReason +")";
79
		}
80
		logger.warn(attributeName + " not yet implemented for class " + destinationClass.getSimpleName() +  localReason);
81
	}
82

    
83
	
84
	
85
	
86
}
(39-39/51)