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.app.common.CdmDestinations;
|
17
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator;
|
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.IImportConfigurator.EDITOR;
|
24
|
import eu.etaxonomy.cdm.io.common.Source;
|
25
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
26
|
|
27
|
|
28
|
/**
|
29
|
* TODO add the following to a wiki page:
|
30
|
* 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
|
31
|
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names.
|
32
|
*
|
33
|
*
|
34
|
* @author a.mueller
|
35
|
*
|
36
|
*/
|
37
|
public class MTMooseActivator {
|
38
|
private static final Logger logger = Logger.getLogger(AlgaTerraActivator.class);
|
39
|
|
40
|
//database validation status (create, update, validate ...)
|
41
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE_DROP;
|
42
|
static final Source berlinModelSource = BerlinModelSources.MT_MOOSE();
|
43
|
|
44
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
45
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_moose_dev();
|
46
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_redlist_moose_production();
|
47
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_moose();
|
48
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test();
|
49
|
|
50
|
static final UUID classificationUuid = UUID.fromString("601d8a00-cffe-4509-af93-b15b543ccf8d");
|
51
|
static final UUID sourceRefUuid = UUID.fromString("601d8a00-cffe-4509-af93-b15b543ccf8d");
|
52
|
|
53
|
// static final UUID featureTreeUuid = UUID.fromString("4c5b5bbe-6fef-4607-96b2-1b0104eac19e");
|
54
|
// static final Object[] featureKeyList = new Integer[]{7,201,202,203,204,205,206,207};
|
55
|
|
56
|
static final boolean includeFlatClassifications = true;
|
57
|
|
58
|
static final String relPTaxonIdQuery = "SELECT * FROM RelPTaxon r " +
|
59
|
" WHERE NOT (r.PTRefFk1 <> r.PTRefFk2 AND r.RelQualifierFk = 1)";
|
60
|
|
61
|
//check - import
|
62
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
63
|
|
64
|
|
65
|
//NomenclaturalCode
|
66
|
static final NomenclaturalCode nomenclaturalCode = NomenclaturalCode.ICNAFP;
|
67
|
|
68
|
static final EDITOR editor = EDITOR.EDITOR_AS_EDITOR;
|
69
|
|
70
|
// ****************** ALL *****************************************
|
71
|
|
72
|
//authors
|
73
|
static final boolean doAuthors = true;
|
74
|
//references
|
75
|
static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
76
|
//names
|
77
|
static final boolean doTaxonNames = true;
|
78
|
static final boolean doRelNames = true;
|
79
|
static final boolean doNameStatus = true;
|
80
|
static final boolean doTypes = true;
|
81
|
static final boolean doNameFacts = false; //no name facts exist
|
82
|
|
83
|
//taxa
|
84
|
static final boolean doTaxa = true;
|
85
|
static final boolean doRelTaxa = true;
|
86
|
static final boolean doFacts = false; //no facts exist
|
87
|
static final boolean doOccurences = false; //no occurrences exist
|
88
|
static final boolean doCommonNames = false; //no common names exist
|
89
|
|
90
|
// ************************ NONE **************************************** //
|
91
|
|
92
|
// //authors
|
93
|
// static final boolean doAuthors = false;
|
94
|
// //references
|
95
|
// static final DO_REFERENCES doReferences = DO_REFERENCES.NONE;
|
96
|
// //names
|
97
|
// static final boolean doTaxonNames = false;
|
98
|
// static final boolean doRelNames = false;
|
99
|
// static final boolean doNameStatus = false;
|
100
|
// static final boolean doTypes = false;
|
101
|
// static final boolean doNameFacts = false;
|
102
|
//
|
103
|
// //taxa
|
104
|
// static final boolean doTaxa = false;
|
105
|
// static final boolean doRelTaxa = false;
|
106
|
// static final boolean doFacts = false;
|
107
|
// static final boolean doOccurences = false;
|
108
|
// static final boolean doCommonNames = false;
|
109
|
|
110
|
|
111
|
public void invoke(String[] args){
|
112
|
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ...");
|
113
|
logger.debug("Start");
|
114
|
//make BerlinModel Source
|
115
|
Source source = berlinModelSource;
|
116
|
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
117
|
|
118
|
BerlinModelImportConfigurator config = BerlinModelImportConfigurator.NewInstance(source, destination);
|
119
|
|
120
|
config.setClassificationUuid(classificationUuid);
|
121
|
// bmImportConfigurator.setSourceSecId(sourceSecId);
|
122
|
config.setNomenclaturalCode(nomenclaturalCode);
|
123
|
config.setEditor(editor);
|
124
|
config.setIncludeFlatClassifications(includeFlatClassifications);
|
125
|
|
126
|
config.setDoAuthors(doAuthors);
|
127
|
config.setDoReferences(doReferences);
|
128
|
config.setDoTaxonNames(doTaxonNames);
|
129
|
config.setDoRelNames(doRelNames);
|
130
|
config.setDoNameStatus(doNameStatus);
|
131
|
config.setDoTypes(doTypes);
|
132
|
config.setDoNameFacts(doNameFacts);
|
133
|
|
134
|
config.setDoTaxa(doTaxa);
|
135
|
config.setDoRelTaxa(doRelTaxa);
|
136
|
config.setDoFacts(doFacts);
|
137
|
config.setDoOccurrence(doOccurences);
|
138
|
config.setDoCommonNames(doCommonNames);
|
139
|
config.setSourceRefUuid(sourceRefUuid);
|
140
|
config.setRelTaxaIdQuery(relPTaxonIdQuery);
|
141
|
|
142
|
config.setDbSchemaValidation(hbm2dll);
|
143
|
|
144
|
config.setCheck(check);
|
145
|
|
146
|
// invoke import
|
147
|
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>();
|
148
|
bmImport.invoke(config);
|
149
|
|
150
|
// if (doFacts && (config.getCheck().equals(CHECK.CHECK_AND_IMPORT) || config.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ) ){
|
151
|
// ICdmRepository app = bmImport.getCdmAppController();
|
152
|
//
|
153
|
// //make feature tree
|
154
|
// FeatureTree tree = TreeCreator.flatTree(featureTreeUuid, config.getFeatureMap(), featureKeyList);
|
155
|
// FeatureNode distributionNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
|
156
|
// tree.getRoot().addChild(distributionNode, 0);
|
157
|
// app.getFeatureTreeService().saveOrUpdate(tree);
|
158
|
// }
|
159
|
|
160
|
|
161
|
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")...");
|
162
|
}
|
163
|
|
164
|
|
165
|
/**
|
166
|
* @param args
|
167
|
*/
|
168
|
public static void main(String[] args) {
|
169
|
MTMooseActivator activator = new MTMooseActivator();
|
170
|
activator.invoke(args);
|
171
|
}
|
172
|
|
173
|
}
|