1) Removed entry for freemarker in visualization-beans-injection.xml

2) Commented out the part related to query.isSelectType() in all the QueryRunners
3) Added a generalized query for temporal vis that doesn't impose hierarchy. (Even if there are only people in a University/School, it works!)
4) Added print method to CoPIData
This commit is contained in:
bkoniden 2010-11-23 15:41:57 +00:00
parent 080458b688
commit 7b9a7cf5e2
9 changed files with 184 additions and 162 deletions

View file

@ -399,23 +399,23 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CoAuthorshipData> {
DataSource dataSource) {
QueryExecution queryExecution = null;
try {
// 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()) {
System.out.println("\n\nquery.isSelectType() is "+ query.isSelectType()+ " \n\n");
// if (query.isSelectType()) {
return queryExecution.execSelect();
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
return null;
// }
// } finally {
// if (queryExecution != null) {
// queryExecution.close();
// }
// }
// return null;
}
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {

View file

@ -95,20 +95,20 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
private ResultSet executeQuery(String queryText, DataSource dataSource) {
QueryExecution queryExecution = null;
try {
// try {
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataSource);
if (query.isSelectType()) {
System.out.println("\n\nquery.isSelectType() is "+ query.isSelectType()+ " \n\n");
// if (query.isSelectType()) {
return queryExecution.execSelect();
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
return null;
// }
// } finally {
// if (queryExecution != null) {
// queryExecution.close();
// }
// }
// return null;
}
public CoPIData getQueryResult()
@ -132,6 +132,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
ResultSet resultSet = executeQuery(generateEgoCoPIquery(this.egoURI),
this.dataSource);
System.out.println("ResultSet ");
return createQueryResult(resultSet);
}
@ -190,11 +191,14 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
nodes.add(egoNode);
nodeURLToVO.put(egoPIURLNode.toString(), egoNode);
RDFNode authorLabelNode = solution.get(QueryFieldLabels.PI_LABEL);
if (authorLabelNode != null) {
egoNode.setNodeName(authorLabelNode.toString());
}
}
System.out.println("\n----------------------------------");
System.out.println("PI: "+ egoNode.getIndividualLabel());
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
Grant grant;
@ -207,6 +211,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
}
egoNode.addGrant(grant);
System.out.println("Adding grant: "+ grant.getIndividualLabel());
/*
* After some discussion we concluded that for the purpose of this visualization
@ -237,6 +242,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
}
}
System.out.println("Adding CO-PI: "+ coPINode.getIndividualLabel());
coPINode.addGrant(grant);
Set<CoPINode> coPIsForCurrentGrant;
@ -251,9 +257,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CoPIData> {
}
coPIsForCurrentGrant.add(coPINode);
System.out.println("Co-PI for current grant : "+ coPINode.getIndividualLabel());
CoPIEdge egoCoPIEdge = getExistingEdge(egoNode, coPINode, edgeUniqueIdentifierToVO);
System.out.println("\n----------------------------------");
/*
* If "egoCoPIEdge" is null it means that no edge exists in between the egoNode
* & current coPINode. Else create a new edge, add it to the edges set & add

View file

@ -41,6 +41,8 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
try{
CoPIData PINodesAndEdges = queryManager.getQueryResult();
PINodesAndEdges.print();
if (VisualizationFrameworkConstants.DATA_RENDER_MODE
.equalsIgnoreCase(renderMode)) {

View file

@ -166,86 +166,123 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
private ResultSet executeQuery(String queryURI, DataSource dataSource) {
QueryExecution queryExecution = null;
try {
// try {
Query query = QueryFactory.create(
getSparqlQuery(queryURI, this.visMode), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataSource);
if (query.isSelectType()) {
return queryExecution.execSelect();
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
return null;
System.out.println("\n\nquery.isSelectType() is "+ query.isSelectType()+ " \n\n");
return queryExecution.execSelect();
// if (query.isSelectType()) {
// return queryExecution.execSelect();
// }
// } finally {
// if (queryExecution != null) {
// queryExecution.close();
// }
// }
// return null;
}
private String getSparqlQuery(String queryURI, String visMode) {
String result = "";
if (visMode.equals("DEPARTMENT")) {
result = getSparqlQueryForDepartment(queryURI);
// result = getSparqlQueryForDepartment(queryURI);
ENTITY_URL = QueryFieldLabels.DEPARTMENT_URL;
ENTITY_LABEL = QueryFieldLabels.DEPARTMENT_LABEL;
SUBENTITY_URL = QueryFieldLabels.PERSON_URL;
SUBENTITY_LABEL = QueryFieldLabels.PERSON_LABEL;
} else {
result = getSparqlQueryForOrganization(queryURI);
// result = getSparqlQueryForOrganization(queryURI);
ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL;
}
result = getSparqlQueryForOrganization(queryURI);
return result;
}
private String getSparqlQueryForDepartment(String queryURI) {
// private String getSparqlQueryForDepartment(String queryURI) {
//
// String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
// + "SELECT (str(?DepartmentLabel) as ?departmentLabelLit) "
// + SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
// + ">) as ?" + QueryFieldLabels.DEPARTMENT_URL + ") "
// + "WHERE { " + "<" + queryURI + "> rdf:type core:Department ;"
// + " rdfs:label ?DepartmentLabel ;"
// + " core:organizationForPosition ?Position . "
// + " ?Position rdf:type core:Position ;"
// + " core:positionForPerson ?Person . "
// + " ?Person core:authorInAuthorship ?Resource ; "
// + " rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
// + " ?Resource core:linkedInformationResource ?Document ."
// + " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
// + SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
// + " ORDER BY ?DocumentLabel";
// System.out.println("\nThe sparql query is :\n" + sparqlQuery);
// return sparqlQuery;
//
// }
// private String getSparqlQueryForOrganization(String queryURI) {
//
// String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
// + "SELECT (str(?organizationLabel) as ?organizationLabelLit) "
// + " (str(?subOrganization) as ?subOrganizationLit) "
// + " (str(?subOrganizationLabel) as ?subOrganizationLabelLit) "
// + SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
// + ">) as ?" + QueryFieldLabels.ORGANIZATION_URL + ") "
// + "WHERE { " + "<" + queryURI + "> rdf:type foaf:Organization ;"
// + " rdfs:label ?organizationLabel ;"
// + " core:hasSubOrganization ?subOrganization ."
// + " ?subOrganization rdfs:label ?subOrganizationLabel ;"
// + " core:organizationForPosition ?Position . "
// + " ?Position rdf:type core:Position ;"
// + " core:positionForPerson ?Person . "
// + " ?Person core:authorInAuthorship ?Resource ; "
// + " rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
// + " ?Resource core:linkedInformationResource ?Document ."
// + " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
// + SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
// + " ORDER BY ?DocumentLabel";
// System.out.println("\nThe sparql query is :\n" + sparqlQuery);
// return sparqlQuery;
//
// }
private String getSparqlQueryForOrganization(String queryURI){
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT (str(?DepartmentLabel) as ?departmentLabelLit) "
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
+ ">) as ?" + QueryFieldLabels.DEPARTMENT_URL + ") "
+ "WHERE { " + "<" + queryURI + "> rdf:type core:Department ;"
+ " rdfs:label ?DepartmentLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position rdf:type core:Position ;"
+ " core:positionForPerson ?Person . "
+ " ?Person core:authorInAuthorship ?Resource ; "
+ " rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
+ " ?Resource core:linkedInformationResource ?Document ."
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ " ORDER BY ?DocumentLabel";
System.out.println("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery;
}
private String getSparqlQueryForOrganization(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT (str(?organizationLabel) as ?organizationLabelLit) "
+ " (str(?subOrganization) as ?subOrganizationLit) "
+ " (str(?subOrganizationLabel) as ?subOrganizationLabelLit) "
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
+ ">) as ?" + QueryFieldLabels.ORGANIZATION_URL + ") "
+ "WHERE { " + "<" + queryURI + "> rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel ;"
+ " core:hasSubOrganization ?subOrganization ."
+ " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position rdf:type core:Position ;"
+ " core:positionForPerson ?Person . "
+ " ?Person core:authorInAuthorship ?Resource ; "
+ " rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
+ " ?Resource core:linkedInformationResource ?Document ."
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ " ORDER BY ?DocumentLabel";
+ "SELECT (str(?organizationLabel) as ?organizationLabelLit) "
+ " (str(?subOrganization) as ?subOrganizationLit) "
+ " (str(?subOrganizationLabel) as ?subOrganizationLabelLit) "
+ " (str(?DepartmentLabel) as ?departmentLabelLit) "
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
+ ">) as ?" + ENTITY_URL + ") "
+ "WHERE { " + "<" + queryURI + "> rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel ."
+ "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization ."
+ "?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . "
+ " ?Position rdf:type core:Position ; core:positionForPerson ?Person ."
+ " ?Person core:authorInAuthorship ?Resource ; rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
+ " ?Resource core:linkedInformationResource ?Document . "
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ "UNION "
+ "{ "
+ "<" + queryURI + "> rdf:type core:Department ; rdfs:label ?DepartmentLabel ; core:organizationForPosition ?Position ."
+ " ?Position rdf:type core:Position ; core:positionForPerson ?Person ."
+ " ?Person core:authorInAuthorship ?Resource ; rdfs:label ?PersonLabel ; core:personInPosition ?SecondaryPosition . "
+ " ?Resource core:linkedInformationResource ?Document ."
+ " ?SecondaryPosition rdfs:label ?SecondaryPositionLabel ."
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ "}";
System.out.println("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery;
}

View file

@ -61,13 +61,7 @@ public class EntityPublicationCountRequestHandler implements
String visContainer = vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
System.out
.println("\nInside EntityPublicationCountRequestHandler! \n----------------------------------------- ");
System.out.println("\nEntity URI: " + entityURI + "\nRender Mode: "
+ renderMode + "\nVis Mode: " + ENTITY_VIS_MODE
+ "\nVis Containter: " + visContainer);
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
entityURI, dataSource, log, ENTITY_VIS_MODE);
@ -77,68 +71,23 @@ public class EntityPublicationCountRequestHandler implements
if (ENTITY_VIS_MODE.equals("DEPARTMENT")) {
SUB_ENTITY_VIS_MODE = "PERSON";
// System.out
// .println("\n\nDocuments within the Entity\n---------------------------------------------");
// for (BiboDocument document : entity.getPublications()) {
// System.out.println(document.getDocumentLabel() + " > "
// + document.getDocumentURL());
// }
//
// System.out
// .println("\n\nSubEntities within the Entity\n---------------------------------------------");
//
// for (SubEntity person : entity.getSubEntities()) {
// System.out.println(person.getIndividualLabel());
// }
}else if (ENTITY_VIS_MODE.equals("SCHOOL")) {
SUB_ENTITY_VIS_MODE = "DEPARTMENT";
// System.out
// .println("\nDocuments within the Entity\n---------------------------------------------");
// for (BiboDocument document : entity.getPublications()) {
// System.out.println(document.getDocumentLabel() + " > "
// + document.getDocumentURL());
// }
//
// System.out
// .println("\n\nSubEntities within the Entity\n---------------------------------------------");
// for (SubEntity department : entity.getSubEntities()) {
// System.out.println(department.getIndividualLabel());
// }
}else {
SUB_ENTITY_VIS_MODE = "SCHOOL";
// System.out
// .println("\nDocuments within the Entity\n---------------------------------------------");
// for (BiboDocument document : entity.getPublications()) {
// System.out.println(document.getDocumentLabel() + " > "
// + document.getDocumentURL());
// }
//
// System.out
// .println("\n\nSubEntities within the Entity\n---------------------------------------------");
//
// for (SubEntity school : entity.getSubEntities()) {
// System.out.println(school.getIndividualLabel());
//
// }
}
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
entityURI, dataSource, log, ENTITY_VIS_MODE);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes.getQueryResult();
System.out.println("Sub Organization Types With Their Labels \n------------------");
for(String label: subOrganizationTypesResult.keySet()){
System.out.println("Label :"+ label);
for(String type : subOrganizationTypesResult.get(label)){
System.out.println("type: "+ type);
}
System.out.println();
}
RequestDispatcher requestDispatcher = null;
if (VisualizationFrameworkConstants.DATA_RENDER_MODE
.equalsIgnoreCase(renderMode)) {
@ -288,7 +237,8 @@ public class EntityPublicationCountRequestHandler implements
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI());
entityJson.setVisMode(SUB_ENTITY_VIS_MODE);
setEntityVisMode(entityJson);
//entityJson.setVisMode(SUB_ENTITY_VIS_MODE);
System.out.println("Adding object with uri: "
+ entityJson.getEntityURI() + " vismode: "
+ entityJson.getVisMode() + " label: "
@ -301,4 +251,15 @@ public class EntityPublicationCountRequestHandler implements
return json.toJson(subEntitiesJson);
}
private void setEntityVisMode(JsonObject entityJson) {
if(entityJson.getOrganizationType().contains("Department")){
entityJson.setVisMode("DEPARTMENT");
}else if(entityJson.getOrganizationType().contains("School")){
entityJson.setVisMode("SCHOOL");
}else{
entityJson.setVisMode(SUB_ENTITY_VIS_MODE);
}
}
}

View file

@ -69,20 +69,20 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
private ResultSet executeQuery(String queryURI, DataSource dataSource) {
QueryExecution queryExecution = null;
try {
// try {
Query query = QueryFactory.create(
getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataSource);
if (query.isSelectType()) {
System.out.println("\n\nquery.isSelectType() is "+ query.isSelectType()+ " \n\n");
// if (query.isSelectType()) {
return queryExecution.execSelect();
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
return null;
// }
// } finally {
// if (queryExecution != null) {
// queryExecution.close();
// }
// }
// return null;
}
private String getSparqlQuery(String queryURI) {
@ -105,7 +105,7 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ " rdf:type ?subOrganizationType . "
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel ."
+ "}";
System.out.println("\nThe sparql query is :\n" + sparqlQuery);
} else{
SUBORGANISATION_LABEL = QueryFieldLabels.PERSON_LABEL;
@ -128,6 +128,7 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ " ?personType rdfs:label ?personTypeLabel ."
+ "}";;
}
System.out.println("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery;
}

View file

@ -151,7 +151,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
DataSource dataSource) {
QueryExecution queryExecution = null;
try {
// try {
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
// QuerySolutionMap qs = new QuerySolutionMap();
@ -160,15 +160,15 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<BiboDo
queryExecution = QueryExecutionFactory.create(query, dataSource);
if (query.isSelectType()) {
// if (query.isSelectType()) {
return queryExecution.execSelect();
}
} finally {
if (queryExecution != null) {
queryExecution.close();
}
}
return null;
// }
// } finally {
// if (queryExecution != null) {
// queryExecution.close();
// }
// }
// return null;
}
private String getSparqlQuery(String queryURI) {

View file

@ -56,7 +56,29 @@ public class CoPIData {
return EDGE_SCHEMA;
}
public void print(){
System.out.println("\n-----------------------------");
System.out.println("Ego node is "+ this.getEgoNode().getNodeName());
System.out.println("\nNodes are: ");
for(CoPINode node : this.getNodes()){
System.out.println(node.getNodeName());
}
System.out.println("\nEdges are: ");
for(CoPIEdge edge : this.getEdges()){
System.out.println(edge.getSourceNode() + "-->" + edge.getTargetNode());
}
System.out.println("\n-----------------------------");
}
private Set<Map<String, String>> initializeEdgeSchema() {
Set<Map<String, String>> edgeSchema = new HashSet<Map<String, String>>();