diff --git a/productMods/templates/freemarker/body/menupage/menupage--classgroup-organizations.ftl b/productMods/templates/freemarker/body/menupage/menupage--classgroup-organizations.ftl
index f8124f39..6cb4ea6a 100644
--- a/productMods/templates/freemarker/body/menupage/menupage--classgroup-organizations.ftl
+++ b/productMods/templates/freemarker/body/menupage/menupage--classgroup-organizations.ftl
@@ -1,7 +1,37 @@
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#assign visualizationLink>
- <#-- Chintan...place your markup for the visualization link here -->
-
+
+ <#assign temporalGraphIcon = '${urls.images}/visualization/temporal_vis_small_icon.jpg'>
+
+
+
+

+
+
+
+
+ ${stylesheets.add("css/visualization/visualization.css")}
+
+
+
+
#assign>
<#include "menupage.ftl">
\ 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 26fce924..c4176367 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
@@ -87,6 +87,7 @@ public class VisualizationFrameworkConstants {
public static final String UNIVERSITY_COMPARISON_VIS_MODE = "UNIVERSITY";
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";
/*
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountQueryRunner.java
index f370a811..957a0ec0 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountQueryRunner.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/personpubcount/PersonPublicationCountQueryRunner.java
@@ -151,28 +151,12 @@ public class PersonPublicationCountQueryRunner implements QueryRunner \n" + sparqlQuery);
return sparqlQuery;
}
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/utilities/UtilitiesRequestHandler.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/utilities/UtilitiesRequestHandler.java
index 4de53f41..7311d25d 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/utilities/UtilitiesRequestHandler.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/utilities/UtilitiesRequestHandler.java
@@ -96,11 +96,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
QueryRunner imageQueryHandler =
- new GenericQueryRunner(individualURI,
- fieldLabelToOutputFieldLabel,
+ new GenericQueryRunner(fieldLabelToOutputFieldLabel,
+ "",
whereClause,
- dataSource,
- log);
+ "",
+ dataSource, log);
return getThumbnailInformation(imageQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel);
@@ -155,6 +155,48 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
personLevelURLParams);
+ } else if (VisualizationFrameworkConstants.HIGHEST_LEVEL_ORGANIZATION_VIS_MODE
+ .equalsIgnoreCase(visMode)) {
+
+ Map fieldLabelToOutputFieldLabel = new HashMap();
+ fieldLabelToOutputFieldLabel.put("organization",
+ QueryFieldLabels.ORGANIZATION_URL);
+ fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL);
+
+ String aggregationRules = "(count(?organization) AS ?numOfChildren)";
+
+ String whereClause = "?organization rdf:type foaf:Organization ; rdfs:label ?organizationLabel . \n"
+ + "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
+ + "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
+ + "FILTER ( !bound(?parent) ). \n";
+
+ String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"
+ + "ORDER BY DESC(?numOfChildren)\n"
+ + "LIMIT 1\n";
+
+ QueryRunner highestLevelOrganizationQueryHandler =
+ new GenericQueryRunner(fieldLabelToOutputFieldLabel,
+ aggregationRules,
+ whereClause,
+ groupOrderClause,
+ dataSource, log);
+
+ return getHighestLevelOrganizationTemporalGraphVisURL(
+ highestLevelOrganizationQueryHandler.getQueryResult(),
+ fieldLabelToOutputFieldLabel);
+
+ /*
+
+ GenericQueryMap highestLevelOrganizationToValues = getHighestLevelOrganizationInformation(
+ highestLevelOrganizationQueryHandler.getQueryResult(),
+ fieldLabelToOutputFieldLabel);
+
+ Gson highestLevelOrganizationInformation = new Gson();
+
+ return highestLevelOrganizationInformation.toJson(highestLevelOrganizationToValues);
+
+ */
+
} else {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
@@ -166,6 +208,58 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
}
+ private String getHighestLevelOrganizationTemporalGraphVisURL(ResultSet resultSet,
+ Map fieldLabelToOutputFieldLabel) {
+
+ GenericQueryMap queryResult = new GenericQueryMap();
+
+
+ while (resultSet.hasNext()) {
+ QuerySolution solution = resultSet.nextSolution();
+
+
+ RDFNode organizationNode = solution.get(
+ fieldLabelToOutputFieldLabel
+ .get("organization"));
+
+ if (organizationNode != null) {
+ queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString());
+
+ ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
+ organizationNode.toString(),
+ VisualizationFrameworkConstants.VIS_TYPE_KEY,
+ VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS,
+
+ /* Remove this hard-coded vis_mode once Deepak fixes the Temporal Graph Vis
+ * front-end to work without vis_modes. */
+ VisualizationFrameworkConstants.VIS_MODE_KEY,
+ "University");
+
+ return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
+ highestLevelOrganizationTemporalGraphVisURLParams);
+
+
+ }
+
+ RDFNode organizationLabelNode = solution.get(
+ fieldLabelToOutputFieldLabel
+ .get("organizationLabel"));
+
+ if (organizationLabelNode != null) {
+ queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"), organizationLabelNode.toString());
+ }
+
+ RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren");
+
+ if (numberOfChildrenNode != null) {
+ queryResult.addEntry("numOfChildren", String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
+ }
+ }
+
+// return queryResult;
+ return "";
+ }
+
private String getThumbnailInformation(ResultSet resultSet,
Map fieldLabelToOutputFieldLabel) {
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/AllPropertiesQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/AllPropertiesQueryRunner.java
index 6ab93ee7..fa5f8be5 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/AllPropertiesQueryRunner.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/AllPropertiesQueryRunner.java
@@ -77,24 +77,10 @@ public class AllPropertiesQueryRunner implements QueryRunner {
DataSource dataSource) {
QueryExecution queryExecution = null;
-// try {
- Query query = QueryFactory.create(queryText, SYNTAX);
+ Query query = QueryFactory.create(queryText, SYNTAX);
-// QuerySolutionMap qs = new QuerySolutionMap();
-// qs.add("authPerson", queryParam); // bind resource to s
-
- queryExecution = QueryExecutionFactory.create(query, dataSource);
-
- // if (query.isSelectType()) {
- return queryExecution.execSelect();
-// }
-// } finally {
-// if (queryExecution != null) {
-// queryExecution.close();
-// }
-//
-// }
-// return null;
+ queryExecution = QueryExecutionFactory.create(query, dataSource);
+ return queryExecution.execSelect();
}
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
diff --git a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/GenericQueryRunner.java b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/GenericQueryRunner.java
index b9a52641..ba89016a 100644
--- a/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/GenericQueryRunner.java
+++ b/src/edu/cornell/mannlib/vitro/webapp/visualization/freemarker/visutils/GenericQueryRunner.java
@@ -4,12 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils;
import java.util.Map;
-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.iri.Violation;
import com.hp.hpl.jena.query.DataSource;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
@@ -33,22 +29,27 @@ public class GenericQueryRunner implements QueryRunner {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
- private String whereClause, individualURLParam;
+ private String whereClause;
private DataSource dataSource;
private Log log;
private Map fieldLabelToOutputFieldLabel;
- public GenericQueryRunner(String individualURLParam,
- Map fieldLabelToOutputFieldLabel,
- String whereClause,
- DataSource dataSource,
- Log log) {
+ private String groupOrderClause;
+
+ private String aggregationRules;
+
+ public GenericQueryRunner(Map fieldLabelToOutputFieldLabel,
+ String aggregationRules,
+ String whereClause,
+ String groupOrderClause,
+ DataSource dataSource, Log log) {
- this.individualURLParam = individualURLParam;
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
+ this.aggregationRules = aggregationRules;
this.whereClause = whereClause;
+ this.groupOrderClause = groupOrderClause;
this.dataSource = dataSource;
this.log = log;
@@ -58,30 +59,12 @@ public class GenericQueryRunner implements QueryRunner {
DataSource dataSource) {
QueryExecution queryExecution = null;
-// try {
- Query query = QueryFactory.create(queryText, SYNTAX);
-
-// QuerySolutionMap qs = new QuerySolutionMap();
-// qs.add("authPerson", queryParam); // bind resource to s
-
- queryExecution = QueryExecutionFactory.create(query, dataSource);
-
-
- //remocve this if loop after knowing what is describe & construct sparql stuff.
-// if (query.isSelectType()) {
- return queryExecution.execSelect();
-// }
-// } finally {
-// if (queryExecution != null) {
-// queryExecution.close();
-// }
-//
-// }
-// return null;
+ Query query = QueryFactory.create(queryText, SYNTAX);
+ queryExecution = QueryExecutionFactory.create(query, dataSource);
+ return queryExecution.execSelect();
}
private String generateGenericSparqlQuery() {
-// Resource uri1 = ResourceFactory.createResource(queryURI);
StringBuilder sparqlQuery = new StringBuilder();
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
@@ -96,32 +79,21 @@ public class GenericQueryRunner implements QueryRunner {
}
+ sparqlQuery.append("\n" + this.aggregationRules + "\n");
+
sparqlQuery.append("WHERE {\n");
sparqlQuery.append(this.whereClause);
sparqlQuery.append("}\n");
+ sparqlQuery.append(this.groupOrderClause);
+
return sparqlQuery.toString();
}
public ResultSet getQueryResult()
throws MalformedQueryParametersException {
- if (StringUtils.isNotBlank(this.individualURLParam)) {
- /*
- * To test for the validity of the URI submitted.
- * */
- IRIFactory iRIFactory = IRIFactory.jenaImplementation();
- IRI iri = iRIFactory.create(this.individualURLParam);
- if (iri.hasViolation(false)) {
- String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
- log.error("Generic Query " + errorMsg);
- throw new MalformedQueryParametersException(
- "URI provided for an individual is malformed.");
- }
- } else {
- throw new MalformedQueryParametersException("URI parameter is either null or empty.");
- }
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.dataSource);
diff --git a/themes/wilma/css/wilma.css b/themes/wilma/css/wilma.css
index acee4502..d2683e54 100644
--- a/themes/wilma/css/wilma.css
+++ b/themes/wilma/css/wilma.css
@@ -837,6 +837,11 @@ ul#foaf-person-childClasses .count-classes {
font-size: .75em;
}
/* VISUAL GRAPH CLASS:GENERIC (ORGANIZATION, RESEARCH, EVENT) ------> */
+#temporal-graph-link-container {
+ display: none;
+ float: right;
+ width: 128px;
+}
#content-generic-class {
width: 900px;
}