Revision 50818ab7
Added by Katja Luther over 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/diptera/DipteraActivator.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
16 | 16 |
|
17 | 17 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
18 | 18 |
import eu.etaxonomy.cdm.app.berlinModelImport.BerlinModelSources; |
19 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
20 | 19 |
import eu.etaxonomy.cdm.app.berlinModelImport.TreeCreator; |
20 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
21 | 21 |
import eu.etaxonomy.cdm.common.CdmUtils; |
22 | 22 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
23 | 23 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
... | ... | |
27 | 27 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
28 | 28 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES; |
29 | 29 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR; |
30 |
import eu.etaxonomy.cdm.io.common.ImportResult; |
|
30 | 31 |
import eu.etaxonomy.cdm.io.common.Source; |
31 | 32 |
import eu.etaxonomy.cdm.model.description.Feature; |
32 | 33 |
import eu.etaxonomy.cdm.model.description.FeatureNode; |
... | ... | |
37 | 38 |
|
38 | 39 |
/** |
39 | 40 |
* TODO add the following to a wiki page: |
40 |
* 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
|
|
41 |
* 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 |
|
41 | 42 |
* you must set the mysql system variable lower_case_table_names = 0 in order to create data base with table compatible names. |
42 |
*
|
|
43 |
*
|
|
43 |
* |
|
44 |
* |
|
44 | 45 |
* @author a.mueller |
45 | 46 |
* |
46 | 47 |
*/ |
... | ... | |
57 | 58 |
static final int sourceSecId = 1000000; |
58 | 59 |
static final UUID featureTreeUuid = UUID.fromString("ae9615b8-bc60-4ed0-ad96-897f9226d568"); |
59 | 60 |
static final Object[] featureKeyList = new Integer[]{1, 4, 5, 10, 11, 12, 99}; |
60 |
|
|
61 |
|
|
61 | 62 |
static boolean useClassification = true; |
62 | 63 |
//editor - import |
63 | 64 |
static final EDITOR editor = EDITOR.EDITOR_AS_EDITOR; |
... | ... | |
75 | 76 |
static final boolean ignoreNull = true; |
76 | 77 |
|
77 | 78 |
|
78 |
|
|
79 |
|
|
79 | 80 |
//update citations ? |
80 | 81 |
static final boolean updateCitations = true; |
81 |
|
|
82 |
|
|
82 | 83 |
//include collections and add to specimen |
83 | 84 |
static final boolean updateCollections = true; |
84 |
|
|
85 |
|
|
85 | 86 |
//authors |
86 | 87 |
static final boolean doAuthors = true; |
87 | 88 |
//references |
... | ... | |
91 | 92 |
static final boolean doRelNames = true; |
92 | 93 |
static final boolean doNameStatus = true; |
93 | 94 |
static final boolean doTypes = true; |
94 |
static final boolean doNameFacts = true;
|
|
95 |
|
|
95 |
static final boolean doNameFacts = true; |
|
96 |
|
|
96 | 97 |
//taxa |
97 | 98 |
static final boolean doTaxa = true; |
98 | 99 |
static final boolean doRelTaxa = true; |
99 | 100 |
static final boolean doFacts = true; |
100 | 101 |
static final boolean doOccurences = false; //There are no occurrence data in diptera |
101 | 102 |
static final boolean doCommonNames = false; //no common names in diptera |
102 |
|
|
103 |
|
|
103 | 104 |
//etc. |
104 | 105 |
static final boolean doMarker = true; |
105 | 106 |
static final boolean doUser = true; |
106 | 107 |
|
107 | 108 |
// **************** SELECTED ********************* |
108 |
|
|
109 |
|
|
109 | 110 |
// //authors |
110 | 111 |
// static final boolean doAuthors = false; |
111 | 112 |
// //references |
... | ... | |
116 | 117 |
// static final boolean doNameStatus = false; |
117 | 118 |
// static final boolean doTypes = true; |
118 | 119 |
// static final boolean doNameFacts = false; |
119 |
//
|
|
120 |
// |
|
120 | 121 |
// //taxa |
121 | 122 |
// static final boolean doTaxa = false; |
122 | 123 |
// static final boolean doRelTaxa = false; |
123 | 124 |
// static final boolean doFacts = false; |
124 | 125 |
// static final boolean doOccurences = false; |
125 |
//
|
|
126 |
// |
|
126 | 127 |
// //etc. |
127 | 128 |
// static final boolean doMarker = false; |
128 |
// static final boolean doUser = true; |
|
129 |
// static final boolean doUser = true; |
|
130 |
|
|
129 | 131 |
|
130 |
|
|
131 | 132 |
/** |
132 |
* @param destination
|
|
133 |
* @param destination |
|
133 | 134 |
* @param args |
134 | 135 |
*/ |
135 |
public boolean doImport(ICdmDataSource destination) {
|
|
136 |
boolean success = true;
|
|
136 |
public ImportResult doImport(ICdmDataSource destination) {
|
|
137 |
ImportResult success;
|
|
137 | 138 |
System.out.println("Start import from BerlinModel("+ berlinModelSource.getDatabase() + ") ..."); |
138 |
|
|
139 |
|
|
139 | 140 |
//make BerlinModel Source |
140 | 141 |
Source source = berlinModelSource; |
141 | 142 |
|
142 |
|
|
143 |
|
|
143 | 144 |
BerlinModelImportConfigurator bmImportConfigurator = BerlinModelImportConfigurator.NewInstance(source, destination); |
144 |
|
|
145 |
|
|
145 | 146 |
bmImportConfigurator.setClassificationUuid(treeUuid); |
146 | 147 |
bmImportConfigurator.setSourceSecId(sourceSecId); |
147 | 148 |
bmImportConfigurator.setNomenclaturalCode(nomenclaturalCode); |
... | ... | |
155 | 156 |
bmImportConfigurator.setDoTypes(doTypes); |
156 | 157 |
bmImportConfigurator.setDoNameFacts(doNameFacts); |
157 | 158 |
bmImportConfigurator.setUseClassification(useClassification); |
158 |
|
|
159 |
|
|
159 | 160 |
bmImportConfigurator.setDoTaxa(doTaxa); |
160 | 161 |
bmImportConfigurator.setDoRelTaxa(doRelTaxa); |
161 | 162 |
bmImportConfigurator.setDoFacts(doFacts); |
162 | 163 |
bmImportConfigurator.setDoOccurrence(doOccurences); |
163 | 164 |
bmImportConfigurator.setDoCommonNames(doCommonNames); |
164 |
|
|
165 |
|
|
165 | 166 |
bmImportConfigurator.setDoMarker(doMarker); |
166 | 167 |
bmImportConfigurator.setDoUser(doUser); |
167 | 168 |
bmImportConfigurator.setEditor(editor); |
... | ... | |
171 | 172 |
bmImportConfigurator.setNameTypeDesignationStatusMethod(nameTypeDesignationStatusMethod); |
172 | 173 |
} catch (Exception e) { |
173 | 174 |
e.printStackTrace(); |
174 |
return false; |
|
175 |
success = new ImportResult(); |
|
176 |
success.setSuccess(false); |
|
177 |
return success; |
|
175 | 178 |
} |
176 |
|
|
179 |
|
|
177 | 180 |
bmImportConfigurator.setDbSchemaValidation(hbm2dll); |
178 | 181 |
|
179 | 182 |
bmImportConfigurator.setCheck(check); |
180 |
|
|
183 |
|
|
181 | 184 |
// invoke import |
182 | 185 |
CdmDefaultImport<BerlinModelImportConfigurator> bmImport = new CdmDefaultImport<BerlinModelImportConfigurator>(); |
183 |
success &= bmImport.invoke(bmImportConfigurator);
|
|
184 |
|
|
186 |
success = bmImport.invoke(bmImportConfigurator); |
|
187 |
|
|
185 | 188 |
if (bmImportConfigurator.getCheck().equals(CHECK.CHECK_AND_IMPORT) || bmImportConfigurator.getCheck().equals(CHECK.IMPORT_WITHOUT_CHECK) ){ |
186 | 189 |
ICdmApplicationConfiguration app = bmImport.getCdmAppController(); |
187 |
|
|
190 |
|
|
188 | 191 |
//parse distributions |
189 | 192 |
if (doDistributionParser){ |
190 | 193 |
DipteraDistributionParser dipDist = new DipteraDistributionParser(); |
... | ... | |
204 | 207 |
System.out.println("End import from BerlinModel ("+ source.getDatabase() + ")..."); |
205 | 208 |
return success; |
206 | 209 |
} |
207 |
|
|
210 |
|
|
208 | 211 |
public static void main(String[] args) { |
209 |
boolean success = true;
|
|
212 |
ImportResult success;
|
|
210 | 213 |
logger.debug("start"); |
211 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination;
|
|
214 |
ICdmDataSource destination = CdmDestinations.chooseDestination(args) != null ? CdmDestinations.chooseDestination(args) : cdmDestination; |
|
212 | 215 |
DipteraActivator me = new DipteraActivator(); |
213 |
success &= me.doImport(destination);
|
|
214 |
|
|
216 |
success = me.doImport(destination); |
|
217 |
|
|
215 | 218 |
DipteraPostImportUpdater updater = new DipteraPostImportUpdater(); |
216 | 219 |
if (updateCitations){ |
217 |
success &= updater.updateCitations(destination);
|
|
220 |
success = updater.updateCitations(destination); |
|
218 | 221 |
} |
219 |
|
|
222 |
|
|
220 | 223 |
if (updateCollections){ |
221 |
success &= updater.updateCollections(destination);
|
|
224 |
success = updater.updateCollections(destination); |
|
222 | 225 |
} |
223 | 226 |
|
224 |
|
|
227 |
|
|
225 | 228 |
} |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
230 | 233 |
|
231 | 234 |
private static NameTypeDesignationStatus nameTypeDesignationStatueMethod(String note){ |
232 | 235 |
if (CdmUtils.isEmpty(note)){ |
... | ... | |
247 | 250 |
logger.warn("NameTypeDesignationStatus could not be defined for: " + note); |
248 | 251 |
return null; |
249 | 252 |
} |
250 |
|
|
251 |
|
|
253 |
|
|
254 |
|
|
252 | 255 |
} |
253 |
|
|
256 |
|
|
254 | 257 |
} |
Also available in: Unified diff
adapt the import classes to the new return type ImportResult