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.pesi.out;
|
11
|
|
12
|
import java.sql.PreparedStatement;
|
13
|
import java.sql.SQLException;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.io.common.DbExportStateBase;
|
18
|
import eu.etaxonomy.cdm.io.common.mapping.MultipleAttributeMapperBase;
|
19
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbExportNotYetImplementedMapper;
|
20
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbLastActionMapper;
|
21
|
import eu.etaxonomy.cdm.io.common.mapping.out.DbSingleAttributeExportMapperBase;
|
22
|
import eu.etaxonomy.cdm.io.common.mapping.out.IDbExportMapper;
|
23
|
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer;
|
24
|
import eu.etaxonomy.cdm.io.common.mapping.out.IndexCounter;
|
25
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
* @since 12.05.2009
|
30
|
* @version 1.0
|
31
|
*/
|
32
|
public class ExpertsAndLastActionMapper extends MultipleAttributeMapperBase<DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>>> implements IDbExportMapper<DbExportStateBase<?, IExportTransformer>, IExportTransformer>{
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger.getLogger(ExpertsAndLastActionMapper.class);
|
35
|
|
36
|
private static final boolean IS_ACTION_TYPE = true;
|
37
|
|
38
|
public static ExpertsAndLastActionMapper NewInstance(){
|
39
|
return new ExpertsAndLastActionMapper();
|
40
|
}
|
41
|
|
42
|
|
43
|
/**
|
44
|
* @param dbAttributString
|
45
|
* @param cdmAttributeString
|
46
|
*/
|
47
|
private ExpertsAndLastActionMapper() {
|
48
|
singleMappers.add(DbLastActionMapper.NewInstance("LastActionDate", ! IS_ACTION_TYPE));
|
49
|
singleMappers.add(DbLastActionMapper.NewInstance("LastAction", IS_ACTION_TYPE));
|
50
|
singleMappers.add(DbExportNotYetImplementedMapper.NewInstance("SpeciesExpertName", "Need to better understand what the species expert name is"));
|
51
|
singleMappers.add(DbExportNotYetImplementedMapper.NewInstance("SpeciesExpertGUID", "SpeciesExpertGUID derives from an external mapeing list: name to GUID from expertsDB"));
|
52
|
}
|
53
|
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.IDbExportMapper#initialize(java.sql.PreparedStatement, eu.etaxonomy.cdm.io.berlinModel.out.mapper.IndexCounter, eu.etaxonomy.cdm.io.berlinModel.out.DbExportState)
|
57
|
*/
|
58
|
public void initialize(PreparedStatement stmt, IndexCounter index, DbExportStateBase<?, IExportTransformer> state, String tableName) {
|
59
|
for (DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> mapper : singleMappers){
|
60
|
mapper.initialize(stmt, index, state, tableName);
|
61
|
}
|
62
|
}
|
63
|
|
64
|
|
65
|
/* (non-Javadoc)
|
66
|
* @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.IDbExportMapper#invoke(eu.etaxonomy.cdm.model.common.CdmBase)
|
67
|
*/
|
68
|
public boolean invoke(CdmBase cdmBase) throws SQLException {
|
69
|
boolean result = true;
|
70
|
for (DbSingleAttributeExportMapperBase<DbExportStateBase<?, IExportTransformer>> mapper : singleMappers){
|
71
|
result &= mapper.invoke(cdmBase);
|
72
|
}
|
73
|
return result;
|
74
|
}
|
75
|
|
76
|
|
77
|
}
|