diff --git a/src/main/java/org/aksw/gerbil/transfer/FileMeta.java b/src/main/java/org/aksw/gerbil/transfer/FileMeta.java index 4a5b46061..1f274e601 100644 --- a/src/main/java/org/aksw/gerbil/transfer/FileMeta.java +++ b/src/main/java/org/aksw/gerbil/transfer/FileMeta.java @@ -20,7 +20,7 @@ /** * Container file to upload files with blueimp/jQuery plugin - * + * * @author didier * */ @@ -36,6 +36,8 @@ public class FileMeta { private String fileType; private byte[] bytes; + private String description; + public String getName() { return name; } @@ -108,4 +110,12 @@ public void setBytes(byte[] bytes) { this.bytes = bytes; } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } diff --git a/src/main/java/org/aksw/gerbil/web/FileUploadController.java b/src/main/java/org/aksw/gerbil/web/FileUploadController.java index 8a83971bd..8423a46b7 100644 --- a/src/main/java/org/aksw/gerbil/web/FileUploadController.java +++ b/src/main/java/org/aksw/gerbil/web/FileUploadController.java @@ -25,8 +25,11 @@ import javax.servlet.http.HttpServletResponse; +import org.aksw.gerbil.dataset.impl.nif.FileBasedNIFDataset; +import org.aksw.gerbil.exceptions.GerbilException; import org.aksw.gerbil.transfer.FileMeta; import org.aksw.gerbil.transfer.UploadFileContainer; +import org.apache.jena.riot.Lang; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -92,9 +95,19 @@ public ModelAndView upload() { } files.add(fileContainer); } - + boolean isErroneousFile = false; + for(FileMeta file:files){ + try{ + FileBasedNIFDataset dataset = new FileBasedNIFDataset(path+file.getName(), file.getName(), Lang.TTL); + dataset.init(); + file.setDescription("Found "+dataset.getInstances().size()+" Instances"); + }catch(Exception e){ + isErroneousFile =true; + file.setError(e.getMessage()); + } + } UploadFileContainer uploadFileContainer = new UploadFileContainer(files); - return new ResponseEntity(uploadFileContainer, HttpStatus.OK); + return new ResponseEntity(uploadFileContainer, isErroneousFile?HttpStatus.BAD_REQUEST:HttpStatus.OK); } private void createFolderIfNotExists() { diff --git a/src/main/webapp/WEB-INF/views/config.jsp b/src/main/webapp/WEB-INF/views/config.jsp index 32f64f408..897c0ad04 100644 --- a/src/main/webapp/WEB-INF/views/config.jsp +++ b/src/main/webapp/WEB-INF/views/config.jsp @@ -625,7 +625,9 @@ + name + "(" + file.name - + ")"); + + ") : " + + file.description + + ""); var listItems = $('#datasetList > li > span'); for (var i = 0; i < listItems.length; i++) { listItems[i].onclick = function() { @@ -646,9 +648,27 @@ $('#progress .progress-bar').css('width', progress + '%'); }, - processfail : function(e, data) { - alert(data.files[data.index].name + "\n" - + data.files[data.index].error); + fail : function(e, data) { + data = data.response().jqXHR.responseJSON; + var name = $('#nameDataset').val(); + $ + .each( + data.files, + function(index, file) { + $('#datasetList') + .append( + "
  •  " + + name + + "(" + + file.name + + ") :" + + file.error + + "
  • "); + $('#nameDataset').val( + ''); + $('#URIDataset') + .val(''); + }); } }).prop('disabled', !$.support.fileInput).parent() .addClass($.support.fileInput ? undefined : 'disabled');