From ef0db47f58a121e8d1b97ba8ff5e13c732a64148 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 7 May 2019 12:24:36 +0000 Subject: [PATCH] Feature #16621 Validation portlet: users should be warned if run analysis is performed on non up-to-data anonymised data git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/branches/portlets/user/PerformFISH-Apps/1.3@179299 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../farmrepository/view_farm_repository.jsp | 97 +++++++++++-------- 1 file changed, 58 insertions(+), 39 deletions(-) diff --git a/src/main/webapp/html/farmrepository/view_farm_repository.jsp b/src/main/webapp/html/farmrepository/view_farm_repository.jsp index 80186e1..c9fb8df 100644 --- a/src/main/webapp/html/farmrepository/view_farm_repository.jsp +++ b/src/main/webapp/html/farmrepository/view_farm_repository.jsp @@ -30,35 +30,40 @@ function closeAndReload() { } $(function () { - checkBatchesThreshold = function (theButton, endpoint, farmId, batchType, farmIdEncoded, batchTypeEncoded) { - $(theButton).html(' checking batches, please wait ...'); - $.ajax({ - url : endpoint, - type : 'POST', - datatype : 'json', - data : { - farmId : farmId, - userId : Liferay.ThemeDisplay.getUserId(), - batchType : batchType, - groupId : Liferay.ThemeDisplay.getScopeGroupId() - }, - success : function(data) { - var content = JSON.parse(data); - if (content.success == "OK") { - location.href='${AnalyticalToolkitPortletEndpoint}?${batchTypeParamEncoded}='+batchTypeEncoded+'&${farmIdParamEncoded}='+farmIdEncoded; - } - else { - $(theButton).html('' + content.message); - $(theButton).addClass("btn-warning"); - $(theButton).unbind('click'); - $(theButton).click(function(){ - alert('You have not published and anonymsed enough batches for this farm'); - }); - } - $('#publishAndAnonymise-Button').html('Anonymise and Publish'); - } - }); - + checkBatchesThreshold = function (theButton, endpoint, farmId, batchType, farmIdEncoded, batchTypeEncoded, lastValidatedTime, lastPublishedTime) { + var cont = true; + if (lastValidatedTime > lastPublishedTime) { + cont = window.confirm('Please note that a more recent validated form exists for this file, if you continue the analysis will use the last anonymised and published form') + } + if (cont) { + $(theButton).html(' checking batches, please wait ...'); + $.ajax({ + url : endpoint, + type : 'POST', + datatype : 'json', + data : { + farmId : farmId, + userId : Liferay.ThemeDisplay.getUserId(), + batchType : batchType, + groupId : Liferay.ThemeDisplay.getScopeGroupId() + }, + success : function(data) { + var content = JSON.parse(data); + if (content.success == "OK") { + location.href='${AnalyticalToolkitPortletEndpoint}?${batchTypeParamEncoded}='+batchTypeEncoded+'&${farmIdParamEncoded}='+farmIdEncoded; + } + else { + $(theButton).html('' + content.message); + $(theButton).addClass("btn-warning"); + $(theButton).unbind('click'); + $(theButton).click(function(){ + alert('You have not published and anonymsed enough batches for this farm'); + }); + } + $('#publishAndAnonymise-Button').html('Anonymise and Publish'); + } + }); + } }; }); @@ -110,9 +115,18 @@ $(function () { SubmittedForm submittedForm = (SubmittedForm) pageContext.getAttribute("form"); ExternalFile item = submittedForm.getFormFile(); String iconHTML = IconsManager.getMDIconTextualName(item.getName()).getHtml(); - String fullName = Utils.getUserByUsername(item.getLastUpdatedBy()).getFullname(); + String fullName = ""; + if (item.getVersionHistory() != null && item.getVersionHistory().size() > 0) { + WorkspaceVersion v = item.getVersionHistory().get(item.getVersionHistory().size()-1); + fullName = Utils.getUserByUsername(v.getUser()).getFullname(); + } else { + fullName = Utils.getUserByUsername(item.getLastUpdatedBy()).getFullname(); + } String userProfileLink = Utils.getUserProfileLink(item.getLastUpdatedBy()); - Date lastUpdated = new Date(item.getLastModificationTime().getTimeInMillis()); + long timeInMillis = item.getLastModificationTime().getTimeInMillis(); + Date lastUpdated = new Date(timeInMillis); + //needed to check if publishing occurs after the validation + pageContext.setAttribute("lastValidatedTime", timeInMillis); pageContext.setAttribute("lastUpdated", lastUpdated); String fullNamePublisher = SubmittedForm.NOT_YET_PUBLISHER; String userProfileLinkPublisher = ""; @@ -126,7 +140,9 @@ $(function () { pageContext.setAttribute("fullNamePublisher", fullNamePublisher); userProfileLinkPublisher = Utils.getUserProfileLink(submittedForm.getSubmitterIdentity()); if (submittedForm.getEndTimeinMillis() != PublishAnonymisedJob.EPOCH_TIME_JOB_NOTFINISHED*1000) { - Date jobEndTime = new Date(submittedForm.getEndTimeinMillis()); + long timeInMillis2 = submittedForm.getEndTimeinMillis(); + pageContext.setAttribute("lastPublishedTime", timeInMillis2); //needed to check if publishing occurs after the validation + Date jobEndTime = new Date(timeInMillis2); pageContext.setAttribute("jobEndTime", jobEndTime); } else { @@ -174,7 +190,14 @@ $(function () {
@@ -207,18 +230,14 @@ $(function () {