1
|
/**
|
2
|
* Copyright (C) 2016 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
|
package eu.etaxonomy.cdm.app.bogota;
|
10
|
|
11
|
import java.net.URI;
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
|
16
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
17
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
18
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
19
|
import eu.etaxonomy.cdm.io.bogota.BogotaSpecimenImportConfigurator;
|
20
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
21
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
22
|
import eu.etaxonomy.cdm.io.common.ImportResult;
|
23
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
24
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
26
|
|
27
|
/**
|
28
|
* Activator for import of Bogota Checklist
|
29
|
*
|
30
|
* @author a.mueller
|
31
|
* @date 21.04.2017
|
32
|
*
|
33
|
*/
|
34
|
public class BogotaSpecimenActivator {
|
35
|
private static final Logger logger = Logger.getLogger(BogotaSpecimenActivator.class);
|
36
|
|
37
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
38
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_bogota();
|
39
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_bogota_production();
|
40
|
|
41
|
// int minRow = 6;
|
42
|
// int maxRow = 15; //minRow + 11999;
|
43
|
|
44
|
int minRow = 180;
|
45
|
int maxRow = 191; //minRow + 11999;
|
46
|
|
47
|
boolean dedupRefs = false;
|
48
|
boolean dedupAuthors = false;
|
49
|
|
50
|
//check - import
|
51
|
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
52
|
|
53
|
protected void doImport(ICdmDataSource cdmDestination){
|
54
|
|
55
|
URI source = bogotaSpecimens();
|
56
|
|
57
|
//make Source
|
58
|
BogotaSpecimenImportConfigurator config= BogotaSpecimenImportConfigurator.NewInstance(source, cdmDestination);
|
59
|
config.setNomenclaturalCode(NomenclaturalCode.ICNAFP);
|
60
|
config.setCheck(check);
|
61
|
config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
|
62
|
|
63
|
config.setMinLineNumber(minRow);
|
64
|
config.setMaxLineNumber(maxRow);
|
65
|
config.setDeduplicateReferences(dedupRefs);
|
66
|
config.setDeduplicateAuthors(dedupAuthors);
|
67
|
|
68
|
config.setSource(source);
|
69
|
String fileName = source.toString();
|
70
|
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 );
|
71
|
|
72
|
String message = "Start import from ("+ fileName + ") ...";
|
73
|
System.out.println(message);
|
74
|
logger.warn(message);
|
75
|
|
76
|
config.setSourceReference(getSourceReference());
|
77
|
|
78
|
CdmDefaultImport<BogotaSpecimenImportConfigurator> myImport = new CdmDefaultImport<>();
|
79
|
|
80
|
ImportResult result = myImport.invoke(config);
|
81
|
System.out.println(result.createReport());
|
82
|
|
83
|
System.out.println("End import from (" + source.toString() + ")...");
|
84
|
|
85
|
}
|
86
|
|
87
|
|
88
|
//bogotaChecklist
|
89
|
public static URI bogotaSpecimens() {
|
90
|
return URI.create("file:////BGBM-PESIHPC/Bogota/Flora_de_Bogota_Dataset_20170901_GB20171011_14607-entries-to-import_GB_20171016.xlsx");
|
91
|
}
|
92
|
|
93
|
|
94
|
private Reference getSourceReference() {
|
95
|
Reference result = ReferenceFactory.newGeneric();
|
96
|
result.setTitle("Flora_de_Bogota_Dataset_20170901_GB20171011_14607-entries-to-import_GB_20171016.xlsx");
|
97
|
result.setUuid(UUID.fromString("05e8c346-4809-4323-a484-822c92ad033d"));
|
98
|
return result;
|
99
|
}
|
100
|
|
101
|
|
102
|
/**
|
103
|
* @param args
|
104
|
*/
|
105
|
public static void main(String[] args) {
|
106
|
BogotaSpecimenActivator me = new BogotaSpecimenActivator();
|
107
|
me.doImport(cdmDestination);
|
108
|
System.exit(0);
|
109
|
}
|
110
|
}
|