diff --git a/productMods/js/visualization/entitycomparison/constants.js b/productMods/js/visualization/entitycomparison/constants.js index 725efd94..823b32fd 100644 --- a/productMods/js/visualization/entitycomparison/constants.js +++ b/productMods/js/visualization/entitycomparison/constants.js @@ -44,6 +44,8 @@ var graphContainer; var tableDiv; var entityLevel; +var lastCachedAtDateTimes; + //options for Flot var FlotOptions; @@ -68,7 +70,7 @@ function initConstants() { setOfLabels = []; labelToCheckedEntities = {}; stopWordsToCount = {}; - + lastCachedAtDateTimes = []; //options for Flot FlotOptions = { legend : { diff --git a/productMods/js/visualization/entitycomparison/gui-event-manager.js b/productMods/js/visualization/entitycomparison/gui-event-manager.js index 4bf0fd52..98b752c1 100644 --- a/productMods/js/visualization/entitycomparison/gui-event-manager.js +++ b/productMods/js/visualization/entitycomparison/gui-event-manager.js @@ -1,289 +1,313 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -$(document).ready(function() { - - /* - * This will set intitial values of the constants present in constants.js - * */ - initConstants(); - /* 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 - more & this variable will be set to false. */ - $("#datatable").data("isEntitySelectionAllowed", true); - - $notificationContainer = $("#notification-container").notify(); - - graphContainer = $("#graphContainer"); - tableDiv = $('#paginatedTable'); - - //temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, jsonString); - - /* - * When the intra-entity parameters are clicked, - * update the status accordingly. - */ - - $("select.comparisonValues").change(function(){ - - var selectedValue = $("select.comparisonValues option:selected").val(); - - var selectedParameter; - - $.each(COMPARISON_PARAMETERS_INFO, function(index, parameter) { - - if (parameter.value === selectedValue) { - selectedParameter = parameter; - window.location = parameter.viewLink; - } - - }); - - //$("#body").empty().html("
Loading " + selectedValue + "  
"); - - /* - * This piece of code is not executed at all because the redirect happens before there is a chance - * to render the below contents. - * */ - - /* - - $("#comparisonParameter").text("Total Number of " + selectedValue); - $('#yaxislabel').html("Number of " + selectedValue).mbFlipText(false); - $('#yaxislabel').css("color", "#595B5B"); - $('#comparisonHeader').html(selectedValue).css('font-weight', 'bold'); - - - */ - - }); - -}); - -//click event handler for clear button -$("a.clear-selected-entities").live('click', function(){ - clearRenderedObjects(); -}); - -$("input[type=checkbox].easyDeselectCheckbox").live('click', function(){ - - var checkbox = $(this); - var checkboxValue = $(this).attr("value"); - var linkedCheckbox = labelToCheckedEntities[checkboxValue]; - var entityToBeRemoved = labelToEntityRecord[checkboxValue]; - - if(!checkbox.is(':checked')){ - //console.log("Easy deselect checkbox is unclicked!"); - updateRowHighlighter(linkedCheckbox); - removeUsedColor(entityToBeRemoved); - removeEntityUnChecked(renderedObjects, entityToBeRemoved); - removeLegendRow(linkedCheckbox); - removeCheckBoxFromGlobalSet(linkedCheckbox); - $(linkedCheckbox).attr('checked', false); - checkIfColorLimitIsReached(); - displayLineGraphs(); - updateCounter(); - } -}); - - -$(".disabled-checkbox-event-receiver").live("click", function () { - - if ($(this).next().is(':disabled')) { - - createNotification("warning-notification", { - title: 'Error', - text: 'A Maximum 10 entities can be compared. Please remove some & try again.' - }, { - custom: true, - expires: false - }); - - } - -}); - -function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) { - - removeUsedColor(entity); - removeEntityUnChecked(renderedObjects, entity); - removeLegendRow(checkbox); - removeCheckBoxFromGlobalSet(checkbox); - - checkbox.closest("tr").removeClass('datatablerowhighlight'); - -} - -function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) { - - getNextFreeColor(entity); - - //Generate the bar, checkbox and label for the legend. - createLegendRow(entity, $("#bottom")); - - renderLineGraph(renderedObjects, entity); - labelToCheckedEntities[checkboxValue] = checkbox; - labelToCheckedEntities[checkboxValue].entity = entity; - -// console.log(labelToCheckedEntities[checkboxValue], entity); - - /* - * To highlight the rows belonging to selected entities. - * */ - checkbox.closest("tr").addClass('datatablerowhighlight'); - -} - -function performEntityCheckboxClickedRedrawActions() { - - setTickSizeOfAxes(); - checkIfColorLimitIsReached(); - displayLineGraphs(); - updateCounter(); - -} - -/* - * function to populate the labelToEntityRecord object with the - * values from the json file and - * dynamically generate checkboxes - */ -function loadData(jsonData, dataTableParams) { - - $.each(jsonData, function (index, val) { - setOfLabels.push(val.label); - labelToEntityRecord[val.label] = val; - }); - - prepareTableForDataTablePagination(jsonData, dataTableParams); - setEntityLevel(getEntityVisMode(jsonData)); - - entityCheckboxOperatedOnEventListener(); - -} - -function entityCheckboxOperatedOnEventListener() { - - /* - * When the elements in the paginated div - * are clicked this event handler is called - */ - $("input." + entityCheckboxSelectorDOMClass).live('click', function () { - - var checkbox = $(this); - var checkboxValue = $(this).attr("value"); - var entity = labelToEntityRecord[checkboxValue]; - - if (checkbox.is(':checked')) { - - performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox); - - } else { - - performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox); - - } - - performEntityCheckboxClickedRedrawActions(); - - }); - -} - -/* - * This method will setup the options for loading screen & then activate the - * loading screen. - * */ -function setupLoadingScreen(visContainerDIV) { - - $.blockUI.defaults.overlayCSS = { - backgroundColor: '#fff', - opacity: 1.0 - }; - - $.blockUI.defaults.css.width = '500px'; - $.blockUI.defaults.css.border = '0px'; - $.blockUI.defaults.css.top = '15%'; - - visContainerDIV.block({ - message: '

 Loading data for ' - + organizationLabel - + '

' - }); - -} - -/* - * 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, - graphBodyDIV, - 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(); - } - } - }); - -} - -temporalGraphProcessor = { - - initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) { - - this.dataTableParams = { - searchBarParentContainerDIVClass : "searchbar", - paginationContainerDIVClass : "paginatedtabs" - }; - - - /* - * initial display of the grid when the page loads - * */ - init(givenGraphContainer); - - /* - * render the temporal graph per the sent content. - * */ - loadData(jsonData, this.dataTableParams); - - /* - * 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(); - - }); - - } - +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +$(document).ready(function() { + + /* + * This will set intitial values of the constants present in constants.js + * */ + initConstants(); + /* 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 + more & this variable will be set to false. */ + $("#datatable").data("isEntitySelectionAllowed", true); + + $notificationContainer = $("#notification-container").notify(); + + graphContainer = $("#graphContainer"); + tableDiv = $('#paginatedTable'); + + //temporalGraphProcessor.initiateTemporalGraphRenderProcess(graphContainer, jsonString); + + /* + * When the intra-entity parameters are clicked, + * update the status accordingly. + */ + + $("select.comparisonValues").change(function(){ + + var selectedValue = $("select.comparisonValues option:selected").val(); + + var selectedParameter; + + $.each(COMPARISON_PARAMETERS_INFO, function(index, parameter) { + + if (parameter.value === selectedValue) { + selectedParameter = parameter; + window.location = parameter.viewLink; + } + + }); + + //$("#body").empty().html("
Loading " + selectedValue + "  
"); + + /* + * This piece of code is not executed at all because the redirect happens before there is a chance + * to render the below contents. + * */ + + /* + + $("#comparisonParameter").text("Total Number of " + selectedValue); + $('#yaxislabel').html("Number of " + selectedValue).mbFlipText(false); + $('#yaxislabel').css("color", "#595B5B"); + $('#comparisonHeader').html(selectedValue).css('font-weight', 'bold'); + + + */ + + }); + +}); + +//click event handler for clear button +$("a.clear-selected-entities").live('click', function(){ + clearRenderedObjects(); +}); + +$("input[type=checkbox].easyDeselectCheckbox").live('click', function(){ + + var checkbox = $(this); + var checkboxValue = $(this).attr("value"); + var linkedCheckbox = labelToCheckedEntities[checkboxValue]; + var entityToBeRemoved = labelToEntityRecord[checkboxValue]; + + if(!checkbox.is(':checked')){ + //console.log("Easy deselect checkbox is unclicked!"); + updateRowHighlighter(linkedCheckbox); + removeUsedColor(entityToBeRemoved); + removeEntityUnChecked(renderedObjects, entityToBeRemoved); + removeLegendRow(linkedCheckbox); + removeCheckBoxFromGlobalSet(linkedCheckbox); + $(linkedCheckbox).attr('checked', false); + checkIfColorLimitIsReached(); + displayLineGraphs(); + updateCounter(); + } +}); + + +$(".disabled-checkbox-event-receiver").live("click", function () { + + if ($(this).next().is(':disabled')) { + + createNotification("warning-notification", { + title: 'Error', + text: 'A Maximum 10 entities can be compared. Please remove some & try again.' + }, { + custom: true, + expires: false + }); + + } + +}); + +function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) { + + removeUsedColor(entity); + removeEntityUnChecked(renderedObjects, entity); + removeLegendRow(checkbox); + removeCheckBoxFromGlobalSet(checkbox); + + checkbox.closest("tr").removeClass('datatablerowhighlight'); + +} + +function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) { + + getNextFreeColor(entity); + + //Generate the bar, checkbox and label for the legend. + createLegendRow(entity, $("#bottom")); + + renderLineGraph(renderedObjects, entity); + labelToCheckedEntities[checkboxValue] = checkbox; + labelToCheckedEntities[checkboxValue].entity = entity; + +// console.log(labelToCheckedEntities[checkboxValue], entity); + + /* + * To highlight the rows belonging to selected entities. + * */ + checkbox.closest("tr").addClass('datatablerowhighlight'); + +} + +function performEntityCheckboxClickedRedrawActions() { + + setTickSizeOfAxes(); + checkIfColorLimitIsReached(); + displayLineGraphs(); + updateCounter(); + +} + +/* + * function to populate the labelToEntityRecord object with the + * values from the json file and + * dynamically generate checkboxes + */ +function loadData(jsonData, dataTableParams) { + + $.each(jsonData, function (index, val) { + setOfLabels.push(val.label); + labelToEntityRecord[val.label] = val; + if (val.lastCachedAtDateTime) { + lastCachedAtDateTimes[lastCachedAtDateTimes.length] = val.lastCachedAtDateTime; + } + }); + + prepareTableForDataTablePagination(jsonData, dataTableParams); + setEntityLevel(getEntityVisMode(jsonData)); + + entityCheckboxOperatedOnEventListener(); + +} + +function entityCheckboxOperatedOnEventListener() { + + /* + * When the elements in the paginated div + * are clicked this event handler is called + */ + $("input." + entityCheckboxSelectorDOMClass).live('click', function () { + + var checkbox = $(this); + var checkboxValue = $(this).attr("value"); + var entity = labelToEntityRecord[checkboxValue]; + + if (checkbox.is(':checked')) { + + performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox); + + } else { + + performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox); + + } + + performEntityCheckboxClickedRedrawActions(); + + }); + +} + +/* + * This method will setup the options for loading screen & then activate the + * loading screen. + * */ +function setupLoadingScreen(visContainerDIV) { + + $.blockUI.defaults.overlayCSS = { + backgroundColor: '#fff', + opacity: 1.0 + }; + + $.blockUI.defaults.css.width = '500px'; + $.blockUI.defaults.css.border = '0px'; + $.blockUI.defaults.css.top = '15%'; + + visContainerDIV.block({ + message: '

 Loading data for ' + + organizationLabel + + '

' + }); + +} + +/* + * 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, + graphBodyDIV, + 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(); + } + } + }); + +} + +function parseXSDateTime(rawDateTimeString) { + + var dateTime = rawDateTimeString.split("T", 2); + var date = dateTime[0].split("-"); + var time = dateTime[1].split(":"); + + return new Date(date[0], date[1], date[2], time[0], time[1], 0); +} + +temporalGraphProcessor = { + + initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) { + + this.dataTableParams = { + searchBarParentContainerDIVClass : "searchbar", + paginationContainerDIVClass : "paginatedtabs" + }; + + + /* + * initial display of the grid when the page loads + * */ + init(givenGraphContainer); + + /* + * render the temporal graph per the sent content. + * */ + loadData(jsonData, this.dataTableParams); + + lastCachedAtDateTimes.sort(function(a, b) { + var dateA = parseXSDateTime(a); + var dateB = parseXSDateTime(b); + return dateA-dateB; //sort by date ascending + }); + + /* + * 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])); + } + + } + } \ No newline at end of file diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl index c5ae99c8..6f9b89d3 100644 --- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl +++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonBody.ftl @@ -2,7 +2,8 @@
-

${organizationLabel}

+

${organizationLabel}  + information icon

diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalGrantVisualizationRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalGrantVisualizationRequestHandler.java index adde2afb..a3fd3378 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalGrantVisualizationRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalGrantVisualizationRequestHandler.java @@ -318,6 +318,8 @@ public class TemporalGrantVisualizationRequestHandler implements entityJson.setEntityURI(subentity.getIndividualURI()); + entityJson.setLastCachedAtDateTime(subentity.getLastCachedAtDateTime()); + if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) { entityJson.setVisMode("PERSON"); } else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalPublicationVisualizationRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalPublicationVisualizationRequestHandler.java index b478310b..034ea98b 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalPublicationVisualizationRequestHandler.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/cached/TemporalPublicationVisualizationRequestHandler.java @@ -313,6 +313,8 @@ public class TemporalPublicationVisualizationRequestHandler implements entityJson.setEntityURI(subentity.getIndividualURI()); + entityJson.setLastCachedAtDateTime(subentity.getLastCachedAtDateTime()); + if (subentity.getEntityClass().equals(VOConstants.EntityClassType.PERSON)) { entityJson.setVisMode("PERSON"); } else if (subentity.getEntityClass().equals(VOConstants.EntityClassType.ORGANIZATION)) { diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/JsonObject.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/JsonObject.java index 8f6b123d..c6e0f922 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/JsonObject.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/JsonObject.java @@ -16,6 +16,7 @@ import java.util.Set; public class JsonObject { private String label; + private String lastCachedAtDateTime; private List> data = new ArrayList>(); private String entityURI; private String visMode; @@ -80,9 +81,11 @@ public class JsonObject { this.data = yearToPublicationCount; } - public void setYearToGrantCount(List> yearGrantCount) { - - + public void setLastCachedAtDateTime(String lastCachedAtDateTime) { + this.lastCachedAtDateTime = lastCachedAtDateTime; + } + + public String getLastCachedAtDateTime() { + return lastCachedAtDateTime; } - } diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SubEntity.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SubEntity.java index c96aa85a..7cd3438d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SubEntity.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/valueobjects/SubEntity.java @@ -10,13 +10,14 @@ import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants; /** * @author bkoniden (Deepak Konidena) * 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 { private Set activities = new HashSet(); private Set entityTypes = new HashSet(); private VOConstants.EntityClassType entityClass; + private String lastCachedAtDateTime = null; public SubEntity(String individualURI) { super(individualURI); @@ -59,4 +60,12 @@ public class SubEntity extends Individual { return entityClass; } + public void setLastCachedAtDateTime(String lastCachedAtDateTime) { + this.lastCachedAtDateTime = lastCachedAtDateTime; + } + + public String getLastCachedAtDateTime() { + return lastCachedAtDateTime; + } + } diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/SelectOnModelUtilities.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/SelectOnModelUtilities.java index 4d2e74f4..e982bebd 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/SelectOnModelUtilities.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/SelectOnModelUtilities.java @@ -228,17 +228,17 @@ public class SelectOnModelUtilities { "", subOrganizationPublicationsModel); - subOrganization.addActivities(getPublicationForEntity( - subOrganizationPublicationsQuery.getQueryResult(), - allDocumentURIToVOs)); + getPublicationForEntity(subOrganizationPublicationsQuery.getQueryResult(), + subOrganization, + allDocumentURIToVOs); } return allDocumentURIToVOs; } - private static Collection getPublicationForEntity( + private static void getPublicationForEntity( ResultSet queryResult, - Map allDocumentURIToVOs) { + SubEntity subEntity, Map allDocumentURIToVOs) { Set currentEntityPublications = new HashSet(); @@ -246,6 +246,14 @@ public class SelectOnModelUtilities { 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); Activity biboDocument; @@ -263,17 +271,15 @@ public class SelectOnModelUtilities { biboDocument.setActivityDate(publicationDateNode.toString()); } } - currentEntityPublications.add(biboDocument); - } - - return currentEntityPublications; + subEntity.addActivities(currentEntityPublications); } - private static Collection getGrantForEntity( + private static void getGrantForEntity( ResultSet queryResult, + SubEntity subEntity, Map allGrantURIToVO) { Set currentEntityGrants = new HashSet(); @@ -282,6 +288,14 @@ public class SelectOnModelUtilities { 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); Activity coreGrant; @@ -307,7 +321,8 @@ public class SelectOnModelUtilities { } currentEntityGrants.add(coreGrant); } - return currentEntityGrants; + + subEntity.addActivities(currentEntityGrants); } public static Map getGrantsForAllSubOrganizations( @@ -330,9 +345,11 @@ 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 = "" + "{" + + " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasInvestigatorWithGrant ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -342,6 +359,7 @@ public class SelectOnModelUtilities { + "}" + "UNION" + "{" + + " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hasPIWithGrant ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -351,6 +369,7 @@ public class SelectOnModelUtilities { + "}" + "UNION" + "{" + + " <" + subOrganization.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + subOrganization.getIndividualURI() + "> vivosocnet:hascoPIWithGrant ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -366,9 +385,15 @@ public class SelectOnModelUtilities { "", subOrganizationGrantsModel); - subOrganization.addActivities(getGrantForEntity( - subOrganizationGrantsQuery.getQueryResult(), - allGrantURIToVO)); +// 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); } return allGrantURIToVO; @@ -378,36 +403,25 @@ public class SelectOnModelUtilities { Dataset dataset, Collection people) throws MalformedQueryParametersException { Map allGrantURIToVOs = new HashMap(); - - 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 .getOrConstructModel( null, PeopleToGrantsModelConstructor.MODEL_TYPE, dataset); - System.out.print("\t construct took " + (System.currentTimeMillis() - before)); - for (SubEntity person : people) { - System.out.println("constructing grants for " + person.getIndividualLabel() + " :: " + person.getIndividualURI()); - - before = System.currentTimeMillis(); - Map fieldLabelToOutputFieldLabel = new HashMap(); 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 = "" + "{" + + " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsAnInvestigator ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -417,6 +431,7 @@ public class SelectOnModelUtilities { + "}" + "UNION" + "{" + + " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsPI ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -426,6 +441,7 @@ public class SelectOnModelUtilities { + "}" + "UNION" + "{" + + " <" + person.getIndividualURI() + "> vivosocnet:lastCachedAt ?lastCachedAtDateTime . " + " <" + person.getIndividualURI() + "> vivosocnet:hasGrantAsCoPI ?grant . " + " ?grant rdfs:label ?grantLabel . " + " OPTIONAL { " @@ -441,12 +457,7 @@ public class SelectOnModelUtilities { "", peopleGrantsModel); - person.addActivities(getGrantForEntity( - personGrantsQuery.getQueryResult(), - allGrantURIToVOs)); - - System.out.println("\t || select took " + (System.currentTimeMillis() - before)); - + getGrantForEntity(personGrantsQuery.getQueryResult(), person, allGrantURIToVOs); } return allGrantURIToVOs; } @@ -464,14 +475,16 @@ public class SelectOnModelUtilities { for (SubEntity person : people) { - System.out.println("getting publications for " + person.getIndividualLabel()); +// System.out.println("getting publications for " + person.getIndividualLabel()); Map fieldLabelToOutputFieldLabel = new HashMap(); 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 { " @@ -485,9 +498,9 @@ public class SelectOnModelUtilities { "", peoplePublicationsModel); - person.addActivities(getPublicationForEntity( - personPublicationsQuery.getQueryResult(), - allDocumentURIToVOs)); + getPublicationForEntity(personPublicationsQuery.getQueryResult(), + person, + allDocumentURIToVOs); } return allDocumentURIToVOs; diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/UtilityFunctions.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/UtilityFunctions.java index 3125cba8..3c42bb2d 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/UtilityFunctions.java +++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/UtilityFunctions.java @@ -9,8 +9,6 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; @@ -21,13 +19,11 @@ import org.joda.time.format.DateTimeFormatter; import com.google.gson.Gson; 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.freemarker.UrlBuilder; 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.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.visualization.constants.VOConstants; 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. * */ - String parsedGrantYear = defaultYearInCaseOfError; + String parsedInputYear = defaultYearInCaseOfError; if (inputDate != null) { @@ -205,7 +201,7 @@ public class UtilityFunctions { } } - return parsedGrantYear; + return parsedInputYear; } public static String getCSVDownloadURL(String individualURI, String visType, String visMode) {