diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonErrorCommonBody.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonErrorCommonBody.ftl
index 36194a1b..e5d9db32 100644
--- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonErrorCommonBody.ftl
+++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonErrorCommonBody.ftl
@@ -5,11 +5,15 @@
<#assign organizationVivoProfileURL = "${urls.base}/individual?uri=${organizationURI?url}">
<#assign temporalGraphURL = '${urls.base}${standardVisualizationURLRoot}?vis=${otherVisType}&uri=${organizationURI}&labelField=label'>
+
+
-
This organization has neither sub-organizations nor people with ${textForCurrentEntityComparisonType} in the system. Please visit the full ${organizationLabel} profile page for a more complete overview.
+
This organization has neither sub-organizations nor people with ${textForCurrentEntityComparisonType} in the system. Please visit the full ${organizationLabel} profile page for a more complete overview.
+
+
\ No newline at end of file
diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnGrantsStandalone.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnGrantsStandalone.ftl
index 027630a8..e699811e 100644
--- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnGrantsStandalone.ftl
+++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnGrantsStandalone.ftl
@@ -8,17 +8,61 @@ corresponding changes in the included Templates. -->
<#include "entityComparisonSetup.ftl">
<#assign temporalGraphDownloadFileLink = '${temporalGraphDownloadCSVCommonURL}&vis=entity_grant_count'>
+<#assign temporalGraphDataURL = "${urls.base}${dataVisualizationURLRoot}?vis=entity_grant_count&uri=${organizationURI}&vis_mode=json">
<#-- variables passed from server-side code -->
<#assign currentParameterObject = grantParameter>
-<#include "entityComparisonBody.ftl">
\ No newline at end of file
+<#include "entityComparisonBody.ftl">
+
+<#--
+Right now we include the error message by default becuae currently I could not devise any more smarted solution. By default
+the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
+via JavaScript.
+-->
+<#include "entityGrantComparisonError.ftl">
\ No newline at end of file
diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnPublicationsStandalone.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnPublicationsStandalone.ftl
index 403138ed..c23ec40f 100644
--- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnPublicationsStandalone.ftl
+++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonOnPublicationsStandalone.ftl
@@ -8,17 +8,69 @@ corresponding changes in the included Templates. -->
<#include "entityComparisonSetup.ftl">
<#assign temporalGraphDownloadFileLink = '${temporalGraphDownloadCSVCommonURL}&vis=entity_comparison'>
+<#assign temporalGraphDataURL = "${urls.base}${dataVisualizationURLRoot}?vis=entity_comparison&uri=${organizationURI}&vis_mode=json">
<#-- variables passed from server-side code -->
<#assign currentParameterObject = publicationParameter>
-<#include "entityComparisonBody.ftl">
\ No newline at end of file
+
+
+<#include "entityComparisonBody.ftl">
+
+<#--
+Right now we include the error message by default becuae currently I could not devise any more smarted solution. By default
+the CSS of the #error-container is display:none; so it will be hidden unless explicitly commanded to be shown which we do in
+via JavaScript.
+-->
+<#include "entityPublicationComparisonError.ftl">
+
+
\ No newline at end of file
diff --git a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonSetup.ftl b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonSetup.ftl
index 36851711..0d9735ec 100644
--- a/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonSetup.ftl
+++ b/productMods/templates/freemarker/visualization/entitycomparison/entityComparisonSetup.ftl
@@ -5,8 +5,6 @@
<#assign dataVisualizationURLRoot ="/visualizationData">
<#assign organizationURI ="${organizationURI?url}">
-<#assign jsonContent ="${jsonContent}">
-<#assign organizationLabel = "${organizationLabel}">
<#assign organizationVivoProfileURL = "${urls.base}/individual?uri=${organizationURI}">
<#assign subOrganizationVivoProfileURL = "${urls.base}/individual?">
@@ -49,6 +47,7 @@ we will use rev 293 (dev build version) of the flot & excanvas files.
<#assign fliptext = 'js/visualization/entitycomparison/jquery_plugins/fliptext/jquery.mb.flipText.js'>
<#assign jqueryNotify = 'js/jquery_plugins/jquery.notify.min.js'>
+<#assign jqueryBlockUI = 'js/jquery_plugins/jquery.blockUI.min.js'>
<#assign jqueryUI = 'js/jquery-ui/js/jquery-ui-1.8.4.custom.min.js'>
<#assign datatable = 'js/jquery_plugins/jquery.dataTables.min.js'>
<#assign entityComparisonUtils = 'js/visualization/entitycomparison/util.js'>
@@ -56,9 +55,11 @@ we will use rev 293 (dev build version) of the flot & excanvas files.
<#assign guiEventManager = 'js/visualization/entitycomparison/gui-event-manager.js'>
+
${scripts.add(flot)}
${scripts.add(fliptext)}
+${scripts.add(jqueryBlockUI)}
${scripts.add(jqueryUI)}
${scripts.add(datatable)}
${scripts.add(entityComparisonUtils)}
@@ -90,14 +91,16 @@ var contextPath = "${urls.base}";
var temporalGraphSmallIcon = "${temporalGraphSmallIcon}";
var subOrganizationVivoProfileURL = "${subOrganizationVivoProfileURL}";
-var jsonString = '${jsonContent}';
+var jsonString = '${jsonContent!}';
var organizationLabel = '${organizationLabel}';
var organizationVIVOProfileURL = "${organizationVivoProfileURL}";
-var loadingImageLink = contextPath + "/images/visualization/ajax-loader.gif";
+var loadingImageLink = contextPath + "/images/visualization/ajax-loader-indicator.gif";
var entityCheckboxSelectorDOMClass = "${entityCheckboxSelectorDOMClass}";
+var temporalGraphProcessor;
+
/*
This has to be declared before making a call to GUI event manager JS.
*/
@@ -119,4 +122,4 @@ var COMPARISON_PARAMETERS_INFO = {
-${scripts.add(guiEventManager)}
\ No newline at end of file
+${headScripts.add(guiEventManager)}
\ No newline at end of file
diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/freemarker/VisualizationFrameworkConstants.java b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/freemarker/VisualizationFrameworkConstants.java
index 1b089de8..0910598a 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/freemarker/VisualizationFrameworkConstants.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/controller/visualization/freemarker/VisualizationFrameworkConstants.java
@@ -90,7 +90,6 @@ public class VisualizationFrameworkConstants {
public static final String SCHOOL_COMPARISON_VIS_MODE = "SCHOOL";
public static final String DEPARTMENT_COMPARISON_VIS_MODE = "DEPARTMENT";
public static final String HIGHEST_LEVEL_ORGANIZATION_VIS_MODE = "HIGHEST_LEVEL_ORGANIZATION";
-
/*
* These values represent possible visualizations provided as values to the "vis" url key.
@@ -105,5 +104,9 @@ public class VisualizationFrameworkConstants {
public static final String ENTITY_COMPARISON_VIS = "entity_comparison";
public static final String CO_PI_VIS = "coprincipalinvestigator";
-
+
+ /*
+ * These values represent possible vis-modes for temporal graph vis
+ * */
+ public static final String TEMPORAL_GRAPH_JSON_DATA_VIS_MODE = "json";
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipRequestHandler.java
index 42d7cc9b..7cb30a4e 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipRequestHandler.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coauthorship/CoAuthorshipRequestHandler.java
@@ -18,8 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
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.VisualizationFrameworkConstants;
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.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.CoAuthorshipData;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Node;
@@ -133,28 +133,40 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
- private String getCoauthorsListCSVContent(Map
coAuthorsToCount) {
+ private String getCoauthorsListCSVContent(CoAuthorshipData coAuthorshipData) {
StringBuilder csvFileContent = new StringBuilder();
- csvFileContent.append("Year, Count\n");
+ csvFileContent.append("Co-author, Count\n");
- for (Entry currentEntry : coAuthorsToCount.entrySet()) {
- csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
+ //for (Entry currentEntry : coAuthorsToCount.entrySet()) {
+ for (Node currNode : coAuthorshipData.getNodes()) {
+
+ /*
+ * We have already printed the Ego Node info.
+ * */
+ if (currNode != coAuthorshipData.getEgoNode()) {
+
+
+ csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getNodeName()));
csvFileContent.append(",");
- csvFileContent.append(currentEntry.getValue());
+ csvFileContent.append(currNode.getNumOfAuthoredWorks());
csvFileContent.append("\n");
+
+ }
+
+
}
return csvFileContent.toString();
-
+
}
private String getCoauthorsPerYearCSVContent(Map> yearToCoauthors) {
StringBuilder csvFileContent = new StringBuilder();
- csvFileContent.append("Year, Count, Co-Author(s)\n");
+ csvFileContent.append("Year, Count, Co-author(s)\n");
for (Entry> currentEntry : yearToCoauthors.entrySet()) {
csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
@@ -225,15 +237,11 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
private Map prepareCoauthorsListDataResponse(CoAuthorshipData coAuthorshipData) {
String outputFileName = "";
- Map coAuthorsToCount = new TreeMap();
-
+
if (coAuthorshipData.getNodes() != null && coAuthorshipData.getNodes().size() > 0) {
outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoNode().getNodeName())
+ "_co-authors" + ".csv";
-
- coAuthorsToCount = getCoAuthorsList(coAuthorshipData);
-
} else {
outputFileName = "no_co-authors" + ".csv";
}
@@ -244,29 +252,11 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
- getCoauthorsListCSVContent(coAuthorsToCount));
+ getCoauthorsListCSVContent(coAuthorshipData));
return fileData;
}
- private Map getCoAuthorsList(CoAuthorshipData coAuthorsipVO) {
-
- Map coAuthorsToCount = new TreeMap();
-
- for (Node currNode : coAuthorsipVO.getNodes()) {
-
- /*
- * We have already printed the Ego Node info.
- * */
- if (currNode != coAuthorsipVO.getEgoNode()) {
-
- coAuthorsToCount.put(currNode.getNodeName(), currNode.getNumOfAuthoredWorks());
-
- }
- }
- return coAuthorsToCount;
- }
-
/**
* Provides a response when graphml formatted co-authorship network is requested, typically by
* the flash vis.
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIGrantCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIGrantCountRequestHandler.java
index 7e73d080..2b635e2d 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIGrantCountRequestHandler.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/coprincipalinvestigator/CoPIGrantCountRequestHandler.java
@@ -153,21 +153,30 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
}
- private String getCoPIsListCSVContent(Map coPIsToCount) {
+ private String getCoPIsListCSVContent(CoPIData coPIData) {
StringBuilder csvFileContent = new StringBuilder();
- csvFileContent.append("Year, Count\n");
+ csvFileContent.append("Co-investigator, Count\n");
- for (Entry currentEntry : coPIsToCount.entrySet()) {
- csvFileContent.append(StringEscapeUtils.escapeCsv(currentEntry.getKey()));
+// for (Entry currentEntry : coPIData.entrySet()) {
+ for (CoPINode currNode : coPIData.getNodes()) {
+
+ /*
+ * We have already printed the Ego Node info.
+ * */
+ if (currNode != coPIData.getEgoNode()) {
+
+ csvFileContent.append(StringEscapeUtils.escapeCsv(currNode.getNodeName()));
csvFileContent.append(",");
- csvFileContent.append(currentEntry.getValue());
+ csvFileContent.append(currNode.getNumberOfInvestigatedGrants());
csvFileContent.append("\n");
+
+ }
+
}
return csvFileContent.toString();
-
}
@@ -175,7 +184,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
StringBuilder csvFileContent = new StringBuilder();
- csvFileContent.append("Year, Count, Co-PI(s)\n");
+ csvFileContent.append("Year, Count, Co-investigator(s)\n");
for (Map.Entry> currentEntry : yearToCoPI.entrySet()) {
@@ -247,15 +256,12 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
private Map prepareCoPIsListDataResponse(CoPIData coPIData) {
String outputFileName = "";
- Map coPIsToCount = new TreeMap();
if (coPIData.getNodes() != null && coPIData.getNodes().size() > 0) {
outputFileName = UtilityFunctions.slugify(coPIData.getEgoNode().getNodeName())
+ "_co-investigators" + ".csv";
- coPIsToCount = getCoPIsList(coPIData);
-
} else {
outputFileName = "no_co-investigators" + ".csv";
}
@@ -266,7 +272,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
- getCoPIsListCSVContent(coPIsToCount));
+ getCoPIsListCSVContent(coPIData));
return fileData;
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java
index 3a9cfd4a..354fe6be 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityComparisonUtilityFunctions.java
@@ -5,14 +5,21 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
+import com.hp.hpl.jena.iri.IRI;
+import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
+import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
+import edu.cornell.mannlib.vitro.webapp.beans.Individual;
+import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
+import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.GenericQueryMap;
@@ -107,4 +114,47 @@ public class EntityComparisonUtilityFunctions {
return subOrganizationTypesResult;
}
+ public static String getEntityLabelFromDAO(VitroRequest vitroRequest,
+ String entityURI) {
+
+ IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
+ Individual ind = iDao.getIndividualByURI(entityURI);
+
+ String organizationLabel = "Unknown Organization";
+
+ if (ind != null) {
+ organizationLabel = ind.getName();
+ }
+ return organizationLabel;
+ }
+
+ public static String getStaffProvidedOrComputedHighestLevelOrganization(Log log,
+ Dataset Dataset)
+ throws MalformedQueryParametersException {
+
+ String finalHighestLevelOrganizationURI = "";
+
+ String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
+
+ /*
+ * First checking if the staff has provided highest level organization in deploy.properties
+ * if so use to temporal graph vis.
+ */
+ if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
+
+ /*
+ * To test for the validity of the URI submitted.
+ */
+ IRIFactory iRIFactory = IRIFactory.jenaImplementation();
+ IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
+
+ if (iri.hasViolation(false)) {
+ finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log, Dataset);
+ } else {
+ finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
+ }
+ }
+ return finalHighestLevelOrganizationURI;
+ }
+
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java
index c62c3c37..9700c5b1 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountConstructQueryRunner.java
@@ -67,10 +67,7 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
- + "?Document rdfs:label ?DocumentLabel . "
- + "?Document core:dateTimeValue ?dateTimeValue . "
- + "?dateTimeValue core:dateTime ?publicationDate . "
- + "?Document core:year ?publicationYearUsing_1_1_property "
+ + "?Document rdfs:label ?DocumentLabel "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
@@ -80,18 +77,8 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
- + "?Document rdfs:label ?DocumentLabel "
-
- + "{"
- + "?Document core:dateTimeValue ?dateTimeValue . "
- + "?dateTimeValue core:dateTime ?publicationDate "
- + "}"
- + "UNION "
- + "{"
- + "?Document core:year ?publicationYearUsing_1_1_property "
- + "}"
-
+ + "?Document rdf:type bibo:Document . "
+ + "?Document rdfs:label ?DocumentLabel "
+ "}" ;
@@ -110,10 +97,7 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
+ "?Document rdf:type bibo:Document . "
- + "?Document rdfs:label ?DocumentLabel . "
- + "?Document core:dateTimeValue ?dateTimeValue . "
- + "?dateTimeValue core:dateTime ?publicationDate . "
- + "?Document core:year ?publicationYearUsing_1_1_property ."
+ + "?Document rdfs:label ?DocumentLabel "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
@@ -121,18 +105,8 @@ public class EntityPublicationCountConstructQueryRunner {
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
- + "?Document rdfs:label ?DocumentLabel "
-
- + "{"
- + "?Document core:dateTimeValue ?dateTimeValue . "
- + "?dateTimeValue core:dateTime ?publicationDate "
- + "}"
- + "UNION "
- + "{"
- + "?Document core:year ?publicationYearUsing_1_1_property "
- + "}"
-
+ + "?Document rdf:type bibo:Document . "
+ + "?Document rdfs:label ?DocumentLabel "
+ "}" ;
@@ -140,90 +114,93 @@ public class EntityPublicationCountConstructQueryRunner {
}
-// private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
-//
-// String sparqlQuery =
-//
-// "CONSTRUCT { "
-// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
-// + "?subOrganization core:organizationForPosition ?Position . "
-// + "?Position core:positionForPerson ?Person . "
-// + "?Person core:authorInAuthorship ?Resource . "
-// + "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
-// + "?Document core:dateTimeValue ?dateTimeValue . "
-// + "?dateTimeValue core:dateTime ?publicationDate . "
-// + "?Document core:year ?publicationYearUsing_1_1_property "
-// +"}"
-// + "WHERE { "
-// + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
-// + "?subOrganization core:organizationForPosition ?Position . "
-// + "?Position core:positionForPerson ?Person . "
-// + "?Person core:authorInAuthorship ?Resource . "
-// + "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
-// + "{"
-// + "?Document core:dateTimeValue ?dateTimeValue . "
-// + "?dateTimeValue core:dateTime ?publicationDate "
-// + "}"
-// + "UNION "
-// + "{"
-// + "?Document core:year ?publicationYearUsing_1_1_property "
-// + "}"
-// + "}" ;
-//
-//
-// return sparqlQuery;
-//
-// }
+ private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
+
+ String sparqlQuery =
+
+ "CONSTRUCT { "
+ + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ + "?subOrganization core:organizationForPosition ?Position . "
+ + "?Position core:positionForPerson ?Person . "
+ + "?Person core:authorInAuthorship ?Resource . "
+ + "?Resource core:linkedInformationResource ?Document . "
+ + "?Document rdf:type bibo:Document . "
+ + "?Document core:dateTimeValue ?dateTimeValue . "
+ + "?dateTimeValue core:dateTime ?publicationDate . "
+ + "?Document core:year ?publicationYearUsing_1_1_property "
+ +"}"
+ + "WHERE { "
+ + "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ + "?subOrganization core:organizationForPosition ?Position . "
+ + "?Position core:positionForPerson ?Person . "
+ + "?Person core:authorInAuthorship ?Resource . "
+ + "?Resource core:linkedInformationResource ?Document . "
+ + "?Document rdf:type bibo:Document . "
+ + "{"
+ + "?Document core:dateTimeValue ?dateTimeValue . "
+ + "?dateTimeValue core:dateTime ?publicationDate "
+ + "}"
+ + "UNION "
+ + "{"
+ + "?Document core:year ?publicationYearUsing_1_1_property "
+ + "}"
+ + "}" ;
+
+
+ return sparqlQuery;
-// private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
-//
-// String sparqlQuery =
-//
-// "CONSTRUCT { "
-// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
-// + "?Position core:positionForPerson ?Person . "
-// + "?Person core:authorInAuthorship ?Resource . "
-// + "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
-// + "?Document core:dateTimeValue ?dateTimeValue . "
-// + "?dateTimeValue core:dateTime ?publicationDate . "
-// + "?Document core:year ?publicationYearUsing_1_1_property "
-// +"}"
-// + "WHERE { "
-// + "<"+queryURI+ "> core:organizationForPosition ?Position . "
-// + "?Position core:positionForPerson ?Person . "
-// + "?Person core:authorInAuthorship ?Resource . "
-// + "?Resource core:linkedInformationResource ?Document . "
-// + "?Document rdf:type bibo:Document . "
-// + "{"
-// + "?Document core:dateTimeValue ?dateTimeValue . "
-// + "?dateTimeValue core:dateTime ?publicationDate "
-// + "}"
-// + "UNION "
-// + "{"
-// + "?Document core:year ?publicationYearUsing_1_1_property "
-// + "}"
-// + "}" ;
-//
-//
-// return sparqlQuery;
-//
-// }
+ }
+
+ private String generateConstructQueryForDocumentDateTimeValue(String queryURI){
+
+ String sparqlQuery =
+
+ "CONSTRUCT { "
+ + "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ + "?Position core:positionForPerson ?Person . "
+ + "?Person core:authorInAuthorship ?Resource . "
+ + "?Resource core:linkedInformationResource ?Document . "
+ + "?Document rdf:type bibo:Document . "
+ + "?Document core:dateTimeValue ?dateTimeValue . "
+ + "?dateTimeValue core:dateTime ?publicationDate . "
+ + "?Document core:year ?publicationYearUsing_1_1_property "
+ +"}"
+ + "WHERE { "
+ + "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ + "?Position core:positionForPerson ?Person . "
+ + "?Person core:authorInAuthorship ?Resource . "
+ + "?Resource core:linkedInformationResource ?Document . "
+ + "?Document rdf:type bibo:Document . "
+ + "{"
+ + "?Document core:dateTimeValue ?dateTimeValue . "
+ + "?dateTimeValue core:dateTime ?publicationDate "
+ + "}"
+ + "UNION "
+ + "{"
+ + "?Document core:year ?publicationYearUsing_1_1_property "
+ + "}"
+ + "}" ;
+
+
+ return sparqlQuery;
+
+ }
private Model executeQuery(Set constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel();
+
+ before = System.currentTimeMillis();
for (String queryString : constructQueries) {
- before = System.currentTimeMillis();
+
log.debug("CONSTRUCT query string : " + queryString);
Query query = null;
try{
- query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
+ query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
+ //log.info("query: "+ queryString);
}catch(Throwable th){
log.error("Could not create CONSTRUCT SPARQL query for query " +
"string. " + th.getMessage());
@@ -232,16 +209,16 @@ public class EntityPublicationCountConstructQueryRunner {
QueryExecution qe = QueryExecutionFactory.create(
query, Dataset);
-
try {
qe.execConstruct(constructedModel);
} finally {
qe.close();
}
-
- after = System.currentTimeMillis();
- log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
+
}
+
+ after = System.currentTimeMillis();
+ log.info("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
// constructedModel.write(System.out);
return constructedModel;
}
@@ -281,8 +258,8 @@ public class EntityPublicationCountConstructQueryRunner {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI));
constructQueries.add(generateConstructQueryForPersons(this.egoURI));
-// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
-// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
+ constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
+ constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
}
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java
index 71237186..116212a2 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitycomparison/EntityPublicationCountRequestHandler.java
@@ -17,20 +17,16 @@ import org.apache.commons.logging.LogFactory;
import com.google.gson.Gson;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
-import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
-
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
-import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
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.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Entity;
@@ -40,6 +36,10 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryR
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.UtilityFunctions;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
+/**
+ * @author cdtank
+ *
+ */
public class EntityPublicationCountRequestHandler implements
VisualizationRequestHandler {
@@ -53,49 +53,15 @@ public class EntityPublicationCountRequestHandler implements
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
- if (StringUtils.isNotBlank(entityURI)){
-
- return getSubjectEntityAndGenerateResponse(vitroRequest, log,
- Dataset, entityURI);
- } else {
+ if (StringUtils.isBlank(entityURI)){
- String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
-
- /*
- * First checking if the staff has provided highest level organization in deploy.properties
- * if so use to temporal graph vis.
- */
- if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
-
- /*
- * To test for the validity of the URI submitted.
- */
- IRIFactory iRIFactory = IRIFactory.jenaImplementation();
- IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
-
- if (iri.hasViolation(false)) {
-
- String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
- log.error("Highest Level Organization URI provided is invalid " + errorMsg);
-
- } else {
-
- return getSubjectEntityAndGenerateResponse(vitroRequest,
- log, Dataset,
- staffProvidedHighestLevelOrganization);
- }
- }
-
- String highestLevelOrgURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log,
- Dataset);
-
- return getSubjectEntityAndGenerateResponse(vitroRequest, log,
- Dataset, highestLevelOrgURI);
+ entityURI = EntityComparisonUtilityFunctions
+ .getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset);
}
-
+ return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
}
-
- private ResponseValues getSubjectEntityAndGenerateResponse(
+
+ private Map getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
@@ -105,25 +71,33 @@ public class EntityPublicationCountRequestHandler implements
QueryRunner queryManager = new EntityPublicationCountQueryRunner(
subjectEntityURI, constructedModel, log);
-
Entity entity = queryManager.getQueryResult();
-
if (entity.getEntityLabel().equals("no-label")) {
- return prepareStandaloneErrorResponse(vitroRequest, subjectEntityURI);
+ return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
} else {
- return getSubEntityTypesAndRenderStandaloneResponse(
+ return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset,
subjectEntityURI, entity);
}
}
+
+ private Map prepareStandaloneDataErrorResponse(
+ VitroRequest vitroRequest, String subjectEntityURI) {
+ Map fileData = new HashMap();
+
+ fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
+ "application/octet-stream");
+ fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
+ return fileData;
+ }
- private ResponseValues getSubEntityTypesAndRenderStandaloneResponse(
+ private Map getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException {
@@ -131,10 +105,9 @@ public class EntityPublicationCountRequestHandler implements
Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, subjectEntityURI);
- return prepareStandaloneResponse(vitroRequest, entity, subjectEntityURI,
+ return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
subOrganizationTypesResult);
}
-
@Override
public Map generateDataVisualization(
@@ -143,20 +116,52 @@ public class EntityPublicationCountRequestHandler implements
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
+
+ /*
+ * This will provide the data in json format mainly used for standalone tmeporal vis.
+ * */
+ if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
+ .equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
+
+ if (StringUtils.isNotBlank(entityURI)){
- EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
- Model constructedModel = constructQueryRunner.getConstructedModel();
+ return getSubjectEntityAndGenerateDataResponse(
+ vitroRequest,
+ log,
+ Dataset,
+ entityURI);
+ } else {
+
+ return getSubjectEntityAndGenerateDataResponse(
+ vitroRequest,
+ log,
+ Dataset,
+ EntityComparisonUtilityFunctions
+ .getStaffProvidedOrComputedHighestLevelOrganization(
+ log,
+ Dataset));
+ }
+
+ } else {
+ /*
+ * This provides csv download files for the content in the tables.
+ * */
+
+ EntityPublicationCountConstructQueryRunner constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log);
+ Model constructedModel = constructQueryRunner.getConstructedModel();
+
+ QueryRunner queryManager = new EntityPublicationCountQueryRunner(
+ entityURI, constructedModel, log);
+
+ Entity entity = queryManager.getQueryResult();
+
+ Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
+ log, Dataset, entityURI);
+
+ return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
+
+ }
- QueryRunner queryManager = new EntityPublicationCountQueryRunner(
- entityURI, constructedModel, log);
-
- Entity entity = queryManager.getQueryResult();
-
- Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
- log, Dataset, entityURI);
-
- return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
-
}
@@ -199,41 +204,49 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
getEntityPublicationsPerYearCSVContent(subentities, subOrganizationTypesResult));
return fileData;
-}
+ }
- /**
- *
- * @param vreq
- * @param valueObjectContainer
- * @return
- */
- private TemplateResponseValues prepareStandaloneResponse(VitroRequest vreq,
- Entity entity, String entityURI, Map> subOrganizationTypesResult) {
+ private Map prepareStandaloneDataResponse(
+ VitroRequest vitroRequest,
+ Entity entity,
+ Set subentities,
+ Map> subOrganizationTypesResult) {
+
+ Map fileData = new HashMap();
+
+ fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
+ "application/octet-stream");
+ fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
+ writePublicationsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
+ return fileData;
+ }
+
+ private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
+ String entityURI) {
Portal portal = vreq.getPortal();
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
- String jsonContent = "";
- jsonContent = writePublicationsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
-
- String title = "";
-
- if (StringUtils.isNotBlank(entity.getEntityLabel())) {
- title = entity.getEntityLabel() + " - ";
- }
-
+ String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq,
+ entityURI);
+
Map body = new HashMap();
body.put("portalBean", portal);
- body.put("title", title + "Temporal Graph Visualization");
+ body.put("title", organizationLabel + " - Temporal Graph Visualization");
body.put("organizationURI", entityURI);
- body.put("organizationLabel", entity.getEntityLabel());
- body.put("jsonContent", jsonContent);
+ body.put("organizationLabel", organizationLabel);
return new TemplateResponseValues(standaloneTemplate, body);
-
}
+
-
+ /**
+ * @deprecated This method should not be called anymore although the templates being
+ * called by this method are still in use, so we should not get rid of it.
+ * @param vitroRequest
+ * @param entityURI
+ * @return
+ */
private ResponseValues prepareStandaloneErrorResponse(
VitroRequest vitroRequest, String entityURI) {
@@ -241,14 +254,8 @@ public class EntityPublicationCountRequestHandler implements
String standaloneTemplate = "entityPublicationComparisonError.ftl";
Map body = new HashMap();
- IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
- Individual ind = iDao.getIndividualByURI(entityURI);
-
- String organizationLabel = "Unknown Organization";
-
- if (ind != null) {
- organizationLabel = ind.getName();
- }
+ String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
+ entityURI);
body.put("organizationLabel", organizationLabel);
body.put("portalBean", portal);
@@ -258,8 +265,7 @@ public class EntityPublicationCountRequestHandler implements
return new TemplateResponseValues(standaloneTemplate, body);
}
-
-
+
/**
* function to generate a json file for year <-> publication count mapping
* @param vreq
@@ -302,7 +308,7 @@ public class EntityPublicationCountRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI());
- boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
+ boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
if(isPerson){
entityJson.setVisMode("PERSON");
@@ -316,7 +322,7 @@ public class EntityPublicationCountRequestHandler implements
return json.toJson(subEntitiesJson);
}
-
+
private String getEntityPublicationsPerYearCSVContent(Set subentities, Map> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder();
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java
index eb2b8b5b..d873a21e 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/entitygrantcount/EntityGrantCountRequestHandler.java
@@ -15,21 +15,15 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.google.gson.Gson;
-import com.hp.hpl.jena.iri.IRI;
-import com.hp.hpl.jena.iri.IRIFactory;
-import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
-import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
-import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
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.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.VOConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison.EntityComparisonUtilityFunctions;
@@ -54,48 +48,13 @@ public class EntityGrantCountRequestHandler implements
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
- if (StringUtils.isNotBlank(entityURI)){
+ if (StringUtils.isBlank(entityURI)){
- return getSubjectEntityAndGenerateResponse(vitroRequest, log,
- Dataset, entityURI);
+ entityURI = EntityComparisonUtilityFunctions
+ .getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset);
- } else {
-
- String staffProvidedHighestLevelOrganization = ConfigurationProperties.getProperty("visualization.topLevelOrg");
-
- /*
- * First checking if the staff has provided highest level organization in deploy.properties
- * if so use to temporal graph vis.
- */
- if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
-
- /*
- * To test for the validity of the URI submitted.
- */
- IRIFactory iRIFactory = IRIFactory.jenaImplementation();
- IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
-
- if (iri.hasViolation(false)) {
-
- String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
- log.error("Highest Level Organization URI provided is invalid " + errorMsg);
-
- } else {
-
- return getSubjectEntityAndGenerateResponse(vitroRequest,
- log, Dataset,
- staffProvidedHighestLevelOrganization);
- }
- }
-
- String highestLevelOrgURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log,
- Dataset);
-
- return getSubjectEntityAndGenerateResponse(vitroRequest, log,
- Dataset, highestLevelOrgURI);
}
-
-
+ return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
}
@Override
@@ -105,6 +64,36 @@ public class EntityGrantCountRequestHandler implements
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
+
+ /*
+ * This will provide the data in json format mainly used for standalone tmeporal vis.
+ * */
+ if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
+ .equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
+
+ if (StringUtils.isNotBlank(entityURI)){
+
+ return getSubjectEntityAndGenerateDataResponse(
+ vitroRequest,
+ log,
+ Dataset,
+ entityURI);
+ } else {
+
+ return getSubjectEntityAndGenerateDataResponse(
+ vitroRequest,
+ log,
+ Dataset,
+ EntityComparisonUtilityFunctions
+ .getStaffProvidedOrComputedHighestLevelOrganization(
+ log,
+ Dataset));
+ }
+
+ } else {
+ /*
+ * This provides csv download files for the content in the tables.
+ * */
EntityGrantCountConstructQueryRunner constructQueryRunner = new EntityGrantCountConstructQueryRunner(entityURI, Dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
@@ -119,6 +108,8 @@ public class EntityGrantCountRequestHandler implements
log, Dataset, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(),subOrganizationTypesResult);
+
+ }
}
@@ -128,7 +119,7 @@ public class EntityGrantCountRequestHandler implements
throw new UnsupportedOperationException("Entity Grant Count does not provide Ajax Response.");
}
- private ResponseValues getSubjectEntityAndGenerateResponse(
+ private Map getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
@@ -142,18 +133,16 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
if (entity.getEntityLabel().equals("no-label")) {
-
- return prepareStandaloneErrorResponse(vitroRequest, subjectEntityURI);
-
+ return prepareStandaloneDataErrorResponse(vitroRequest, subjectEntityURI);
} else {
- return getSubEntityTypesAndRenderStandaloneResponse(
+ return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset,
subjectEntityURI, entity);
}
}
- private ResponseValues getSubEntityTypesAndRenderStandaloneResponse(
+ private Map getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
String subjectOrganization, Entity entity)
throws MalformedQueryParametersException {
@@ -161,8 +150,34 @@ public class EntityGrantCountRequestHandler implements
Map> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, subjectOrganization);
- return prepareStandaloneResponse(vitroRequest, entity, subjectOrganization,
- subOrganizationTypesResult);
+ return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
+ }
+
+
+ private Map prepareStandaloneDataErrorResponse(
+ VitroRequest vitroRequest, String subjectEntityURI) {
+
+ Map fileData = new HashMap();
+
+ fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
+ "application/octet-stream");
+ fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Grants for this Organization found in VIVO.\"}");
+ return fileData;
+ }
+
+
+ private Map prepareStandaloneDataResponse(
+ VitroRequest vitroRequest,
+ Entity entity,
+ Map> subOrganizationTypesResult) {
+
+ Map fileData = new HashMap();
+
+ fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
+ "application/octet-stream");
+ fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
+ writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
+ return fileData;
}
/**
@@ -200,39 +215,30 @@ public class EntityGrantCountRequestHandler implements
return fileData;
}
- /**
- *
- * @param vreq
- * @param valueObjectContainer
- * @return
- */
- private TemplateResponseValues prepareStandaloneResponse(VitroRequest vreq,
- Entity entity, String entityURI, Map> subOrganizationTypesResult) {
- Portal portal = vreq.getPortal();
- String standaloneTemplate = "entityComparisonOnGrantsStandalone.ftl";
+ private TemplateResponseValues prepareStandaloneMarkupResponse(VitroRequest vreq,
+ String entityURI) {
+
+ Portal portal = vreq.getPortal();
+ String standaloneTemplate = "entityComparisonOnGrantsStandalone.ftl";
- String jsonContent = "";
- jsonContent = writeGrantsOverTimeJSON(vreq, entity.getSubEntities(), subOrganizationTypesResult);
-
- String title = "";
+ String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq,
+ entityURI);
- if (StringUtils.isNotBlank(entity.getEntityLabel())) {
- title = entity.getEntityLabel() + " - ";
- }
-
-
- Map body = new HashMap();
- body.put("portalBean", portal);
- body.put("title", title + "Temporal Graph Visualization");
- body.put("organizationURI", entityURI);
- body.put("organizationLabel", entity.getEntityLabel());
- body.put("jsonContent", jsonContent);
-
- return new TemplateResponseValues(standaloneTemplate, body);
-
+ Map body = new HashMap();
+ body.put("portalBean", portal);
+ body.put("title", organizationLabel + " - Temporal Graph Visualization");
+ body.put("organizationURI", entityURI);
+ body.put("organizationLabel", organizationLabel);
+
+ return new TemplateResponseValues(standaloneTemplate, body);
}
+ /**
+ * @deprecated This method should not be called anymore although the templates being
+ * called by this method are still in use, so we should not get rid of it.
+ * @return
+ */
private ResponseValues prepareStandaloneErrorResponse(
VitroRequest vitroRequest, String entityURI) {
@@ -240,14 +246,8 @@ public class EntityGrantCountRequestHandler implements
String standaloneTemplate = "entityGrantComparisonError.ftl";
Map body = new HashMap();
- IndividualDao iDao = vitroRequest.getWebappDaoFactory().getIndividualDao();
- Individual ind = iDao.getIndividualByURI(entityURI);
-
- String organizationLabel = "Unknown Organization";
-
- if (ind != null) {
- organizationLabel = ind.getName();
- }
+ String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vitroRequest,
+ entityURI);
body.put("organizationLabel", organizationLabel);
@@ -300,7 +300,7 @@ public class EntityGrantCountRequestHandler implements
entityJson.setEntityURI(subentity.getIndividualURI());
- boolean isPerson = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
+ boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
if(isPerson){
entityJson.setVisMode("PERSON");
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 dd52e479..7fbb89eb 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
@@ -35,6 +35,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Co
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.CoPINode;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Grant;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.Node;
+import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.valueobjects.SubEntity;
public class UtilityFunctions {
@@ -320,5 +321,9 @@ public class UtilityFunctions {
return collaboratorshipNetworkURL != null ? collaboratorshipNetworkURL : "" ;
}
+
+ public static boolean isEntityAPerson(VitroRequest vreq, SubEntity subentity) {
+ return vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
+ }
}