1. Made use of the lastC

This commit is contained in:
cdtank 2011-03-21 22:40:27 +00:00
parent f80de8c1ba
commit 4d008e00c5
9 changed files with 390 additions and 338 deletions

View file

@ -44,6 +44,8 @@ var graphContainer;
var tableDiv; var tableDiv;
var entityLevel; var entityLevel;
var lastCachedAtDateTimes;
//options for Flot //options for Flot
var FlotOptions; var FlotOptions;
@ -68,7 +70,7 @@ function initConstants() {
setOfLabels = []; setOfLabels = [];
labelToCheckedEntities = {}; labelToCheckedEntities = {};
stopWordsToCount = {}; stopWordsToCount = {};
lastCachedAtDateTimes = [];
//options for Flot //options for Flot
FlotOptions = { FlotOptions = {
legend : { legend : {

View file

@ -1,289 +1,313 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */ /* $This file is distributed under the terms of the license in /doc/license.txt$ */
$(document).ready(function() { $(document).ready(function() {
/* /*
* This will set intitial values of the constants present in constants.js * This will set intitial values of the constants present in constants.js
* */ * */
initConstants(); initConstants();
/* This is used to cache the current state whether the user is allowed to select more entities from /* This is used to cache the current state whether the user is allowed to select more entities from
the datatable or not. Once Max number of entity selection is reached the user can no longer select the datatable or not. Once Max number of entity selection is reached the user can no longer select
more & this variable will be set to false. */ more & this variable will be set to false. */
$("#datatable").data("isEntitySelectionAllowed", true); $("#datatable").data("isEntitySelectionAllowed", true);
$notificationContainer = $("#notification-container").notify(); $notificationContainer = $("#notification-container").notify();
graphContainer = $("#graphContainer"); graphContainer = $("#graphContainer");
tableDiv = $('#paginatedTable'); tableDiv = $('#paginatedTable');
//temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, jsonString); //temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, jsonString);
/* /*
* When the intra-entity parameters are clicked, * When the intra-entity parameters are clicked,
* update the status accordingly. * update the status accordingly.
*/ */
$("select.comparisonValues").change(function(){ $("select.comparisonValues").change(function(){
var selectedValue = $("select.comparisonValues option:selected").val(); var selectedValue = $("select.comparisonValues option:selected").val();
var selectedParameter; var selectedParameter;
$.each(COMPARISON_PARAMETERS_INFO, function(index, parameter) { $.each(COMPARISON_PARAMETERS_INFO, function(index, parameter) {
if (parameter.value === selectedValue) { if (parameter.value === selectedValue) {
selectedParameter = parameter; selectedParameter = parameter;
window.location = parameter.viewLink; window.location = parameter.viewLink;
} }
}); });
//$("#body").empty().html("<div id='loading-comparisons'>Loading " + selectedValue + "&nbsp;&nbsp;<img src='" + loadingImageLink + "' /></div>"); //$("#body").empty().html("<div id='loading-comparisons'>Loading " + selectedValue + "&nbsp;&nbsp;<img src='" + loadingImageLink + "' /></div>");
/* /*
* This piece of code is not executed at all because the redirect happens before there is a chance * This piece of code is not executed at all because the redirect happens before there is a chance
* to render the below contents. * to render the below contents.
* */ * */
/* /*
$("#comparisonParameter").text("Total Number of " + selectedValue); $("#comparisonParameter").text("Total Number of " + selectedValue);
$('#yaxislabel').html("Number of " + selectedValue).mbFlipText(false); $('#yaxislabel').html("Number of " + selectedValue).mbFlipText(false);
$('#yaxislabel').css("color", "#595B5B"); $('#yaxislabel').css("color", "#595B5B");
$('#comparisonHeader').html(selectedValue).css('font-weight', 'bold'); $('#comparisonHeader').html(selectedValue).css('font-weight', 'bold');
*/ */
}); });
}); });
//click event handler for clear button //click event handler for clear button
$("a.clear-selected-entities").live('click', function(){ $("a.clear-selected-entities").live('click', function(){
clearRenderedObjects(); clearRenderedObjects();
}); });
$("input[type=checkbox].easyDeselectCheckbox").live('click', function(){ $("input[type=checkbox].easyDeselectCheckbox").live('click', function(){
var checkbox = $(this); var checkbox = $(this);
var checkboxValue = $(this).attr("value"); var checkboxValue = $(this).attr("value");
var linkedCheckbox = labelToCheckedEntities[checkboxValue]; var linkedCheckbox = labelToCheckedEntities[checkboxValue];
var entityToBeRemoved = labelToEntityRecord[checkboxValue]; var entityToBeRemoved = labelToEntityRecord[checkboxValue];
if(!checkbox.is(':checked')){ if(!checkbox.is(':checked')){
//console.log("Easy deselect checkbox is unclicked!"); //console.log("Easy deselect checkbox is unclicked!");
updateRowHighlighter(linkedCheckbox); updateRowHighlighter(linkedCheckbox);
removeUsedColor(entityToBeRemoved); removeUsedColor(entityToBeRemoved);
removeEntityUnChecked(renderedObjects, entityToBeRemoved); removeEntityUnChecked(renderedObjects, entityToBeRemoved);
removeLegendRow(linkedCheckbox); removeLegendRow(linkedCheckbox);
removeCheckBoxFromGlobalSet(linkedCheckbox); removeCheckBoxFromGlobalSet(linkedCheckbox);
$(linkedCheckbox).attr('checked', false); $(linkedCheckbox).attr('checked', false);
checkIfColorLimitIsReached(); checkIfColorLimitIsReached();
displayLineGraphs(); displayLineGraphs();
updateCounter(); updateCounter();
} }
}); });
$(".disabled-checkbox-event-receiver").live("click", function () { $(".disabled-checkbox-event-receiver").live("click", function () {
if ($(this).next().is(':disabled')) { if ($(this).next().is(':disabled')) {
createNotification("warning-notification", { createNotification("warning-notification", {
title: 'Error', title: 'Error',
text: 'A Maximum 10 entities can be compared. Please remove some & try again.' text: 'A Maximum 10 entities can be compared. Please remove some & try again.'
}, { }, {
custom: true, custom: true,
expires: false expires: false
}); });
} }
}); });
function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) { function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) {
removeUsedColor(entity); removeUsedColor(entity);
removeEntityUnChecked(renderedObjects, entity); removeEntityUnChecked(renderedObjects, entity);
removeLegendRow(checkbox); removeLegendRow(checkbox);
removeCheckBoxFromGlobalSet(checkbox); removeCheckBoxFromGlobalSet(checkbox);
checkbox.closest("tr").removeClass('datatablerowhighlight'); checkbox.closest("tr").removeClass('datatablerowhighlight');
} }
function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) { function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) {
getNextFreeColor(entity); getNextFreeColor(entity);
//Generate the bar, checkbox and label for the legend. //Generate the bar, checkbox and label for the legend.
createLegendRow(entity, $("#bottom")); createLegendRow(entity, $("#bottom"));
renderLineGraph(renderedObjects, entity); renderLineGraph(renderedObjects, entity);
labelToCheckedEntities[checkboxValue] = checkbox; labelToCheckedEntities[checkboxValue] = checkbox;
labelToCheckedEntities[checkboxValue].entity = entity; labelToCheckedEntities[checkboxValue].entity = entity;
// console.log(labelToCheckedEntities[checkboxValue], entity); // console.log(labelToCheckedEntities[checkboxValue], entity);
/* /*
* To highlight the rows belonging to selected entities. * To highlight the rows belonging to selected entities.
* */ * */
checkbox.closest("tr").addClass('datatablerowhighlight'); checkbox.closest("tr").addClass('datatablerowhighlight');
} }
function performEntityCheckboxClickedRedrawActions() { function performEntityCheckboxClickedRedrawActions() {
setTickSizeOfAxes(); setTickSizeOfAxes();
checkIfColorLimitIsReached(); checkIfColorLimitIsReached();
displayLineGraphs(); displayLineGraphs();
updateCounter(); updateCounter();
} }
/* /*
* function to populate the labelToEntityRecord object with the * function to populate the labelToEntityRecord object with the
* values from the json file and * values from the json file and
* dynamically generate checkboxes * dynamically generate checkboxes
*/ */
function loadData(jsonData, dataTableParams) { function loadData(jsonData, dataTableParams) {
$.each(jsonData, function (index, val) { $.each(jsonData, function (index, val) {
setOfLabels.push(val.label); setOfLabels.push(val.label);
labelToEntityRecord[val.label] = val; labelToEntityRecord[val.label] = val;
}); if (val.lastCachedAtDateTime) {
lastCachedAtDateTimes[lastCachedAtDateTimes.length] = val.lastCachedAtDateTime;
prepareTableForDataTablePagination(jsonData, dataTableParams); }
setEntityLevel(getEntityVisMode(jsonData)); });
entityCheckboxOperatedOnEventListener(); prepareTableForDataTablePagination(jsonData, dataTableParams);
setEntityLevel(getEntityVisMode(jsonData));
}
entityCheckboxOperatedOnEventListener();
function entityCheckboxOperatedOnEventListener() {
}
/*
* When the elements in the paginated div function entityCheckboxOperatedOnEventListener() {
* are clicked this event handler is called
*/ /*
$("input." + entityCheckboxSelectorDOMClass).live('click', function () { * When the elements in the paginated div
* are clicked this event handler is called
var checkbox = $(this); */
var checkboxValue = $(this).attr("value"); $("input." + entityCheckboxSelectorDOMClass).live('click', function () {
var entity = labelToEntityRecord[checkboxValue];
var checkbox = $(this);
if (checkbox.is(':checked')) { var checkboxValue = $(this).attr("value");
var entity = labelToEntityRecord[checkboxValue];
performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox);
if (checkbox.is(':checked')) {
} else {
performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox);
performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox);
} else {
}
performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox);
performEntityCheckboxClickedRedrawActions();
}
});
performEntityCheckboxClickedRedrawActions();
}
});
/*
* This method will setup the options for loading screen & then activate the }
* loading screen.
* */ /*
function setupLoadingScreen(visContainerDIV) { * This method will setup the options for loading screen & then activate the
* loading screen.
$.blockUI.defaults.overlayCSS = { * */
backgroundColor: '#fff', function setupLoadingScreen(visContainerDIV) {
opacity: 1.0
}; $.blockUI.defaults.overlayCSS = {
backgroundColor: '#fff',
$.blockUI.defaults.css.width = '500px'; opacity: 1.0
$.blockUI.defaults.css.border = '0px'; };
$.blockUI.defaults.css.top = '15%';
$.blockUI.defaults.css.width = '500px';
visContainerDIV.block({ $.blockUI.defaults.css.border = '0px';
message: '<h3><img src="' + loadingImageLink $.blockUI.defaults.css.top = '15%';
+ '" />&nbsp;Loading data for <i>'
+ organizationLabel visContainerDIV.block({
+ '</i></h3>' message: '<h3><img src="' + loadingImageLink
}); + '" />&nbsp;Loading data for <i>'
+ organizationLabel
} + '</i></h3>'
});
/*
* 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.
* */ /*
function getTemporalGraphData(temporalGraphDataURL, * This function gets json data for temporal graph & after rendering removes the
graphBodyDIV, * loading message. It will also display the error container in case of any error.
errorBodyDIV, * */
visContainerDIV) { function getTemporalGraphData(temporalGraphDataURL,
graphBodyDIV,
$.ajax({ errorBodyDIV,
url: temporalGraphDataURL, visContainerDIV) {
dataType: "json",
timeout: 5 * 60 * 1000, $.ajax({
success: function (data) { url: temporalGraphDataURL,
dataType: "json",
if (data.error) { timeout: 5 * 60 * 1000,
graphBodyDIV.remove(); success: function (data) {
errorBodyDIV.show();
visContainerDIV.unblock(); if (data.error) {
graphBodyDIV.remove();
} else { errorBodyDIV.show();
graphBodyDIV.show(); visContainerDIV.unblock();
errorBodyDIV.remove();
temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data); } else {
visContainerDIV.unblock(); graphBodyDIV.show();
} errorBodyDIV.remove();
} temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, data);
}); visContainerDIV.unblock();
}
} }
});
temporalGraphProcessor = {
}
initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) {
function parseXSDateTime(rawDateTimeString) {
this.dataTableParams = {
searchBarParentContainerDIVClass : "searchbar", var dateTime = rawDateTimeString.split("T", 2);
paginationContainerDIVClass : "paginatedtabs" var date = dateTime[0].split("-");
}; var time = dateTime[1].split(":");
return new Date(date[0], date[1], date[2], time[0], time[1], 0);
/* }
* initial display of the grid when the page loads
* */ temporalGraphProcessor = {
init(givenGraphContainer);
initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) {
/*
* render the temporal graph per the sent content. this.dataTableParams = {
* */ searchBarParentContainerDIVClass : "searchbar",
loadData(jsonData, this.dataTableParams); paginationContainerDIVClass : "paginatedtabs"
};
/*
* This will make sure that top 3 entities are selected by default when the page loads.
*/ /*
$.each($("input." + entityCheckboxSelectorDOMClass), function(index, checkbox) { * initial display of the grid when the page loads
* */
if (index > 2) { init(givenGraphContainer);
return false;
} /*
* render the temporal graph per the sent content.
$(this).attr('checked', true); * */
loadData(jsonData, this.dataTableParams);
var checkboxValue = $(this).attr("value");
var entity = labelToEntityRecord[checkboxValue]; lastCachedAtDateTimes.sort(function(a, b) {
var dateA = parseXSDateTime(a);
performEntityCheckboxSelectedActions(entity, checkboxValue, $(this)); var dateB = parseXSDateTime(b);
return dateA-dateB; //sort by date ascending
performEntityCheckboxClickedRedrawActions(); });
}); /*
* This will make sure that top 3 entities are selected by default when the page loads.
} */
$.each($("input." + entityCheckboxSelectorDOMClass), function(index, checkbox) {
if (index > 2) {
return false;
}
$(this).attr('checked', true);
var checkboxValue = $(this).attr("value");
var entity = labelToEntityRecord[checkboxValue];
performEntityCheckboxSelectedActions(entity, checkboxValue, $(this));
performEntityCheckboxClickedRedrawActions();
});
if ($("#incomplete-data-disclaimer").length > 0 && lastCachedAtDateTimes.length > 0) {
$("#incomplete-data-disclaimer").attr(
"title",
$("#incomplete-data-disclaimer").attr("title") + " as of " + parseXSDateTime(lastCachedAtDateTimes[0]));
}
}
} }

View file

@ -2,7 +2,8 @@
<div id="body"> <div id="body">
<h2 id="header-entity-label"><span><a id="organizationMoniker" href="${organizationVivoProfileURL}">${organizationLabel}</a></span></h2> <h2 id="header-entity-label"><span><a id="organizationMoniker" href="${organizationVivoProfileURL}">${organizationLabel}</a>&nbsp;
<img id="incomplete-data-disclaimer" class="infoIcon" src="${urls.images}/iconInfo.png" alt="information icon" title="This information is based solely on ${currentParameterObject.value} which have been loaded into the VIVO system" /></span></h2>
<div id="leftblock"> <div id="leftblock">
<div id="leftUpper"> <div id="leftUpper">

View file

@ -318,6 +318,8 @@ public class TemporalGrantVisualizationRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI()); entityJson.setEntityURI(subentity.getIndividualURI());
entityJson.setLastCachedAtDateTime(subentity.getLastCachedAtDateTime());
if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) { if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) {
entityJson.setVisMode("PERSON"); entityJson.setVisMode("PERSON");
} else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) { } else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) {

View file

@ -313,6 +313,8 @@ public class TemporalPublicationVisualizationRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI()); entityJson.setEntityURI(subentity.getIndividualURI());
entityJson.setLastCachedAtDateTime(subentity.getLastCachedAtDateTime());
if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) { if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) {
entityJson.setVisMode("PERSON"); entityJson.setVisMode("PERSON");
} else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) { } else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) {

View file

@ -16,6 +16,7 @@ import java.util.Set;
public class JsonObject { public class JsonObject {
private String label; private String label;
private String lastCachedAtDateTime;
private List<List<Integer>> data = new ArrayList<List<Integer>>(); private List<List<Integer>> data = new ArrayList<List<Integer>>();
private String entityURI; private String entityURI;
private String visMode; private String visMode;
@ -80,9 +81,11 @@ public class JsonObject {
this.data = yearToPublicationCount; this.data = yearToPublicationCount;
} }
public void setYearToGrantCount(List<List<Integer>> yearGrantCount) { public void setLastCachedAtDateTime(String lastCachedAtDateTime) {
this.lastCachedAtDateTime = lastCachedAtDateTime;
}
public String getLastCachedAtDateTime() {
return lastCachedAtDateTime;
} }
} }

View file

@ -10,13 +10,14 @@ import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
/** /**
* @author bkoniden (Deepak Konidena) * @author bkoniden (Deepak Konidena)
* modified by @author cdtank (Chintan Tank) * modified by @author cdtank (Chintan Tank)
* last modified at Mar 16, 2011 2:57:20 PM * last modified at Mar 21, 2011 2:57:20 PM
*/ */
public class SubEntity extends Individual { public class SubEntity extends Individual {
private Set<Activity> activities = new HashSet<Activity>(); private Set<Activity> activities = new HashSet<Activity>();
private Set<String> entityTypes = new HashSet<String>(); private Set<String> entityTypes = new HashSet<String>();
private VOConstants.EntityClassType entityClass; private VOConstants.EntityClassType entityClass;
private String lastCachedAtDateTime = null;
public SubEntity(String individualURI) { public SubEntity(String individualURI) {
super(individualURI); super(individualURI);
@ -59,4 +60,12 @@ public class SubEntity extends Individual {
return entityClass; return entityClass;
} }
public void setLastCachedAtDateTime(String lastCachedAtDateTime) {
this.lastCachedAtDateTime = lastCachedAtDateTime;
}
public String getLastCachedAtDateTime() {
return lastCachedAtDateTime;
}
} }

View file

@ -228,17 +228,17 @@ public class SelectOnModelUtilities {
"", "",
subOrganizationPublicationsModel); subOrganizationPublicationsModel);
subOrganization.addActivities(getPublicationForEntity( getPublicationForEntity(subOrganizationPublicationsQuery.getQueryResult(),
subOrganizationPublicationsQuery.getQueryResult(), subOrganization,
allDocumentURIToVOs)); allDocumentURIToVOs);
} }
return allDocumentURIToVOs; return allDocumentURIToVOs;
} }
private static Collection<Activity> getPublicationForEntity( private static void getPublicationForEntity(
ResultSet queryResult, ResultSet queryResult,
Map<String, Activity> allDocumentURIToVOs) { SubEntity subEntity, Map<String, Activity> allDocumentURIToVOs) {
Set<Activity> currentEntityPublications = new HashSet<Activity>(); Set<Activity> currentEntityPublications = new HashSet<Activity>();
@ -246,6 +246,14 @@ public class SelectOnModelUtilities {
QuerySolution solution = queryResult.nextSolution(); QuerySolution solution = queryResult.nextSolution();
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
if (lastCachedAtNode != null) {
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
}
}
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL); RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
Activity biboDocument; Activity biboDocument;
@ -263,17 +271,15 @@ public class SelectOnModelUtilities {
biboDocument.setActivityDate(publicationDateNode.toString()); biboDocument.setActivityDate(publicationDateNode.toString());
} }
} }
currentEntityPublications.add(biboDocument); currentEntityPublications.add(biboDocument);
} }
subEntity.addActivities(currentEntityPublications);
return currentEntityPublications;
} }
private static Collection<Activity> getGrantForEntity( private static void getGrantForEntity(
ResultSet queryResult, ResultSet queryResult,
SubEntity subEntity,
Map<String, Activity> allGrantURIToVO) { Map<String, Activity> allGrantURIToVO) {
Set<Activity> currentEntityGrants = new HashSet<Activity>(); Set<Activity> currentEntityGrants = new HashSet<Activity>();
@ -282,6 +288,14 @@ public class SelectOnModelUtilities {
QuerySolution solution = queryResult.nextSolution(); QuerySolution solution = queryResult.nextSolution();
if (StringUtils.isEmpty(subEntity.getLastCachedAtDateTime())) {
RDFNode lastCachedAtNode = solution.get(QueryFieldLabels.LAST_CACHED_AT_DATETIME);
if (lastCachedAtNode != null) {
subEntity.setLastCachedAtDateTime(lastCachedAtNode.toString());
}
}
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL); RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
Activity coreGrant; Activity coreGrant;
@ -307,7 +321,8 @@ public class SelectOnModelUtilities {
} }
currentEntityGrants.add(coreGrant); currentEntityGrants.add(coreGrant);
} }
return currentEntityGrants;
subEntity.addActivities(currentEntityGrants);
} }
public static Map<String, Activity> getGrantsForAllSubOrganizations( public static Map<String, Activity> getGrantsForAllSubOrganizations(
@ -330,9 +345,11 @@ 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 = ""
+ "{" + "{"
+ " <" + 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 { "
@ -342,6 +359,7 @@ 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 { "
@ -351,6 +369,7 @@ 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 { "
@ -366,9 +385,15 @@ public class SelectOnModelUtilities {
"", "",
subOrganizationGrantsModel); subOrganizationGrantsModel);
subOrganization.addActivities(getGrantForEntity( // subOrganization.addActivities(getGrantForEntity(
subOrganizationGrantsQuery.getQueryResult(), // subOrganizationGrantsQuery.getQueryResult(),
allGrantURIToVO)); // allGrantURIToVO));
/*
* This method side-affects the subOrganization entity & the map containing all the grants for
* the subject organization.
* */
getGrantForEntity(subOrganizationGrantsQuery.getQueryResult(), subOrganization, allGrantURIToVO);
} }
return allGrantURIToVO; return allGrantURIToVO;
@ -378,36 +403,25 @@ public class SelectOnModelUtilities {
Dataset dataset, Collection<SubEntity> people) Dataset dataset, Collection<SubEntity> people)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>(); Map<String, Activity> allGrantURIToVOs = new HashMap<String, Activity>();
System.out.println("peopel for grants under consideration are ");
for (SubEntity person : people) {
System.out.println(person.getIndividualURI() + " -- " + person.getIndividualLabel());
}
long before = System.currentTimeMillis();
Model peopleGrantsModel = ModelConstructorUtilities Model peopleGrantsModel = ModelConstructorUtilities
.getOrConstructModel( .getOrConstructModel(
null, null,
PeopleToGrantsModelConstructor.MODEL_TYPE, PeopleToGrantsModelConstructor.MODEL_TYPE,
dataset); dataset);
System.out.print("\t construct took " + (System.currentTimeMillis() - before));
for (SubEntity person : people) { for (SubEntity person : people) {
System.out.println("constructing grants for " + person.getIndividualLabel() + " :: " + person.getIndividualURI());
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 = ""
+ "{" + "{"
+ " <" + 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 { "
@ -417,6 +431,7 @@ 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 { "
@ -426,6 +441,7 @@ 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 { "
@ -441,12 +457,7 @@ public class SelectOnModelUtilities {
"", "",
peopleGrantsModel); peopleGrantsModel);
person.addActivities(getGrantForEntity( getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs);
personGrantsQuery.getQueryResult(),
allGrantURIToVOs));
System.out.println("\t || select took " + (System.currentTimeMillis() - before));
} }
return allGrantURIToVOs; return allGrantURIToVOs;
} }
@ -464,14 +475,16 @@ public class SelectOnModelUtilities {
for (SubEntity person : people) { for (SubEntity person : people) {
System.out.println("getting publications for " + person.getIndividualLabel()); // System.out.println("getting publications for " + person.getIndividualLabel());
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>(); Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
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 { "
@ -485,9 +498,9 @@ public class SelectOnModelUtilities {
"", "",
peoplePublicationsModel); peoplePublicationsModel);
person.addActivities(getPublicationForEntity( getPublicationForEntity(personPublicationsQuery.getQueryResult(),
personPublicationsQuery.getQueryResult(), person,
allDocumentURIToVOs)); allDocumentURIToVOs);
} }
return allDocumentURIToVOs; return allDocumentURIToVOs;

View file

@ -9,8 +9,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap; import java.util.TreeMap;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -21,13 +19,11 @@ import org.joda.time.format.DateTimeFormatter;
import com.google.gson.Gson; import com.google.gson.Gson;
import edu.cornell.mannlib.vitro.webapp.beans.Portal; import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.DataVisualizationController;
import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants; import edu.cornell.mannlib.vitro.webapp.controller.visualization.freemarker.VisualizationFrameworkConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants; import edu.cornell.mannlib.vitro.webapp.visualization.constants.VisConstants;
@ -193,7 +189,7 @@ public class UtilityFunctions {
/* /*
* Always return default year identifier in case of an illegal parsed year. * Always return default year identifier in case of an illegal parsed year.
* */ * */
String parsedGrantYear = defaultYearInCaseOfError; String parsedInputYear = defaultYearInCaseOfError;
if (inputDate != null) { if (inputDate != null) {
@ -205,7 +201,7 @@ public class UtilityFunctions {
} }
} }
return parsedGrantYear; return parsedInputYear;
} }
public static String getCSVDownloadURL(String individualURI, String visType, String visMode) { public static String getCSVDownloadURL(String individualURI, String visType, String visMode) {