1. Updated front-end for temporal graph to display helpful message when it takes mnore than 10 seconds to get the data, most likely due to a cached version not available for the requested entity.
This commit is contained in:
parent
15b07e56f0
commit
caa941049b
6 changed files with 165 additions and 54 deletions
|
@ -192,6 +192,17 @@ function entityCheckboxOperatedOnEventListener() {
|
|||
|
||||
}
|
||||
|
||||
function renderTemporalGraphVisualization(parameters) {
|
||||
|
||||
setupLoadingScreen(parameters.responseContainer);
|
||||
|
||||
getTemporalGraphData(parameters.dataURL,
|
||||
parameters.bodyContainer,
|
||||
parameters.errorContainer,
|
||||
parameters.responseContainer);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This method will setup the options for loading screen & then activate the
|
||||
* loading screen.
|
||||
|
@ -208,14 +219,38 @@ function setupLoadingScreen(visContainerDIV) {
|
|||
$.blockUI.defaults.css.top = '15%';
|
||||
|
||||
visContainerDIV.block({
|
||||
message: '<h3><img src="' + loadingImageLink
|
||||
message: '<div id="loading-data-container"><h3><img id="data-loading-icon" src="' + loadingImageLink
|
||||
+ '" /> Loading data for <i>'
|
||||
+ organizationLabel
|
||||
+ '</i></h3>'
|
||||
+ '</i></h3></div>'
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
$("#loading-data-container")
|
||||
.html('<h3><img id="refresh-page-icon" src="'
|
||||
+ refreshPageImageLink
|
||||
+ '" /> Data for <i>' + organizationLabel
|
||||
+ '</i> is now being refreshed. The visualization will load as soon as we are done computing, '
|
||||
+ 'or you can come back in a few minutes.</h3>')
|
||||
.css({'cursor': 'pointer'});
|
||||
|
||||
}, 10 * 1000);
|
||||
|
||||
}
|
||||
|
||||
$("#reload-data").live('click', function() {
|
||||
|
||||
options = {
|
||||
responseContainer: $("div#temporal-graph-response"),
|
||||
bodyContainer: $("#body"),
|
||||
errorContainer: $("#error-container"),
|
||||
dataURL: temporalGraphDataURL
|
||||
};
|
||||
|
||||
renderTemporalGraphVisualization(options);
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
* This function gets json data for temporal graph & after rendering removes the
|
||||
* loading message. It will also display the error container in case of any error.
|
||||
|
@ -225,25 +260,34 @@ function getTemporalGraphData(temporalGraphDataURL,
|
|||
errorBodyDIV,
|
||||
visContainerDIV) {
|
||||
|
||||
$.ajax({
|
||||
url: temporalGraphDataURL,
|
||||
dataType: "json",
|
||||
timeout: 5 * 60 * 1000,
|
||||
success: function (data) {
|
||||
|
||||
if (data.error) {
|
||||
graphBodyDIV.remove();
|
||||
errorBodyDIV.show();
|
||||
visContainerDIV.unblock();
|
||||
|
||||
} else {
|
||||
graphBodyDIV.show();
|
||||
errorBodyDIV.remove();
|
||||
temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data);
|
||||
visContainerDIV.unblock();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!isDataRequestSentViaAJAX) {
|
||||
|
||||
isDataRequestSentViaAJAX = true;
|
||||
|
||||
$.ajax({
|
||||
url: temporalGraphDataURL,
|
||||
dataType: "json",
|
||||
timeout: 5 * 60 * 1000,
|
||||
success: function (data) {
|
||||
|
||||
if (data.error) {
|
||||
graphBodyDIV.remove();
|
||||
errorBodyDIV.show();
|
||||
visContainerDIV.unblock();
|
||||
|
||||
} else {
|
||||
graphBodyDIV.show();
|
||||
errorBodyDIV.remove();
|
||||
temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data);
|
||||
visContainerDIV.unblock();
|
||||
}
|
||||
},
|
||||
complete: function() {
|
||||
isDataRequestSentViaAJAX = false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,18 @@ This is used in util.js to print grant temporal graph links for all sub-organiza
|
|||
*/
|
||||
var subOrganizationTemporalGraphURL = "${subOrganizationGrantTemporalGraphCommonURL}";
|
||||
|
||||
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
setupLoadingScreen($("div#temporal-graph-response"));
|
||||
|
||||
getTemporalGraphData('${temporalGraphDataURL}',
|
||||
$("#body"),
|
||||
$("#error-container"),
|
||||
$("div#temporal-graph-response"));
|
||||
options = {
|
||||
responseContainer: $("div#temporal-graph-response"),
|
||||
bodyContainer: $("#body"),
|
||||
errorContainer: $("#error-container"),
|
||||
dataURL: temporalGraphDataURL
|
||||
};
|
||||
|
||||
renderTemporalGraphVisualization(options);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -19,14 +19,18 @@ This is used in util.js to print grant temporal graph links for all sub-organiza
|
|||
*/
|
||||
var subOrganizationTemporalGraphURL = "${subOrganizationPublicationTemporalGraphCommonURL}";
|
||||
|
||||
var temporalGraphDataURL = '${temporalGraphDataURL}';
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
setupLoadingScreen($("div#temporal-graph-response"));
|
||||
|
||||
getTemporalGraphData('${temporalGraphDataURL}',
|
||||
$("#body"),
|
||||
$("#error-container"),
|
||||
$("div#temporal-graph-response"));
|
||||
options = {
|
||||
responseContainer: $("div#temporal-graph-response"),
|
||||
bodyContainer: $("#body"),
|
||||
errorContainer: $("#error-container"),
|
||||
dataURL: temporalGraphDataURL
|
||||
};
|
||||
|
||||
renderTemporalGraphVisualization(options);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -74,9 +74,12 @@ var organizationLabel = '${organizationLabel}';
|
|||
var organizationVIVOProfileURL = "${organizationVivoProfileURL}";
|
||||
|
||||
var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif";
|
||||
var refreshPageImageLink = contextPath + "/images/visualization/refresh-green.png";
|
||||
|
||||
var entityCheckboxSelectorDOMClass = "${entityCheckboxSelectorDOMClass}";
|
||||
|
||||
var isDataRequestSentViaAJAX = false;
|
||||
|
||||
var temporalGraphProcessor;
|
||||
|
||||
/*
|
||||
|
@ -100,4 +103,4 @@ var COMPARISON_PARAMETERS_INFO = {
|
|||
|
||||
</script>
|
||||
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/visualization/entitycomparison/gui-event-manager.js"></script>')}
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/visualization/entitycomparison/gui-event-manager.js"></script>')}
|
|
@ -57,10 +57,10 @@ public class TemporalGrantVisualizationRequestHandler implements
|
|||
|
||||
}
|
||||
|
||||
// System.out.println("current models in the system are");
|
||||
// for (Map.Entry<String, Model> entry : ConstructedModelTracker.getAllModels().entrySet()) {
|
||||
// System.out.println(entry.getKey() + " -> " + entry.getValue().size());
|
||||
// }
|
||||
System.out.println("current models in the system are");
|
||||
for (Map.Entry<String, Model> entry : ConstructedModelTracker.getAllModels().entrySet()) {
|
||||
System.out.println(entry.getKey() + " -> " + entry.getValue().size());
|
||||
}
|
||||
//
|
||||
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
|
||||
}
|
||||
|
|
|
@ -211,11 +211,9 @@ public class SelectOnModelUtilities {
|
|||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("lastCachedDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
|
||||
String whereClause = ""
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedDateTime . "
|
||||
+ " ?document rdfs:label ?documentLabel . "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?document core:dateTimeValue ?dateTimeValue . "
|
||||
|
@ -232,6 +230,12 @@ public class SelectOnModelUtilities {
|
|||
subOrganization,
|
||||
allDocumentURIToVOs);
|
||||
|
||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
||||
subOrganization,
|
||||
subOrganizationPublicationsModel);
|
||||
|
||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
||||
|
||||
}
|
||||
return allDocumentURIToVOs;
|
||||
}
|
||||
|
@ -276,6 +280,22 @@ public class SelectOnModelUtilities {
|
|||
subEntity.addActivities(currentEntityPublications);
|
||||
}
|
||||
|
||||
public static String getLastCachedAtForEntity(ResultSet queryResult) {
|
||||
|
||||
String lastCachedAtDateTime = null;
|
||||
|
||||
while (queryResult.hasNext()) {
|
||||
|
||||
QuerySolution solution = queryResult.nextSolution();
|
||||
|
||||
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
if (lastCachedAtNode != null) {
|
||||
lastCachedAtDateTime = lastCachedAtNode.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return lastCachedAtDateTime;
|
||||
}
|
||||
|
||||
private static void getGrantForEntity(
|
||||
ResultSet queryResult,
|
||||
|
@ -334,22 +354,26 @@ public class SelectOnModelUtilities {
|
|||
|
||||
System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
|
||||
|
||||
long before = System.currentTimeMillis();
|
||||
|
||||
Model subOrganizationGrantsModel = ModelConstructorUtilities
|
||||
.getOrConstructModel(
|
||||
subOrganization.getIndividualURI(),
|
||||
OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
|
||||
dataset);
|
||||
|
||||
System.out.println("\t construct -> " + (System.currentTimeMillis() - before));
|
||||
|
||||
before = System.currentTimeMillis();
|
||||
|
||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
|
||||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
|
||||
String whereClause = ""
|
||||
+ "{"
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -359,7 +383,6 @@ public class SelectOnModelUtilities {
|
|||
+ "}"
|
||||
+ "UNION"
|
||||
+ "{"
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -369,7 +392,6 @@ public class SelectOnModelUtilities {
|
|||
+ "}"
|
||||
+ "UNION"
|
||||
+ "{"
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -385,19 +407,45 @@ public class SelectOnModelUtilities {
|
|||
"",
|
||||
subOrganizationGrantsModel);
|
||||
|
||||
// subOrganization.addActivities(getGrantForEntity(
|
||||
// subOrganizationGrantsQuery.getQueryResult(),
|
||||
// allGrantURIToVO));
|
||||
|
||||
/*
|
||||
* This method side-affects the subOrganization entity & the map containing all the grants for
|
||||
* the subject organization.
|
||||
* */
|
||||
getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO);
|
||||
|
||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
||||
subOrganization,
|
||||
subOrganizationGrantsModel);
|
||||
|
||||
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
|
||||
|
||||
System.out.println("\t select -> " + (System.currentTimeMillis() - before));
|
||||
}
|
||||
return allGrantURIToVO;
|
||||
}
|
||||
|
||||
private static String getLastCachedAtDateTimeForEntityInModel(
|
||||
SubEntity entity, Model subOrganizationGrantsModel)
|
||||
throws MalformedQueryParametersException {
|
||||
|
||||
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
|
||||
String whereClause = ""
|
||||
+ "{"
|
||||
+ " <" + entity.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ "}";
|
||||
|
||||
QueryRunner<ResultSet> entityLastCachedAtQuery =
|
||||
new GenericQueryRunnerOnModel(fieldLabelToOutputFieldLabel,
|
||||
"",
|
||||
whereClause,
|
||||
"",
|
||||
subOrganizationGrantsModel);
|
||||
|
||||
String lastCachedAtForEntity = getLastCachedAtForEntity(entityLastCachedAtQuery.getQueryResult());
|
||||
return lastCachedAtForEntity;
|
||||
}
|
||||
|
||||
public static Map<String, Activity> getGrantsForAssociatedPeople(
|
||||
Dataset dataset, Collection<SubEntity> people)
|
||||
|
@ -417,11 +465,9 @@ public class SelectOnModelUtilities {
|
|||
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
|
||||
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
|
||||
String whereClause = ""
|
||||
+ "{"
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -431,7 +477,6 @@ public class SelectOnModelUtilities {
|
|||
+ "}"
|
||||
+ "UNION"
|
||||
+ "{"
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -441,7 +486,6 @@ public class SelectOnModelUtilities {
|
|||
+ "}"
|
||||
+ "UNION"
|
||||
+ "{"
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . "
|
||||
+ " ?grant rdfs:label ?grantLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -458,6 +502,14 @@ public class SelectOnModelUtilities {
|
|||
peopleGrantsModel);
|
||||
|
||||
getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs);
|
||||
|
||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
||||
person,
|
||||
peopleGrantsModel);
|
||||
|
||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
||||
|
||||
|
||||
}
|
||||
return allGrantURIToVOs;
|
||||
}
|
||||
|
@ -481,10 +533,8 @@ public class SelectOnModelUtilities {
|
|||
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
|
||||
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
|
||||
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
|
||||
|
||||
String whereClause = ""
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
|
||||
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
|
||||
+ " ?document rdfs:label ?documentLabel . "
|
||||
+ " OPTIONAL { "
|
||||
|
@ -502,6 +552,12 @@ public class SelectOnModelUtilities {
|
|||
person,
|
||||
allDocumentURIToVOs);
|
||||
|
||||
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
|
||||
person,
|
||||
peoplePublicationsModel);
|
||||
|
||||
person.setLastCachedAtDateTime(lastCachedAtForEntity);
|
||||
|
||||
}
|
||||
return allDocumentURIToVOs;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue