1
|
package eu.etaxonomy.cdm.io.plantglossary.kew;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import java.net.URI;
|
5
|
|
6
|
import org.apache.log4j.Logger;
|
7
|
|
8
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
9
|
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
|
10
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
11
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
12
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
13
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
14
|
|
15
|
/**
|
16
|
*
|
17
|
* @author pplitzner
|
18
|
* @since Jan 25, 2019
|
19
|
*
|
20
|
*/
|
21
|
public class KewPlantGlossaryActivator {
|
22
|
@SuppressWarnings("unused")
|
23
|
private static final Logger logger = Logger.getLogger(KewPlantGlossaryActivator.class);
|
24
|
|
25
|
private void doImport(ICdmDataSource cdmDestination) throws IOException{
|
26
|
|
27
|
/*
|
28
|
* Source file:
|
29
|
* extracted data from Kew Plant Glossary
|
30
|
*
|
31
|
*/
|
32
|
URI uri = URI.create("file:/home/pplitzner/projects/Additivity/KEW_Plant_Glossary.csv");
|
33
|
KewPlantGlossaryCsvImportConfigurator config = KewPlantGlossaryCsvImportConfigurator.NewInstance(uri, cdmDestination);
|
34
|
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
35
|
config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
|
36
|
|
37
|
CdmDefaultImport<KewPlantGlossaryCsvImportConfigurator> myImport = new CdmDefaultImport<>();
|
38
|
|
39
|
System.out.println("Start import from ("+ cdmDestination.toString() + ") ...");
|
40
|
myImport.invoke(config);
|
41
|
System.out.println("End import from ("+ cdmDestination.toString() + ")...");
|
42
|
}
|
43
|
|
44
|
public static void main(String[] args) {
|
45
|
KewPlantGlossaryActivator activator = new KewPlantGlossaryActivator();
|
46
|
try {
|
47
|
ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "empty", 3306, "root", null);
|
48
|
// ICdmDataSource dataSource = CdmDestinations.cdm_additivity_ontology();
|
49
|
activator.doImport(dataSource);
|
50
|
} catch (IOException e) {
|
51
|
e.printStackTrace();
|
52
|
}
|
53
|
}
|
54
|
}
|