v0.2.50..v0.2.51 changeset ImportCommand.java
Garret Voltz edited this page Jan 15, 2020
·
1 revision
diff --git a/hoot-services/src/main/java/hoot/services/controllers/ingest/ImportCommand.java b/hoot-services/src/main/java/hoot/services/controllers/ingest/ImportCommand.java
index 108a14b..84d74dd 100644
--- a/hoot-services/src/main/java/hoot/services/controllers/ingest/ImportCommand.java
+++ b/hoot-services/src/main/java/hoot/services/controllers/ingest/ImportCommand.java
@@ -29,12 +29,6 @@ package hoot.services.controllers.ingest;
import static hoot.services.HootProperties.HOME_FOLDER;
import static hoot.services.HootProperties.HOOTAPI_DB_URL;
import static hoot.services.HootProperties.SCRIPT_FOLDER;
-import static hoot.services.controllers.ingest.UploadClassification.FGDB;
-import static hoot.services.controllers.ingest.UploadClassification.GEOJSON;
-import static hoot.services.controllers.ingest.UploadClassification.GEONAMES;
-import static hoot.services.controllers.ingest.UploadClassification.GPKG;
-import static hoot.services.controllers.ingest.UploadClassification.OSM;
-import static hoot.services.controllers.ingest.UploadClassification.SHP;
import static hoot.services.controllers.ingest.UploadClassification.ZIP;
import java.io.File;
@@ -66,15 +60,6 @@ class ImportCommand extends ExternalCommand {
super(jobId);
this.workDir = workDir;
- // TODO: Reconcile this logic with the UI. Passing of translation script's name appears to be inconsistent!
- String translationPath;
- if (translation.startsWith("translations/")) {
- translationPath = new File(HOME_FOLDER, translation).getAbsolutePath();
- }
- else {
- translationPath = new File(new File(SCRIPT_FOLDER), translation).getAbsolutePath();
- }
-
List<String> inputs = filesToImport.stream().map(File::getAbsolutePath).collect(Collectors.toList());
List<String> options = new LinkedList<>();
@@ -83,13 +68,15 @@ class ImportCommand extends ExternalCommand {
options.add("job.id=" + jobId);
options.add("api.db.email=" + user.getEmail());
- //if (((classification == OSM) && !isNoneTranslation) || (classification == GEONAMES)) {
- //options.add("convert.ops=hoot::SchemaTranslationVisitor");
- //options.add("schema.translation.script=" + translationPath);
- //}
-
- if (!isNoneTranslation && (classification == SHP) || (classification == FGDB) || (classification == ZIP))
- {
+ //Built-in translations are passed with the translations/ path in the name
+ String translationPath;
+ if (translation.startsWith("translations/")) {
+ translationPath = new File(HOME_FOLDER, translation).getAbsolutePath();
+ } else { //user submitted translations are in the customscript path
+ translationPath = new File(new File(SCRIPT_FOLDER), translation).getAbsolutePath();
+ }
+ //A boolean gets passed if we don't mean to translate, but the UI has a dummy translation name of None
+ if (!isNoneTranslation) {
options.add("schema.translation.script=" + translationPath);
}
@@ -117,21 +104,14 @@ class ImportCommand extends ExternalCommand {
substitutionMap.put("INPUT_NAME", inputName);
substitutionMap.put("INPUTS", inputs);
- String hootConvertCommand = "hoot convert --${DEBUG_LEVEL} -C Import.conf ${HOOT_OPTIONS} ${INPUTS} ${INPUT_NAME}";
-
- String command = null;
- if ((classification == SHP) || (classification == FGDB) || (classification == ZIP)) {
- if ((classification == ZIP) && !zipsToImport.isEmpty()) {
- //Reading a GDAL dataset in a .gz file or a .zip archive
- inputs = zipsToImport.stream().map(zip -> "/vsizip/" + zip.getAbsolutePath()).collect(Collectors.toList());
- substitutionMap.put("INPUTS", inputs);
- }
- command = hootConvertCommand;
- }
- else if ((classification == OSM) || (classification == GEOJSON) || (classification == GEONAMES) || (classification == GPKG)) {
- command = hootConvertCommand;
+ if ((classification == ZIP) && !zipsToImport.isEmpty()) {
+ //Reading a GDAL dataset in a .gz file or a .zip archive
+ inputs = zipsToImport.stream().map(zip -> "/vsizip/" + zip.getAbsolutePath()).collect(Collectors.toList());
+ substitutionMap.put("INPUTS", inputs);
}
+ String command = "hoot convert --${DEBUG_LEVEL} -C Import.conf ${HOOT_OPTIONS} ${INPUTS} ${INPUT_NAME}";
+
super.configureCommand(command, substitutionMap, caller);
}