2 * Copyright (C) 2009 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.app
.pesi
;
11 import org
.apache
.log4j
.Logger
;
13 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
14 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
15 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultExport
;
16 import eu
.etaxonomy
.cdm
.io
.common
.DbExportConfiguratorBase
.IdType
;
17 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.CHECK
;
18 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.DO_REFERENCES
;
19 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
20 import eu
.etaxonomy
.cdm
.io
.pesi
.out
.PesiExportConfigurator
;
21 import eu
.etaxonomy
.cdm
.io
.pesi
.out
.PesiTransformer
;
29 public class PesiExportActivatorFE
{
30 @SuppressWarnings("unused")
31 private static final Logger logger
= Logger
.getLogger(PesiExportActivatorFE
.class);
33 //database validation status (create, update, validate ...)
34 static final Source pesiDestination
= PesiDestinations
.pesi_test_local_CDM_FE2PESI();
35 // static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI();
37 static final ICdmDataSource cdmSource
= CdmDestinations
.cdm_test_local_faunaEu_mysql();
38 // static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_mysql();
40 //Taxon names can't be mapped to their CDM ids as PESI Taxon table mainly holds taxa and there IDs. We ad nameIdStart to the TaxonName id to get a unique id
41 static final int nameIdStart
= 10000000;
43 static final int partitionSize
= 2000;
46 static final CHECK check
= CHECK
.EXPORT_WITHOUT_CHECK
;
48 static final boolean deleteAll
= true;
50 static final IdType idType
= IdType
.CDM_ID_WITH_EXCEPTIONS
;
52 // ****************** ALL *****************************************
55 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
58 static final boolean doTaxa
= true;
59 static final boolean doRelTaxa
= true;
60 static final boolean doNotes
= true;
61 static final boolean doNoteSources
= true;
62 static final boolean doAdditionalTaxonSource
= true;
63 static final boolean doOccurrence
= true;
64 static final boolean doOccurrenceSource
= true;
65 static final boolean doImage
= true;
66 static final boolean doTreeIndex
= true;
67 static final boolean doRank
= true;
68 static final boolean doInferredSynonyms
= true;
69 static final boolean doPureNames
= false; // !!!
70 static final boolean doDescription
= true;
73 // ************************ NONE **************************************** //
76 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
79 // static final boolean doTaxa = false;
80 // static final boolean doRelTaxa = false;
81 // static final boolean doNotes = false;
82 // static final boolean doNoteSources = false;
83 // static final boolean doAdditionalTaxonSource = false;
84 // static final boolean doOccurrence = false;
85 // static final boolean doOccurrenceSource = false;
86 // static final boolean doImage = false;
87 // static final boolean doTreeIndex = true;
88 // static final boolean doRank = true;
89 // static final boolean doInferredSynonyms = true;
90 // static final boolean doDescription = false;
93 public boolean doExport(ICdmDataSource source
){
94 System
.out
.println("Start export to PESI ("+ pesiDestination
.getDatabase() + ") ...");
97 Source destination
= pesiDestination
;
98 PesiTransformer transformer
= new PesiTransformer(destination
);
100 PesiExportConfigurator config
= PesiExportConfigurator
.NewInstance(destination
, source
, transformer
);
102 config
.setDoTaxa(doTaxa
);
103 config
.setDoRelTaxa(doRelTaxa
);
104 config
.setDoOccurrence(doOccurrence
);
105 config
.setDoReferences(doReferences
);
106 config
.setDoImages(doImage
);
107 config
.setDoNotes(doNotes
);
108 config
.setDoNoteSources(doNoteSources
);
109 config
.setDoOccurrenceSource(doOccurrenceSource
);
110 config
.setDoTreeIndex(doTreeIndex
);
111 config
.setDoInferredSynonyms(doInferredSynonyms
);
112 config
.setDoPureNames(doPureNames
);
113 config
.setDoDescription(doDescription
);
115 config
.setCheck(check
);
116 config
.setLimitSave(partitionSize
);
117 config
.setIdType(idType
);
118 config
.setNameIdStart(nameIdStart
);
120 destination
.update("EXEC sp_deleteAllData");
125 CdmDefaultExport
<PesiExportConfigurator
> pesiExport
= new CdmDefaultExport
<PesiExportConfigurator
>();
127 boolean result
= pesiExport
.invoke(config
).isSuccess();
129 System
.out
.println("End export to PESI ("+ destination
.getDatabase() + ")..." + (result?
"(successful)":"(with errors)"));
136 public static void main(String
[] args
) {
137 PesiExportActivatorFE ex
= new PesiExportActivatorFE();
138 ICdmDataSource source
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmSource
;