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:
cdtank 2011-03-22 20:59:59 +00:00
parent 15b07e56f0
commit caa941049b
6 changed files with 165 additions and 54 deletions

View file

@ -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 * This method will setup the options for loading screen & then activate the
* loading screen. * loading screen.
@ -208,14 +219,38 @@ function setupLoadingScreen(visContainerDIV) {
$.blockUI.defaults.css.top = '15%'; $.blockUI.defaults.css.top = '15%';
visContainerDIV.block({ visContainerDIV.block({
message: '<h3><img src="' + loadingImageLink message: '<div id="loading-data-container"><h3><img id="data-loading-icon" src="' + loadingImageLink
+ '" />&nbsp;Loading data for <i>' + '" />&nbsp;Loading data for <i>'
+ organizationLabel + organizationLabel
+ '</i></h3>' + '</i></h3></div>'
}); });
setTimeout(function() {
$("#loading-data-container")
.html('<h3><img id="refresh-page-icon" src="'
+ refreshPageImageLink
+ '" />&nbsp;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 * 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. * loading message. It will also display the error container in case of any error.
@ -225,6 +260,10 @@ function getTemporalGraphData(temporalGraphDataURL,
errorBodyDIV, errorBodyDIV,
visContainerDIV) { visContainerDIV) {
if (!isDataRequestSentViaAJAX) {
isDataRequestSentViaAJAX = true;
$.ajax({ $.ajax({
url: temporalGraphDataURL, url: temporalGraphDataURL,
dataType: "json", dataType: "json",
@ -242,9 +281,14 @@ function getTemporalGraphData(temporalGraphDataURL,
temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data); temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data);
visContainerDIV.unblock(); visContainerDIV.unblock();
} }
},
complete: function() {
isDataRequestSentViaAJAX = false;
} }
}); });
}
} }
function parseXSDateTime(rawDateTimeString) { function parseXSDateTime(rawDateTimeString) {

View file

@ -19,14 +19,18 @@ This is used in util.js to print grant temporal graph links for all sub-organiza
*/ */
var subOrganizationTemporalGraphURL = "${subOrganizationGrantTemporalGraphCommonURL}"; var subOrganizationTemporalGraphURL = "${subOrganizationGrantTemporalGraphCommonURL}";
var temporalGraphDataURL = '${temporalGraphDataURL}';
$(document).ready(function () { $(document).ready(function () {
setupLoadingScreen($("div#temporal-graph-response")); options = {
responseContainer: $("div#temporal-graph-response"),
bodyContainer: $("#body"),
errorContainer: $("#error-container"),
dataURL: temporalGraphDataURL
};
getTemporalGraphData('${temporalGraphDataURL}', renderTemporalGraphVisualization(options);
$("#body"),
$("#error-container"),
$("div#temporal-graph-response"));
}); });

View file

@ -19,14 +19,18 @@ This is used in util.js to print grant temporal graph links for all sub-organiza
*/ */
var subOrganizationTemporalGraphURL = "${subOrganizationPublicationTemporalGraphCommonURL}"; var subOrganizationTemporalGraphURL = "${subOrganizationPublicationTemporalGraphCommonURL}";
var temporalGraphDataURL = '${temporalGraphDataURL}';
$(document).ready(function () { $(document).ready(function () {
setupLoadingScreen($("div#temporal-graph-response")); options = {
responseContainer: $("div#temporal-graph-response"),
bodyContainer: $("#body"),
errorContainer: $("#error-container"),
dataURL: temporalGraphDataURL
};
getTemporalGraphData('${temporalGraphDataURL}', renderTemporalGraphVisualization(options);
$("#body"),
$("#error-container"),
$("div#temporal-graph-response"));
}); });

View file

@ -74,9 +74,12 @@ var organizationLabel = '${organizationLabel}';
var organizationVIVOProfileURL = "${organizationVivoProfileURL}"; var organizationVIVOProfileURL = "${organizationVivoProfileURL}";
var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif"; var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif";
var refreshPageImageLink = contextPath + "/images/visualization/refresh-green.png";
var entityCheckboxSelectorDOMClass = "${entityCheckboxSelectorDOMClass}"; var entityCheckboxSelectorDOMClass = "${entityCheckboxSelectorDOMClass}";
var isDataRequestSentViaAJAX = false;
var temporalGraphProcessor; var temporalGraphProcessor;
/* /*

View file

@ -57,10 +57,10 @@ public class TemporalGrantVisualizationRequestHandler implements
} }
// System.out.println("current models in the system are"); System.out.println("current models in the system are");
// for (Map.Entry<String, Model> entry : ConstructedModelTracker.getAllModels().entrySet()) { for (Map.Entry<String, Model> entry : ConstructedModelTracker.getAllModels().entrySet()) {
// System.out.println(entry.getKey() + " -> " + entry.getValue().size()); System.out.println(entry.getKey() + " -> " + entry.getValue().size());
// } }
// //
return prepareStandaloneMarkupResponse(vitroRequest, entityURI); return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
} }

View file

@ -211,11 +211,9 @@ public class SelectOnModelUtilities {
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL); fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL); fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE); fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
fieldLabelToOutputFieldLabel.put("lastCachedDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
String whereClause = "" String whereClause = ""
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPersonWithPublication ?document . "
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedDateTime . "
+ " ?document rdfs:label ?documentLabel . " + " ?document rdfs:label ?documentLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
+ " ?document core:dateTimeValue ?dateTimeValue . " + " ?document core:dateTimeValue ?dateTimeValue . "
@ -232,6 +230,12 @@ public class SelectOnModelUtilities {
subOrganization, subOrganization,
allDocumentURIToVOs); allDocumentURIToVOs);
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
subOrganization,
subOrganizationPublicationsModel);
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
} }
return allDocumentURIToVOs; return allDocumentURIToVOs;
} }
@ -276,6 +280,22 @@ public class SelectOnModelUtilities {
subEntity.addActivities(currentEntityPublications); 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( private static void getGrantForEntity(
ResultSet queryResult, ResultSet queryResult,
@ -334,22 +354,26 @@ public class SelectOnModelUtilities {
System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI()); System.out.println("constructing grants for " + subOrganization.getIndividualLabel() + " :: " + subOrganization.getIndividualURI());
long before = System.currentTimeMillis();
Model subOrganizationGrantsModel = ModelConstructorUtilities Model subOrganizationGrantsModel = ModelConstructorUtilities
.getOrConstructModel( .getOrConstructModel(
subOrganization.getIndividualURI(), subOrganization.getIndividualURI(),
OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE, OrganizationToGrantsForSubOrganizationsModelConstructor.MODEL_TYPE,
dataset); dataset);
System.out.println("\t construct -> " + (System.currentTimeMillis() - before));
before = System.currentTimeMillis();
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>(); Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL); fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL); fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE); fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE); fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
String whereClause = "" String whereClause = ""
+ "{" + "{"
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -359,7 +383,6 @@ public class SelectOnModelUtilities {
+ "}" + "}"
+ "UNION" + "UNION"
+ "{" + "{"
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -369,7 +392,6 @@ public class SelectOnModelUtilities {
+ "}" + "}"
+ "UNION" + "UNION"
+ "{" + "{"
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -385,20 +407,46 @@ public class SelectOnModelUtilities {
"", "",
subOrganizationGrantsModel); subOrganizationGrantsModel);
// subOrganization.addActivities(getGrantForEntity(
// subOrganizationGrantsQuery.getQueryResult(),
// allGrantURIToVO));
/* /*
* This method side-affects the subOrganization entity & the map containing all the grants for * This method side-affects the subOrganization entity & the map containing all the grants for
* the subject organization. * the subject organization.
* */ * */
getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO); getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO);
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
subOrganization,
subOrganizationGrantsModel);
subOrganization.setLastCachedAtDateTime(lastCachedAtForEntity);
System.out.println("\t select -> " + (System.currentTimeMillis() - before));
} }
return allGrantURIToVO; 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( public static Map<String, Activity> getGrantsForAssociatedPeople(
Dataset dataset, Collection<SubEntity> people) Dataset dataset, Collection<SubEntity> people)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
@ -417,11 +465,9 @@ public class SelectOnModelUtilities {
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL); fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE); fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE); fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
String whereClause = "" String whereClause = ""
+ "{" + "{"
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -431,7 +477,6 @@ public class SelectOnModelUtilities {
+ "}" + "}"
+ "UNION" + "UNION"
+ "{" + "{"
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -441,7 +486,6 @@ public class SelectOnModelUtilities {
+ "}" + "}"
+ "UNION" + "UNION"
+ "{" + "{"
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . "
+ " ?grant rdfs:label ?grantLabel . " + " ?grant rdfs:label ?grantLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -458,6 +502,14 @@ public class SelectOnModelUtilities {
peopleGrantsModel); peopleGrantsModel);
getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs); getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs);
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
person,
peopleGrantsModel);
person.setLastCachedAtDateTime(lastCachedAtForEntity);
} }
return allGrantURIToVOs; return allGrantURIToVOs;
} }
@ -481,10 +533,8 @@ public class SelectOnModelUtilities {
fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL); fieldLabelToOutputFieldLabel.put("document", QueryFieldLabels.DOCUMENT_URL);
fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL); fieldLabelToOutputFieldLabel.put("documentLabel", QueryFieldLabels.DOCUMENT_LABEL);
fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE); fieldLabelToOutputFieldLabel.put("documentPublicationDate", QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
String whereClause = "" String whereClause = ""
+ " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . "
+ " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . " + " <" + person.getIndividualURI() + "> vivosocnet:hasPublication ?document . "
+ " ?document rdfs:label ?documentLabel . " + " ?document rdfs:label ?documentLabel . "
+ " OPTIONAL { " + " OPTIONAL { "
@ -502,6 +552,12 @@ public class SelectOnModelUtilities {
person, person,
allDocumentURIToVOs); allDocumentURIToVOs);
String lastCachedAtForEntity = getLastCachedAtDateTimeForEntityInModel(
person,
peoplePublicationsModel);
person.setLastCachedAtDateTime(lastCachedAtForEntity);
} }
return allDocumentURIToVOs; return allDocumentURIToVOs;
} }