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
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
17
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
18
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
19
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
20
|
import eu.etaxonomy.cdm.io.common.events.LoggingIoObserver;
|
21
|
import eu.etaxonomy.cdm.io.dwca.in.DwcaDataImportConfiguratorBase.DatasetUse;
|
22
|
import eu.etaxonomy.cdm.io.dwca.in.DwcaImportConfigurator;
|
23
|
import eu.etaxonomy.cdm.io.dwca.in.IImportMapping.MappingType;
|
24
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @created 03.04.2012
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class CentralAfricaFernsFdacImportActivator {
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(CentralAfricaFernsFdacImportActivator.class);
|
36
|
|
37
|
//database validation status (create, update, validate ...)
|
38
|
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE;
|
39
|
static final URI source = dwca_ferns();
|
40
|
|
41
|
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
43
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_fdac();
|
44
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_preview();
|
45
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_flora_central_africa_production();
|
46
|
|
47
|
static final String sourceReferenceTitle = "Ferns import(Dwc-A)";
|
48
|
static boolean useSourceReferenceAsSec = true;
|
49
|
|
50
|
//default nom code is ICZN as it allows adding publication year
|
51
|
static final NomenclaturalCode defaultNomCode = NomenclaturalCode.ICNAFP;
|
52
|
|
53
|
|
54
|
//check - import
|
55
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
56
|
|
57
|
//config
|
58
|
static DatasetUse datasetUse = DatasetUse.CLASSIFICATION;
|
59
|
|
60
|
//validate
|
61
|
static boolean validateRankConsistency = true;
|
62
|
|
63
|
|
64
|
//taxa
|
65
|
static final boolean doTaxa = true;
|
66
|
|
67
|
|
68
|
|
69
|
static final MappingType mappingType = MappingType.InMemoryMapping;
|
70
|
|
71
|
private void doImport(ICdmDataSource cdmDestination){
|
72
|
|
73
|
//make Source
|
74
|
DwcaImportConfigurator config= DwcaImportConfigurator.NewInstance(source, cdmDestination);
|
75
|
config.addObserver(new LoggingIoObserver());
|
76
|
config.setCheck(check);
|
77
|
config.setDbSchemaValidation(hbm2dll);
|
78
|
config.setMappingType(mappingType);
|
79
|
config.setValidateRankConsistency(validateRankConsistency);
|
80
|
config.setNomenclaturalCode(defaultNomCode);
|
81
|
config.setSourceReferenceTitle(sourceReferenceTitle);
|
82
|
config.setUseSourceReferenceAsSec(useSourceReferenceAsSec);
|
83
|
|
84
|
CdmDefaultImport myImport = new CdmDefaultImport();
|
85
|
|
86
|
|
87
|
//...
|
88
|
if (true){
|
89
|
System.out.println("Start import from ("+ source.toString() + ") ...");
|
90
|
config.setSourceReference(getSourceReference(config.getSourceReferenceTitle()));
|
91
|
myImport.invoke(config);
|
92
|
System.out.println("End import from ("+ source.toString() + ")...");
|
93
|
}
|
94
|
|
95
|
|
96
|
}
|
97
|
|
98
|
private Reference<?> getSourceReference(String string) {
|
99
|
Reference<?> result = ReferenceFactory.newGeneric();
|
100
|
result.setTitleCache(string);
|
101
|
return result;
|
102
|
}
|
103
|
|
104
|
|
105
|
//Scratchpads test
|
106
|
public static URI dwca_ferns() {
|
107
|
URI sourceUrl = URI.create("file:////PESIIMPORT3/fdac/dwca/ferns.zip");
|
108
|
return sourceUrl;
|
109
|
}
|
110
|
|
111
|
|
112
|
/**
|
113
|
* @param args
|
114
|
*/
|
115
|
public static void main(String[] args) {
|
116
|
CentralAfricaFernsFdacImportActivator me = new CentralAfricaFernsFdacImportActivator();
|
117
|
me.doImport(cdmDestination);
|
118
|
}
|
119
|
|
120
|
}
|