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
|
|
16
|
import org.apache.logging.log4j.LogManager;
|
17
|
import org.apache.logging.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.IdentifierType;
|
27
|
|
28
|
/**
|
29
|
* @author a.mueller
|
30
|
* @since 25.03.2017
|
31
|
*
|
32
|
*/
|
33
|
public class NepenthesIdentifierActivator {
|
34
|
|
35
|
@SuppressWarnings("unused")
|
36
|
private static final Logger logger = LogManager.getLogger();
|
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_nepenthaceae();
|
43
|
|
44
|
//check - import
|
45
|
static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
46
|
|
47
|
private void doImport(ICdmDataSource cdmDestination){
|
48
|
|
49
|
InputStreamReader source = getNepenthesIdentifier();
|
50
|
IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
|
51
|
config.setDbSchemaValidation(dbSchemaValidation);
|
52
|
config.setIdentifierTypeUuid(IdentifierType.uuidWfoNameIdentifier);
|
53
|
config.setCdmClass(TaxonName.class);
|
54
|
config.setCheck(check);
|
55
|
|
56
|
CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
|
57
|
myImport.invoke(config);
|
58
|
|
59
|
}
|
60
|
|
61
|
private InputStreamReader getNepenthesIdentifier() {
|
62
|
String filename = "WfoIds.csv";
|
63
|
|
64
|
// URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml")
|
65
|
String path = "C://opt//data//Caryophyllales";
|
66
|
File file = new File(path + File.separator + filename);
|
67
|
if (!file.exists()){
|
68
|
System.exit(-1);
|
69
|
return null;
|
70
|
}
|
71
|
try {
|
72
|
InputStreamReader input = new FileReader(file);
|
73
|
return input;
|
74
|
} catch (IOException e) {
|
75
|
e.printStackTrace();
|
76
|
System.exit(-1);
|
77
|
return null;
|
78
|
}
|
79
|
}
|
80
|
|
81
|
|
82
|
/**
|
83
|
* @param args
|
84
|
*/
|
85
|
public static void main(String[] args) {
|
86
|
NepenthesIdentifierActivator me = new NepenthesIdentifierActivator();
|
87
|
me.doImport(cdmDestination);
|
88
|
System.exit(0);
|
89
|
}
|
90
|
}
|