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
|
}
|