Latest changes for PESI export and introduce transformers in export mappings
[cdmlib-apps.git] / cdm-pesi / src / main / java / eu / etaxonomy / cdm / io / pesi / out / ExpertsAndLastActionMapper.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.pesi.out;
12
13 import java.sql.PreparedStatement;
14 import java.sql.SQLException;
15
16 import org.apache.log4j.Logger;
17
18 import eu.etaxonomy.cdm.io.common.DbExportStateBase;
19 import eu.etaxonomy.cdm.io.common.mapping.MultipleAttributeMapperBase;
20 import eu.etaxonomy.cdm.io.common.mapping.out.DbSingleAttributeExportMapperBase;
21 import eu.etaxonomy.cdm.io.common.mapping.out.IDbExportMapper;
22 import eu.etaxonomy.cdm.io.common.mapping.out.IndexCounter;
23 import eu.etaxonomy.cdm.model.common.CdmBase;
24
25 /**
26 * @author a.mueller
27 * @created 12.05.2009
28 * @version 1.0
29 */
30 public class ExpertsAndLastActionMapper extends MultipleAttributeMapperBase<DbSingleAttributeExportMapperBase<DbExportStateBase<?>>> implements IDbExportMapper<DbExportStateBase<?>>{
31 @SuppressWarnings("unused")
32 private static final Logger logger = Logger.getLogger(ExpertsAndLastActionMapper.class);
33
34 public static ExpertsAndLastActionMapper NewInstance(){
35 return new ExpertsAndLastActionMapper(true);
36 }
37
38
39 /**
40 * @param dbAttributString
41 * @param cdmAttributeString
42 */
43 private ExpertsAndLastActionMapper(boolean withUpdate) {
44 // singleMappers.add(DbUserMapper.NewInstance("createdBy", "Created_Who"));
45 // singleMappers.add(DbDateMapper.NewInstance("created", "Created_When"));
46 // singleMappers.add(MethodMapper.NewInstance("Notes", this.getClass(), "getNotes", AnnotatableEntity.class));
47 // if (withUpdate){
48 // singleMappers.add(DbUserMapper.NewInstance("updatedBy", "Updated_Who"));
49 // singleMappers.add(DbDateMapper.NewInstance("updated", "Updated_When"));
50 // }
51 }
52
53
54 /* (non-Javadoc)
55 * @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)
56 */
57 public void initialize(PreparedStatement stmt, IndexCounter index, DbExportStateBase<?> state, String tableName) {
58 for (DbSingleAttributeExportMapperBase<DbExportStateBase<?>> mapper : singleMappers){
59 mapper.initialize(stmt, index, state, tableName);
60 }
61 }
62
63
64 /* (non-Javadoc)
65 * @see eu.etaxonomy.cdm.io.berlinModel.out.mapper.IDbExportMapper#invoke(eu.etaxonomy.cdm.model.common.CdmBase)
66 */
67 public boolean invoke(CdmBase cdmBase) throws SQLException {
68 boolean result = true;
69 for (DbSingleAttributeExportMapperBase<DbExportStateBase<?>> mapper : singleMappers){
70 result &= mapper.invoke(cdmBase);
71 }
72 return result;
73 }
74
75 // //used by MethodMapper
76 // @SuppressWarnings("unused")
77 // private static String getNotes(AnnotatableEntity obj){
78 // String result = "";
79 // String separator = ";";
80 // for (Annotation annotation :obj.getAnnotations()){
81 // if (! AnnotationType.TECHNICAL().equals(annotation.getAnnotationType())){
82 // if (! ( annotation.getText() != null && annotation.getText().startsWith("ORDER:"))){ //TODO casus Salvador, should be stored in Extension ones extensions are also for annotatable entities
83 // result = CdmUtils.concat(separator, result, annotation.getText());
84 // }
85 // }
86 // }
87 // return (result.trim().equals("")? null : result);
88 // }
89
90 }