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.database.DatabaseTypeEnum;
|
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.IImportConfigurator.DO_REFERENCES;
|
23
|
import eu.etaxonomy.cdm.io.common.Source;
|
24
|
import eu.etaxonomy.cdm.io.pesi.indexFungorum.IndexFungorumImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
|
26
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
27
|
|
28
|
|
29
|
/**
|
30
|
* TODO add the following to a wiki page:
|
31
|
* HINT: If you are about to import into a mysql data base running under windows and if you wish to dump and restore the resulting data base under another operation systen
|
32
|
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
|
33
|
*
|
34
|
*
|
35
|
* @author a.mueller
|
36
|
*
|
37
|
*/
|
38
|
public class IndexFungorumActivator {
|
39
|
@SuppressWarnings("unused")
|
40
|
private static final Logger logger = Logger.getLogger(IndexFungorumActivator.class);
|
41
|
|
42
|
//database validation status (create, update, validate ...)
|
43
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
44
|
static final Source indexFungorumSource = PesiSources.PESI_IF();
|
45
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_erms();
|
46
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_indexFungorum();
|
47
|
static final UUID treeUuid = UUID.fromString("4bea48c3-eb10-41d1-b708-b5ee625ed243");
|
48
|
|
49
|
//check - import
|
50
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
51
|
|
52
|
static final int partitionSize = 2000;
|
53
|
|
54
|
static final boolean doPesiExport = true;
|
55
|
|
56
|
|
57
|
//NomeclaturalCode
|
58
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP;
|
59
|
|
60
|
|
61
|
// ***************** ALL ************************************************//
|
62
|
|
63
|
//taxa
|
64
|
static final boolean doTaxa = true;
|
65
|
|
66
|
|
67
|
|
68
|
//******************** NONE ***************************************//
|
69
|
|
70
|
//
|
71
|
// //taxa
|
72
|
// static final boolean doTaxa = false;
|
73
|
|
74
|
|
75
|
public void doImport(Source source, ICdmDataSource destination){
|
76
|
System.out.println("Start import from ("+ indexFungorumSource.getDatabase() + ") ...");
|
77
|
|
78
|
IndexFungorumImportConfigurator ifImportConfigurator = IndexFungorumImportConfigurator.NewInstance(source, destination);
|
79
|
|
80
|
ifImportConfigurator.setClassificationUuid(treeUuid);
|
81
|
ifImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
|
82
|
|
83
|
ifImportConfigurator.setDoTaxa(doTaxa);
|
84
|
ifImportConfigurator.setDbSchemaValidation(hbm2dll);
|
85
|
|
86
|
ifImportConfigurator.setCheck(check);
|
87
|
ifImportConfigurator.setRecordsPerTransaction(partitionSize);
|
88
|
ifImportConfigurator.setSourceRefUuid(PesiTransformer.uuidSourceRefIndexFungorum);
|
89
|
|
90
|
// invoke import
|
91
|
CdmDefaultImport<IndexFungorumImportConfigurator> ifImport = new CdmDefaultImport<IndexFungorumImportConfigurator>();
|
92
|
ifImport.invoke(ifImportConfigurator);
|
93
|
|
94
|
if (ifImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || ifImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
95
|
// ICdmApplicationConfiguration app = ifImport.getCdmAppController();
|
96
|
// ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
97
|
// logger.info(obj);
|
98
|
|
99
|
// //make feature tree
|
100
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
101
|
// app = ermsImport.getCdmAppController();
|
102
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
103
|
}
|
104
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
105
|
}
|
106
|
|
107
|
|
108
|
/**
|
109
|
* @param args
|
110
|
*/
|
111
|
public static void main(String[] args) {
|
112
|
|
113
|
//make IF Source
|
114
|
Source source = indexFungorumSource;
|
115
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
116
|
IndexFungorumActivator ifActivator = new IndexFungorumActivator();
|
117
|
ifActivator.doImport(source, destination);
|
118
|
|
119
|
if (doPesiExport){
|
120
|
PesiExportActivatorIF ifExportActivator = new PesiExportActivatorIF();
|
121
|
ifExportActivator.doExport(destination);
|
122
|
}
|
123
|
}
|
124
|
|
125
|
|
126
|
|
127
|
}
|