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.common.CdmUtils;
|
21
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
22
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
23
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
24
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
25
|
import eu.etaxonomy.cdm.io.identifier.IdentifierImportConfigurator;
|
26
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
27
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
28
|
|
29
|
/**
|
30
|
* @author a.mueller
|
31
|
* @since 18.10.2017
|
32
|
*
|
33
|
*/
|
34
|
public class CaryoSppIdentifierActivator {
|
35
|
|
36
|
@SuppressWarnings("unused")
|
37
|
private static final Logger logger = Logger.getLogger(CaryoSppIdentifierActivator.class);
|
38
|
|
39
|
//database validation status (create, update, validate ...)
|
40
|
static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.VALIDATE;
|
41
|
|
42
|
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_caryo_spp2();
|
43
|
static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_caryophyllales_spp();
|
44
|
|
45
|
private static final UUID idTypeUuid = DefinedTerm.uuidWfoNameIdentifier;
|
46
|
// private static final UUID idTypeUuid = DefinedTerm.uuidIpniNameIdentifier;
|
47
|
|
48
|
//check - import
|
49
|
static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
|
50
|
|
51
|
private void doImport(ICdmDataSource cdmDestination){
|
52
|
|
53
|
InputStreamReader source = getIdentifierStream();
|
54
|
IdentifierImportConfigurator config= IdentifierImportConfigurator.NewInstance(source, cdmDestination);
|
55
|
config.setDbSchemaValidation(dbSchemaValidation);
|
56
|
config.setIdentifierTypeUuid(idTypeUuid);
|
57
|
config.setCdmClass(TaxonName.class);
|
58
|
config.setCheck(check);
|
59
|
config.setIgnoreEmptyIdentifier(true);
|
60
|
|
61
|
CdmDefaultImport<IdentifierImportConfigurator> myImport = new CdmDefaultImport<>();
|
62
|
myImport.invoke(config);
|
63
|
|
64
|
}
|
65
|
|
66
|
private InputStreamReader getIdentifierStream() {
|
67
|
String filename = "Abgleich-CDM-WFO-GattungenUndTypen.csv";
|
68
|
|
69
|
// URI.create("file:////BGBM-PESIHPC/FloraMalesianaXml/fmvol14_final2.xml")
|
70
|
String path = "C://opt//data//Caryophyllales";
|
71
|
File file = new File(path + CdmUtils.getFolderSeperator() + filename);
|
72
|
if (!file.exists()){
|
73
|
System.exit(-1);
|
74
|
return null;
|
75
|
}
|
76
|
try {
|
77
|
InputStreamReader input = new FileReader(file);
|
78
|
return input;
|
79
|
} catch (IOException e) {
|
80
|
e.printStackTrace();
|
81
|
System.exit(-1);
|
82
|
return null;
|
83
|
}
|
84
|
}
|
85
|
|
86
|
/**
|
87
|
* @param args
|
88
|
*/
|
89
|
public static void main(String[] args) {
|
90
|
CaryoSppIdentifierActivator me = new CaryoSppIdentifierActivator();
|
91
|
me.doImport(cdmDestination);
|
92
|
System.exit(0);
|
93
|
}
|
94
|
}
|