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.app.pesi;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
17
|
import eu.etaxonomy.cdm.app.common.PesiSources;
|
18
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
19
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
20
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.io.common.Source;
|
23
|
import eu.etaxonomy.cdm.io.pesi.indexFungorum.IndexFungorumImportConfigurator;
|
24
|
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
|
25
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
26
|
|
27
|
/**
|
28
|
* @author a.mueller
|
29
|
*/
|
30
|
public class IndexFungorumImportActivator {
|
31
|
|
32
|
@SuppressWarnings("unused")
|
33
|
private static final Logger logger = Logger.getLogger(IndexFungorumImportActivator.class);
|
34
|
|
35
|
//database validation status (create, update, validate ...)
|
36
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
37
|
|
38
|
static final Source indexFungorumSource = PesiSources.PESI3_IF();
|
39
|
|
40
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum();
|
41
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum2();
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
43
|
|
44
|
static final UUID classificationUuid = UUID.fromString("4bea48c3-eb10-41d1-b708-b5ee625ed243");
|
45
|
|
46
|
static final boolean doPesiExport = false;
|
47
|
|
48
|
//check - import
|
49
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
50
|
static final int partitionSize = 2000;
|
51
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP;
|
52
|
|
53
|
|
54
|
public void doImport(Source source, ICdmDataSource destination){
|
55
|
System.out.println("Start import from ("+ indexFungorumSource.getDatabase() + ") ...");
|
56
|
|
57
|
IndexFungorumImportConfigurator ifImportConfigurator = IndexFungorumImportConfigurator.NewInstance(source, destination);
|
58
|
|
59
|
ifImportConfigurator.setClassificationUuid(classificationUuid);
|
60
|
ifImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
|
61
|
|
62
|
ifImportConfigurator.setDoTaxa(true);
|
63
|
ifImportConfigurator.setDbSchemaValidation(hbm2dll);
|
64
|
|
65
|
ifImportConfigurator.setCheck(check);
|
66
|
ifImportConfigurator.setRecordsPerTransaction(partitionSize);
|
67
|
ifImportConfigurator.setSourceRefUuid(PesiTransformer.uuidSourceRefIndexFungorum);
|
68
|
|
69
|
// invoke import
|
70
|
CdmDefaultImport<IndexFungorumImportConfigurator> ifImport = new CdmDefaultImport<IndexFungorumImportConfigurator>();
|
71
|
ifImport.invoke(ifImportConfigurator);
|
72
|
|
73
|
if (ifImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || ifImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
74
|
// ICdmApplicationConfiguration app = ifImport.getCdmAppController();
|
75
|
// ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
76
|
// logger.info(obj);
|
77
|
|
78
|
// //make feature tree
|
79
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
80
|
// app = ermsImport.getCdmAppController();
|
81
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
82
|
}
|
83
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
84
|
}
|
85
|
|
86
|
public static void main(String[] args) {
|
87
|
|
88
|
//make IF Source
|
89
|
Source source = indexFungorumSource;
|
90
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
91
|
IndexFungorumImportActivator ifActivator = new IndexFungorumImportActivator();
|
92
|
ifActivator.doImport(source, destination);
|
93
|
|
94
|
if (doPesiExport){
|
95
|
PesiExportActivatorIF ifExportActivator = new PesiExportActivatorIF();
|
96
|
ifExportActivator.doExport(destination);
|
97
|
}
|
98
|
System.exit(0);
|
99
|
}
|
100
|
}
|