1
|
/**
|
2
|
* Copyright (C) 2015 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.caryophyllales;
|
10
|
|
11
|
import java.io.File;
|
12
|
import java.io.FileReader;
|
13
|
import java.io.IOException;
|
14
|
import java.io.InputStreamReader;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import org.apache.log4j.Logger;
|
18
|
|
19
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
20
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
21
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
22
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
23
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
24
|
import eu.etaxonomy.cdm.io.identifier.IdentifierImportConfigurator;
|
25
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
26
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @since 18.10.2017
|
31
|
*
|
32
|
*/
|
33
|
public class PlumbaginaceaeIdentifierActivator {
|
34
|
|
35
|
@SuppressWarnings("unused")
|
36
|
private static final Logger logger = Logger.getLogger(PlumbaginaceaeIdentifierActivator.class);
|
37
|
|
38
|
//database validation status (create, update, validate ...)
|
39
|
static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
|
40
|
|
41
|
// static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
|
42
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
|
43
|
|
44
|
// private static final UUID idTypeUuid = DefinedTerm.uuidWfoNameIdentifier;
|
45
|
private static final UUID idTypeUuid = DefinedTerm.uuidIpniNameIdentifier;
|
46
|
|
47
|
//check - import
|
48
|
static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
49
|
|
50
|
private void doImport(ICdmDataSource cdmDestination){
|
51
|
|
52
|
InputStreamReader source = getPlumbaginaceaeIdentifier_IPNI();
|
53
|
IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
|
54
|
config.setDbSchemaValidation(dbSchemaValidation);
|
55
|
config.setIdentifierTypeUuid(idTypeUuid);
|
56
|
config.setCdmClass(TaxonName.class);
|
57
|
config.setCheck(check);
|
58
|
config.setIgnoreEmptyIdentifier(true);
|
59
|
|
60
|
CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
|
61
|
myImport.invoke(config);
|
62
|
|
63
|
}
|
64
|
|
65
|
private InputStreamReader getPlumbaginaceaeIdentifier() {
|
66
|
String filename = "WFONamesInCDM_Plumbaginaceae.csv";
|
67
|
|
68
|
// URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml")
|
69
|
String path = "C://opt//data//Caryophyllales";
|
70
|
File file = new File(path + File.separator + filename);
|
71
|
if (!file.exists()){
|
72
|
System.exit(-1);
|
73
|
return null;
|
74
|
}
|
75
|
try {
|
76
|
InputStreamReader input = new FileReader(file);
|
77
|
return input;
|
78
|
} catch (IOException e) {
|
79
|
e.printStackTrace();
|
80
|
System.exit(-1);
|
81
|
return null;
|
82
|
}
|
83
|
}
|
84
|
|
85
|
private InputStreamReader getPlumbaginaceaeIdentifier_IPNI() {
|
86
|
String filename = "WFONamesInCDM_Plumbaginaceae_IPNI.csv";
|
87
|
|
88
|
String path = "C://opt//data//Caryophyllales";
|
89
|
File file = new File(path + File.separator + filename);
|
90
|
if (!file.exists()){
|
91
|
System.exit(-1);
|
92
|
return null;
|
93
|
}
|
94
|
try {
|
95
|
InputStreamReader input = new FileReader(file);
|
96
|
return input;
|
97
|
} catch (IOException e) {
|
98
|
e.printStackTrace();
|
99
|
System.exit(-1);
|
100
|
return null;
|
101
|
}
|
102
|
}
|
103
|
|
104
|
|
105
|
/**
|
106
|
* @param args
|
107
|
*/
|
108
|
public static void main(String[] args) {
|
109
|
PlumbaginaceaeIdentifierActivator me = new PlumbaginaceaeIdentifierActivator();
|
110
|
me.doImport(cdmDestination);
|
111
|
System.exit(0);
|
112
|
}
|
113
|
}
|