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 entityLevel;
var lastCachedAtDateTimes;
//options for Flot
var FlotOptions;
@ -68,7 +70,7 @@ function initConstants() {
setOfLabels = [];
labelToCheckedEntities = {};
stopWordsToCount = {};
lastCachedAtDateTimes = [];
//options for Flot
FlotOptions = {
legend : {

View file

@ -152,6 +152,9 @@ 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);
@ -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 = {
initiateTemporalGraphRenderProcess: function(givenGraphContainer, jsonData) {
@ -264,6 +276,12 @@ temporalGraphProcessor = {
* */
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.
*/
@ -282,7 +300,13 @@ temporalGraphProcessor = {
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">
<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="leftUpper">

View file

@ -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)) {

View file

@ -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)) {

View file

@ -16,6 +16,7 @@ import java.util.Set;
public class JsonObject {
private String label;
private String lastCachedAtDateTime;
private List<List<Integer>> data = new ArrayList<List<Integer>>();
private String entityURI;
private String visMode;
@ -80,9 +81,11 @@ public class JsonObject {
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)
* 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<Activity> activities = new HashSet<Activity>();
private Set<String> entityTypes = new HashSet<String>();
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;
}
}

View file

@ -228,17 +228,17 @@ public class SelectOnModelUtilities {
"",
subOrganizationPublicationsModel);
subOrganization.addActivities(getPublicationForEntity(
subOrganizationPublicationsQuery.getQueryResult(),
allDocumentURIToVOs));
getPublicationForEntity(subOrganizationPublicationsQuery.getQueryResult(),
subOrganization,
allDocumentURIToVOs);
}
return allDocumentURIToVOs;
}
private static Collection<Activity> getPublicationForEntity(
private static void getPublicationForEntity(
ResultSet queryResult,
Map<String, Activity> allDocumentURIToVOs) {
SubEntity subEntity, Map<String, Activity> allDocumentURIToVOs) {
Set<Activity> currentEntityPublications = new HashSet<Activity>();
@ -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<Activity> getGrantForEntity(
private static void getGrantForEntity(
ResultSet queryResult,
SubEntity subEntity,
Map<String, Activity> allGrantURIToVO) {
Set<Activity> currentEntityGrants = new HashSet<Activity>();
@ -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<String, Activity> 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;
@ -379,35 +404,24 @@ public class SelectOnModelUtilities {
throws MalformedQueryParametersException {
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
.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<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
fieldLabelToOutputFieldLabel.put("grant", QueryFieldLabels.GRANT_URL);
fieldLabelToOutputFieldLabel.put("grantLabel", QueryFieldLabels.GRANT_LABEL);
fieldLabelToOutputFieldLabel.put("grantStartDate", QueryFieldLabels.GRANT_START_DATE);
fieldLabelToOutputFieldLabel.put("roleStartDate", QueryFieldLabels.ROLE_START_DATE);
fieldLabelToOutputFieldLabel.put("lastCachedAtDateTime", QueryFieldLabels.LAST_CACHED_AT_DATETIME);
String whereClause = ""
+ "{"
+ " <" + 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<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
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;

View file

@ -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) {