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.berlinModelImport;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
|
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.berlinModel.BerlinModelImportConfigurator;
|
21
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
22
|
import eu.etaxonomy.cdm.io.common.Source;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
|
25
|
import eu.etaxonomy.cdm.model.common.ISourceable;
|
26
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
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 bas 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 DipteraActivator {
|
41
|
private static final Logger logger = Logger.getLogger(DipteraActivator.class);
|
42
|
|
43
|
//database validation status (create, update, validate ...)
|
44
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
|
45
|
static final Source berlinModelSource = BerlinModelSources.EDIT_Diptera();
|
46
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM();
|
47
|
static final UUID secUuid = UUID.fromString("06fd671f-1226-4e3b-beca-1959b3b32e20");
|
48
|
static final int sourceSecId = 1000000;
|
49
|
static final UUID featureTreeUuid = UUID.fromString("ae9615b8-bc60-4ed0-ad96-897f9226d568");
|
50
|
static final Object[] featureKeyList = new Integer[]{1,4,5,10,11,12,13,99};
|
51
|
|
52
|
//check - import
|
53
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
54
|
|
55
|
static final boolean doDistributionParser = true; //also run DipteraDistributionParser
|
56
|
|
57
|
//NomeclaturalCode
|
58
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICZN();
|
59
|
|
60
|
|
61
|
|
62
|
//ignore null
|
63
|
static final boolean ignoreNull = true;
|
64
|
|
65
|
//authors
|
66
|
static final boolean doAuthors = true;
|
67
|
//references
|
68
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
69
|
//names
|
70
|
static final boolean doTaxonNames = true;
|
71
|
static final boolean doRelNames = true;
|
72
|
static final boolean doNameStatus = true;
|
73
|
static final boolean doTypes = true;
|
74
|
static final boolean doNameFacts = true;
|
75
|
|
76
|
//taxa
|
77
|
static final boolean doTaxa = true;
|
78
|
static final boolean doRelTaxa = true;
|
79
|
static final boolean doFacts = true;
|
80
|
static final boolean doOccurences = false;
|
81
|
|
82
|
// //authors
|
83
|
// static final boolean doAuthors = false;
|
84
|
// //references
|
85
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
86
|
// //names
|
87
|
// static final boolean doTaxonNames = false;
|
88
|
// static final boolean doRelNames = false;
|
89
|
// static final boolean doNameStatus = false;
|
90
|
// static final boolean doTypes = false;
|
91
|
// static final boolean doNameFacts = false;
|
92
|
//
|
93
|
// //taxa
|
94
|
// static final boolean doTaxa = true;
|
95
|
// static final boolean doRelTaxa = false;
|
96
|
// static final boolean doFacts = false;
|
97
|
// static final boolean doOccurences = false;
|
98
|
|
99
|
|
100
|
|
101
|
/**
|
102
|
* @param args
|
103
|
*/
|
104
|
public static void main(String[] args) {
|
105
|
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ...");
|
106
|
|
107
|
//make BerlinModel Source
|
108
|
Source source = berlinModelSource;
|
109
|
ICdmDataSource destination = cdmDestination;
|
110
|
|
111
|
BerlinModelImportConfigurator bmImportConfigurator = BerlinModelImportConfigurator.NewInstance(source, destination);
|
112
|
|
113
|
bmImportConfigurator.setSecUuid(secUuid);
|
114
|
bmImportConfigurator.setSourceSecId(sourceSecId);
|
115
|
bmImportConfigurator.setNomenclaturalCode(nomenclaturalCode);
|
116
|
|
117
|
bmImportConfigurator.setIgnoreNull(ignoreNull);
|
118
|
bmImportConfigurator.setDoAuthors(doAuthors);
|
119
|
bmImportConfigurator.setDoReferences(doReferences);
|
120
|
bmImportConfigurator.setDoTaxonNames(doTaxonNames);
|
121
|
bmImportConfigurator.setDoRelNames(doRelNames);
|
122
|
bmImportConfigurator.setDoNameStatus(doNameStatus);
|
123
|
bmImportConfigurator.setDoTypes(doTypes);
|
124
|
bmImportConfigurator.setDoNameFacts(doNameFacts);
|
125
|
|
126
|
bmImportConfigurator.setDoTaxa(doTaxa);
|
127
|
bmImportConfigurator.setDoRelTaxa(doRelTaxa);
|
128
|
bmImportConfigurator.setDoFacts(doFacts);
|
129
|
bmImportConfigurator.setDoOccurrence(doOccurences);
|
130
|
bmImportConfigurator.setDbSchemaValidation(hbm2dll);
|
131
|
|
132
|
bmImportConfigurator.setCheck(check);
|
133
|
|
134
|
// invoke import
|
135
|
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>();
|
136
|
bmImport.invoke(bmImportConfigurator);
|
137
|
|
138
|
if (bmImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || bmImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){
|
139
|
CdmApplicationController app = bmImportConfigurator.getCdmAppController();
|
140
|
ISourceable obj = app.getCommonService().getSourcedObjectByIdInSource(ZoologicalName.class, "1000027", null);
|
141
|
logger.info(obj);
|
142
|
|
143
|
//parse distributions
|
144
|
if (doDistributionParser == true){
|
145
|
DipteraDistributionParser dipDist = new DipteraDistributionParser();
|
146
|
dipDist.doDistribution(app);
|
147
|
}
|
148
|
|
149
|
//make feature tree
|
150
|
FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, bmImportConfigurator.getFeatureMap(), featureKeyList);
|
151
|
app = bmImportConfigurator.getCdmAppController();
|
152
|
app.getDescriptionService().saveFeatureTree(tree);
|
153
|
}
|
154
|
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")...");
|
155
|
}
|
156
|
|
157
|
}
|