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

@ -152,6 +152,9 @@ 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); prepareTableForDataTablePagination(jsonData, dataTableParams);
@ -244,6 +247,15 @@ function getTemporalGraphData(temporalGraphDataURL,
} }
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 = { temporalGraphProcessor = {
initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) { initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) {
@ -264,6 +276,12 @@ temporalGraphProcessor = {
* */ * */
loadData(jsonData, this.dataTableParams); 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. * This will make sure that top 3 entities are selected by default when the page loads.
*/ */
@ -284,6 +302,12 @@ temporalGraphProcessor = {
}); });
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;
@ -379,35 +404,24 @@ public class SelectOnModelUtilities {
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) {