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
This commit is contained in:
Massimiliano Assante 2019-05-07 12:24:36 +00:00
parent a6ca6a9409
commit ef0db47f58
1 changed files with 58 additions and 39 deletions

View File

@ -30,35 +30,40 @@ function closeAndReload() {
}
$(function () {
checkBatchesThreshold = function (theButton, endpoint, farmId, batchType, farmIdEncoded, batchTypeEncoded) {
$(theButton).html('<i class="icon-cog"> 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('<i class="icon-warning-sign">' + 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('<i class="icon-cog"> 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('<i class="icon-warning-sign">' + 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');
}
});
}
};
});
</script>
@ -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 () {
<c:otherwise>
<div style="display: inline;">
<button class="btn" type="button"
onClick="checkBatchesThreshold(this, '${checkBatchesThresholdURL}', '${farmId}', '${form.batchType}', '${farmIdEncoded}', '${batchTypeEncoded}')">
onClick="checkBatchesThreshold(this,
'${checkBatchesThresholdURL}',
'${farmId}',
'${form.batchType}',
'${farmIdEncoded}',
'${batchTypeEncoded}',
'${lastValidatedTime}',
'${lastPublishedTime}')">
Analyse
</button>
</div>
@ -207,18 +230,14 @@ $(function () {
</c:choose>
</div>
<div id="modalSuccess" class="modal" style="display: none;">
<div class="logo-circular"
style="background-image: url('${logoURL}');
background-size: cover; "></div>
<div><img class="logo-circular" src="${logoURL}" /></div>
<p class="lead">
The publishing and anonymising process started correctly.<br>
Please <a href="#" onClick="closeAndReload();">click here</a> to monitor the progress.
</p>
</div>
<div id="modalFailed" class="modal" style="display: none;">
<div class="logo-circular"
style="background-image: url('${logoURL}');
background-size: cover; "></div>
<div><img class="logo-circular" src="${logoURL}" /></div>
<p class="lead">
We're sorry. An error occurred in the server. <br>
The publishing and anonymising process could not start, please report this issue.