Commit 97b0fbc4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

client dialog for publication supports sorting and searching

parent 2e41c14e
......@@ -10,6 +10,7 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.apache.commons.lang3.SerializationException;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Document;
......@@ -116,7 +117,12 @@ public class PubmedParser extends CachableInterface implements IExternalService
*/
public Article getPubmedArticleById(Integer id) throws PubmedSearchException {
String queryString = "pubmed: " + id;
Article result = articleSerializer.xmlToObject(getCacheNode(queryString));
Article result = null;
try {
result = articleSerializer.xmlToObject(getCacheNode(queryString));
} catch (SerializationException e) {
logger.warn("Problem with deserialization of the string: " + queryString);
}
if (result != null && result.getTitle() != null) {
return result;
} else {
......
......@@ -377,4 +377,8 @@ table.mapInfoBoxResultsTable, table.mapInfoBoxResultsTable th, table.mapInfoBoxR
.minerva-export-dual-listbox-container {
padding: 10px;
float: left;
}
table.minerva-publication-table td {
padding: 0px;
}
\ No newline at end of file
......@@ -1248,6 +1248,9 @@ ServerConnector.getPublications = function(params) {
var filterParams = {
start : params.start,
length : params.length,
sortColumn : params.sortColumn,
sortOrder : params.sortOrder,
search : params.search,
};
return self.getProjectId(params.projectId).then(function(result) {
queryParams.projectId = result;
......
......@@ -17,10 +17,11 @@ function PublicationListDialog(params) {
var self = this;
self.createPublicationListDialogGui();
$(self.getElement()).dialog({
title : "Publication list",
autoOpen : false,
resizable : false,
width : window.innerWidth / 2,
height : window.innerHeight / 2,
width : Math.max(window.innerWidth / 2, window.innerWidth - 100),
height : Math.max(window.innerHeight / 2, window.innerHeight - 100),
});
}
......@@ -44,6 +45,7 @@ PublicationListDialog.prototype.createPublicationListDialogGui = function() {
});
var tableElement = Functions.createElement({
type : "table",
className : "minerva-publication-table",
style : "width: 100%",
});
......@@ -56,9 +58,13 @@ PublicationListDialog.prototype.createPublicationListDialogGui = function() {
PublicationListDialog.prototype._dataTableAjaxCall = function(data, callback) {
var self = this;
logger.info(data);
return ServerConnector.getPublications({
start : data.start,
length : data.length,
sortColumn : self.getColumnsDefinition()[data.order[0].column].name,
sortOrder : data.order[0].dir,
search : data.search.value,
})
.then(
function(publicationList) {
......@@ -114,11 +120,12 @@ PublicationListDialog.prototype.show = function() {
return new Promise(function(resolve) {
$(self.tableElement).dataTable({
serverSide : true,
ordering : false,
searching : false,
ordering : true,
searching : true,
ajax : function(data, callback, settings) {
resolve(self._dataTableAjaxCall(data, callback, settings));
},
columns : self.getColumnsDefinition(),
});
});
} else {
......@@ -127,6 +134,22 @@ PublicationListDialog.prototype.show = function() {
};
PublicationListDialog.prototype.getColumnsDefinition = function() {
return [ {
name : "pubmedId"
}, {
name : "authors"
}, {
name : "journal"
}, {
name : "year"
}, {
orderable : false,
searchable : false,
name : "elemnts"
} ]
};
PublicationListDialog.prototype.destroy = function() {
$(this.getElement()).dialog("destroy");
};
......
......@@ -36,7 +36,9 @@ describe('PublicationListDialog', function() {
});
return dialog._dataTableAjaxCall({
start : 0,
length : 10
length : 10,
order: [ { column: 0, dir: 'asc' } ],
search: { value: '', regex: false }
}, function(){
callbackCalled = true;
});
......
{"totalSize":1,"data":[{"elements":[{"modelId":15781,"id":153508,"type":"REACTION"}],"publication":{"resource":"123","link":"http://www.ncbi.nlm.nih.gov/pubmed/123","id":860355,"type":"PUBMED","article":{"title":"The importance of an innervated and intact antrum and pylorus in preventing postoperative duodenogastric reflux and gastritis.","authors":["Keighley MR"," Asquith P"," Edwards JA"," Alexander-Williams J."],"journal":"The British journal of surgery","year":1975,"link":"http://www.ncbi.nlm.nih.gov/pubmed/123","id":"123","citationCount":12,"stringAuthors":"Keighley MR, Asquith P, Edwards JA, Alexander-Williams J."}}}],"start":0,"length":1}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment