Project

General

Profile

« Previous | Next » 

Revision 614872b1

Added by Andreas Müller over 12 years ago

move eflora activators from app-import to cdm-eflora

View differences:

.gitattributes
1195 1195
cdm-eflora/LICENSE.TXT -text
1196 1196
cdm-eflora/README.TXT -text
1197 1197
cdm-eflora/pom.xml -text
1198
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CdmDestinations.java -text
1199
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CdmImportSources.java -text
1200
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaChecklistActivator.java -text
1201
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaEricaceaeActivator.java -text
1202
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaFernsActivator.java -text
1203
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/EfloraSources.java -text
1204
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraMalesianaActivator.java -text
1205
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/FloraMalesianaVol13Activator.java -text
1198 1206
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportBase.java -text
1199 1207
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportConfigurator.java -text
1200 1208
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/EfloraImportState.java -text
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CdmDestinations.java
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.eflora;
11

  
12
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.Method;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.common.AccountStore;
18
import eu.etaxonomy.cdm.database.CdmDataSource;
19
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
20
import eu.etaxonomy.cdm.database.ICdmDataSource;
21

  
22
public class CdmDestinations {
23
	@SuppressWarnings("unused")
24
	private static Logger logger = Logger.getLogger(CdmDestinations.class);
25
	
26
	/**
27
	 * Intended to be used for imports
28
	 */
29
	public static ICdmDataSource import_a(){
30
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
31
		String cdmServer = "localhost";
32
		String cdmDB = "import_a";
33
		String cdmUserName = "root";
34
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
35
	}
36

  
37
	public static ICdmDataSource cdm_test_alex(){
38
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
39
		String cdmServer = "192.168.2.10";
40
		String cdmDB = "cdm_production_palmae"; 
41
		String cdmUserName = "edit";
42
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
43
	}
44
	
45

  
46
	public static ICdmDataSource cdm_test_useSummary(){
47
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
48
		String cdmServer = "localhost";
49
		String cdmDB = "palmae_2011_07_17"; 
50
		String cdmUserName = "edit";
51
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
52
	}
53
	
54
	public static ICdmDataSource cdm_test_jaxb(){
55
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
56
		String cdmServer = "192.168.2.10";
57
		String cdmDB = "cdm_test_jaxb"; 
58
		String cdmUserName = "edit";
59
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
60
	}
61
	
62
	public static ICdmDataSource cdm_test_jaxb2(){
63
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
64
		String cdmServer = "192.168.2.10";
65
		String cdmDB = "cdm_test_jaxb2"; 
66
		String cdmUserName = "edit";
67
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
68
	}
69

  
70
	public static ICdmDataSource cdm_test_andreasM(){
71
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
72
		String cdmServer = "192.168.2.10";
73
		String cdmDB = "cdm_test_andreasM"; 
74
		String cdmUserName = "edit";
75
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
76
	}
77
	
78
	public static ICdmDataSource cdm_test_andreasM2(){
79
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
80
		String cdmServer = "192.168.2.10";
81
		String cdmDB = "cdm_test_andreasM2"; 
82
		String cdmUserName = "edit";
83
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
84
	}
85
	
86
	public static ICdmDataSource cdm_test_local_mysql(){
87
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
88
		String cdmServer = "127.0.0.1";
89
		String cdmDB = "cdm_test"; 
90
		String cdmUserName = "edit";
91
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
92
	}
93

  
94
	public static ICdmDataSource cdm_test_local_mysql_fdac(){
95
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
96
		String cdmServer = "127.0.0.1";
97
		String cdmDB = "fdac"; 
98
		String cdmUserName = "edit";
99
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
100
	}
101
	
102
	public static ICdmDataSource cdm_test_local_mysql_test(){
103
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
104
		String cdmServer = "127.0.0.1";
105
		String cdmDB = "test"; 
106
		String cdmUserName = "edit";
107
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
108
	}
109

  
110
	
111
	public static ICdmDataSource cdm_portal(){
112
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
113
		String cdmServer = "192.168.2.10";
114
		String cdmDB = "cdm_portal";
115
		String cdmUserName = "edit";
116
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
117
	}
118
	
119
	public static ICdmDataSource cdm_portal_test(){
120
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
121
		String cdmServer = "192.168.2.10";
122
		String cdmDB = "cdm_portal_test";
123
		String cdmUserName = "edit";
124
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
125
	}
126
	
127
	public static ICdmDataSource cdm_test_patricia(){
128
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
129
		String cdmServer = "192.168.2.10";
130
		String cdmDB = "cdm_test_patricia";
131
		String cdmUserName = "edit";
132
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
133
	}
134
	
135
	//
136
	public static ICdmDataSource cdm_test_andreasK1(){
137
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
138
		String cdmServer = "192.168.2.10";
139
		String cdmDB = "cdm_test_andreasK1";
140
		String cdmUserName = "edit";
141
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
142
	}
143
	
144

  
145
	public static ICdmDataSource cdm_pesi_erms(){
146
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
147
		String cdmServer = "192.168.2.10";
148
		String cdmDB = "cdm_pesi_erms";
149
		String cdmUserName = "edit";
150
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
151
	}
152
	
153
	public static ICdmDataSource cdm_campanulaceae(){
154
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
155
		String cdmServer = "192.168.2.10";
156
		String cdmDB = "cdm_campanulaceae";
157
		String cdmUserName = "edit";
158
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
159
	}
160

  
161
	public static ICdmDataSource cdm_ildis_dev(){
162
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
163
		String cdmServer = "160.45.63.201";
164
		String cdmDB = "cdm_edit_ildis";
165
		String cdmUserName = "edit";
166
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
167
	}
168
	
169
//
170
//	public static ICdmDataSource cdm_ildis_production(){
171
//		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
172
//		String cdmServer = "160.45.63.151";
173
//		String cdmDB = "cdm_edit_ildis";
174
//		String cdmUserName = "edit";
175
//		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
176
//	}
177
	
178
	public static ICdmDataSource cdm_cyprus_dev(){
179
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
180
		String cdmServer = "160.45.63.201";
181
		String cdmDB = "cdm_cyprus";
182
		String cdmUserName = "edit";
183
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
184
	}
185
	
186
	public static ICdmDataSource cdm_cyprus_production(){
187
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
188
		String cdmServer = "160.45.63.151";
189
		String cdmDB = "cdm_production_cyprus";
190
		String cdmUserName = "edit";
191
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
192
	}
193

  
194
	public static ICdmDataSource cdm_cyprus_production_tunnel(){
195
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
196
		String cdmServer = "127.0.0.1";
197
		int port = 13306;
198
		String cdmDB = "cdm_production_cyprus";
199
		String cdmUserName = "edit";
200
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
201
	}
202
	
203
	public static ICdmDataSource cdm_cyprus_dev_tunnel(){
204
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
205
		String cdmServer = "127.0.0.1";
206
		int port = 13306;
207
		String cdmDB = "cdm_cyprus";
208
		String cdmUserName = "edit";
209
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
210
	}
211
	
212
	public static ICdmDataSource cdm_campanulaceae_production(){
213
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
214
		String cdmServer = "160.45.63.151";
215
		String cdmDB = "cdm_production_campanulaceae";
216
		String cdmUserName = "edit";
217
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
218
	}
219
	
220
	public static ICdmDataSource cdm_flora_malesiana_preview(){
221
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
222
		String cdmServer = "160.45.63.201";
223
		String cdmDB = "cdm_edit_flora_malesiana";
224
		String cdmUserName = "edit";
225
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
226
	}
227

  
228
	public static ICdmDataSource cdm_flora_malesiana_production(){
229
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
230
		String cdmServer = "160.45.63.151";
231
		String cdmDB = "cdm_production_flora_malesiana";
232
		String cdmUserName = "edit";
233
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
234
	}
235
	
236
	public static ICdmDataSource cdm_flora_central_africa_preview(){
237
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
238
		String cdmServer = "160.45.63.201";
239
		String cdmDB = "cdm_edit_flora_central_africa";
240
		String cdmUserName = "edit";
241
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
242
	}
243
	
244
	public static ICdmDataSource cdm_flora_central_africa_production(){
245
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
246
		String cdmServer = "160.45.63.151";
247
		String cdmDB = "cdm_production_flora_central_africa";
248
		String cdmUserName = "edit";
249
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
250
	}
251
	
252
	public static ICdmDataSource cdm_pesi_euroMed(){
253
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
254
		String cdmServer = "192.168.2.10";
255
		String cdmDB = "cdm_pesi_euroMed";
256
		String cdmUserName = "edit";
257
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
258
	}
259
	
260
	public static ICdmDataSource cdm_pesi_all(){
261
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
262
		String cdmServer = "192.168.2.10";
263
		String cdmDB = "cdm_pesi_all";
264
		String cdmUserName = "edit";
265
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
266
	}
267
	
268
	public static ICdmDataSource cdm_portal_test_localhost(){
269
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
270
		String cdmServer = "127.0.0.1";
271
		String cdmDB = "cdm_portal_test";
272
		String cdmUserName = "edit";
273
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
274
	}
275
	
276
	public static ICdmDataSource cdm_portal_test_localhost2(){
277
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
278
		String cdmServer = "127.0.0.1";
279
		String cdmDB = "cdm_portal_test2";
280
		String cdmUserName = "edit";
281
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
282
	}
283
	
284
	public static ICdmDataSource cdm_local_cichorieae(){
285
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
286
		String cdmServer = "127.0.0.1";
287
		String cdmDB = "cdm_edit_cichorieae";
288
		String cdmUserName = "edit";
289
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
290
	}
291
	
292
	public static ICdmDataSource cdm_local_dipera(){
293
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
294
		String cdmServer = "127.0.0.1";
295
		String cdmDB = "cdm_edit_diptera";
296
		String cdmUserName = "edit";
297
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
298
	}
299
	
300
	public static ICdmDataSource cdm_local_palmae(){
301
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
302
		String cdmServer = "127.0.0.1";
303
		String cdmDB = "cdm_edit_palmae";
304
		String cdmUserName = "edit";
305
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
306
	}
307
	
308
	public static ICdmDataSource cdm_local_globis(){
309
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
310
		String cdmServer = "127.0.0.1";
311
		String cdmDB = "cdm_globis";
312
		String cdmUserName = "edit";
313
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
314
	}
315
	
316
	public static ICdmDataSource cdm_local_cichorieae_d(){
317
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
318
		String cdmServer = "127.0.0.1";
319
		String cdmDB = "cdm_edit_cichorieae_d";
320
		String cdmUserName = "root";
321
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
322
	}
323
	
324
	public static ICdmDataSource cdm_local_postgres_CdmTest(){
325
		DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
326
		String cdmServer = "127.0.0.1";
327
		String cdmDB = "CdmTest";
328
		String cdmUserName = "edit";
329
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
330
	}
331

  
332
	public static ICdmDataSource cdm_local_tdwg2010(){
333
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
334
		String cdmServer = "127.0.0.1";
335
		String cdmDB = "cdm_tdwg2010";
336
		String cdmUserName = "edit";
337
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
338
	}
339
	
340
	
341
	public static ICdmDataSource NULL(){
342
		return null;
343
	}
344
	
345
	
346
	public static ICdmDataSource localH2(){
347
		return CdmDataSource.NewH2EmbeddedInstance("cdm", "sa", "");
348
	}
349
	
350
	public static ICdmDataSource localH2(String database, String username, String filePath){
351
		return CdmDataSource.NewH2EmbeddedInstance(database, "sa", "", filePath, null);
352
	}
353
	
354
	public static ICdmDataSource localH2Salvador(){
355
		return CdmDataSource.NewH2EmbeddedInstance("salvador", "sa", "");
356
	}
357
	
358
	public static ICdmDataSource localH2Diptera(){
359
		return CdmDataSource.NewH2EmbeddedInstance("diptera", "sa", "");
360
	}
361
	
362
	
363
	public static ICdmDataSource localH2Cichorieae(){
364
		return CdmDataSource.NewH2EmbeddedInstance("cichorieae", "sa", "");
365
	}
366
	
367
	public static ICdmDataSource localH2Palmae(){
368
		return CdmDataSource.NewH2EmbeddedInstance("palmae", "sa", "");
369
	}
370
	
371
	public static ICdmDataSource localH2EuroMed(){
372
		return CdmDataSource.NewH2EmbeddedInstance("euroMed", "sa", "");
373
	}
374
	
375
	public static ICdmDataSource localH2Erms(){
376
		return CdmDataSource.NewH2EmbeddedInstance("erms", "sa", "");
377
	}
378
	
379
	public static ICdmDataSource localH2_viola(){
380
		return CdmDataSource.NewH2EmbeddedInstance("testViola", "sa", "");
381
	}
382
	
383
	public static ICdmDataSource localH2_LIAS(){
384
		return CdmDataSource.NewH2EmbeddedInstance("testLIAS", "sa", "");
385
	}
386
	
387
	public static ICdmDataSource localH2_Erythroneura(){
388
		return CdmDataSource.NewH2EmbeddedInstance("testErythroneura", "sa", "");
389
	}
390
	
391
	public static ICdmDataSource localH2_Cicad(){
392
		return CdmDataSource.NewH2EmbeddedInstance("testCicad", "sa", "");
393
	}
394
	
395
	public static ICdmDataSource localH2_ValRosandraFRIDAKey(){
396
		return CdmDataSource.NewH2EmbeddedInstance("testValRosandraFRIDAKey", "sa", "");
397
	}
398
	
399
	public static ICdmDataSource localH2_FreshwaterAquaticInsects(){
400
		return CdmDataSource.NewH2EmbeddedInstance("testFreshwaterAquaticInsects", "sa", "");
401
	}
402
	
403
	public static ICdmDataSource cdm_portal_test_pollux(){
404
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
405
		String cdmServer = "192.168.2.11";
406
		String cdmDB = "cdm_portal_test";
407
		String cdmUserName = "edit";
408
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
409
	}
410

  
411
	public static ICdmDataSource cdm_algaterra_preview(){
412
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
413
		String cdmServer = "160.45.63.201";
414
		String cdmDB = "cdm_edit_algaterra"; 
415
		String cdmUserName = "edit";
416
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
417
	}
418
	
419
	public static ICdmDataSource cdm_edit_cichorieae_PG(){
420
		DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
421
		String cdmServer = "127.0.0.1";
422
		String cdmDB = "cdm_edit_cichorieae_a"; 
423
		String cdmUserName = "edit";
424
		int port = 15432;
425
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
426
	}
427

  
428
	public static ICdmDataSource cdm_cichorieae_preview(){
429
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
430
		String cdmServer = "160.45.63.201";
431
		String cdmDB = "cdm_edit_cichorieae"; 
432
		String cdmUserName = "edit";
433
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
434
	}
435
	
436
	public static ICdmDataSource cdm_production_cichorieae(){
437
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
438
		String cdmServer = "160.45.63.151";
439
//		String cdmServer = "127.0.0.1";
440
		String cdmDB = "cdm_production_cichorieae"; 
441
		String cdmUserName = "edit";
442
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
443
	}
444
	
445
	public static ICdmDataSource cdm_production_palmae(){
446
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
447
		String cdmServer = "160.45.63.151";
448
		String cdmDB = "cdm_production_palmae"; 
449
		String cdmUserName = "edit";
450
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
451
	}
452
	
453
	
454
	public static ICdmDataSource cdm_production_diptera(){
455
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
456
		String cdmServer = "160.45.63.151";
457
		String cdmDB = "cdm_production_diptera"; 
458
		String cdmUserName = "edit";
459
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
460
	}
461
	
462
	public static ICdmDataSource local_cdm_edit_cichorieae_a(){
463
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
464
		String cdmServer = "127.0.0.1";
465
		String cdmDB = "cdm_edit_cichorieae_a"; 
466
		String cdmUserName = "edit";
467
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
468
	}
469
	
470
	public static ICdmDataSource local_cdm_edit_cichorieae_b(){
471
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
472
		String cdmServer = "127.0.0.1";
473
		String cdmDB = "cdm_edit_cichorieae_b"; 
474
		String cdmUserName = "edit";
475
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
476
	}
477

  
478
	public static ICdmDataSource cdm_edit_palmae_a(){
479
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
480
		String cdmServer = "192.168.2.10";
481
		String cdmDB = "cdm_edit_palmae_a";
482
		String cdmUserName = "edit";
483
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
484
	}
485

  
486
	public static ICdmDataSource cdm_edit_diptera_preview_B(){
487
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
488
		String cdmServer = "127.0.0.1";
489
		String cdmDB = "cdm_edit_diptera_b"; 
490
		String cdmUserName = "edit";
491
		int port = 13306;
492
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
493
	}
494
	
495
	public static ICdmDataSource cdm_edit_cichorieae_preview(){
496
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
497
		String cdmServer = "127.0.0.1";
498
		String cdmDB = "cdm_edit_cichorieae"; 
499
		String cdmUserName = "edit";
500
		int port = 13306;
501
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
502
	}
503

  
504
	public static ICdmDataSource cdm_edit_palmae_preview(){
505
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
506
		String cdmServer = "127.0.0.1";
507
		String cdmDB = "cdm_edit_palmae"; 
508
		String cdmUserName = "edit";
509
		int port = 13306;
510
		return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
511
	}		
512
	
513
	public static ICdmDataSource cdm_edit_salvador(){
514
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
515
		String cdmServer = "192.168.2.10";
516
		String cdmDB = "cdm_edit_salvador"; 
517
		String cdmUserName = "edit";
518
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
519
	}
520
	
521
	public static ICdmDataSource cdm_import_salvador() {
522
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
523
		String cdmServer = "192.168.2.10";
524
		String cdmDB = "cdm_import_salvador"; 
525
		String cdmUserName = "edit";
526
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
527
	}
528
	
529
	public static ICdmDataSource cdm_salvador_production() {
530
		DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
531
		String cdmServer = "192.168.2.10";
532
		String cdmDB = "salvador_cdm"; 
533
		String cdmUserName = "salvador";
534
		return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
535
	}
536
	
537
	
538
//	public static ICdmDataSource LAPTOP_HP(){
539
//		DatabaseTypeEnum dbType = DatabaseTypeEnum.SqlServer2005;
540
//		String cdmServer = "LAPTOPHP";
541
//		String cdmDB = "cdmTest"; 
542
//		String cdmUserName = "edit";
543
//		return makeDestination(cdmServer, cdmDB, -1, cdmUserName, null);
544
//	}
545
	
546
	
547

  
548
	 
549
	/**
550
	 * initializes source
551
	 * TODO only supports MySQL and PostgreSQL
552
	 * 
553
	 * @param dbType
554
	 * @param cdmServer
555
	 * @param cdmDB
556
	 * @param port
557
	 * @param cdmUserName
558
	 * @param pwd
559
	 * @return
560
	 */
561
	private static ICdmDataSource makeDestination(DatabaseTypeEnum dbType, String cdmServer, String cdmDB, int port, String cdmUserName, String pwd ){
562
		//establish connection
563
		pwd = AccountStore.readOrStorePassword(cdmServer, cdmDB, cdmUserName, pwd);
564
		ICdmDataSource destination;
565
		if(dbType.equals(DatabaseTypeEnum.MySQL)){
566
			destination = CdmDataSource.NewMySqlInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);			
567
		} else if(dbType.equals(DatabaseTypeEnum.PostgreSQL)){
568
			destination = CdmDataSource.NewPostgreSQLInstance(cdmServer, cdmDB, port, cdmUserName, pwd, null);			
569
		} else {
570
			//TODO others
571
			throw new RuntimeException("Unsupported DatabaseType");
572
		}
573
		return destination;
574

  
575
	}
576

  
577

  
578
	/**
579
	 * Accepts a string array and tries to find a method returning an ICdmDataSource with 
580
	 * the name of the given first string in the array
581
	 * 
582
	 * @param args
583
	 * @return
584
	 */
585
	public static ICdmDataSource chooseDestination(String[] args) {
586
		if(args == null)
587
			return null;
588
		
589
		if(args.length != 1)
590
			return null;
591
		
592
		String possibleDestination = args[0];
593
		
594
		Method[] methods = CdmDestinations.class.getMethods();
595
		
596
		for (Method method : methods){
597
			if(method.getName().equals(possibleDestination)){
598
				try {
599
					return (ICdmDataSource) method.invoke(null, null);
600
				} catch (IllegalArgumentException e) {
601
					// TODO Auto-generated catch block
602
					e.printStackTrace();
603
				} catch (IllegalAccessException e) {
604
					// TODO Auto-generated catch block
605
					e.printStackTrace();
606
				} catch (InvocationTargetException e) {
607
					// TODO Auto-generated catch block
608
					e.printStackTrace();
609
				}
610
			}
611
		}
612
		return null;
613
	}
614

  
615
}
616

  
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CdmImportSources.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.cdm.app.eflora;
11

  
12
import java.net.URI;
13
import java.net.URL;
14

  
15
import org.apache.log4j.Logger;
16

  
17
import eu.etaxonomy.cdm.common.AccountStore;
18
import eu.etaxonomy.cdm.io.common.Source;
19

  
20
/**
21
 * @author a.mueller
22
 * @date 21.04.2010
23
 *
24
 */
25
public class CdmImportSources {
26
	@SuppressWarnings("unused")
27
	private static final Logger logger = Logger.getLogger(CdmImportSources.class);
28
	
29

  
30
	public static Source AFRICA_CHECKLIST_ACCESS(){
31
		//	
32
		String dbms = Source.ACCESS;
33
		String strServer = null;
34
		//String strDB = "fernsTest";
35
		String strDB = "C:\\localCopy\\Data\\eflora\\africa\\checklist\\checklist_flore_afrique_centrale_corr.mdb";
36
		int port = 1433;
37
		String userName = "";
38
		return  makeSource(dbms, strServer, strDB, port, userName, null);
39
	}
40

  
41
	
42
	public static Source AFRICA_FERNS_ACCESS(){
43
		//	
44
		String dbms = Source.ACCESS;
45
		String strServer = null;
46
		//String strDB = "fernsTest";
47
		String strDB = "C:\\localCopy\\Data\\eflora\\africa\\ferns\\Synopsis_Database_corrected.mdb";
48
		int port = 1433;
49
		String userName = "";
50
		return  makeSource(dbms, strServer, strDB, port, userName, null);
51
	}
52
	
53
	public static Source GLOBIS(){
54
		String dbms = Source.SQL_SERVER_2005;
55
		String strServer = "LENOVO-T61";
56
		String strDB = "globis";
57
		int port = 1433;
58
		String userName = "adam";
59
		return  makeSource(dbms, strServer, strDB, port, userName, null);
60
	}
61

  
62
	public static Source GLOBIS_ODBC(){
63
		String dbms = Source.ODDBC;
64
		String strServer = "LENOVO-T61";
65
		String strDB = "globis";
66
		int port = 1433;
67
		String userName = "sa";
68
		return  makeSource(dbms, strServer, strDB, port, userName, null);
69
	}
70
	
71
	public static Source GLOBIS_MDB(){
72
		String dbms = Source.ACCESS;
73
		String strServer = null;
74
		String strDB = "C:\\localCopy\\Data\\globis\\globis.mdb";
75
		int port = -1;
76
		String userName = "";
77
		return  makeSource(dbms, strServer, strDB, port, userName, null);
78
	}
79
	
80
	
81
	public static URI SYNTHESYS_SPECIMEN(){
82
		//		tcsXmlTest.xml
83
		URL url = new CdmImportSources().getClass().getResource("/specimen/SynthesysSpecimenExample.xls");
84
		String sourceUrl = url.toString();
85
		URI uri = URI.create(sourceUrl);
86
		return uri;	
87
	}
88
	
89
	/**
90
	 * Initializes the source.
91
	 * @param dbms
92
	 * @param strServer
93
	 * @param strDB
94
	 * @param port
95
	 * @param userName
96
	 * @param pwd
97
	 * @return the source
98
	 */
99
	private static Source makeSource(String dbms, String strServer, String strDB, int port, String userName, String pwd ){
100
		//establish connection
101
		Source source = null;
102
		source = new Source(dbms, strServer, strDB);
103
		source.setPort(port);
104
			
105
		pwd = AccountStore.readOrStorePassword(dbms, strServer, userName, pwd);
106
		source.setUserAndPwd(userName, pwd);
107
		// write pwd to account store
108
		return source;
109
	}
110
}
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaChecklistActivator.java
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.eflora;
11

  
12
import java.util.UUID;
13

  
14
import org.apache.log4j.Logger;
15

  
16
import eu.etaxonomy.cdm.app.eflora.CdmDestinations;
17
import eu.etaxonomy.cdm.app.eflora.CdmImportSources;
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.Source;
22
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
23
import eu.etaxonomy.cdm.io.eflora.centralAfrica.checklist.CentralAfricaChecklistImportConfigurator;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26

  
27
/**
28
 * @author a.mueller
29
 * @created 20.06.2008
30
 * @version 1.0
31
 */
32
public class CentralAfricaChecklistActivator {
33
	@SuppressWarnings("unused")
34
	private static final Logger logger = Logger.getLogger(CentralAfricaChecklistActivator.class);
35
	
36
	//database validation status (create, update, validate ...)
37
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
38
	static final Source mySource = CdmImportSources.AFRICA_CHECKLIST_ACCESS();
39
	
40
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM3();
41
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview();
42
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
43
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
44

  
45
	int recordsPerTransaction = 1000;
46
	
47
	//feature tree uuid
48
	public static final UUID featureTreeUuid = UUID.fromString("ebe558b5-d04d-41d5-83d9-b61c56e6e34a");
49
	
50
	public static final String sourceReference = "Flora of Central Africa - Checklist";
51
	
52
	private UUID uuidGenevaReference = UUID.fromString("cf3fd13d-6cad-430c-ab70-7ea841b7159f");
53
	
54
	private String genevaReferenceTitle = "Geneva Database";
55
	
56
	//classification
57
	public static final UUID classificationUuid = UUID.fromString("ce1d035a-79a9-4a3a-95bf-26641ecb4fbe");
58
	
59
	//check - import
60
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
61
	
62
	//taxa
63
	static final boolean doTaxa = true;
64

  
65
	private void doImport(ICdmDataSource cdmDestination){
66
		
67
		//make Source
68
		Source source = mySource;
69
		
70
		CentralAfricaChecklistImportConfigurator config= CentralAfricaChecklistImportConfigurator.NewInstance(source, cdmDestination);
71
		config.setClassificationUuid(classificationUuid);
72
		config.setDoTaxa(doTaxa);
73
		config.setCheck(check);
74
		config.setDbSchemaValidation(hbm2dll);
75
		config.setRecordsPerTransaction(recordsPerTransaction);
76
		config.setGenevaReferenceTitle(genevaReferenceTitle);
77
		config.setUuidGenevaReference(uuidGenevaReference);
78
		
79
		CdmDefaultImport<CentralAfricaChecklistImportConfigurator> myImport = new CdmDefaultImport<CentralAfricaChecklistImportConfigurator>();
80

  
81
		System.out.println("Start import from ("+ source.toString() + ") ...");
82
		config.setSourceReference(getSourceReference(sourceReference));
83
		myImport.invoke(config);
84
		System.out.println("End import from ("+ source.toString() + ")...");
85
		
86

  
87
		
88
//		FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
89
//		myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
90
		
91
	}
92
	
93
	private Reference getSourceReference(String string) {
94
		Reference result = ReferenceFactory.newGeneric();
95
		result.setTitleCache(string);
96
		return result;
97
	}
98

  
99
//	private FeatureTree makeFeatureNode(ITermService service){
100
//		FloraMalesianaTransformer transformer = new FloraMalesianaTransformer();
101
//		
102
//		FeatureTree result = FeatureTree.NewInstance(featureTreeUuid);
103
//		result.setTitleCache("Flora Malesiana Presentation Feature Tree");
104
//		FeatureNode root = result.getRoot();
105
//		FeatureNode newNode;
106
//		
107
//		newNode = FeatureNode.NewInstance(Feature.CITATION());
108
//		root.addChild(newNode);
109
//		
110
//		newNode = FeatureNode.NewInstance(Feature.DESCRIPTION());
111
//		root.addChild(newNode);
112
//		
113
//		return result;
114
//	}
115
	
116

  
117

  
118
	/**
119
	 * @param args
120
	 */
121
	public static void main(String[] args) {
122
		CentralAfricaChecklistActivator me = new CentralAfricaChecklistActivator();
123
		me.doImport(cdmDestination);
124
	}
125
	
126
}
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaEricaceaeActivator.java
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.eflora;
11

  
12
import java.net.URI;
13
import java.util.List;
14
import java.util.UUID;
15

  
16
import org.apache.log4j.Logger;
17
import org.springframework.transaction.TransactionStatus;
18

  
19
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
20
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
21
import eu.etaxonomy.cdm.api.service.ITermService;
22
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor;
23
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
24
import eu.etaxonomy.cdm.database.DbSchemaValidation;
25
import eu.etaxonomy.cdm.database.ICdmDataSource;
26
import eu.etaxonomy.cdm.database.update.CdmUpdater;
27
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
28
import eu.etaxonomy.cdm.io.common.CdmImportBase.TermMatchMode;
29
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
30
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
31
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
32
import eu.etaxonomy.cdm.io.eflora.EfloraImportConfigurator;
33
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeImportConfigurator;
34
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ericaceae.CentralAfricaEricaceaeTransformer;
35
import eu.etaxonomy.cdm.io.specimen.excel.in.SpecimenCdmExcelImportConfigurator;
36
import eu.etaxonomy.cdm.model.agent.Team;
37
import eu.etaxonomy.cdm.model.common.Language;
38
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
39
import eu.etaxonomy.cdm.model.description.Feature;
40
import eu.etaxonomy.cdm.model.description.FeatureNode;
41
import eu.etaxonomy.cdm.model.description.FeatureTree;
42
import eu.etaxonomy.cdm.model.description.PolytomousKey;
43
import eu.etaxonomy.cdm.model.location.NamedArea;
44
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
45
import eu.etaxonomy.cdm.model.location.NamedAreaType;
46
import eu.etaxonomy.cdm.model.reference.Reference;
47
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
48

  
49
/**
50
 * @author a.mueller
51
 * @created 20.06.2008
52
 * @version 1.0
53
 */
54
public class CentralAfricaEricaceaeActivator {
55
	private static final Logger logger = Logger.getLogger(CentralAfricaEricaceaeActivator.class);
56
	
57
	//database validation status (create, update, validate ...)
58
	static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
59
	static final URI source = EfloraSources.ericacea_local();
60
	
61
	static final URI specimenSource = EfloraSources.ericacea_specimen_local();
62

  
63
	
64
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM3();
65
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview();
66
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
67
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
68
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();
69
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
70
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_jaxb();
71
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_edit_cichorieae_preview();
72
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_campanulaceae_production();
73
	
74
	//feature tree uuid
75
	public static final UUID featureTreeUuid = UUID.fromString("051d35ee-22f1-42d8-be07-9e9bfec5bcf7");
76
	
77
	public static UUID defaultLanguageUuid = Language.uuidFrench;
78
	
79
	//classification
80
	static final UUID classificationUuid = UUID.fromString("10e5efcc-6e13-4abc-ad42-e0b46e50cbe7");
81
	
82
	//check - import
83
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
84
	
85
	static boolean doPrintKeys = false;
86
	
87
	//taxa
88
	private boolean includeEricaceae = true;
89
	static final boolean doTaxa = true;
90
	static final boolean doDeduplicate = false;
91

  
92
	
93
	private boolean doNewNamedAreas = false;
94
	private boolean doFeatureTree = false;
95
	
96
	private boolean doSpecimen = false;
97
	private TermMatchMode specimenAreaMatchMode = TermMatchMode.UUID_ABBREVLABEL;
98

  
99
	
100
	private void doImport(ICdmDataSource cdmDestination){
101
		
102
		CdmUpdater su = CdmUpdater.NewInstance();
103
		IProgressMonitor monitor = DefaultProgressMonitor.NewInstance();
104
//		
105
//		try {
106
//			su.updateToCurrentVersion(cdmDestination, monitor);
107
//		} catch (Exception e) {
108
//			e.printStackTrace();
109
//		}
110
//		if (true){
111
//			return;
112
//		}
113
		
114
		//make Source
115
		CentralAfricaEricaceaeImportConfigurator config= CentralAfricaEricaceaeImportConfigurator.NewInstance(source, cdmDestination);
116
		config.setClassificationUuid(classificationUuid);
117
		config.setDoTaxa(doTaxa);
118
		config.setCheck(check);
119
		config.setDefaultLanguageUuid(defaultLanguageUuid);
120
		config.setDoPrintKeys(doPrintKeys);
121
		config.setDbSchemaValidation(hbm2dll);
122
		
123
		CdmDefaultImport<EfloraImportConfigurator> myImport = new CdmDefaultImport<EfloraImportConfigurator>();
124

  
125
		
126
		//Ericaceae
127
		if (includeEricaceae){
128
			System.out.println("Start import from ("+ source.toString() + ") ...");
129
			config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));
130
			myImport.invoke(config);
131
			System.out.println("End import from ("+ source.toString() + ")...");
132
		}
133
		
134
		if (doFeatureTree){
135
			FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
136
			myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
137
		}
138
		
139
		//check keys
140
		if (doPrintKeys){
141
			TransactionStatus tx = myImport.getCdmAppController().startTransaction();
142
			List<PolytomousKey> keys = myImport.getCdmAppController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
143
			for(PolytomousKey key : keys){
144
				key.print(System.out);
145
				System.out.println();
146
			}
147
			myImport.getCdmAppController().commitTransaction(tx);
148
		}
149
		
150
		//deduplicate
151
		if (doDeduplicate){
152
			ICdmApplicationConfiguration app = myImport.getCdmAppController();
153
			if (app == null){
154
				app = CdmApplicationController.NewInstance(cdmDestination, hbm2dll, false);
155
			}
156
			app.getAgentService().updateTitleCache(Team.class, null, null, null);
157
			return;
158
//			int count = app.getAgentService().deduplicate(Person.class, null, null);
159
//			
160
//			logger.warn("Deduplicated " + count + " persons.");
161
////			count = app.getAgentService().deduplicate(Team.class, null, null);
162
////			logger.warn("Deduplicated " + count + " teams.");
163
//			count = app.getReferenceService().deduplicate(Reference.class, null, null);
164
//			logger.warn("Deduplicated " + count + " references.");
165
		}
166
		
167
		if(doNewNamedAreas){
168
			newNamedAreas(myImport);
169
		}
170

  
171
		if (doSpecimen){
172
			logger.warn("Start specimen import");
173
			ICdmApplicationConfiguration app = myImport.getCdmAppController();
174
			SpecimenCdmExcelImportConfigurator specimenConfig= SpecimenCdmExcelImportConfigurator.NewInstance(specimenSource, cdmDestination);
175
			specimenConfig.setCdmAppController((CdmApplicationController)app);
176
			specimenConfig.setAreaMatchMode(specimenAreaMatchMode);
177
			
178
			config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
179
			specimenConfig.setSourceReference(getSourceReference(specimenConfig.getSourceReferenceTitle()));
180
			
181
			CdmDefaultImport<SpecimenCdmExcelImportConfigurator> specimenImport = new CdmDefaultImport<SpecimenCdmExcelImportConfigurator>();
182
			specimenImport.setCdmAppController(app);
183
			specimenImport.invoke(specimenConfig);
184
			
185
			
186
		}
187
		return;
188
	
189

  
190
		
191
	}
192

  
193
	private void newNamedAreas(CdmDefaultImport<EfloraImportConfigurator> myImport) {
194
		ICdmApplicationConfiguration app = myImport.getCdmAppController();
195
		if (app == null){
196
			app = CdmApplicationController.NewInstance(cdmDestination, hbm2dll, false);
197
		}
198
		TransactionStatus tx = app.startTransaction();
199
		
200
		OrderedTermVocabulary<NamedArea> voc = OrderedTermVocabulary.NewInstance("Phytogeographic Regions of Central Africa", "Phytogeographic Regions of Central Africa", "FdAC regions", null);
201
		app.getVocabularyService().save(voc);
202
		
203
		NamedAreaLevel level = NamedAreaLevel.NewInstance("Phytogeographic Regions of Central Africa", "Phytogeographic Regions of Central Africa", "FdAC regions");
204
		ITermService termService = app.getTermService();
205
		
206
		termService.save(level);
207
		
208
		NamedArea area = NamedArea.NewInstance("C?tier", "C?tier", "I");
209
		area.setLevel(level);
210
		area.setType(NamedAreaType.NATURAL_AREA());
211
		voc.addTerm(area);
212
		termService.save(area);
213
		
214

  
215
		area = NamedArea.NewInstance("Mayumbe", "Mayumbe", "II");
216
		area.setLevel(level);
217
		area.setType(NamedAreaType.NATURAL_AREA());
218
		voc.addTerm(area);
219
		termService.save(area);
220

  
221
		area = NamedArea.NewInstance("Bas-Congo", "Bas-Congo", "III");
222
		area.setLevel(level);
223
		area.setType(NamedAreaType.NATURAL_AREA());
224
		voc.addTerm(area);
225
		termService.save(area);
226

  
227
		area = NamedArea.NewInstance("Kasai", "Kasai", "IV");
228
		area.setLevel(level);
229
		area.setType(NamedAreaType.NATURAL_AREA());
230
		voc.addTerm(area);
231
		termService.save(area);
232

  
233
		area = NamedArea.NewInstance("Bas-Katanga", "Bas-Katanga", "V");
234
		area.setLevel(level);
235
		area.setType(NamedAreaType.NATURAL_AREA());
236
		voc.addTerm(area);
237
		termService.save(area);
238

  
239
		area = NamedArea.NewInstance("Forestier Central", "Forestier Central", "VI");
240
		area.setLevel(level);
241
		area.setType(NamedAreaType.NATURAL_AREA());
242
		voc.addTerm(area);
243
		termService.save(area);
244

  
245
		area = NamedArea.NewInstance("Ubangi-Uele", "Ubangi-Uele", "VII");
246
		area.setLevel(level);
247
		area.setType(NamedAreaType.NATURAL_AREA());
248
		voc.addTerm(area);
249
		termService.save(area);
250

  
251
		area = NamedArea.NewInstance("Lac Albert", "Lac Albert", "VIII");
252
		area.setLevel(level);
253
		area.setType(NamedAreaType.NATURAL_AREA());
254
		voc.addTerm(area);
255
		termService.save(area);
256

  
257
		area = NamedArea.NewInstance("Lacs ?douard et Kivu", "Lacs ?douard et Kivu", "IX");
258
		area.setLevel(level);
259
		area.setType(NamedAreaType.NATURAL_AREA());
260
		voc.addTerm(area);
261
		termService.save(area);
262

  
263
		area = NamedArea.NewInstance("Rwanda-Burundi", "Rwanda-Burundi", "X");
264
		area.setLevel(level);
265
		area.setType(NamedAreaType.NATURAL_AREA());
266
		voc.addTerm(area);
267
		termService.save(area);
268

  
269
		area = NamedArea.NewInstance("Haut-Katanga", "Haut-Katanga", "XI");
270
		area.setLevel(level);
271
		area.setType(NamedAreaType.NATURAL_AREA());
272
		voc.addTerm(area);
273
		termService.save(area);
274
		
275
		app.getVocabularyService().save(voc);
276
		
277
		app.commitTransaction(tx);
278

  
279
	}
280

  
281
	private Reference getSourceReference(String string) {
282
		Reference result = ReferenceFactory.newGeneric();
283
		result.setTitleCache(string);
284
		return result;
285
	}
286

  
287
	private FeatureTree makeFeatureNode(ITermService service){
288
		CentralAfricaEricaceaeTransformer transformer = new CentralAfricaEricaceaeTransformer();
289
		
290
		FeatureTree result = FeatureTree.NewInstance(featureTreeUuid);
291
		result.setTitleCache("Central Africa Ericaceae Feature Tree");
292
		FeatureNode root = result.getRoot();
293
		FeatureNode newNode;
294
		
295
		newNode = FeatureNode.NewInstance(Feature.DESCRIPTION());
296
		root.addChild(newNode);
297
		
298
		addFeataureNodesByStringList(descriptionFeatureList, newNode, transformer, service);
299

  
300
		addFeataureNodesByStringList(generellDescriptionsList, root, transformer, service);
301

  
302
		
303
		newNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
304
		root.addChild(newNode);
305

  
306
		newNode = FeatureNode.NewInstance(Feature.ECOLOGY());
307
		root.addChild(newNode);
308
		addFeataureNodesByStringList(habitatEcologyList, root, transformer, service);
309
		
310
		newNode = FeatureNode.NewInstance(Feature.USES());
311
		root.addChild(newNode);
312
		
313
		addFeataureNodesByStringList(chomosomesList, root, transformer, service);
314

  
315
		newNode = FeatureNode.NewInstance(Feature.COMMON_NAME());
316
		root.addChild(newNode);
317
		
318
		newNode = FeatureNode.NewInstance(Feature.CITATION());
319
		root.addChild(newNode);
320
		
321
		return result;
322
	}
323
	
324
	private static String [] chomosomesList = new String[]{
325
		"Chromosomes", 
326
	};
327

  
328
	
329
	private static String [] habitatEcologyList = new String[]{
330
		"Habitat",
331
		"Habitat & Ecology"
332
	};
333
	
334
	
335
	private static String [] generellDescriptionsList = new String[]{
336
		"Fossils",
337
		"Morphology and anatomy",
338
		"Morphology", 
339
		"Vegetative morphology and anatomy",
340
		"Flower morphology",
341
		"Palynology",  
342
		"Pollination",  
343
		"Pollen morphology",
344
		"Life cycle",
345
		"Fruits and embryology",
346
		"Dispersal",
347
		"Wood anatomy",  
348
		"Leaf anatomy",  
349
		"Chromosome numbers", 
350
		"Phytochemistry and Chemotaxonomy",
351
		"Phytochemistry",
352
		"Taxonomy",	
353
	};
354

  
355
	private static String [] descriptionFeatureList = new String[]{
356
		"lifeform", 
357
		"Bark",  
358
		"Indumentum",  
359
		"endophytic body",  
360
		"flowering buds",  
361
		"Branchlets",  
362
		"Branches",  
363
		"Branch",  
364
		"Flowering branchlets",
365
		"Trees",  
366
		"Twigs",  
367
		"stem",  
368
		"Stems",  
369
		"stem leaves", 
370
		"Leaves",
371
		"flower-bearing stems",  
372
		"Petiole",  
373
		"Petiolules",  
374
		"Leaflets", 
375
		"Thyrsus",  
376
		"Thyrses",  
377
		"Inflorescences",  
378
		"Inflorescence",
379
		"Young inflorescences", 
380
		"Bracts",  
381
		"Pedicels",  
382
		"flowering buds",  
383
		"scales",  
384
		"Buds",  
385
		"Flowers",  
386
		"Flower",  
387
		"Flowering",
388
		"Stigma",  
389
		"perianth",  
390
		"Sepals",  
391
		"Sepal",  
392
		"Outer Sepals",  
393
		"Axillary",  
394
		"cymes",  
395
		"Calyx",  
396
		"Petal",  
397
		"Petals",  
398
		"perigone tube",
399
		"Disc",  
400
		"corolla",  
401
		"Stamens",  
402
		"Staminodes",  
403
		"Ovary",  
404
		"Anthers",
405
		"anther",  
406
		"Pistil",  
407
		"Pistillode",  
408
		"Ovules",  
409
		"androecium",  
410
		"gynoecium",  
411
		"Filaments",  		
412
		"Style",  
413
		"annulus",  
414
		"female flowers",  
415
		"Male flowers",  
416
		"Female",  
417
		"Infructescences",    //order not consistent (sometimes before "Flowers")  
418
		"Fruit",  
419
		"Fruits",  
420
		"fruiting axes",  
421
		"drupes",  
422
		"Arillode",  
423
		"seed",  
424
		"Seeds",  
425
		"Seedling",  
426
		"flower tube", 
427
		"nutlets",  
428
		"pollen",  
429
		"secondary xylem",  
430
		"chromosome number",  
431
	
432
		"figure",  
433
		"fig",  
434
		"figs",  
435

  
436

  
437

  
438
		
439
	};
440
	
441
	public void addFeataureNodesByStringList(String[] featureStringList, FeatureNode root, IInputTransformer transformer, ITermService termService){
442
		try {
443
			for (String featureString : featureStringList){
444
			UUID featureUuid;
445
			featureUuid = transformer.getFeatureUuid(featureString);
446
			Feature feature = (Feature)termService.find(featureUuid);
447
			if (feature != null){
448
				FeatureNode child = FeatureNode.NewInstance(feature);
449
				root.addChild(child);	
450
			}
451
		}
452
		} catch (UndefinedTransformerMethodException e) {
453
			logger.error("getFeatureUuid is not implemented in transformer. Features could not be added");
454
		}
455
	}
456
	
457

  
458

  
459
	/**
460
	 * @param args
461
	 */
462
	public static void main(String[] args) {
463
		CentralAfricaEricaceaeActivator me = new CentralAfricaEricaceaeActivator();
464
		me.doImport(cdmDestination);
465
	}
466
	
467
}
cdm-eflora/src/main/java/eu/etaxonomy/cdm/app/eflora/CentralAfricaFernsActivator.java
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.eflora;
11

  
12
import java.util.UUID;
13

  
14
import org.apache.log4j.Logger;
15

  
16
import eu.etaxonomy.cdm.api.service.ITermService;
17
import eu.etaxonomy.cdm.database.DbSchemaValidation;
18
import eu.etaxonomy.cdm.database.ICdmDataSource;
19
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
20
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
21
import eu.etaxonomy.cdm.io.common.Source;
22
import eu.etaxonomy.cdm.io.eflora.centralAfrica.ferns.CentralAfricaFernsImportConfigurator;
23
import eu.etaxonomy.cdm.io.eflora.floraMalesiana.FloraMalesianaTransformer;
24
import eu.etaxonomy.cdm.model.description.Feature;
25
import eu.etaxonomy.cdm.model.description.FeatureNode;
26
import eu.etaxonomy.cdm.model.description.FeatureTree;
27
import eu.etaxonomy.cdm.model.reference.Reference;
28
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
29

  
30
/**
31
 * @author a.mueller
32
 * @created 20.06.2008
33
 * @version 1.0
34
 */
35
public class CentralAfricaFernsActivator {
36
	@SuppressWarnings("unused")
37
	private static final Logger logger = Logger.getLogger(CentralAfricaFernsActivator.class);
38
	
39
	//database validation status (create, update, validate ...)
40
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
41
	static final Source mySource = CdmImportSources.AFRICA_FERNS_ACCESS();
42
	
43
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_andreasM2();
44
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview();
45
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
46
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
47
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_postgres_CdmTest();
48
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
49
	
50
	//feature tree uuid
51
	public static final UUID featureTreeUuid = UUID.fromString("62d930cb-aabb-461c-ad16-0fdbd2bae592");
52
	
53
	public static final String sourceReference = "Flora of Central Africa";
54

  
55
	public static final String classificationName = "Flora of Central Africa - Ferns"; 
56
	
57
	//classification
58
	static final UUID classificationUuid = UUID.fromString("a90fa160-8f33-4a19-9c5a-ab05a1553017");
59
	
60
	//check - import
61
	static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
62
	
63
//	static boolean doPrintKeys = false;
64
	
65
	//taxa
66
	static final boolean doTaxa = true;
67

  
68
//	private boolean includeSapindaceae1 = true;
69

  
70

  
71
	
72
	private void doImport(ICdmDataSource cdmDestination){
73
		
74
		
75
		//make Source
76
		Source source = mySource;
77
		
78
//		mySource.getResultSet("SELECT * FROM tmp");
79
		CentralAfricaFernsImportConfigurator config= CentralAfricaFernsImportConfigurator.NewInstance(source, cdmDestination);
80
		config.setClassificationUuid(classificationUuid);
81
		config.setClassificationName(classificationName);
82
		config.setDoTaxa(doTaxa);
83
		config.setCheck(check);
84
//		configsetDoPrintKeys(doPrintKeys);
85
		config.setDbSchemaValidation(hbm2dll);
86
		
87
		CdmDefaultImport<CentralAfricaFernsImportConfigurator> myImport = new CdmDefaultImport<CentralAfricaFernsImportConfigurator>();
88

  
89
		
90
//		if (includeSapindaceae1){
91
			System.out.println("Start import from ("+ source.toString() + ") ...");
92
			config.setSourceReference(getSourceReference(sourceReference));
93
			myImport.invoke(config);
94
			System.out.println("End import from ("+ source.toString() + ")...");
95
//		}
96
		
97

  
98
		
99
		FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
100
		myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
101
		
102
		//check keys
103
//		if (doPrintKeys){
104
//			TransactionStatus tx = myImport.getCdmAppController().startTransaction();
105
//			List<FeatureTree> keys = myImport.getCdmAppController().getFeatureTreeService().list(PolytomousKey.class, null, null, null, null);
106
//			for(FeatureTree key : keys){
107
//				((PolytomousKey)key).print(System.out);
108
//				System.out.println();
109
//			}
110
//			myImport.getCdmAppController().commitTransaction(tx);
111
//		}
112
		
113
	}
114
	
115
	private Reference getSourceReference(String string) {
116
		Reference result = ReferenceFactory.newGeneric();
117
		result.setTitleCache(string);
118
		return result;
119
	}
120

  
121
	private FeatureTree makeFeatureNode(ITermService service){
122
		FloraMalesianaTransformer transformer = new FloraMalesianaTransformer();
123
		
124
		FeatureTree result = FeatureTree.NewInstance(featureTreeUuid);
125
		result.setTitleCache("Flora Malesiana Presentation Feature Tree");
126
		FeatureNode root = result.getRoot();
127
		FeatureNode newNode;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff