patch for issue #708. fix few hanging UIs when importing file
This commit is contained in:
parent
fa7733e03e
commit
819e1ba5c6
@ -41,6 +41,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.marc4j.MarcException;
|
||||||
import org.marc4j.MarcPermissiveStreamReader;
|
import org.marc4j.MarcPermissiveStreamReader;
|
||||||
import org.marc4j.MarcWriter;
|
import org.marc4j.MarcWriter;
|
||||||
import org.marc4j.MarcXmlWriter;
|
import org.marc4j.MarcXmlWriter;
|
||||||
@ -58,14 +59,11 @@ public class MarcImporter extends XmlImporter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject createParserUIInitializationData(ImportingJob job, java.util.List<JSONObject> fileRecords, String format) {
|
public JSONObject createParserUIInitializationData(ImportingJob job, java.util.List<JSONObject> fileRecords, String format) {
|
||||||
|
|
||||||
if (fileRecords.size() > 0) {
|
if (fileRecords.size() > 0) {
|
||||||
JSONObject firstFileRecord = fileRecords.get(0);
|
JSONObject firstFileRecord = fileRecords.get(0);
|
||||||
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
||||||
File tempFile = new File(file.getAbsolutePath()+".xml");
|
File tempFile = new File(file.getAbsolutePath()+".xml");
|
||||||
|
|
||||||
JSONUtilities.safePut(firstFileRecord, "location",
|
|
||||||
JSONUtilities.getString(firstFileRecord, "location", "")+".xml");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = new FileInputStream(file);
|
InputStream inputStream = new FileInputStream(file);
|
||||||
@ -84,7 +82,14 @@ public class MarcImporter extends XmlImporter {
|
|||||||
try {
|
try {
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
file.delete(); // get rid of our original file
|
|
||||||
|
if (tempFile.length() == 0) // write failed. Most of time because of wrong Marc format
|
||||||
|
tempFile.delete();
|
||||||
|
else // only set json if write the temp file successfully:
|
||||||
|
JSONUtilities.safePut(firstFileRecord, "location",
|
||||||
|
JSONUtilities.getString(firstFileRecord, "location", "")+".xml");
|
||||||
|
|
||||||
|
// file.delete(); // get rid of our original file
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Just ignore - not much we can do anyway
|
// Just ignore - not much we can do anyway
|
||||||
}
|
}
|
||||||
@ -93,11 +98,8 @@ public class MarcImporter extends XmlImporter {
|
|||||||
logger.error("Failed to create temporary XML file from MARC file", e);
|
logger.error("Failed to create temporary XML file from MARC file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -533,6 +533,7 @@
|
|||||||
"specify-sep": "Please specify a separator.",
|
"specify-sep": "Please specify a separator.",
|
||||||
"warning-no-length": "No field length is specified.",
|
"warning-no-length": "No field length is specified.",
|
||||||
"warning-format": "The given field lengths are not properly formatted.",
|
"warning-format": "The given field lengths are not properly formatted.",
|
||||||
|
"check-format": "Please check the file format.",
|
||||||
"split-into-col": "Split into several columns",
|
"split-into-col": "Split into several columns",
|
||||||
"add-based-col": "Add column based on this column",
|
"add-based-col": "Add column based on this column",
|
||||||
"add-by-urls": "Add column by fetching URLs",
|
"add-by-urls": "Add column by fetching URLs",
|
||||||
|
@ -533,6 +533,7 @@
|
|||||||
"specify-sep": "Please specify a separator.",
|
"specify-sep": "Please specify a separator.",
|
||||||
"warning-no-length": "No field length is specified.",
|
"warning-no-length": "No field length is specified.",
|
||||||
"warning-format": "The given field lengths are not properly formatted.",
|
"warning-format": "The given field lengths are not properly formatted.",
|
||||||
|
"check-format": "Please check the file format.",
|
||||||
"split-into-col": "Split into several columns",
|
"split-into-col": "Split into several columns",
|
||||||
"add-based-col": "Add column based on this column",
|
"add-based-col": "Add column based on this column",
|
||||||
"add-by-urls": "Add column by fetching URLs",
|
"add-by-urls": "Add column by fetching URLs",
|
||||||
|
@ -533,6 +533,7 @@
|
|||||||
"specify-sep": "Por favor especifique un separador.",
|
"specify-sep": "Por favor especifique un separador.",
|
||||||
"warning-no-length": "No se especificó un valor de longitud.",
|
"warning-no-length": "No se especificó un valor de longitud.",
|
||||||
"warning-format": "Los valores de longitud no cumplen con el formato.",
|
"warning-format": "Los valores de longitud no cumplen con el formato.",
|
||||||
|
"check-format": "Favor verificar el formato de archivo.",
|
||||||
"split-into-col": "Dividir en varias columnas",
|
"split-into-col": "Dividir en varias columnas",
|
||||||
"add-based-col": "Agregar columna basada en esta columna",
|
"add-based-col": "Agregar columna basada en esta columna",
|
||||||
"add-by-urls": "Agregar columna accediendo a URLs",
|
"add-by-urls": "Agregar columna accediendo a URLs",
|
||||||
|
@ -533,6 +533,7 @@
|
|||||||
"specify-sep": "Merci d’indiquer un séparateur.",
|
"specify-sep": "Merci d’indiquer un séparateur.",
|
||||||
"warning-no-length": "Aucune longueur de champ n’a été indiquée.",
|
"warning-no-length": "Aucune longueur de champ n’a été indiquée.",
|
||||||
"warning-format": "Le paramètre des longueurs de champs n’est pas formaté correctement.",
|
"warning-format": "Le paramètre des longueurs de champs n’est pas formaté correctement.",
|
||||||
|
"check-format": "Merci de vérifier le format du fichier.",
|
||||||
"split-into-col": "Diviser en plusieurs colonnes",
|
"split-into-col": "Diviser en plusieurs colonnes",
|
||||||
"add-based-col": "Ajouter une colonne en fonction de cette colonne",
|
"add-based-col": "Ajouter une colonne en fonction de cette colonne",
|
||||||
"add-by-urls": "Ajouter une colonne en moissonant des URL",
|
"add-by-urls": "Ajouter une colonne en moissonant des URL",
|
||||||
|
@ -533,6 +533,7 @@
|
|||||||
"specify-sep": "Per favore specifica il separatore.",
|
"specify-sep": "Per favore specifica il separatore.",
|
||||||
"warning-no-length": "Nessuna lunghezza dei campi specificata.",
|
"warning-no-length": "Nessuna lunghezza dei campi specificata.",
|
||||||
"warning-format": "Le lunghezze dei campi non sono formattate correttamente.",
|
"warning-format": "Le lunghezze dei campi non sono formattate correttamente.",
|
||||||
|
"check-format": "Per favore controlla il formato del file.",
|
||||||
"split-into-col": "Dividi in diverse colonne",
|
"split-into-col": "Dividi in diverse colonne",
|
||||||
"add-based-col": "Aggiungi colonna basata su questa",
|
"add-based-col": "Aggiungi colonna basata su questa",
|
||||||
"add-by-urls": "Aggiungi colonna recuperando da URLs",
|
"add-by-urls": "Aggiungi colonna recuperando da URLs",
|
||||||
|
@ -534,6 +534,7 @@
|
|||||||
"specify-sep": "请制定一个分隔符.",
|
"specify-sep": "请制定一个分隔符.",
|
||||||
"warning-no-length": "No field length is specified.",
|
"warning-no-length": "No field length is specified.",
|
||||||
"warning-format": "The given field lengths are not properly formatted.",
|
"warning-format": "The given field lengths are not properly formatted.",
|
||||||
|
"check-format": "请检查文件格式.",
|
||||||
"split-into-col": "分割此列",
|
"split-into-col": "分割此列",
|
||||||
"add-based-col": "由此列派生新列",
|
"add-based-col": "由此列派生新列",
|
||||||
"add-by-urls": "添加远程数据为新列",
|
"add-by-urls": "添加远程数据为新列",
|
||||||
|
@ -192,13 +192,17 @@ Refine.DefaultImportingController.prototype._ensureFormatParserUIHasInitializati
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"json"
|
"json"
|
||||||
);
|
)
|
||||||
|
.fail(function() {
|
||||||
|
dismissBusy();
|
||||||
|
alert($.i18n._('core-views')["check-format"]);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
onDone();
|
onDone();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(options, callback) {
|
Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(options, callback, finallyCallBack) {
|
||||||
var self = this;
|
var self = this;
|
||||||
$.post(
|
$.post(
|
||||||
"command/core/importing-controller?" + $.param({
|
"command/core/importing-controller?" + $.param({
|
||||||
@ -219,6 +223,7 @@ Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(op
|
|||||||
$.each(o.errors, function() { messages.push(this.message); });
|
$.each(o.errors, function() { messages.push(this.message); });
|
||||||
alert(messages.join('\n\n'));
|
alert(messages.join('\n\n'));
|
||||||
}
|
}
|
||||||
|
finallyCallBack();
|
||||||
} else {
|
} else {
|
||||||
callback(o);
|
callback(o);
|
||||||
}
|
}
|
||||||
|
@ -217,5 +217,7 @@ Refine.ExcelParserUI.prototype._updatePreview = function() {
|
|||||||
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
|
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}, function() {
|
||||||
|
self._progressContainer.hide();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -120,5 +120,7 @@ Refine.RdfTriplesParserUI.prototype._updatePreview = function() {
|
|||||||
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
|
new Refine.PreviewTable(projectData, self._dataContainer.unbind().empty());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}, function() {
|
||||||
|
self._progressContainer.hide();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user