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 org.json.JSONObject;
|
||||
import org.marc4j.MarcException;
|
||||
import org.marc4j.MarcPermissiveStreamReader;
|
||||
import org.marc4j.MarcWriter;
|
||||
import org.marc4j.MarcXmlWriter;
|
||||
@ -58,14 +59,11 @@ public class MarcImporter extends XmlImporter {
|
||||
|
||||
@Override
|
||||
public JSONObject createParserUIInitializationData(ImportingJob job, java.util.List<JSONObject> fileRecords, String format) {
|
||||
|
||||
if (fileRecords.size() > 0) {
|
||||
JSONObject firstFileRecord = fileRecords.get(0);
|
||||
File file = ImportingUtilities.getFile(job, firstFileRecord);
|
||||
File tempFile = new File(file.getAbsolutePath()+".xml");
|
||||
|
||||
JSONUtilities.safePut(firstFileRecord, "location",
|
||||
JSONUtilities.getString(firstFileRecord, "location", "")+".xml");
|
||||
|
||||
try {
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
@ -84,7 +82,14 @@ public class MarcImporter extends XmlImporter {
|
||||
try {
|
||||
outputStream.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) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
@ -533,6 +533,7 @@
|
||||
"specify-sep": "Please specify a separator.",
|
||||
"warning-no-length": "No field length is specified.",
|
||||
"warning-format": "The given field lengths are not properly formatted.",
|
||||
"check-format": "Please check the file format.",
|
||||
"split-into-col": "Split into several columns",
|
||||
"add-based-col": "Add column based on this column",
|
||||
"add-by-urls": "Add column by fetching URLs",
|
||||
|
@ -533,6 +533,7 @@
|
||||
"specify-sep": "Please specify a separator.",
|
||||
"warning-no-length": "No field length is specified.",
|
||||
"warning-format": "The given field lengths are not properly formatted.",
|
||||
"check-format": "Please check the file format.",
|
||||
"split-into-col": "Split into several columns",
|
||||
"add-based-col": "Add column based on this column",
|
||||
"add-by-urls": "Add column by fetching URLs",
|
||||
|
@ -533,6 +533,7 @@
|
||||
"specify-sep": "Por favor especifique un separador.",
|
||||
"warning-no-length": "No se especificó un valor de longitud.",
|
||||
"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",
|
||||
"add-based-col": "Agregar columna basada en esta columna",
|
||||
"add-by-urls": "Agregar columna accediendo a URLs",
|
||||
|
@ -533,6 +533,7 @@
|
||||
"specify-sep": "Merci d’indiquer un séparateur.",
|
||||
"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.",
|
||||
"check-format": "Merci de vérifier le format du fichier.",
|
||||
"split-into-col": "Diviser en plusieurs colonnes",
|
||||
"add-based-col": "Ajouter une colonne en fonction de cette colonne",
|
||||
"add-by-urls": "Ajouter une colonne en moissonant des URL",
|
||||
|
@ -533,6 +533,7 @@
|
||||
"specify-sep": "Per favore specifica il separatore.",
|
||||
"warning-no-length": "Nessuna lunghezza dei campi specificata.",
|
||||
"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",
|
||||
"add-based-col": "Aggiungi colonna basata su questa",
|
||||
"add-by-urls": "Aggiungi colonna recuperando da URLs",
|
||||
|
@ -534,6 +534,7 @@
|
||||
"specify-sep": "请制定一个分隔符.",
|
||||
"warning-no-length": "No field length is specified.",
|
||||
"warning-format": "The given field lengths are not properly formatted.",
|
||||
"check-format": "请检查文件格式.",
|
||||
"split-into-col": "分割此列",
|
||||
"add-based-col": "由此列派生新列",
|
||||
"add-by-urls": "添加远程数据为新列",
|
||||
|
@ -192,13 +192,17 @@ Refine.DefaultImportingController.prototype._ensureFormatParserUIHasInitializati
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
)
|
||||
.fail(function() {
|
||||
dismissBusy();
|
||||
alert($.i18n._('core-views')["check-format"]);
|
||||
});
|
||||
} else {
|
||||
onDone();
|
||||
}
|
||||
};
|
||||
|
||||
Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(options, callback) {
|
||||
Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(options, callback, finallyCallBack) {
|
||||
var self = this;
|
||||
$.post(
|
||||
"command/core/importing-controller?" + $.param({
|
||||
@ -213,12 +217,13 @@ Refine.DefaultImportingController.prototype.updateFormatAndOptions = function(op
|
||||
function(o) {
|
||||
if (o.status == 'error') {
|
||||
if (o.message) {
|
||||
alert(o.message);
|
||||
alert(o.message);
|
||||
} else {
|
||||
var messages = [];
|
||||
$.each(o.errors, function() { messages.push(this.message); });
|
||||
alert(messages.join('\n\n'));
|
||||
}
|
||||
finallyCallBack();
|
||||
} else {
|
||||
callback(o);
|
||||
}
|
||||
|
@ -217,5 +217,7 @@ Refine.ExcelParserUI.prototype._updatePreview = function() {
|
||||
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());
|
||||
});
|
||||
}
|
||||
}, function() {
|
||||
self._progressContainer.hide();
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user