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 PesiExportActivatorEM
{
32 @SuppressWarnings("unused")
33 private static final Logger logger
= Logger
.getLogger(PesiExportActivatorEM
.class);
35 //database validation status (create, update, validate ...)
36 static final Source pesiDestination
= PesiDestinations
.pesi_test_local_CDM_EM2PESI();
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_pesi_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 doPureNames
= true;
64 static final boolean doTreeIndex
= true;
65 static final boolean doParentAndBiota
= true;
66 static final boolean doRank
= true;
67 static final boolean doInferredSynonyms
= false; //no inferred synonyms in E+M
68 static final boolean doRelTaxa
= true;
69 static final boolean doDescriptions
= true;
71 static final boolean doNotes
= true;
72 static final boolean doNoteSources
= true;
73 static final boolean doAdditionalTaxonSource
= true;
74 static final boolean doOccurrence
= true;
75 static final boolean doOccurrenceSource
= true;
76 static final boolean doImage
= true;
79 // ************************ NONE **************************************** //
82 // static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
85 // static final boolean doTaxa = false;
86 // static final boolean doPureNames = false;
87 // static final boolean doRelTaxa = false;
88 // static final boolean doNotes = false;
89 // static final boolean doNoteSources = false;
90 // static final boolean doAdditionalTaxonSource = false;
91 // static final boolean doOccurrence = false;
92 // static final boolean doOccurrenceSource = false;
93 // static final boolean doImage = false;
94 // static final boolean doTreeIndex = false;
95 // static final boolean doRank = true;
96 // static final boolean doInferredSynonyms = true;
99 public boolean doExport(ICdmDataSource source
){
100 System
.out
.println("Start export to PESI ("+ pesiDestination
.getDatabase() + ") ...");
103 Source destination
= pesiDestination
;
104 PesiTransformer transformer
= new PesiTransformer(destination
);
106 PesiExportConfigurator config
= PesiExportConfigurator
.NewInstance(destination
, source
, transformer
);
108 config
.setDoTaxa(doTaxa
);
109 config
.setDoPureNames(doPureNames
);
110 config
.setDoRelTaxa(doRelTaxa
);
111 config
.setDoOccurrence(doOccurrence
);
112 config
.setDoReferences(doReferences
);
113 config
.setDoImages(doImage
);
114 config
.setDoNotes(doNotes
);
115 config
.setDoNoteSources(doNoteSources
);
116 config
.setDoOccurrenceSource(doOccurrenceSource
);
117 config
.setDoTreeIndex(doTreeIndex
);
118 config
.setDoTreeIndex(doParentAndBiota
);
119 config
.setDoRank(doRank
);
120 config
.setDoInferredSynonyms(doInferredSynonyms
);
121 config
.setDoDescription(doDescriptions
);
123 config
.setCheck(check
);
124 config
.setLimitSave(partitionSize
);
125 config
.setIdType(idType
);
126 config
.setNameIdStart(nameIdStart
);
128 destination
.update("EXEC sp_deleteAllData");
132 CdmDefaultExport
<PesiExportConfigurator
> pesiExport
= new CdmDefaultExport
<PesiExportConfigurator
>();
133 boolean result
= pesiExport
.invoke(config
);
135 System
.out
.println("End export to PESI ("+ destination
.getDatabase() + ")..." + (result?
"(successful)":"(with errors)"));
142 public static void main(String
[] args
) {
143 PesiExportActivatorEM ex
= new PesiExportActivatorEM();
144 ICdmDataSource source
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmSource
;
145 // Connection con = pesiDestination.getConnection();
146 // System.out.println(con);