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.api.application.ICdmRepository;
|
17
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
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.erms.ErmsImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer;
|
26
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
27
|
import eu.etaxonomy.cdm.model.reference.ISourceable;
|
28
|
|
29
|
|
30
|
/**
|
31
|
* @author a.mueller
|
32
|
*/
|
33
|
public class ErmsActivator {
|
34
|
private static final Logger logger = Logger.getLogger(ErmsActivator.class);
|
35
|
|
36
|
//database validation status (create, update, validate ...)
|
37
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
38
|
// static final Source ermsSource = PesiSources.PESI3_ERMS();
|
39
|
static final Source ermsSource = PesiSources.PESI2019_ERMS();
|
40
|
// static final ICdmDataSource cdmDestination = CdmDestinations.test_cdm_pesi_erms();
|
41
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_erms();
|
42
|
|
43
|
static final UUID classificationUuid = UUID.fromString("6fa988a9-10b7-48b0-a370-2586fbc066eb");
|
44
|
|
45
|
static final String classificationName = "ERMS 2019";
|
46
|
|
47
|
//check - import
|
48
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
49
|
|
50
|
static final int partitionSize = 5000;
|
51
|
|
52
|
//ignore null
|
53
|
static final boolean ignoreNull = true;
|
54
|
|
55
|
static final boolean includeExport = true;
|
56
|
|
57
|
// ***************** ALL ************************************************//
|
58
|
|
59
|
//references
|
60
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
61
|
|
62
|
//taxa
|
63
|
static final boolean doTaxa = true;
|
64
|
static final boolean doRelTaxa = true;
|
65
|
static final boolean doLinks = true;
|
66
|
static final boolean doOccurences = true;
|
67
|
static final boolean doImages = true;
|
68
|
|
69
|
|
70
|
//******************** NONE ***************************************//
|
71
|
|
72
|
|
73
|
// //references
|
74
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
75
|
//
|
76
|
// //taxa
|
77
|
// static final boolean doTaxa = false;
|
78
|
// static final boolean doRelTaxa = false;
|
79
|
// static final boolean doLinks = false;
|
80
|
// static final boolean doOccurences = false;
|
81
|
//
|
82
|
|
83
|
|
84
|
private void doImport(Source source, ICdmDataSource destination, DbSchemaValidation hbm2dll){
|
85
|
System.out.println("Start import from ("+ ermsSource.getDatabase() + ") ...");
|
86
|
|
87
|
//make ERMS Source
|
88
|
|
89
|
ErmsImportConfigurator config = ErmsImportConfigurator.NewInstance(source, destination);
|
90
|
|
91
|
config.setClassificationUuid(classificationUuid);
|
92
|
|
93
|
config.setIgnoreNull(ignoreNull);
|
94
|
config.setDoReferences(doReferences);
|
95
|
|
96
|
config.setDoTaxa(doTaxa);
|
97
|
config.setDoRelTaxa(doRelTaxa);
|
98
|
config.setDoLinks(doLinks);
|
99
|
config.setDoOccurrence(doOccurences);
|
100
|
config.setDbSchemaValidation(hbm2dll);
|
101
|
|
102
|
config.setCheck(check);
|
103
|
config.setRecordsPerTransaction(partitionSize);
|
104
|
config.setSourceRefUuid(PesiTransformer.uuidSourceRefErms);
|
105
|
config.setClassificationName(classificationName);
|
106
|
|
107
|
// invoke import
|
108
|
CdmDefaultImport<ErmsImportConfigurator> ermsImport = new CdmDefaultImport<ErmsImportConfigurator>();
|
109
|
ermsImport.invoke(config);
|
110
|
|
111
|
if (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
112
|
ICdmRepository app = ermsImport.getCdmAppController();
|
113
|
ISourceable<?> obj = app.getCommonService().getSourcedObjectByIdInSource(TaxonName.class, "1000027", null);
|
114
|
logger.info(obj);
|
115
|
|
116
|
// //make feature tree
|
117
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
118
|
// app = ermsImport.getCdmAppController();
|
119
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
120
|
}
|
121
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* @param args
|
126
|
*/
|
127
|
public static void main(String[] args) {
|
128
|
ICdmDataSource cdmDB = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
129
|
ErmsActivator ermsImport = new ErmsActivator();
|
130
|
ermsImport.doImport(ermsSource, cdmDB, hbm2dll);
|
131
|
|
132
|
if (includeExport){
|
133
|
PesiExportActivatorERMS ermsExport = new PesiExportActivatorERMS();
|
134
|
ermsExport.doExport(cdmDB);
|
135
|
}
|
136
|
System.exit(0);
|
137
|
}
|
138
|
|
139
|
}
|