From: Patrick Plitzner
Date: Fri, 7 Dec 2018 14:01:31 +0000 (+0100)
Subject: Fix db connection
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib-apps.git/commitdiff_plain/43c3f7df27b6474f5bf327149a29c8bb250a803e?ds=inline
Fix db connection
---
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/plantglossary/PlantGlossaryActivator.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/plantglossary/PlantGlossaryActivator.java
index 2dca5c4a..e8795834 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/plantglossary/PlantGlossaryActivator.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/plantglossary/PlantGlossaryActivator.java
@@ -7,7 +7,6 @@ import java.io.InputStreamReader;
import org.apache.log4j.Logger;
import eu.etaxonomy.cdm.app.common.CdmDestinations;
-import eu.etaxonomy.cdm.app.util.TestDatabase;
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
import eu.etaxonomy.cdm.database.DbSchemaValidation;
import eu.etaxonomy.cdm.database.ICdmDataSource;
@@ -20,11 +19,20 @@ public class PlantGlossaryActivator {
private void doImport(ICdmDataSource cdmDestination) throws FileNotFoundException{
+ /*
+ * Source file:
+ * https://github.com/biosemantics/glossaries/blob/925f2c1691ed00bf2b9a9cd7f83609cffae47145/Plant/0.11/Plant_glossary_term_category.csv
+ *
+ * Cleaning data:
+ * - remove all comments in csv file
+ * - fix "coetaneouser" by adding missing paramater for "remarks" -> "active"
+ */
FileInputStream inStream = new FileInputStream("/home/pplitzner/plantglossary.csv");
PlantGlossaryCsvImportConfigurator config = PlantGlossaryCsvImportConfigurator.NewInstance(new InputStreamReader(inStream), cdmDestination);
config.setCheck(CHECK.IMPORT_WITHOUT_CHECK);
+ config.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
- CdmDefaultImport myImport = new CdmDefaultImport();
+ CdmDefaultImport myImport = new CdmDefaultImport<>();
System.out.println("Start import from ("+ cdmDestination.toString() + ") ...");
myImport.invoke(config);
@@ -32,11 +40,10 @@ public class PlantGlossaryActivator {
}
public static void main(String[] args) {
- PlantGlossaryActivator me = new PlantGlossaryActivator();
+ PlantGlossaryActivator activator = new PlantGlossaryActivator();
try {
- ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "additivity", 3306, "root", "root");
- TestDatabase.initDb(dataSource, DbSchemaValidation.VALIDATE, true);
- me.doImport(dataSource);
+ ICdmDataSource dataSource = CdmDestinations.makeDestination(DatabaseTypeEnum.MySQL, "127.0.0.1", "empty", 3306, "root", null);
+ activator.doImport(dataSource);
} catch (FileNotFoundException e) {
e.printStackTrace();
}