Project

General

Profile

Download (16.6 KB) Statistics
| Branch: | Revision:
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.service.ITermService;
20
import eu.etaxonomy.cdm.database.DbSchemaValidation;
21
import eu.etaxonomy.cdm.database.ICdmDataSource;
22
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
23
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
24
import eu.etaxonomy.cdm.io.common.mapping.UndefinedTransformerMethodException;
25
import eu.etaxonomy.cdm.io.markup.MarkupTransformer;
26
import eu.etaxonomy.cdm.model.description.Feature;
27
import eu.etaxonomy.cdm.model.description.FeatureNode;
28
import eu.etaxonomy.cdm.model.description.FeatureTree;
29
import eu.etaxonomy.cdm.model.description.PolytomousKey;
30
import eu.etaxonomy.cdm.model.reference.Reference;
31
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
32

    
33
/**
34
 * @author a.mueller
35
 * @created 20.06.2008
36
 */
37
public class FloreGabonActivator extends EfloraActivatorBase {
38
	private static final Logger logger = Logger.getLogger(FloreGabonActivator.class);
39

    
40
	//database validation status (create, update, validate ...)
41
	static DbSchemaValidation hbm2dll = DbSchemaValidation.CREATE;
42
//	static final URI source = EfloraSources.fdg_sample();
43
	static final URI fdg1 = EfloraSources.fdg_1();
44
	static final URI fdg2 = EfloraSources.fdg_2();
45
	static final URI fdg3 = EfloraSources.fdg_3();
46
	static final URI fdg4 = EfloraSources.fdg_4();
47
	static final URI fdg5 = EfloraSources.fdg_5();
48
	static final URI fdg5bis = EfloraSources.fdg_5bis();
49
	static final URI fdg6 = EfloraSources.fdg_6();
50
	static final URI fdg7 = EfloraSources.fdg_7();
51
	static final URI fdg8 = EfloraSources.fdg_8();
52
	static final URI fdg9 = EfloraSources.fdg_9();
53
	static final URI fdg10 = EfloraSources.fdg_10();
54
	static final URI fdg11 = EfloraSources.fdg_11();
55
	static final URI fdg12_17 = EfloraSources.fdg_12_17();
56
	static final URI fdg13 = EfloraSources.fdg_13();
57
	static final URI fdg14 = EfloraSources.fdg_14();
58
	static final URI fdg15 = EfloraSources.fdg_15();
59
	static final URI fdg16 = EfloraSources.fdg_16();
60
	static final URI fdg18 = EfloraSources.fdg_18();
61
	static final URI fdg19 = EfloraSources.fdg_19();
62
	static final URI fdg20 = EfloraSources.fdg_20();
63
	static final URI fdg21 = EfloraSources.fdg_21();
64
	static final URI fdg22 = EfloraSources.fdg_22();
65
	static final URI fdg23 = EfloraSources.fdg_23();
66
	static final URI fdg24 = EfloraSources.fdg_24();
67
	static final URI fdg25 = EfloraSources.fdg_25();
68
	static final URI fdg26 = EfloraSources.fdg_26();
69
	static final URI fdg27 = EfloraSources.fdg_27();
70
	static final URI fdg28 = EfloraSources.fdg_28();
71
	static final URI fdg29 = EfloraSources.fdg_29();
72
	static final URI fdg30 = EfloraSources.fdg_30();
73
	static final URI fdg31 = EfloraSources.fdg_31();
74
	static final URI fdg32 = EfloraSources.fdg_32();
75
	static final URI fdg33 = EfloraSources.fdg_33();
76
	static final URI fdg34 = EfloraSources.fdg_34();
77
	static final URI fdg35 = EfloraSources.fdg_35();
78

    
79
//	static final URI fdg36 = EfloraSources.fdg_36();
80
//	static final URI fdg37 = EfloraSources.fdg_37();
81
	static final URI fdg36_37 = EfloraSources.fdg_36_37();
82

    
83
	static final URI fdg38 = EfloraSources.fdg_38();
84
	static final URI fdg39 = EfloraSources.fdg_39();
85
	static final URI fdg40 = EfloraSources.fdg_40();
86
	static final URI fdg41 = EfloraSources.fdg_41();
87
	static final URI fdg42 = EfloraSources.fdg_42();
88
	static final URI fdg43 = EfloraSources.fdg_43();
89
	static final URI fdg44 = EfloraSources.fdg_44();
90
	static final URI fdg45 = EfloraSources.fdg_45();
91

    
92

    
93

    
94

    
95
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flore_gabon_preview();
96
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flore_gabon_production();
97
	static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
98
//	static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql();
99

    
100

    
101
	//feature tree uuid
102
	public static final UUID featureTreeUuid = UUID.fromString("ee688973-2595-4d4d-b11e-6df71e96a5c2");
103
	private static final String featureTreeTitle = "Flore Gabon Presentation Feature Tree";
104

    
105
	//classification
106
	static final UUID classificationUuid = UUID.fromString("2f892452-ff49-48cf-834f-52ca29600719");
107
	static final String classificationTitle = "Flore du Gabon";
108

    
109
	//check - import
110
	private boolean h2ForCheck = false;
111
	static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
112

    
113
	static boolean doPrintKeys = false;
114

    
115

    
116
	private boolean replaceStandardKeyTitles = true;
117

    
118
	//taxa
119
	static final boolean doTaxa = true;
120

    
121
	static final boolean reuseState = true;
122

    
123

    
124
	//if true, use inverse include information
125
	private boolean inverseInclude = true;
126

    
127
	private boolean includeFdg1 = true;
128
	private boolean includeFdg2 = true;
129
	private boolean includeFdg3 = true;
130
	private boolean includeFdg4 = true;
131
	private boolean includeFdg5 = true;
132
	private boolean includeFdg5bis = true;
133
	private boolean includeFdg6 = true;
134
	private boolean includeFdg7 = true;
135
	private boolean includeFdg8 = true;
136
	private boolean includeFdg9 = true;
137
	private boolean includeFdg10 = true;
138
	private boolean includeFdg11 = true;
139
	private boolean includeFdg12_17 = true;
140
	private boolean includeFdg13 = true;
141
	private boolean includeFdg14 = true;
142
	private boolean includeFdg15 = true;
143
	private boolean includeFdg16 = true;
144
	private boolean includeFdg18 = true;
145
	private boolean includeFdg19 = true;
146
	private boolean includeFdg20 = true;
147
	private boolean includeFdg21 = true;
148
	private boolean includeFdg22 = true;
149

    
150
	private boolean includeFdg23 = false;
151
	private boolean includeFdg24 = true;
152
	private boolean includeFdg25 = true;
153
	private boolean includeFdg26 = true;
154

    
155
	private boolean includeFdg27 = true;
156
	private boolean includeFdg28 = true;
157

    
158
	private boolean includeFdg29 = true;
159

    
160
	private boolean includeFdg30 = true;
161

    
162
	private boolean includeFdg31 = true;
163
	private boolean includeFdg32 = true;
164
	private boolean includeFdg33 = true;
165

    
166
	private boolean includeFdg34 = true;
167
	private boolean includeFdg35 = true;
168

    
169
//	private boolean includeFdg36 = true;
170
//	private boolean includeFdg37 = true;
171
	private boolean includeFdg36_37 = true;
172
	private boolean includeFdg38 = true;
173
	private boolean includeFdg39 = true;
174
	private boolean includeFdg40 = true;
175
	private boolean includeFdg41 = true;
176
	private boolean includeFdg42 = true;
177
	private boolean includeFdg43 = true;
178
	private boolean includeFdg44 = true;
179
	private boolean includeFdg45 = true;
180

    
181
// **************** NO CHANGE **********************************************/
182

    
183
	private void doImport(ICdmDataSource cdmDestination){
184
		super.doImport(fdg1, cdmDestination,check, h2ForCheck);
185

    
186
		//make config
187
		config.setClassificationUuid(classificationUuid);
188
		config.setDoTaxa(doTaxa);
189
		config.setDoPrintKeys(doPrintKeys);
190
		config.setDbSchemaValidation(hbm2dll);
191
		config.setReplaceStandardKeyTitles(replaceStandardKeyTitles);
192
		config.setSourceReference(getSourceReference("Flore du Gabon"));
193
		config.setClassificationName(classificationTitle);
194
		config.setReuseExistingState(reuseState);
195

    
196
		//Vol1
197
		executeVolume( fdg1, includeFdg1 ^ inverseInclude);
198

    
199
		//Vol2
200
		executeVolume(fdg2, includeFdg2 ^ inverseInclude);
201

    
202
		//Vol3
203
		executeVolume(fdg3, includeFdg3 ^ inverseInclude);
204

    
205
		//Vol4
206
		executeVolume(fdg4, includeFdg4 ^ inverseInclude);
207

    
208
		//Vol5
209
		executeVolume(fdg5, includeFdg5 ^ inverseInclude);
210

    
211
		//Vol5bis
212
		executeVolume(fdg5bis, includeFdg5bis ^ inverseInclude);
213

    
214
		//Vol6
215
		executeVolume(fdg6, includeFdg6 ^ inverseInclude);
216

    
217
		//Vol7
218
		executeVolume(fdg7, includeFdg7 ^ inverseInclude);
219

    
220
		//Vol8
221
		executeVolume(fdg8, includeFdg8 ^ inverseInclude);
222

    
223
		//Vol9
224
		executeVolume(fdg9, includeFdg9 ^ inverseInclude);
225

    
226
		//Vol10
227
		executeVolume(fdg10, includeFdg10 ^ inverseInclude);
228

    
229
		//Vol11
230
		executeVolume(fdg11, includeFdg11 ^ inverseInclude);
231

    
232
		//Vol12
233
		executeVolume(fdg12_17, includeFdg12_17 ^ inverseInclude);
234

    
235
		//Vol13
236
		executeVolume(fdg13, includeFdg13 ^ inverseInclude);
237

    
238
		//Vol14
239
		executeVolume(fdg14, includeFdg14 ^ inverseInclude);
240

    
241
		//Vol15
242
		executeVolume(fdg15, includeFdg15 ^ inverseInclude);
243

    
244
		//Vol16
245
		executeVolume(fdg16, includeFdg16 ^ inverseInclude);
246

    
247
		//Vol18
248
		executeVolume(fdg18, includeFdg18 ^ inverseInclude);
249

    
250
		//Vol19
251
		executeVolume(fdg19, includeFdg19 ^ inverseInclude);
252

    
253
		//Vol20
254
		executeVolume(fdg20, includeFdg20 ^ inverseInclude);
255

    
256
		//Vol21
257
		executeVolume(fdg21, includeFdg21 ^ inverseInclude);
258
		//Vol22
259
		executeVolume(fdg22, includeFdg22 ^ inverseInclude);
260
		//Vol23
261
		executeVolume(fdg23, includeFdg23 ^ inverseInclude);
262
		//Vol24
263
		executeVolume(fdg24, includeFdg24 ^ inverseInclude);
264
		//Vol25
265
		executeVolume(fdg25, includeFdg25 ^ inverseInclude);
266
		//Vol26
267
		executeVolume(fdg26, includeFdg26 ^ inverseInclude);
268
		//Vol27
269
		executeVolume(fdg27, includeFdg27 ^ inverseInclude);
270
		//Vol28
271
		executeVolume(fdg28, includeFdg28 ^ inverseInclude);
272
		//Vol29
273
		executeVolume(fdg29, includeFdg29 ^ inverseInclude);
274
		//Vol30
275
		executeVolume(fdg30, includeFdg30 ^ inverseInclude);
276
		//Vol31
277
		executeVolume(fdg31, includeFdg31 ^ inverseInclude);
278
		//Vol32
279
		executeVolume(fdg32, includeFdg32 ^ inverseInclude);
280
		//Vol33
281
		executeVolume(fdg33, includeFdg33 ^ inverseInclude);
282
		//Vol34
283
		executeVolume(fdg34, includeFdg34 ^ inverseInclude);
284
		//Vol35
285
		executeVolume(fdg35, includeFdg35 ^ inverseInclude);
286

    
287
//		//Vol36
288
//		executeVolume(fdg36, includeFdg36 ^ inverseInclude);
289
//
290
//		//Vol37
291
//		executeVolume(fdg37, includeFdg37 ^ inverseInclude);
292

    
293
		//Vol 36_37
294
		executeVolume(fdg36_37, includeFdg36_37 ^ inverseInclude);
295

    
296
		//Vol38
297
		executeVolume(fdg38, includeFdg38 ^ inverseInclude);
298

    
299
		//Vol39
300
		executeVolume(fdg39, includeFdg39 ^ inverseInclude);
301

    
302
		//Vol40
303
		executeVolume(fdg40, includeFdg40 ^ inverseInclude);
304

    
305
		//Vol41
306
		executeVolume(fdg41, includeFdg41 ^ inverseInclude);
307

    
308
		//Vol42
309
		executeVolume(fdg42, includeFdg42 ^ inverseInclude);
310

    
311
		//Vol43
312
		executeVolume(fdg43, includeFdg43 ^ inverseInclude);
313

    
314
		//Vol44
315
		executeVolume(fdg44, includeFdg44 ^ inverseInclude);
316

    
317
		//Vol45
318
		executeVolume(fdg45, includeFdg45 ^ inverseInclude);
319

    
320

    
321

    
322
		FeatureTree tree = makeFeatureNode(myImport.getCdmAppController().getTermService());
323
		myImport.getCdmAppController().getFeatureTreeService().saveOrUpdate(tree);
324

    
325
		makeAutomatedFeatureTree(myImport.getCdmAppController(), config.getState(),
326
				featureTreeUuid, featureTreeTitle);
327

    
328

    
329
		//check keys
330
		if (doPrintKeys){
331
			TransactionStatus tx = myImport.getCdmAppController().startTransaction();
332
			List<PolytomousKey> keys = myImport.getCdmAppController().getPolytomousKeyService().list(PolytomousKey.class, null, null, null, null);
333
			for(PolytomousKey key : keys){
334
				key.print(System.out);
335
				System.out.println();
336
			}
337
			myImport.getCdmAppController().commitTransaction(tx);
338
		}
339

    
340
	}
341

    
342
	private Reference getSourceReference(String string) {
343
		Reference result = ReferenceFactory.newGeneric();
344
		result.setTitleCache(string, true);
345
		return result;
346
	}
347

    
348

    
349

    
350

    
351
	private FeatureTree makeFeatureNode(ITermService service){
352
		MarkupTransformer transformer = new MarkupTransformer();
353

    
354
		FeatureTree result = FeatureTree.NewInstance();
355
		result.setTitleCache("Old feature tree", true);
356
		FeatureNode root = result.getRoot();
357
		FeatureNode newNode;
358

    
359
		newNode = FeatureNode.NewInstance(Feature.DESCRIPTION());
360
		root.addChild(newNode);
361

    
362
		addFeataureNodesByStringList(descriptionFeatureList, newNode, transformer, service);
363

    
364
		addFeataureNodesByStringList(generellDescriptionsUpToAnatomyList, root, transformer, service);
365
		newNode = FeatureNode.NewInstance(Feature.ANATOMY());
366
		addFeataureNodesByStringList(anatomySubfeatureList, newNode, transformer, service);
367

    
368
		newNode = addFeataureNodesByStringList(generellDescriptionsFromAnatomyToPhytoChemoList, root, transformer, service);
369
		addFeataureNodesByStringList(phytoChemoSubFeaturesList, newNode, transformer, service);
370

    
371
		newNode = addFeataureNodesByStringList(generellDescriptionsFromPhytoChemoList, root, transformer, service);
372

    
373
		newNode = FeatureNode.NewInstance(Feature.COMMON_NAME());
374
		root.addChild(newNode);
375

    
376
		newNode = FeatureNode.NewInstance(Feature.DISTRIBUTION());
377
		root.addChild(newNode);
378

    
379
		newNode = FeatureNode.NewInstance(Feature.ECOLOGY());
380
		root.addChild(newNode);
381
		addFeataureNodesByStringList(habitatEcologyList, root, transformer, service);
382

    
383
		newNode = FeatureNode.NewInstance(Feature.USES());
384
		root.addChild(newNode);
385

    
386
		addFeataureNodesByStringList(chomosomesList, root, transformer, service);
387

    
388
		newNode = FeatureNode.NewInstance(Feature.CITATION());
389
		root.addChild(newNode);
390

    
391
		return result;
392
	}
393

    
394
	private static String [] chomosomesList = new String[]{
395
		"Chromosomes",
396
	};
397

    
398

    
399
	private static String [] habitatEcologyList = new String[]{
400
		"Habitat",
401
		"Habitat & Ecology"
402
	};
403

    
404

    
405
	private static String [] generellDescriptionsUpToAnatomyList = new String[]{
406
		"Fossils",
407
		"Morphology and anatomy",
408
		"Morphology",
409
		"Vegetative morphology and anatomy",
410
	};
411

    
412

    
413
	private static String [] anatomySubfeatureList = new String[]{
414
		"Leaf anatomy",
415
		"Wood anatomy"
416
	};
417

    
418
	private static String [] generellDescriptionsFromAnatomyToPhytoChemoList = new String[]{
419
		"Flower morphology",
420
		"Palynology",
421
		"Pollination",
422
		"Pollen morphology",
423
		"embryology",
424
		"cytology",
425
		"Life cycle",
426
		"Fruits and embryology",
427
		"Dispersal",
428
		"Chromosome numbers",
429
		"Phytochemistry and Chemotaxonomy",
430
	};
431

    
432

    
433
	private static String [] phytoChemoSubFeaturesList = new String[]{
434
		"Alkaloids",
435
		"Iridoid glucosides",
436
		"Leaf phenolics",
437
		"Storage products of seeds",
438
		"Aluminium",
439
		"Chemotaxonomy",
440
	};
441

    
442

    
443
	private static String [] generellDescriptionsFromPhytoChemoList = new String[]{
444
		"Phytochemistry",
445
		"Taxonomy",
446
		"history",
447
		"cultivation",
448
		"Notes"
449
	};
450

    
451

    
452
	private static String [] descriptionFeatureList = new String[]{
453
		"lifeform",
454
		"Juvenile parts",
455
		"Bark",
456
		//new
457
		"wood",
458
		"Indumentum",
459
		"endophytic body",
460
		"apical buds",
461
		"flowering buds",
462
		"Branchlets",
463
		"Branches",
464
		"Branch",
465
		"Flowering branchlets",
466
		"Trees",
467
		"Twigs",
468
		"stem",
469
		"Stems",
470
		"stem leaves",
471
		"Leaves",
472
		"extraxylary sclerenchyma",
473
		"flower-bearing stems",
474
		"Petiole",
475
		"Petiolules",
476
		"Leaflets",
477
		"Lamina",
478
		"Veins",
479
		"Lateral veins",
480
		"secondary veins",
481
		"Intersecondary veins",
482
		"veinlets",
483
		"Thyrsus",
484
		"Thyrses",
485
		"Inflorescences",
486
		"Inflorescence",
487
		"Young inflorescences",
488
		"Male inflorescences",
489
		"Female inflorescences",
490
		"rachises",
491
		"Bracts",
492
		"Pedicels",
493
		"flowering buds",
494
		"scales",
495
		"Buds",
496
		"Flowers",
497
		"Flower",
498
		"Flowering",
499
		"Stigma",
500
		"perianth",
501
		"Sepals",
502
		"Sepal",
503
		"Outer Sepals",
504
		"Axillary",
505
		"cymes",
506
		"Calyx",
507
		"Androgynophore",
508
		"Petal",
509
		"Petals",
510
		"perigone",
511
		"perigone lobes",
512
		"perigone tube",
513
		"Disc",
514
		"corolla",
515
		"Stamens",
516
		"Staminodes",
517
		"Ovary",
518
		"Anthers",
519
		"anther",
520
		"Pistil",
521
		"Pistillode",
522
		"Ovules",
523
		"androecium",
524
		"gynoecium",
525
		"Filaments",
526
		"Style",
527
		"annulus",
528
		"female flowers",
529
		"Male flowers",
530
		"Androphore",
531
		"Female",
532
		"Infructescences",    //order not consistent (sometimes before "Flowers")
533
		"Fruit",
534
		"Fruits",
535
		"fruiting axes",
536
		"drupes",
537
		"Arillode",
538
		"seed",
539
		"Seeds",
540
		"Seedling",
541
		"flower tube",
542
		"nutlets",
543
		"pollen",
544
		"secondary xylem",
545
		"chromosome number",
546

    
547
		"figure",
548
		"fig",
549
		"figs",
550

    
551

    
552

    
553
	};
554

    
555
	public FeatureNode addFeataureNodesByStringList(String[] featureStringList, FeatureNode root, IInputTransformer transformer, ITermService termService){
556
		FeatureNode lastChild = null;
557
		try {
558
			for (String featureString : featureStringList){
559
				UUID featureUuid;
560
				featureUuid = transformer.getFeatureUuid(featureString);
561
				Feature feature = (Feature)termService.find(featureUuid);
562
				if (feature != null){
563
					FeatureNode child = FeatureNode.NewInstance(feature);
564
					root.addChild(child);
565
				}
566
			}
567

    
568
		} catch (UndefinedTransformerMethodException e) {
569
			logger.error("getFeatureUuid is not implemented in transformer. Features could not be added");
570
		}
571
		return lastChild;
572
	}
573

    
574

    
575

    
576
	/**
577
	 * @param args
578
	 */
579
	public static void main(String[] args) {
580
		FloreGabonActivator me = new FloreGabonActivator();
581
		me.doImport(cdmDestination);
582
	}
583
}
(13-13/13)