1
|
package eu.etaxonomy.cdm.io.plantglossary;
|
2
|
|
3
|
import java.io.IOException;
|
4
|
import eu.etaxonomy.cdm.common.URI;
|
5
|
|
6
|
import org.apache.log4j.Logger;
|
7
|
|
8
|
import eu.etaxonomy.cdm.app.common.CdmDestinations;
|
9
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
10
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
11
|
import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
|
12
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK;
|
13
|
|
14
|
public class PlantGlossaryActivator {
|
15
|
@SuppressWarnings("unused")
|
16
|
private static final Logger logger = Logger.getLogger(PlantGlossaryActivator.class);
|
17
|
|
18
|
private void doImport(ICdmDataSource cdmDestination) throws IOException{
|
19
|
|
20
|
/*
|
21
|
* Source file:
|
22
|
* extracted data from https://terms.tdwg.org
|
23
|
*
|
24
|
* Cleaning data with OpenRefine:
|
25
|
* - generated URI column
|
26
|
* - parsed term description by crawling term html pages (description are not retrieved via web interface)
|
27
|
*/
|
28
|
URI uri = URI.create("file:/home/pplitzner/projects/Additivity/plant_glossary_states.csv");
|
29
|
PlantGlossaryCsvImportConfigurator config = PlantGlossaryCsvImportConfigurator.NewInstance(uri, cdmDestination);
|
30
|
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
|
31
|
config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
|
32
|
|
33
|
CdmDefaultImport<PlantGlossaryCsvImportConfigurator> myImport = new CdmDefaultImport<>();
|
34
|
|
35
|
System.out.println("Start import from ("+ cdmDestination.toString() + ") ...");
|
36
|
myImport.invoke(config);
|
37
|
System.out.println("End import from ("+ cdmDestination.toString() + ")...");
|
38
|
}
|
39
|
|
40
|
public static void main(String[] args) {
|
41
|
PlantGlossaryActivator activator = new PlantGlossaryActivator();
|
42
|
try {
|
43
|
// ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "empty", 3306, "root", null);
|
44
|
ICdmDataSource dataSource = CdmDestinations.cdm_additivity_ontology();
|
45
|
activator.doImport(dataSource);
|
46
|
} catch (IOException e) {
|
47
|
e.printStackTrace();
|
48
|
}
|
49
|
}
|
50
|
}
|