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.ICdmApplicationConfiguration;
|
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.common.ISourceable;
|
27
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
28
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
29
|
|
30
|
|
31
|
/**
|
32
|
* TODO add the following to a wiki page:
|
33
|
* 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
|
34
|
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
|
35
|
*
|
36
|
*
|
37
|
* @author a.mueller
|
38
|
*
|
39
|
*/
|
40
|
public class ErmsActivator {
|
41
|
private static final Logger logger = Logger.getLogger(ErmsActivator.class);
|
42
|
|
43
|
//database validation status (create, update, validate ...)
|
44
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
45
|
static final Source ermsSource = PesiSources.PESI_ERMS();
|
46
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_pesi_erms();
|
47
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
48
|
static final UUID treeUuid = UUID.fromString("8bd27d84-fd4f-4bfa-bde0-3e6b7311b334");
|
49
|
static final UUID featureTreeUuid = UUID.fromString("33cbf7a8-0c47-4d47-bd11-b7d77a38d0f6");
|
50
|
//static final Object[] featureKeyList = new Integer[]{1,4,5,10,11,12,13,14, 249, 250, 251, 252, 253};
|
51
|
|
52
|
//check - import
|
53
|
static final CHECK check = CHECK.CHECK_AND_IMPORT;
|
54
|
|
55
|
static final int partitionSize = 5000;
|
56
|
|
57
|
|
58
|
//NomeclaturalCode
|
59
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN;
|
60
|
|
61
|
//ignore null
|
62
|
static final boolean ignoreNull = true;
|
63
|
|
64
|
// ***************** ALL ************************************************//
|
65
|
|
66
|
//references
|
67
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
68
|
|
69
|
//taxa
|
70
|
static final boolean doTaxa = true;
|
71
|
static final boolean doRelTaxa = true;
|
72
|
static final boolean doLinks = true;
|
73
|
static final boolean doOccurences = true;
|
74
|
static final boolean doImages = true;
|
75
|
|
76
|
|
77
|
//******************** NONE ***************************************//
|
78
|
|
79
|
|
80
|
// //references
|
81
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
82
|
//
|
83
|
// //taxa
|
84
|
// static final boolean doTaxa = false;
|
85
|
// static final boolean doRelTaxa = false;
|
86
|
// static final boolean doLinks = false;
|
87
|
// static final boolean doOccurences = false;
|
88
|
//
|
89
|
|
90
|
|
91
|
/**
|
92
|
* @param args
|
93
|
*/
|
94
|
public static void main(String[] args) {
|
95
|
System.out.println("Start import from ("+ ermsSource.getDatabase() + ") ...");
|
96
|
|
97
|
//make ERMS Source
|
98
|
Source source = ermsSource;
|
99
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
100
|
|
101
|
ErmsImportConfigurator ermsImportConfigurator = ErmsImportConfigurator.NewInstance(source, destination);
|
102
|
|
103
|
ermsImportConfigurator.setClassificationUuid(treeUuid);
|
104
|
ermsImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
|
105
|
|
106
|
ermsImportConfigurator.setIgnoreNull(ignoreNull);
|
107
|
ermsImportConfigurator.setDoReferences(doReferences);
|
108
|
|
109
|
ermsImportConfigurator.setDoTaxa(doTaxa);
|
110
|
ermsImportConfigurator.setDoRelTaxa(doRelTaxa);
|
111
|
ermsImportConfigurator.setDoLinks(doLinks);
|
112
|
ermsImportConfigurator.setDoOccurrence(doOccurences);
|
113
|
ermsImportConfigurator.setDbSchemaValidation(hbm2dll);
|
114
|
|
115
|
ermsImportConfigurator.setCheck(check);
|
116
|
ermsImportConfigurator.setRecordsPerTransaction(partitionSize);
|
117
|
ermsImportConfigurator.setSourceRefUuid(PesiTransformer.uuidSourceRefErms);
|
118
|
|
119
|
// invoke import
|
120
|
CdmDefaultImport<ErmsImportConfigurator> ermsImport = new CdmDefaultImport<ErmsImportConfigurator>();
|
121
|
ermsImport.invoke(ermsImportConfigurator);
|
122
|
|
123
|
if (ermsImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || ermsImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
124
|
ICdmApplicationConfiguration app = ermsImport.getCdmAppController();
|
125
|
ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
126
|
logger.info(obj);
|
127
|
|
128
|
// //make feature tree
|
129
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, ermsImportConfigurator.getFeatureMap(), featureKeyList);
|
130
|
// app = ermsImport.getCdmAppController();
|
131
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
132
|
}
|
133
|
System.out.println("End import from ("+ source.getDatabase() + ")...");
|
134
|
}
|
135
|
|
136
|
}
|