3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.app
.pesi
;
12 import org
.apache
.log4j
.Logger
;
14 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
15 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
16 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultExport
;
17 import eu
.etaxonomy
.cdm
.io
.common
.DbExportConfiguratorBase
.IdType
;
18 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.CHECK
;
19 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.DO_REFERENCES
;
20 import eu
.etaxonomy
.cdm
.io
.common
.Source
;
21 import eu
.etaxonomy
.cdm
.io
.pesi
.out
.PesiExportConfigurator
;
22 import eu
.etaxonomy
.cdm
.io
.pesi
.out
.PesiTransformer
;
23 import eu
.etaxonomy
.cdm
.model
.name
.NomenclaturalCode
;
31 public class PesiExportActivatorERMS
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= Logger
.getLogger(PesiExportActivatorERMS
.class);
35 //database validation status (create, update, validate ...)
36 static final Source pesiDestination
= PesiDestinations
.pesi_test_local_CDM_ERMS2PESI();
37 // static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_FE2PESI();
38 // static final Source pesiDestination = PesiDestinations.pesi_test_local_CDM_ERMS2PESI();
40 static final ICdmDataSource cdmSource
= CdmDestinations
.cdm_test_local_mysql_erms();
41 //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
42 static final int nameIdStart
= 10000000;
43 static final IdType idType
= IdType
.CDM_ID_WITH_EXCEPTIONS
;
45 static final int partitionSize
= 1000;
48 static final CHECK check
= CHECK
.EXPORT_WITHOUT_CHECK
;
51 static final NomenclaturalCode nomenclaturalCode
= NomenclaturalCode
.ICNAFP
;
53 static final boolean deleteAll
= true;
56 // ****************** ALL *****************************************
59 static final DO_REFERENCES doReferences
= DO_REFERENCES
.ALL
;
62 static final boolean doTaxa
= true;
63 static final boolean doTreeIndex
= true;
64 static final boolean doRank
= true;
65 static final boolean doInferredSynonyms
= false;
66 static final boolean doRelTaxa
= true;
67 static final boolean doDescriptions
= true;
69 static final boolean doNotes
= true;
70 static final boolean doNoteSources
= true;
71 static final boolean doAdditionalTaxonSource
= true;
72 static final boolean doOccurrence
= true;
73 static final boolean doOccurrenceSource
= true;
74 static final boolean doImage
= true;
77 // ************************ NONE **************************************** //
80 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
83 // static final boolean doTaxa = false;
84 // static final boolean doRelTaxa = false;
85 // static final boolean doNotes = false;
86 // static final boolean doNoteSources = false;
87 // static final boolean doAdditionalTaxonSource = false;
88 // static final boolean doOccurrence = false;
89 // static final boolean doOccurrenceSource = false;
90 // static final boolean doImage = false;
91 // static final boolean doTreeIndex = true;
92 // static final boolean doRank = true;
93 // static final boolean doInferredSynonyms = true;
96 public boolean doExport(ICdmDataSource source
){
97 System
.out
.println("Start export to PESI ("+ pesiDestination
.getDatabase() + ") ...");
100 Source destination
= pesiDestination
;
101 PesiTransformer transformer
= new PesiTransformer(destination
);
103 PesiExportConfigurator config
= PesiExportConfigurator
.NewInstance(destination
, source
, transformer
);
105 config
.setDoTaxa(doTaxa
);
106 config
.setDoRelTaxa(doRelTaxa
);
107 config
.setDoOccurrence(doOccurrence
);
108 config
.setDoReferences(doReferences
);
109 config
.setDoImages(doImage
);
110 config
.setDoNotes(doNotes
);
111 config
.setDoNoteSources(doNoteSources
);
112 config
.setDoOccurrenceSource(doOccurrenceSource
);
113 config
.setDoTreeIndex(doTreeIndex
);
114 config
.setDoRank(doRank
);
115 config
.setDoInferredSynonyms(doInferredSynonyms
);
116 config
.setDoDescription(doDescriptions
);
118 config
.setCheck(check
);
119 config
.setLimitSave(partitionSize
);
120 config
.setIdType(idType
);
121 config
.setNameIdStart(nameIdStart
);
123 destination
.update("EXEC sp_deleteAllData");
127 CdmDefaultExport
<PesiExportConfigurator
> pesiExport
= new CdmDefaultExport
<PesiExportConfigurator
>();
128 boolean result
= pesiExport
.invoke(config
);
130 System
.out
.println("End export to PESI ("+ destination
.getDatabase() + ")..." + (result?
"(successful)":"(with errors)"));
137 public static void main(String
[] args
) {
138 PesiExportActivatorERMS ex
= new PesiExportActivatorERMS();
139 ICdmDataSource source
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmSource
;