1. Added temporal graph link for the highest organization code for "organizations" page.
2. Cleaned up some query runners. 3. Made GenericQueryRunner to accept sparql queries that does not depend on URIs. 4. Adde style for temporal graph link to wilma.css
This commit is contained in:
parent
f5e6fbf409
commit
3d8f5d921c
7 changed files with 161 additions and 90 deletions
|
@ -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 -->
|
||||
<a class="visualiztionMenupage" href="${urls.base}/vis/temporalGraph" title="Compare this organization">Temporal Graph</a>
|
||||
|
||||
<#assign temporalGraphIcon = '${urls.images}/visualization/temporal_vis_small_icon.jpg'>
|
||||
|
||||
<div id="temporal-graph-link-container">
|
||||
<div class="collaboratorship-icon">
|
||||
<a class="temporal-graph-link" href="#"><img src="${temporalGraphIcon}" alt="Temporal Graph"/></a>
|
||||
</div>
|
||||
<div class="collaboratorship-link">
|
||||
<h3><a class="temporal-graph-link" href="#">Temporal Graph</a></h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${stylesheets.add("css/visualization/visualization.css")}
|
||||
|
||||
<script type="text/javascript">
|
||||
var contextPath = '${contextPath}';
|
||||
|
||||
$.ajax({
|
||||
url: contextPath + "/visualizationAjax",
|
||||
data: ({vis: "utilities", vis_mode: "HIGHEST_LEVEL_ORGANIZATION"}),
|
||||
dataType: "text",
|
||||
success:function(data){
|
||||
if (data != null && data != "") {
|
||||
$("#temporal-graph-link-container .temporal-graph-link").attr("href", data);
|
||||
$("#temporal-graph-link-container").show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</#assign>
|
||||
|
||||
<#include "menupage.ftl">
|
|
@ -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";
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -151,28 +151,12 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
|
|||
DataSource dataSource) {
|
||||
|
||||
QueryExecution queryExecution = null;
|
||||
// try {
|
||||
Query query = QueryFactory.create(getSparqlQuery(queryURI), 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;
|
||||
}
|
||||
|
||||
private String getSparqlQuery(String queryURI) {
|
||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||
|
||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
|
||||
|
@ -186,7 +170,6 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
|
|||
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
|
||||
+ "}";
|
||||
|
||||
// System.out.println("SPARQL query for person pub count -> \n" + sparqlQuery);
|
||||
return sparqlQuery;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,11 +96,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
|||
|
||||
|
||||
QueryRunner<ResultSet> 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<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
|
||||
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<ResultSet> 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<String, String> 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<String, String> fieldLabelToOutputFieldLabel) {
|
||||
|
||||
|
|
|
@ -77,24 +77,10 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
|||
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);
|
||||
|
||||
// if (query.isSelectType()) {
|
||||
return queryExecution.execSelect();
|
||||
// }
|
||||
// } finally {
|
||||
// if (queryExecution != null) {
|
||||
// queryExecution.close();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
||||
|
|
|
@ -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<ResultSet> {
|
|||
|
||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||
|
||||
private String whereClause, individualURLParam;
|
||||
private String whereClause;
|
||||
private DataSource dataSource;
|
||||
|
||||
private Log log;
|
||||
|
||||
private Map<String, String> fieldLabelToOutputFieldLabel;
|
||||
|
||||
public GenericQueryRunner(String individualURLParam,
|
||||
Map<String, String> fieldLabelToOutputFieldLabel,
|
||||
String whereClause,
|
||||
DataSource dataSource,
|
||||
Log log) {
|
||||
private String groupOrderClause;
|
||||
|
||||
private String aggregationRules;
|
||||
|
||||
public GenericQueryRunner(Map<String, String> 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<ResultSet> {
|
|||
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;
|
||||
}
|
||||
|
||||
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<ResultSet> {
|
|||
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue