Revision 9d8ab33d
Added by Patrick Plitzner about 5 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/plantglossary/PlantGlossaryActivator.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.io.plantglossary; |
2 | 2 |
|
3 |
import java.io.FileInputStream; |
|
4 |
import java.io.FileNotFoundException; |
|
5 |
import java.io.InputStreamReader; |
|
3 |
import java.io.IOException; |
|
4 |
import java.net.URI; |
|
6 | 5 |
|
7 | 6 |
import org.apache.log4j.Logger; |
8 | 7 |
|
... | ... | |
17 | 16 |
@SuppressWarnings("unused") |
18 | 17 |
private static final Logger logger = Logger.getLogger(PlantGlossaryActivator.class); |
19 | 18 |
|
20 |
private void doImport(ICdmDataSource cdmDestination) throws FileNotFoundException{
|
|
19 |
private void doImport(ICdmDataSource cdmDestination) throws IOException{
|
|
21 | 20 |
|
22 | 21 |
/* |
23 | 22 |
* Source file: |
24 |
* https://github.com/biosemantics/glossaries/blob/925f2c1691ed00bf2b9a9cd7f83609cffae47145/Plant/0.11/Plant_glossary_term_category.csv
|
|
23 |
* extracted data from https://terms.tdwg.org
|
|
25 | 24 |
* |
26 |
* Cleaning data: |
|
27 |
* - remove all comments in csv file
|
|
28 |
* - fix "coetaneouser" by adding missing paramater for "remarks" -> "active"
|
|
25 |
* Cleaning data with OpenRefine:
|
|
26 |
* - generated URI column
|
|
27 |
* - parsed term description by crawling term html pages (description are not retrieved via web interface)
|
|
29 | 28 |
*/ |
30 |
FileInputStream inStream = new FileInputStream("/home/pplitzner/plantglossary.csv");
|
|
31 |
PlantGlossaryCsvImportConfigurator config = PlantGlossaryCsvImportConfigurator.NewInstance(new InputStreamReader(inStream), cdmDestination);
|
|
29 |
URI uri = URI.create("file:/home/pplitzner/projects/Additivity/plant_glossary_states.csv");
|
|
30 |
PlantGlossaryCsvImportConfigurator config = PlantGlossaryCsvImportConfigurator.NewInstance(uri, cdmDestination);
|
|
32 | 31 |
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK); |
33 | 32 |
config.setDbSchemaValidation(DbSchemaValidation.VALIDATE); |
34 | 33 |
|
... | ... | |
42 | 41 |
public static void main(String[] args) { |
43 | 42 |
PlantGlossaryActivator activator = new PlantGlossaryActivator(); |
44 | 43 |
try { |
45 |
ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "additivity", 3306, "root", null);
|
|
44 |
ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "empty", 3306, "root", null);
|
|
46 | 45 |
activator.doImport(dataSource); |
47 |
} catch (FileNotFoundException e) {
|
|
46 |
} catch (IOException e) {
|
|
48 | 47 |
e.printStackTrace(); |
49 | 48 |
} |
50 | 49 |
} |
Also available in: Unified diff
Import categories and states of FloraTerms (PlantGlossary)