1. Code cleanup & refactor to suit the checkstyle.

This commit is contained in:
cdtank 2011-02-25 20:25:40 +00:00
parent 98f53d6409
commit dfef8878cf
38 changed files with 1052 additions and 1054 deletions

View file

@ -73,18 +73,18 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
if (visRequestHandler != null) { if (visRequestHandler != null) {
/* /*
* Pass the query to the selected visualization request handler & render the visualization. * Pass the query to the selected visualization request handler & render the
* Since the visualization content is directly added to the response object we are side- * visualization. Since the visualization content is directly added to the response
* effecting this method. * object we are side-effecting this method.
* */ * */
return renderVisualization(vreq, visRequestHandler); return renderVisualization(vreq, visRequestHandler);
} else { } else {
return UtilityFunctions.handleMalformedParameters("Visualization Query Error", return UtilityFunctions.handleMalformedParameters(
"Visualization Query Error",
"Inappropriate query parameters were submitted.", "Inappropriate query parameters were submitted.",
vreq); vreq);
} }
} }
@ -147,7 +147,8 @@ public class AjaxVisualizationController extends FreemarkerHttpServlet {
try { try {
visRequestHandler = VisualizationsDependencyInjector visRequestHandler = VisualizationsDependencyInjector
.getVisualizationIDsToClassMap(getServletContext()).get(visType); .getVisualizationIDsToClassMap(
getServletContext()).get(visType);
} catch (NullPointerException nullKeyException) { } catch (NullPointerException nullKeyException) {

View file

@ -58,7 +58,7 @@ public class DataVisualizationController extends VitroHttpServlet {
if (visRequestHandler != null) { if (visRequestHandler != null) {
/* /*
* Pass the query to the selected visualization request handler & render the visualization. * Pass the query to the selected visualization request handler & render the vis.
* Since the visualization content is directly added to the response object we are side- * Since the visualization content is directly added to the response object we are side-
* effecting this method. * effecting this method.
* */ * */
@ -92,7 +92,8 @@ public class DataVisualizationController extends VitroHttpServlet {
} else { } else {
UtilityFunctions.handleMalformedParameters("Visualization Query Error", UtilityFunctions.handleMalformedParameters(
"Visualization Query Error",
"Inappropriate query parameters were submitted.", "Inappropriate query parameters were submitted.",
vreq, vreq,
request, request,

View file

@ -18,8 +18,8 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Utilit
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler; import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.VisualizationRequestHandler;
/** /**
* Services a standard visualization request, which involves templates. This will return a simple error message and a 501 if * Services a standard visualization request, which involves templates. This will return a simple
* there is no jena Model. * error message and a 501 if there is no jena Model.
* *
* @author cdtank * @author cdtank
*/ */
@ -45,14 +45,15 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
if (visRequestHandler != null) { if (visRequestHandler != null) {
/* /*
* Pass the query to the selected visualization request handler & render the visualization. * Pass the query to the selected visualization request handler & render the vis.
* Since the visualization content is directly added to the response object we are side- * Since the visualization content is directly added to the response object we are side-
* effecting this method. * effecting this method.
* */ * */
return renderVisualization(vreq, visRequestHandler); return renderVisualization(vreq, visRequestHandler);
} else { } else {
return UtilityFunctions.handleMalformedParameters("Visualization Query Error", return UtilityFunctions.handleMalformedParameters(
"Visualization Query Error",
"Inappropriate query parameters were submitted.", "Inappropriate query parameters were submitted.",
vreq); vreq);
} }

View file

@ -67,11 +67,13 @@ public class CoAuthorshipGraphMLWriter {
graphMLContent.append("\n<graph edgedefault=\"undirected\">\n"); graphMLContent.append("\n<graph edgedefault=\"undirected\">\n");
if (coAuthorshipData.getCollaborators() != null & coAuthorshipData.getCollaborators().size() > 0) { if (coAuthorshipData.getCollaborators() != null
&& coAuthorshipData.getCollaborators().size() > 0) {
generateNodeSectionContent(coAuthorshipData, graphMLContent); generateNodeSectionContent(coAuthorshipData, graphMLContent);
} }
if (coAuthorshipData.getCollaborations() != null & coAuthorshipData.getCollaborations().size() > 0) { if (coAuthorshipData.getCollaborations() != null
&& coAuthorshipData.getCollaborations().size() > 0) {
generateEdgeSectionContent(coAuthorshipData, graphMLContent); generateEdgeSectionContent(coAuthorshipData, graphMLContent);
} }
@ -92,8 +94,8 @@ public class CoAuthorshipGraphMLWriter {
for (Collaboration currentEdge : orderedEdges) { for (Collaboration currentEdge : orderedEdges) {
/* /*
* This method actually creates the XML code for a single Collaboration. "graphMLContent" * This method actually creates the XML code for a single Collaboration.
* is being side-effected. * "graphMLContent" is being side-effected.
* */ * */
getEdgeContent(graphMLContent, currentEdge); getEdgeContent(graphMLContent, currentEdge);
} }
@ -103,8 +105,10 @@ public class CoAuthorshipGraphMLWriter {
graphMLContent.append("<edge " graphMLContent.append("<edge "
+ "id=\"" + currentEdge.getCollaborationID() + "\" " + "id=\"" + currentEdge.getCollaborationID() + "\" "
+ "source=\"" + currentEdge.getSourceCollaborator().getCollaboratorID() + "\" " + "source=\"" + currentEdge.getSourceCollaborator()
+ "target=\"" + currentEdge.getTargetCollaborator().getCollaboratorID() + "\" " .getCollaboratorID() + "\" "
+ "target=\"" + currentEdge.getTargetCollaborator()
.getCollaboratorID() + "\" "
+ ">\n"); + ">\n");
graphMLContent.append("\t<data key=\"collaborator1\">" graphMLContent.append("\t<data key=\"collaborator1\">"
@ -205,7 +209,8 @@ public class CoAuthorshipGraphMLWriter {
private void getNodeContent(StringBuilder graphMLContent, Collaborator node) { private void getNodeContent(StringBuilder graphMLContent, Collaborator node) {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap individualProfileURLParams =
new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
node.getCollaboratorURI()); node.getCollaboratorURI());
String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX, String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX,

View file

@ -53,7 +53,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
private String egoURI; private String egoURI;
private Dataset Dataset; private Dataset dataset;
private Log log; private Log log;
@ -62,10 +62,10 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
private UniqueIDGenerator edgeIDGenerator; private UniqueIDGenerator edgeIDGenerator;
public CoAuthorshipQueryRunner(String egoURI, public CoAuthorshipQueryRunner(String egoURI,
Dataset Dataset, Log log) { Dataset dataset, Log log) {
this.egoURI = egoURI; this.egoURI = egoURI;
this.Dataset = Dataset; this.dataset = dataset;
this.log = log; this.log = log;
this.nodeIDGenerator = new UniqueIDGenerator(); this.nodeIDGenerator = new UniqueIDGenerator();
@ -78,7 +78,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
Set<Collaborator> nodes = new HashSet<Collaborator>(); Set<Collaborator> nodes = new HashSet<Collaborator>();
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>(); Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors = new HashMap<String, Set<Collaborator>>(); Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors =
new HashMap<String, Set<Collaborator>>();
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>(); Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>(); Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
@ -165,17 +166,19 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
coAuthorsForCurrentBiboDocument.add(coAuthorNode); coAuthorsForCurrentBiboDocument.add(coAuthorNode);
Collaboration egoCoAuthorEdge = getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO); Collaboration egoCoAuthorEdge =
getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO);
/* /*
* If "egoCoAuthorEdge" is null it means that no Collaboration exists in between the egoNode * If "egoCoAuthorEdge" is null it means that no Collaboration exists in between the
* & current coAuthorNode. Else create a new Collaboration, add it to the edges set & add * egoNode & current coAuthorNode. Else create a new Collaboration, add it to the edges
* the collaborator document to it. * set & add the collaborator document to it.
* */ * */
if (egoCoAuthorEdge != null) { if (egoCoAuthorEdge != null) {
egoCoAuthorEdge.addActivity(biboDocument); egoCoAuthorEdge.addActivity(biboDocument);
} else { } else {
egoCoAuthorEdge = new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator); egoCoAuthorEdge =
new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
edges.add(egoCoAuthorEdge); edges.add(egoCoAuthorEdge);
edgeUniqueIdentifierToVO.put( edgeUniqueIdentifierToVO.put(
getEdgeUniqueIdentifier(egoNode.getCollaboratorID(), getEdgeUniqueIdentifier(egoNode.getCollaboratorID(),
@ -223,7 +226,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
return new CoAuthorshipData(egoNode, nodes, edges); return new CoAuthorshipData(egoNode, nodes, edges);
} }
private void removeLowQualityNodesAndEdges(Set<Collaborator> nodes, private void removeLowQualityNodesAndEdges(
Set<Collaborator> nodes,
Map<String, Activity> biboDocumentURLToVO, Map<String, Activity> biboDocumentURLToVO,
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors, Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors,
Set<Collaboration> edges) { Set<Collaboration> edges) {
@ -291,7 +295,9 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
* In order to leverage the nested "for loop" for making edges between all the * In order to leverage the nested "for loop" for making edges between all the
* co-authors we need to create a list out of the set first. * co-authors we need to create a list out of the set first.
* */ * */
List<Collaborator> coAuthorNodes = new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue()); List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator()); Collections.sort(coAuthorNodes, new CollaboratorComparator());
int numOfCoAuthors = coAuthorNodes.size(); int numOfCoAuthors = coAuthorNodes.size();
@ -336,7 +342,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
Collaborator collaboratingNode2, Collaborator collaboratingNode2,
Map<String, Collaboration> edgeUniqueIdentifierToVO) { Map<String, Collaboration> edgeUniqueIdentifierToVO) {
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(collaboratingNode1.getCollaboratorID(), String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
collaboratingNode1.getCollaboratorID(),
collaboratingNode2.getCollaboratorID()); collaboratingNode2.getCollaboratorID());
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier); return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
@ -368,17 +375,16 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
} }
private ResultSet executeQuery(String queryText, private ResultSet executeQuery(String queryText,
Dataset Dataset) { Dataset dataset) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX); Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, Dataset); queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) { private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
// Resource uri1 = ResourceFactory.createResource(queryURI);
String sparqlQuery = QueryConstants.getSparqlPrefixQuery() String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT \n" + "SELECT \n"
@ -387,8 +393,8 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n" + " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n" + " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n" + " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n" + " (str(?publicationDate) as ?"
// + " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") \n" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ "WHERE { \n" + "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;" + "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;" + " rdfs:label ?authorLabel ;"
@ -400,7 +406,6 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n" + "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n" + "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n" + " ?dateTimeValue core:dateTime ?publicationDate } .\n"
// + "OPTIONAL { ?document core:year ?publicationYearUsing_1_1_property } .\n"
+ "} \n" + "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n"; + "ORDER BY ?document ?coAuthorPerson\n";
@ -430,7 +435,7 @@ public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
} }
ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI), ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI),
this.Dataset); this.dataset);
return createQueryResult(resultSet); return createQueryResult(resultSet);
} }

View file

@ -40,13 +40,13 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("CoAuthorship does not provide Ajax Response."); throw new UnsupportedOperationException("CoAuthorship does not provide Ajax Response.");
} }
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
@ -59,7 +59,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
.VIS_MODE_KEY); .VIS_MODE_KEY);
QueryRunner<CollaborationData> queryManager = QueryRunner<CollaborationData> queryManager =
new CoAuthorshipQueryRunner(egoURI, Dataset, log); new CoAuthorshipQueryRunner(egoURI, dataset, log);
CollaborationData authorNodesAndEdges = CollaborationData authorNodesAndEdges =
queryManager.getQueryResult(); queryManager.getQueryResult();
@ -105,43 +105,20 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
public ResponseValues generateStandardVisualization(VitroRequest vitroRequest, public ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
Log log, Log log,
Dataset Dataset) Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
/* throw new UnsupportedOperationException("CoAuthorship Visualization "
* Support for this has ceased to exist. Standalone mode was created only for demo + "does not provide Standalone response.");
* purposes for VIVO Conf.
* */
/* String egoURI = vitroRequest.getParameter(
VisualizationFrameworkConstants
.INDIVIDUAL_URI_KEY);
QueryRunner<CoAuthorshipData> queryManager =
new CoAuthorshipQueryRunner(egoURI, Dataset, log);
CoAuthorshipData authorNodesAndEdges =
queryManager.getQueryResult();
return prepareStandaloneResponse(egoURI,
authorNodesAndEdges,
vitroRequest);*/
throw new UnsupportedOperationException("CoAuthorship does not provide Standalone Response.");
} }
private String getCoauthorsListCSVContent(CollaborationData coAuthorshipData) { private String getCoauthorsListCSVContent(CollaborationData coAuthorshipData) {
StringBuilder csvFileContent = new StringBuilder(); StringBuilder csvFileContent = new StringBuilder();
csvFileContent.append("Co-author, Count\n"); csvFileContent.append("Co-author, Count\n");
//for (Entry<String, Integer> currentEntry : coAuthorsToCount.entrySet()) {
for (Collaborator currNode : coAuthorshipData.getCollaborators()) { for (Collaborator currNode : coAuthorshipData.getCollaborators()) {
/* /*
* We have already printed the Ego Node info. * We have already printed the Ego Node info.
* */ * */
@ -157,7 +134,6 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
} }
return csvFileContent.toString(); return csvFileContent.toString();
} }
private String getCoauthorsPerYearCSVContent(Map<String, Set<Collaborator>> yearToCoauthors) { private String getCoauthorsPerYearCSVContent(Map<String, Set<Collaborator>> yearToCoauthors) {
@ -171,7 +147,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
csvFileContent.append(","); csvFileContent.append(",");
csvFileContent.append(currentEntry.getValue().size()); csvFileContent.append(currentEntry.getValue().size());
csvFileContent.append(","); csvFileContent.append(",");
csvFileContent.append(StringEscapeUtils.escapeCsv(getCoauthorNamesAsString(currentEntry.getValue()))); csvFileContent.append(StringEscapeUtils.escapeCsv(
getCoauthorNamesAsString(currentEntry.getValue())));
csvFileContent.append("\n"); csvFileContent.append("\n");
} }
@ -197,12 +174,14 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges * @param authorNodesAndEdges
* @param response * @param response
*/ */
private Map<String, String> prepareCoauthorsCountPerYearDataResponse(CollaborationData authorNodesAndEdges) { private Map<String, String> prepareCoauthorsCountPerYearDataResponse(
CollaborationData authorNodesAndEdges) {
String outputFileName; String outputFileName;
Map<String, Set<Collaborator>> yearToCoauthors = new TreeMap<String, Set<Collaborator>>(); Map<String, Set<Collaborator>> yearToCoauthors = new TreeMap<String, Set<Collaborator>>();
if (authorNodesAndEdges.getCollaborators() != null && authorNodesAndEdges.getCollaborators().size() > 0) { if (authorNodesAndEdges.getCollaborators() != null
&& authorNodesAndEdges.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
.getEgoCollaborator().getCollaboratorName()) .getEgoCollaborator().getCollaboratorName())
@ -232,13 +211,16 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges * @param authorNodesAndEdges
* @param response * @param response
*/ */
private Map<String, String> prepareCoauthorsListDataResponse(CollaborationData coAuthorshipData) { private Map<String, String> prepareCoauthorsListDataResponse(
CollaborationData coAuthorshipData) {
String outputFileName = ""; String outputFileName = "";
if (coAuthorshipData.getCollaborators() != null && coAuthorshipData.getCollaborators().size() > 0) { if (coAuthorshipData.getCollaborators() != null
&& coAuthorshipData.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoCollaborator().getCollaboratorName()) outputFileName = UtilityFunctions.slugify(coAuthorshipData.getEgoCollaborator()
.getCollaboratorName())
+ "_co-authors" + ".csv"; + "_co-authors" + ".csv";
} else { } else {
outputFileName = "no_co-authors" + ".csv"; outputFileName = "no_co-authors" + ".csv";
@ -261,7 +243,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges * @param authorNodesAndEdges
* @param response * @param response
*/ */
private Map<String, String> prepareNetworkStreamDataResponse(CollaborationData authorNodesAndEdges) { private Map<String, String> prepareNetworkStreamDataResponse(
CollaborationData authorNodesAndEdges) {
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter = CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
new CoAuthorshipGraphMLWriter(authorNodesAndEdges); new CoAuthorshipGraphMLWriter(authorNodesAndEdges);
@ -276,13 +259,16 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
} }
private Map<String, String> prepareNetworkDownloadDataResponse(CollaborationData authorNodesAndEdges) { private Map<String, String> prepareNetworkDownloadDataResponse(
CollaborationData authorNodesAndEdges) {
String outputFileName = ""; String outputFileName = "";
if (authorNodesAndEdges.getCollaborators() != null && authorNodesAndEdges.getCollaborators().size() > 0) { if (authorNodesAndEdges.getCollaborators() != null
&& authorNodesAndEdges.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(authorNodesAndEdges.getEgoCollaborator().getCollaboratorName()) outputFileName = UtilityFunctions.slugify(authorNodesAndEdges
.getEgoCollaborator().getCollaboratorName())
+ "_co-author-network.graphml" + ".xml"; + "_co-author-network.graphml" + ".xml";
} else { } else {
@ -301,47 +287,5 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString()); coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
return fileData; return fileData;
} }
/**
* When the page for person level visualization is requested.
* @param egoURI
* @param coAuthorshipVO
* @param vitroRequest
* @param request
* @return
*/
private TemplateResponseValues prepareStandaloneResponse(
String egoURI,
CollaborationData coAuthorshipVO,
VitroRequest vitroRequest) {
Portal portal = vitroRequest.getPortal();
String title = "";
Map<String, Object> body = new HashMap<String, Object>();
if (coAuthorshipVO.getCollaborators() != null && coAuthorshipVO.getCollaborators().size() > 0) {
title = coAuthorshipVO.getEgoCollaborator().getCollaboratorName() + " - ";
body.put("numOfAuthors", coAuthorshipVO.getCollaborators().size());
}
if (coAuthorshipVO.getCollaborations() != null && coAuthorshipVO.getCollaborations().size() > 0) {
body.put("numOfCoAuthorShips", coAuthorshipVO.getCollaborations().size());
}
//request.setAttribute("scripts", "/templates/visualization/person_level_inject_head.jsp");
String standaloneTemplate = "coAuthorship.ftl";
body.put("portalBean", portal);
body.put("egoURIParam", egoURI);
body.put("title", title + "Co-Authorship Visualization");
return new TemplateResponseValues(standaloneTemplate, body);
}
} }

View file

@ -124,14 +124,16 @@ public class CoAuthorshipVisCodeGenerator {
int uniqueCoAuthorCounter = 0; int uniqueCoAuthorCounter = 0;
Set<Collaborator> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Collaborator>(); Set<Collaborator> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Collaborator>();
List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable = new ArrayList<YearToEntityCountDataElement>(); List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable =
new ArrayList<YearToEntityCountDataElement>();
for (int publicationYear = minPubYearConsidered; for (int publicationYear = minPubYearConsidered;
publicationYear <= currentYear; publicationYear <= currentYear;
publicationYear++) { publicationYear++) {
String publicationYearAsString = String.valueOf(publicationYear); String publicationYearAsString = String.valueOf(publicationYear);
Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors.get(publicationYearAsString); Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors
.get(publicationYearAsString);
Integer currentUniqueCoAuthors = null; Integer currentUniqueCoAuthors = null;
@ -142,7 +144,8 @@ public class CoAuthorshipVisCodeGenerator {
currentUniqueCoAuthors = 0; currentUniqueCoAuthors = 0;
} }
yearToUniqueCoauthorsCountDataTable.add(new YearToEntityCountDataElement(uniqueCoAuthorCounter, yearToUniqueCoauthorsCountDataTable.add(
new YearToEntityCountDataElement(uniqueCoAuthorCounter,
publicationYearAsString, publicationYearAsString,
currentUniqueCoAuthors)); currentUniqueCoAuthors));
uniqueCoAuthorCounter++; uniqueCoAuthorCounter++;
@ -159,12 +162,13 @@ public class CoAuthorshipVisCodeGenerator {
sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable); sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable);
/* /*
* This is required only for the sparklines which convey collaborationships like coinvestigatorships * This is required only for the sparklines which convey collaborationships like
* and coauthorship. There are edge cases where a collaborator can be present for in a collaboration * coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
* with known & unknown year. We do not want to repeat the count for this collaborator when we present * present for in a collaboration with known & unknown year. We do not want to repeat the
* it in the front-end. * count for this collaborator when we present it in the front-end.
* */ * */
Set<Collaborator> totalUniqueCoInvestigators = new HashSet<Collaborator>(allCoAuthorsWithKnownAuthorshipYears); Set<Collaborator> totalUniqueCoInvestigators =
new HashSet<Collaborator>(allCoAuthorsWithKnownAuthorshipYears);
/* /*
* Total publications will also consider publications that have no year associated with * Total publications will also consider publications that have no year associated with
@ -175,7 +179,8 @@ public class CoAuthorshipVisCodeGenerator {
unknownYearCoauthors = yearToUniqueCoauthors unknownYearCoauthors = yearToUniqueCoauthors
.get(VOConstants.DEFAULT_PUBLICATION_YEAR).size(); .get(VOConstants.DEFAULT_PUBLICATION_YEAR).size();
totalUniqueCoInvestigators.addAll(yearToUniqueCoauthors.get(VOConstants.DEFAULT_GRANT_YEAR)); totalUniqueCoInvestigators.addAll(
yearToUniqueCoauthors.get(VOConstants.DEFAULT_GRANT_YEAR));
} }
sparklineData.setUnknownYearPublications(unknownYearCoauthors); sparklineData.setUnknownYearPublications(unknownYearCoauthors);
@ -214,19 +219,22 @@ public class CoAuthorshipVisCodeGenerator {
if (yearToUniqueCoauthors.size() > 0) { if (yearToUniqueCoauthors.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(
individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE)); VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions sparklineData.setDownloadDataLink(
.getCSVDownloadURL( UtilityFunctions.getCSVDownloadURL(
individualURI, individualURI,
VisualizationFrameworkConstants.COAUTHORSHIP_VIS, VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE)); VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE));
Map<String, Integer> yearToUniqueCoauthorsCount = new HashMap<String, Integer>(); Map<String, Integer> yearToUniqueCoauthorsCount = new HashMap<String, Integer>();
for (Map.Entry<String, Set<Collaborator>> currentYearToCoAuthors : yearToUniqueCoauthors.entrySet()) { for (Map.Entry<String, Set<Collaborator>> currentYearToCoAuthors
: yearToUniqueCoauthors.entrySet()) {
yearToUniqueCoauthorsCount.put(currentYearToCoAuthors.getKey(), yearToUniqueCoauthorsCount.put(currentYearToCoAuthors.getKey(),
currentYearToCoAuthors.getValue().size()); currentYearToCoAuthors.getValue().size());
} }

View file

@ -30,21 +30,22 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
private String egoURI; private String egoURI;
private Dataset Dataset; private Dataset dataset;
private long before, after; private long before, after;
private Log log = LogFactory private Log log = LogFactory
.getLog(CoPIGrantCountConstructQueryRunner.class.getName()); .getLog(CoPIGrantCountConstructQueryRunner.class.getName());
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING = "?Role core:roleIn ?Grant . " private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
"?Role core:roleIn ?Grant . "
+ "?Grant rdfs:label ?GrantLabel . " + "?Grant rdfs:label ?GrantLabel . "
+ "?Grant core:relatedRole ?RelatedRole . "; + "?Grant core:relatedRole ?RelatedRole . ";
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
Log log) { Log log) {
this.egoURI = egoURI; this.egoURI = egoURI;
this.Dataset = Dataset; this.dataset = dataset;
// this.log = log; // this.log = log;
} }
@ -191,7 +192,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
return sparqlQuery; return sparqlQuery;
} }
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) { private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
@ -213,7 +214,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
log.error(queryString); log.error(queryString);
} }
QueryExecution qe = QueryExecutionFactory.create(query, Dataset); QueryExecution qe = QueryExecutionFactory.create(query, dataset);
try { try {
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} finally { } finally {
@ -253,7 +254,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
populateConstructQueries(constructQueries); populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, this.Dataset); Model model = executeQuery(constructQueries, this.dataset);
return model; return model;

View file

@ -92,12 +92,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
this.nodeIDGenerator = new UniqueIDGenerator(); this.nodeIDGenerator = new UniqueIDGenerator();
this.edgeIDGenerator = new UniqueIDGenerator(); this.edgeIDGenerator = new UniqueIDGenerator();
} }
private String generateEgoCoPIquery(String queryURI) { private String generateEgoCoPIquery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery() String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT " + "SELECT "
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.PI_URL + ") " + " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.PI_URL + ") "
@ -319,13 +317,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "} " + "} "
+ "} "; + "} ";
// log.debug("COPI QUERY - " + sparqlQuery);
//System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n"); //System.out.println("\n\nCOPI QUERY - " + sparqlQuery + "\n\n");
return sparqlQuery; return sparqlQuery;
} }
private ResultSet executeQuery(String queryText, Model dataSource) { private ResultSet executeQuery(String queryText, Model dataSource) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
@ -371,7 +366,8 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
Collaborator collaboratingNode2, Collaborator collaboratingNode2,
Map<String, Collaboration> edgeUniqueIdentifierToVO) { Map<String, Collaboration> edgeUniqueIdentifierToVO) {
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(collaboratingNode1.getCollaboratorID(), String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
collaboratingNode1.getCollaboratorID(),
collaboratingNode2.getCollaboratorID()); collaboratingNode2.getCollaboratorID());
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier); return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
@ -488,7 +484,8 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
coPIsForCurrentGrant.add(coPINode); coPIsForCurrentGrant.add(coPINode);
log.debug("Co-PI for current grant : " + coPINode.getIndividualLabel()); log.debug("Co-PI for current grant : " + coPINode.getIndividualLabel());
Collaboration egoCoPIEdge = getExistingEdge(egoNode, coPINode, edgeUniqueIdentifierToVO); Collaboration egoCoPIEdge =
getExistingEdge(egoNode, coPINode, edgeUniqueIdentifierToVO);
/* /*
* If "egoCoPIEdge" is null it means that no edge exists in between the egoNode * 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 * & current coPINode. Else create a new edge, add it to the edges set & add
@ -507,12 +504,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
} }
/* /*
* This method takes out all the PIs & edges between PIs that belong to grants * This method takes out all the PIs & edges between PIs that belong to grants
* that have more than 100 PIs. We conjecture that these grants do not provide much * that have more than 100 PIs. We conjecture that these grants do not provide much
* insight. However, we have left the grants be. * insight. However, we have left the grants be.
*
* This method side-effects "nodes" & "edges". * This method side-effects "nodes" & "edges".
* */ * */
removeLowQualityNodesAndEdges(nodes, removeLowQualityNodesAndEdges(nodes,
@ -527,20 +522,20 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
* The below sub-routine will take care of, * The below sub-routine will take care of,
* A - B * A - B
* *
* We are side-effecting "edges" here. The only reason to do this is because we are adding * We are side-effecting "edges" here. The only reason to do this is because we are
* edges en masse for all the co-PIs on all the grants considered so far. The * adding edges en masse for all the co-PIs on all the grants considered so far. The
* other reason being we dont want to compare against 2 sets of edges (edges created before * other reason being we dont want to compare against 2 sets of edges (edges created
* & co-PI edges created during the course of this method) when we are creating a new * before & co-PI edges created during the course of this method) when we are creating
* edge. * a new edge.
* */ * */
createCoPIEdges(grantURLToVO, createCoPIEdges(grantURLToVO,
grantURLToCoPIs, grantURLToCoPIs,
edges, edges,
edgeUniqueIdentifierToVO); edgeUniqueIdentifierToVO);
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to iterate through the ResultSet of SELECT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to iterate through the ResultSet of SELECT queries is in ms: "
+ (after - before));
return new CoInvestigationData(egoNode, nodes, edges); return new CoInvestigationData(egoNode, nodes, edges);
} }
@ -564,14 +559,14 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
&& currentGrantEntry.getValue().size() && currentGrantEntry.getValue().size()
<= MAX_PI_PER_GRANT_ALLOWED) { <= MAX_PI_PER_GRANT_ALLOWED) {
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>(); Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
/* /*
* In order to leverage the nested "for loop" for making edges between all the * In order to leverage the nested "for loop" for making edges between all the
* co-PIs we need to create a list out of the set first. * co-PIs we need to create a list out of the set first.
* */ * */
List<Collaborator> coPINodes = new ArrayList<Collaborator>(currentGrantEntry.getValue()); List<Collaborator> coPINodes =
new ArrayList<Collaborator>(currentGrantEntry.getValue());
Collections.sort(coPINodes, new CollaboratorComparator()); Collections.sort(coPINodes, new CollaboratorComparator());
int numOfCoPIs = coPINodes.size(); int numOfCoPIs = coPINodes.size();
@ -605,9 +600,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
} }
edges.addAll(newlyAddedEdges); edges.addAll(newlyAddedEdges);
} }
} }
} }
private void removeLowQualityNodesAndEdges(Set<Collaborator> nodes, private void removeLowQualityNodesAndEdges(Set<Collaborator> nodes,

View file

@ -33,24 +33,28 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Co-PI Grant Count does not provide Ajax Response."); throw new UnsupportedOperationException("Co-PI Grant Count"
+ " does not provide Ajax response.");
} }
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String egoURI = vitroRequest.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); String egoURI = vitroRequest.getParameter(VisualizationFrameworkConstants
.INDIVIDUAL_URI_KEY);
String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY); String visMode = vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY);
ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log); ModelConstructor constructQueryRunner =
new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<CollaborationData> queryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log); QueryRunner<CollaborationData> queryManager =
new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
CollaborationData PINodesAndEdges = queryManager.getQueryResult(); CollaborationData investigatorNodesAndEdges = queryManager.getQueryResult();
/* /*
* We will be using the same visualization package for both sparkline & co-pi * We will be using the same visualization package for both sparkline & co-pi
@ -63,7 +67,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will * When the csv file is required - based on which sparkline visualization will
* be rendered. * be rendered.
* */ * */
return prepareCoPIsCountPerYearDataResponse(PINodesAndEdges); return prepareCoPIsCountPerYearDataResponse(investigatorNodesAndEdges);
} else if (VisualizationFrameworkConstants.COPIS_LIST_VIS_MODE } else if (VisualizationFrameworkConstants.COPIS_LIST_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -71,7 +75,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will * When the csv file is required - based on which sparkline visualization will
* be rendered. * be rendered.
* */ * */
return prepareCoPIsListDataResponse(PINodesAndEdges); return prepareCoPIsListDataResponse(investigatorNodesAndEdges);
} else if (VisualizationFrameworkConstants.COPI_NETWORK_DOWNLOAD_VIS_MODE } else if (VisualizationFrameworkConstants.COPI_NETWORK_DOWNLOAD_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
@ -79,28 +83,27 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will * When the csv file is required - based on which sparkline visualization will
* be rendered. * be rendered.
* */ * */
return prepareNetworkDownloadDataResponse(PINodesAndEdges); return prepareNetworkDownloadDataResponse(investigatorNodesAndEdges);
} else { } else {
/* /*
* When the graphML file is required - based on which co-pi network * When the graphML file is required - based on which co-pi network
* visualization will be rendered. * visualization will be rendered.
* */ * */
return prepareNetworkStreamDataResponse(PINodesAndEdges); return prepareNetworkStreamDataResponse(investigatorNodesAndEdges);
} }
} }
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
/* /*
* Support for this has ceased to exist. Standalone mode was created only for demo * Support for this has ceased to exist. Standalone mode was created only for demo
* purposes for VIVO Conf. * purposes for VIVO Conf.
* */ * */
throw new UnsupportedOperationException("CoPI does not provide Standalone Response."); throw new UnsupportedOperationException("CoPI does not provide Standalone Response.");
} }
private String getCoPIsListCSVContent(CollaborationData coPIData) { private String getCoPIsListCSVContent(CollaborationData coPIData) {
@ -141,19 +144,20 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
csvFileContent.append(","); csvFileContent.append(",");
csvFileContent.append(currentEntry.getValue().size()); csvFileContent.append(currentEntry.getValue().size());
csvFileContent.append(","); csvFileContent.append(",");
csvFileContent.append(StringEscapeUtils.escapeCsv(getCoPINamesAsString(currentEntry.getValue()))); csvFileContent.append(StringEscapeUtils.escapeCsv(
getCoPINamesAsString(currentEntry.getValue())));
csvFileContent.append("\n"); csvFileContent.append("\n");
} }
return csvFileContent.toString(); return csvFileContent.toString();
} }
private String getCoPINamesAsString(Set<Collaborator> CoPIs) { private String getCoPINamesAsString(Set<Collaborator> coInvestigators) {
StringBuilder coPIsMerged = new StringBuilder(); StringBuilder coPIsMerged = new StringBuilder();
String coPISeparator = ";"; String coPISeparator = ";";
for(Collaborator currentCoPI : CoPIs){ for (Collaborator currentCoPI : coInvestigators) {
coPIsMerged.append(currentCoPI.getCollaboratorName() + coPISeparator); coPIsMerged.append(currentCoPI.getCollaboratorName() + coPISeparator);
} }
@ -167,12 +171,14 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* @param piNodesAndEdges * @param piNodesAndEdges
* @param response * @param response
*/ */
private Map<String, String> prepareCoPIsCountPerYearDataResponse(CollaborationData piNodesAndEdges) { private Map<String, String> prepareCoPIsCountPerYearDataResponse(
CollaborationData piNodesAndEdges) {
String outputFileName; String outputFileName;
Map<String, Set<Collaborator>> yearToCoPIs = new TreeMap<String, Set<Collaborator>>(); Map<String, Set<Collaborator>> yearToCoPIs = new TreeMap<String, Set<Collaborator>>();
if (piNodesAndEdges.getCollaborators() != null && piNodesAndEdges.getCollaborators().size() > 0) { if (piNodesAndEdges.getCollaborators() != null
&& piNodesAndEdges.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(piNodesAndEdges outputFileName = UtilityFunctions.slugify(piNodesAndEdges
.getEgoCollaborator().getCollaboratorName()) .getEgoCollaborator().getCollaboratorName())
@ -208,7 +214,8 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
if (coPIData.getCollaborators() != null && coPIData.getCollaborators().size() > 0) { if (coPIData.getCollaborators() != null && coPIData.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator().getCollaboratorName()) outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator()
.getCollaboratorName())
+ "_co-investigators" + ".csv"; + "_co-investigators" + ".csv";
} else { } else {
@ -253,7 +260,8 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
if (coPIData.getCollaborators() != null && coPIData.getCollaborators().size() > 0) { if (coPIData.getCollaborators() != null && coPIData.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator().getCollaboratorName()) outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator()
.getCollaboratorName())
+ "_co-investigator-network.graphml" + ".xml"; + "_co-investigator-network.graphml" + ".xml";
} else { } else {
@ -274,8 +282,4 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
return fileData; return fileData;
} }
} }

View file

@ -105,8 +105,10 @@ public class CoPIGraphMLWriter {
graphMLContent.append("<edge " graphMLContent.append("<edge "
+ "id=\"" + currentEdge.getCollaborationID() + "\" " + "id=\"" + currentEdge.getCollaborationID() + "\" "
+ "source=\"" + currentEdge.getSourceCollaborator().getCollaboratorID() + "\" " + "source=\"" + currentEdge.getSourceCollaborator()
+ "target=\"" + currentEdge.getTargetCollaborator().getCollaboratorID() + "\" " .getCollaboratorID() + "\" "
+ "target=\"" + currentEdge.getTargetCollaborator()
.getCollaboratorID() + "\" "
+ ">\n"); + ">\n");
graphMLContent.append("\t<data key=\"collaborator1\">" graphMLContent.append("\t<data key=\"collaborator1\">"
@ -208,7 +210,8 @@ public class CoPIGraphMLWriter {
private void getNodeContent(StringBuilder graphMLContent, Collaborator node) { private void getNodeContent(StringBuilder graphMLContent, Collaborator node) {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap individualProfileURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
node.getCollaboratorURI()); node.getCollaboratorURI());
String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX, String profileURL = UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX,

View file

@ -39,7 +39,8 @@ public class CoPIVisCodeGenerator {
* spanning the career of the person & last 10 years at the minimum, in case if * spanning the career of the person & last 10 years at the minimum, in case if
* the person started his career in the last 10 years. * the person started his career in the last 10 years.
* */ * */
private static final String DEFAULT_VISCONTAINER_DIV_ID = "unique_coinvestigators_vis_container"; private static final String DEFAULT_VISCONTAINER_DIV_ID =
"unique_coinvestigators_vis_container";
private Map<String, Set<Collaborator>> yearToUniqueCoPIs; private Map<String, Set<Collaborator>> yearToUniqueCoPIs;
@ -134,7 +135,8 @@ public class CoPIVisCodeGenerator {
int uniqueCoPICounter = 0; int uniqueCoPICounter = 0;
Set<Collaborator> allCoPIsWithKnownGrantShipYears = new HashSet<Collaborator>(); Set<Collaborator> allCoPIsWithKnownGrantShipYears = new HashSet<Collaborator>();
List<YearToEntityCountDataElement> yearToUniqueInvestigatorsCountDataTable = new ArrayList<YearToEntityCountDataElement>(); List<YearToEntityCountDataElement> yearToUniqueInvestigatorsCountDataTable =
new ArrayList<YearToEntityCountDataElement>();
for (int grantYear = minGrantYearConsidered; grantYear <= currentYear; grantYear++) { for (int grantYear = minGrantYearConsidered; grantYear <= currentYear; grantYear++) {
@ -151,7 +153,8 @@ public class CoPIVisCodeGenerator {
currentUniqueCoPIs = 0; currentUniqueCoPIs = 0;
} }
yearToUniqueInvestigatorsCountDataTable.add(new YearToEntityCountDataElement(uniqueCoPICounter, yearToUniqueInvestigatorsCountDataTable.add(new YearToEntityCountDataElement(
uniqueCoPICounter,
grantYearAsString, grantYearAsString,
currentUniqueCoPIs)); currentUniqueCoPIs));
@ -169,12 +172,13 @@ public class CoPIVisCodeGenerator {
sparklineData.setYearToEntityCountDataTable(yearToUniqueInvestigatorsCountDataTable); sparklineData.setYearToEntityCountDataTable(yearToUniqueInvestigatorsCountDataTable);
/* /*
* This is required only for the sparklines which convey collaborationships like coinvestigatorships * This is required only for the sparklines which convey collaborationships like
* and coauthorship. There are edge cases where a collaborator can be present for in a collaboration * coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
* with known & unknown year. We do not want to repeat the count for this collaborator when we present * present for in a collaboration with known & unknown year. We do not want to repeat the
* it in the front-end. * count for this collaborator when we present it in the front-end.
* */ * */
Set<Collaborator> totalUniqueCoInvestigators = new HashSet<Collaborator>(allCoPIsWithKnownGrantShipYears); Set<Collaborator> totalUniqueCoInvestigators =
new HashSet<Collaborator>(allCoPIsWithKnownGrantShipYears);
/* /*
* Total grants will also consider grants that have no year * Total grants will also consider grants that have no year
@ -184,9 +188,8 @@ public class CoPIVisCodeGenerator {
if (yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR) != null) { if (yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR) != null) {
unknownYearGrants = yearToUniqueCoPIs.get( unknownYearGrants = yearToUniqueCoPIs.get(
VOConstants.DEFAULT_GRANT_YEAR).size(); VOConstants.DEFAULT_GRANT_YEAR).size();
totalUniqueCoInvestigators.addAll(
totalUniqueCoInvestigators.addAll(yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR)); yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR));
} }
sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size()); sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size());
@ -227,18 +230,22 @@ public class CoPIVisCodeGenerator {
if (yearToUniqueCoPIs.size() > 0) { if (yearToUniqueCoPIs.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(
individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COPI_VIS_MODE)); VisualizationFrameworkConstants.COPI_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions sparklineData.setDownloadDataLink(
.getCSVDownloadURL( UtilityFunctions.getCSVDownloadURL(
individualURI, individualURI,
VisualizationFrameworkConstants.CO_PI_VIS, VisualizationFrameworkConstants.CO_PI_VIS,
VisualizationFrameworkConstants.COPIS_COUNT_PER_YEAR_VIS_MODE)); VisualizationFrameworkConstants.COPIS_COUNT_PER_YEAR_VIS_MODE));
Map<String, Integer> yearToUniqueCoPIsCount = new HashMap<String, Integer>(); Map<String, Integer> yearToUniqueCoPIsCount = new HashMap<String, Integer>();
for (Map.Entry<String, Set<Collaborator>> currentYearToUniqueCoPIsCount : yearToUniqueCoPIs.entrySet()) { for (Map.Entry<String, Set<Collaborator>> currentYearToUniqueCoPIsCount
: yearToUniqueCoPIs.entrySet()) {
yearToUniqueCoPIsCount.put(currentYearToUniqueCoPIsCount.getKey(), yearToUniqueCoPIsCount.put(currentYearToUniqueCoPIsCount.getKey(),
currentYearToUniqueCoPIsCount.getValue().size()); currentYearToUniqueCoPIsCount.getValue().size());
} }

View file

@ -69,7 +69,7 @@ public class EntityComparisonUtilityFunctions {
return ""; return "";
} }
public static String getHighestLevelOrganizationURI(Log log, Dataset Dataset) public static String getHighestLevelOrganizationURI(Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>(); Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
@ -80,7 +80,8 @@ public class EntityComparisonUtilityFunctions {
String aggregationRules = "(count(?organization) AS ?numOfChildren)"; String aggregationRules = "(count(?organization) AS ?numOfChildren)";
String whereClause = "?organization rdf:type foaf:Organization ; rdfs:label ?organizationLabel . \n" String whereClause = "?organization rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel . \n"
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n" + "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n" + "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
+ "FILTER ( !bound(?parent) ). \n"; + "FILTER ( !bound(?parent) ). \n";
@ -90,7 +91,7 @@ public class EntityComparisonUtilityFunctions {
QueryRunner<ResultSet> highestLevelOrganizationQueryHandler = new GenericQueryRunner( QueryRunner<ResultSet> highestLevelOrganizationQueryHandler = new GenericQueryRunner(
fieldLabelToOutputFieldLabel, aggregationRules, whereClause, fieldLabelToOutputFieldLabel, aggregationRules, whereClause,
groupOrderClause, Dataset, log); groupOrderClause, dataset, log);
String highestLevelOrgURI = EntityComparisonUtilityFunctions String highestLevelOrgURI = EntityComparisonUtilityFunctions
.getHighestLevelOrganizationURI( .getHighestLevelOrganizationURI(
@ -100,13 +101,19 @@ public class EntityComparisonUtilityFunctions {
} }
public static Map<String, Set<String>> getSubEntityTypes(Log log, public static Map<String, Set<String>> getSubEntityTypes(Log log,
Dataset Dataset, String subjectOrganization) Dataset dataset, String subjectOrganization)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
ModelConstructor constructQueryRunnerForSubOrganizationTypes = new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization, Dataset, log) ; ModelConstructor constructQueryRunnerForSubOrganizationTypes =
Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes.getConstructedModel(); new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization,
dataset,
log);
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner( Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes
.getConstructedModel();
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes =
new EntitySubOrganizationTypesQueryRunner(
subjectOrganization, constructedModelForSubOrganizationTypes, log); subjectOrganization, constructedModelForSubOrganizationTypes, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
@ -130,12 +137,13 @@ public class EntityComparisonUtilityFunctions {
} }
public static String getStaffProvidedOrComputedHighestLevelOrganization(Log log, public static String getStaffProvidedOrComputedHighestLevelOrganization(Log log,
Dataset Dataset, VitroRequest vitroRequest) Dataset dataset, VitroRequest vitroRequest)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String finalHighestLevelOrganizationURI = ""; String finalHighestLevelOrganizationURI = "";
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest).getProperty("visualization.topLevelOrg"); String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest)
.getProperty("visualization.topLevelOrg");
/* /*
* First checking if the staff has provided highest level organization in deploy.properties * First checking if the staff has provided highest level organization in deploy.properties
@ -150,12 +158,12 @@ public class EntityComparisonUtilityFunctions {
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization); IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
if (iri.hasViolation(false)) { if (iri.hasViolation(false)) {
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log, Dataset); finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions
.getHighestLevelOrganizationURI(log, dataset);
} else { } else {
finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization; finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
} }
} }
return finalHighestLevelOrganizationURI; return finalHighestLevelOrganizationURI;
} }
} }

View file

@ -30,15 +30,15 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
private String egoURI; private String egoURI;
private Dataset Dataset; private Dataset dataset;
private Log log = LogFactory.getLog(EntityPublicationCountConstructQueryRunner.class.getName()); private Log log = LogFactory.getLog(EntityPublicationCountConstructQueryRunner.class.getName());
private long before, after; private long before, after;
public EntityPublicationCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){ public EntityPublicationCountConstructQueryRunner(String egoURI, Dataset dataset, Log log) {
this.egoURI = egoURI; this.egoURI = egoURI;
this.Dataset = Dataset; this.dataset = dataset;
//this.log = log; //this.log = log;
} }
@ -71,7 +71,6 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document rdfs:label ?DocumentLabel . " + "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . " + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . " + "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property "
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
@ -82,7 +81,6 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Person core:authorInAuthorship ?Resource . " + "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . " + "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . " + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel " + "?Document rdfs:label ?DocumentLabel "
+ "}" + "}"
+ "UNION " + "UNION "
@ -90,16 +88,9 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document core:dateTimeValue ?dateTimeValue . " + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate " + "?dateTimeValue core:dateTime ?publicationDate "
+ "}" + "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}"; + "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForPersons(String queryURI) { private String generateConstructQueryForPersons(String queryURI) {
@ -116,7 +107,6 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document rdfs:label ?DocumentLabel . " + "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . " + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . " + "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property ."
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
@ -125,7 +115,6 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Person core:authorInAuthorship ?Resource . " + "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . " + "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . " + "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel " + "?Document rdfs:label ?DocumentLabel "
+ "}" + "}"
+ "UNION" + "UNION"
@ -133,16 +122,9 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document core:dateTimeValue ?dateTimeValue . " + "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate " + "?dateTimeValue core:dateTime ?publicationDate "
+ "}" + "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}"; + "}";
return sparqlQuery; return sparqlQuery;
} }
// private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){ // private String generateConstructQueryForDocumentDateTimeValueOneLevelDeep(String queryURI){
@ -217,7 +199,7 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
// //
// } // }
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) { private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
@ -228,15 +210,16 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
Query query = null; Query query = null;
try { try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX); query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
+ queryString, SYNTAX);
} catch (Throwable th) { } catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query " + log.error("Could not create CONSTRUCT SPARQL query for query "
"string. " + th.getMessage()); + "string. " + th.getMessage());
log.error(queryString); log.error(queryString);
} }
QueryExecution qe = QueryExecutionFactory.create( QueryExecution qe = QueryExecutionFactory.create(
query, Dataset); query, dataset);
try { try {
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
@ -245,9 +228,9 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
} }
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
+ (after - before));
} }
// constructedModel.write(System.out);
return constructedModel; return constructedModel;
} }
@ -275,7 +258,7 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
populateConstructQueries(constructQueries); populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, Model model = executeQuery(constructQueries,
this.Dataset); this.dataset);
return model; return model;
@ -288,6 +271,5 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
constructQueries.add(generateConstructQueryForPersons(this.egoURI)); constructQueries.add(generateConstructQueryForPersons(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI)); // constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI)); // constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
} }
} }

View file

@ -54,8 +54,7 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?PersonLabel) as ?personLabelLit) " + " (str(?PersonLabel) as ?personLabelLit) "
+ " (str(?Document) as ?documentLit) " + " (str(?Document) as ?documentLit) "
+ " (str(?DocumentLabel) as ?documentLabelLit) " + " (str(?DocumentLabel) as ?documentLabelLit) "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") " + " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")";
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") ";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = "" private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
@ -65,10 +64,10 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " ?dateTimeValue core:dateTime ?publicationDate } ." + " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } ."; + "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } .";
private static String ENTITY_LABEL; private static final String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
private static String ENTITY_URL; private static final String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
private static String SUBENTITY_LABEL; private static final String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL;
private static String SUBENTITY_URL; private static final String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
public EntityPublicationCountQueryRunner(String entityURI, public EntityPublicationCountQueryRunner(String entityURI,
Model dataSource, Log log) { Model dataSource, Log log) {
@ -108,13 +107,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
biboDocument = new Activity(documentNode.toString()); biboDocument = new Activity(documentNode.toString());
biboDocumentURLToVO.put(documentNode.toString(), biboDocument); biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
// RDFNode documentLabelNode = solution RDFNode publicationDateNode = solution.get(QueryFieldLabels
// .get(QueryFieldLabels.DOCUMENT_LABEL); .DOCUMENT_PUBLICATION_DATE);
// if (documentLabelNode != null) {
// biboDocument.setDocumentLabel(documentLabelNode.toString());
// }
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) { if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString()); biboDocument.setActivityDate(publicationDateNode.toString());
} }
@ -163,8 +157,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
/* /*
* This makes sure that either, * This makes sure that either,
* 1. the parent organization is a department-like organization with no organizations * 1. the parent organization is a department-like organization with no
* beneath it, or * organizations beneath it, or
* 2. the parent organizations has both sub-organizations and people directly * 2. the parent organizations has both sub-organizations and people directly
* attached to that organizations e.g. president of a university. * attached to that organizations e.g. president of a university.
* */ * */
@ -187,9 +181,9 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
} }
// log.debug("Returning entity that contains the following set of subentities: "+entity.getSubEntities().toString());
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to iterate through the ResultSet of SELECT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to iterate through the ResultSet of SELECT queries is in ms: "
+ (after - before));
return entity; return entity;
} }
@ -198,26 +192,11 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create( Query query = QueryFactory.create(
getSparqlQuery(queryURI), SYNTAX); getSparqlQueryForOrganization(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataSource); queryExecution = QueryExecutionFactory.create(query, dataSource);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
private String getSparqlQuery(String queryURI) {
String result = "";
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 getSparqlQueryForOrganization(String queryURI) { private String getSparqlQueryForOrganization(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery() String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
@ -229,7 +208,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ." + "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization ." + "<" + queryURI + "> core:hasSubOrganization ?subOrganization ."
+ "?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . " + "?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ." + " ?Position core:positionForPerson ?Person ."
+ " ?Person core:authorInAuthorship ?Resource ; rdfs:label ?PersonLabel . " + " ?Person core:authorInAuthorship ?Resource ; rdfs:label ?PersonLabel . "
+ " ?Resource core:linkedInformationResource ?Document . " + " ?Resource core:linkedInformationResource ?Document . "
@ -243,9 +223,7 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}" + SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ "}"; + "}";
//System.out.println("\n\nEntity Pub Count query is: "+ sparqlQuery);
log.debug("\nThe sparql query is :\n" + sparqlQuery); log.debug("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }
@ -253,7 +231,6 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
public Entity getQueryResult() throws MalformedQueryParametersException { public Entity getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) { if (StringUtils.isNotBlank(this.entityURI)) {
/* /*
* To test for the validity of the URI submitted. * To test for the validity of the URI submitted.
*/ */
@ -278,12 +255,9 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to execute the SELECT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to execute the SELECT queries is in milliseconds: "
+ (after - before));
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }
} }

View file

@ -38,7 +38,7 @@ public class EntityPublicationCountRequestHandler implements
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String entityURI = vitroRequest String entityURI = vitroRequest
@ -47,17 +47,22 @@ public class EntityPublicationCountRequestHandler implements
if (StringUtils.isBlank(entityURI)) { if (StringUtils.isBlank(entityURI)) {
entityURI = EntityComparisonUtilityFunctions entityURI = EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset, vitroRequest); .getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
} }
return prepareStandaloneMarkupResponse(vitroRequest, entityURI); return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
} }
private Map<String, String> getSubjectEntityAndGenerateDataResponse( private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI) String subjectEntityURI)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(subjectEntityURI, Dataset, log); ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner( QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
@ -72,7 +77,7 @@ public class EntityPublicationCountRequestHandler implements
} else { } else {
return getSubEntityTypesAndComputeDataResponse( return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset, vitroRequest, log, dataset,
subjectEntityURI, entity); subjectEntityURI, entity);
} }
} }
@ -84,17 +89,19 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream"); "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Publications for this Organization found in VIVO.\"}"); fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
"{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
return fileData; return fileData;
} }
private Map<String, String> getSubEntityTypesAndComputeDataResponse( private Map<String, String> getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, Entity entity) String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( Map<String, Set<String>> subOrganizationTypesResult =
log, Dataset, subjectEntityURI); EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, subjectEntityURI);
return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(), return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
subOrganizationTypesResult); subOrganizationTypesResult);
@ -102,7 +109,7 @@ public class EntityPublicationCountRequestHandler implements
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String entityURI = vitroRequest String entityURI = vitroRequest
@ -112,25 +119,26 @@ public class EntityPublicationCountRequestHandler implements
* This will provide the data in json format mainly used for standalone tmeporal vis. * This will provide the data in json format mainly used for standalone tmeporal vis.
* */ * */
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) { .equalsIgnoreCase(vitroRequest.getParameter(
VisualizationFrameworkConstants.VIS_MODE_KEY))) {
if (StringUtils.isNotBlank(entityURI)) { if (StringUtils.isNotBlank(entityURI)) {
return getSubjectEntityAndGenerateDataResponse( return getSubjectEntityAndGenerateDataResponse(
vitroRequest, vitroRequest,
log, log,
Dataset, dataset,
entityURI); entityURI);
} else { } else {
return getSubjectEntityAndGenerateDataResponse( return getSubjectEntityAndGenerateDataResponse(
vitroRequest, vitroRequest,
log, log,
Dataset, dataset,
EntityComparisonUtilityFunctions EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization( .getStaffProvidedOrComputedHighestLevelOrganization(
log, log,
Dataset, dataset,
vitroRequest)); vitroRequest));
} }
@ -139,7 +147,9 @@ public class EntityPublicationCountRequestHandler implements
* This provides csv download files for the content in the tables. * This provides csv download files for the content in the tables.
* */ * */
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(entityURI, Dataset, log); ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(entityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner( QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
@ -147,8 +157,9 @@ public class EntityPublicationCountRequestHandler implements
Entity entity = queryManager.getQueryResult(); Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( Map<String, Set<String>> subOrganizationTypesResult =
log, Dataset, entityURI); EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult); return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult);
@ -159,7 +170,7 @@ public class EntityPublicationCountRequestHandler implements
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Entity Pub Count does not provide Ajax Response."); throw new UnsupportedOperationException("Entity Pub Count does not provide Ajax Response.");
} }
@ -209,7 +220,9 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream"); "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writePublicationsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult)); writePublicationsOverTimeJSON(vitroRequest,
entity.getSubEntities(),
subOrganizationTypesResult));
return fileData; return fileData;
} }
@ -219,7 +232,8 @@ public class EntityPublicationCountRequestHandler implements
Portal portal = vreq.getPortal(); Portal portal = vreq.getPortal();
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl"; String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq, String organizationLabel = EntityComparisonUtilityFunctions
.getEntityLabelFromDAO(vreq,
entityURI); entityURI);
Map<String, Object> body = new HashMap<String, Object>(); Map<String, Object> body = new HashMap<String, Object>();
@ -232,7 +246,7 @@ public class EntityPublicationCountRequestHandler implements
} }
/** /**
* function to generate a json file for year <-> publication count mapping * Function to generate a json file for year <-> publication count mapping.
* @param vreq * @param vreq
* @param subentities * @param subentities
* @param subOrganizationTypesResult * @param subOrganizationTypesResult
@ -266,10 +280,9 @@ public class EntityPublicationCountRequestHandler implements
yearPubCount.add(currentPubYear); yearPubCount.add(currentPubYear);
} }
//log.info("entityJson.getLabel() : " + entityJson.getLabel() + " subOrganizationTypesResult " + subOrganizationTypesResult.toString());
entityJson.setYearToActivityCount(yearPubCount); entityJson.setYearToActivityCount(yearPubCount);
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel())); entityJson.getOrganizationType().addAll(
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI()); entityJson.setEntityURI(subentity.getIndividualURI());
@ -280,15 +293,14 @@ public class EntityPublicationCountRequestHandler implements
} else { } else {
entityJson.setVisMode("ORGANIZATION"); entityJson.setVisMode("ORGANIZATION");
} }
// setEntityVisMode(entityJson);
subEntitiesJson.add(entityJson); subEntitiesJson.add(entityJson);
} }
return json.toJson(subEntitiesJson); return json.toJson(subEntitiesJson);
} }
private String getEntityPublicationsPerYearCSVContent(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) { private String getEntityPublicationsPerYearCSVContent(
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder(); StringBuilder csvFileContent = new StringBuilder();
@ -303,17 +315,14 @@ public class EntityPublicationCountRequestHandler implements
StringBuilder joinedTypes = new StringBuilder(); StringBuilder joinedTypes = new StringBuilder();
for(String subOrganizationType : subOrganizationTypesResult.get(subEntity.getIndividualLabel())){ for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; "); joinedTypes.append(subOrganizationType + "; ");
} }
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString())); csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append("\n"); csvFileContent.append("\n");
} }
return csvFileContent.toString(); return csvFileContent.toString();
} }
} }

View file

@ -30,13 +30,14 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
private String egoURI; private String egoURI;
private Dataset Dataset; private Dataset dataset;
private Log log = LogFactory.getLog(EntitySubOrganizationTypesConstructQueryRunner.class.getName()); private Log log = LogFactory.getLog(EntitySubOrganizationTypesConstructQueryRunner
.class.getName());
public EntitySubOrganizationTypesConstructQueryRunner(String egoURI, Dataset Dataset, Log log){ public EntitySubOrganizationTypesConstructQueryRunner(String egoURI, Dataset dataset, Log log) {
this.egoURI = egoURI; this.egoURI = egoURI;
this.Dataset = Dataset; this.dataset = dataset;
//this.log = log; //this.log = log;
} }
@ -77,12 +78,9 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
+ "?Person rdfs:label ?PersonLabel ." + "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . " + "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel " + "?PersonType rdfs:label ?PersonTypeLabel "
+ "}"; + "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForPersonTypes(String queryURI) { private String generateConstructQueryForPersonTypes(String queryURI) {
@ -104,12 +102,10 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
+ "?PersonType rdfs:label ?PersonTypeLabel " + "?PersonType rdfs:label ?PersonTypeLabel "
+ "}"; + "}";
return sparqlQuery; return sparqlQuery;
} }
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) { private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
long before = 0; long before = 0;
@ -122,15 +118,16 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
Query query = null; Query query = null;
try { try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX); query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
+ queryString, SYNTAX);
} catch (Throwable th) { } catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query " + log.error("Could not create CONSTRUCT SPARQL query for query "
"string. " + th.getMessage()); + "string. " + th.getMessage());
log.error(queryString); log.error(queryString);
} }
QueryExecution qe = QueryExecutionFactory.create( QueryExecution qe = QueryExecutionFactory.create(
query, Dataset); query, dataset);
try { try {
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} finally { } finally {
@ -167,19 +164,14 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
populateConstructQueries(constructQueries); populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, Model model = executeQuery(constructQueries,
this.Dataset); this.dataset);
//model.write(System.out); //model.write(System.out);
return model; return model;
} }
private void populateConstructQueries(Set<String> constructQueries) { private void populateConstructQueries(Set<String> constructQueries) {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI)); constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizationTypes(this.egoURI)); constructQueries.add(generateConstructQueryForSubOrganizationTypes(this.egoURI));
constructQueries.add(generateConstructQueryForPersonTypes(this.egoURI)); constructQueries.add(generateConstructQueryForPersonTypes(this.egoURI));
} }
} }

View file

@ -2,7 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison; package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -11,7 +13,6 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.iri.IRI; import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory; import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation; 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.Query;
import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryExecutionFactory;
@ -19,24 +20,21 @@ import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax; import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants; import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels; 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.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner; import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
import java.util.Set;
import java.util.HashSet;
/** /**
* @author bkoniden * @author bkoniden
* Deepak Konidena * Deepak Konidena
*/ */
public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<String, Set<String>>> { public class EntitySubOrganizationTypesQueryRunner
implements QueryRunner<Map<String, Set<String>>> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ; protected static final Syntax SYNTAX = Syntax.syntaxARQ;
@ -48,7 +46,8 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ " (str(?organizationLabel) as ?" + QueryFieldLabels.ORGANIZATION_LABEL + ") " + " (str(?organizationLabel) as ?" + QueryFieldLabels.ORGANIZATION_LABEL + ") "
+ " (str(?subOrganizationLabel) as ?" + QueryFieldLabels.SUBORGANIZATION_LABEL + ") " + " (str(?subOrganizationLabel) as ?" + QueryFieldLabels.SUBORGANIZATION_LABEL + ") "
+ " (str(?subOrganizationType) as ?" + QueryFieldLabels.SUBORGANIZATION_TYPE + ")" + " (str(?subOrganizationType) as ?" + QueryFieldLabels.SUBORGANIZATION_TYPE + ")"
+ " (str(?subOrganizationTypeLabel) as ?"+QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL+") " + " (str(?subOrganizationTypeLabel) as ?"
+ QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL + ") "
+ " (str(?Person) as ?personLit) " + " (str(?Person) as ?personLit) "
+ " (str(?PersonLabel) as ?personLabelLit) " + " (str(?PersonLabel) as ?personLabelLit) "
+ " (str(?PersonTypeLabel) as ?personTypeLabelLit) "; + " (str(?PersonTypeLabel) as ?personTypeLabelLit) ";
@ -84,7 +83,8 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ "> rdfs:label ?organizationLabel . " + "> rdfs:label ?organizationLabel . "
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . " + "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel ; rdf:type ?subOrganizationType ;" + "?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " rdf:type ?subOrganizationType ;"
+ " core:organizationForPosition ?Position . " + " core:organizationForPosition ?Position . "
+ "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . " + "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
+ "?Position core:positionForPerson ?Person ." + "?Position core:positionForPerson ?Person ."
@ -97,18 +97,11 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ "?PersonType rdfs:label ?PersonTypeLabel . " + "?PersonType rdfs:label ?PersonTypeLabel . "
+ "}" + "}"
+ "}"; + "}";
// log.debug("\n SubOrganizationTypesQuery :" + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }
private Map<String, Set<String>> createJavaValueObjects(ResultSet resultSet) { private Map<String, Set<String>> createJavaValueObjects(ResultSet resultSet) {
// Map<String, Set<String>> subOrganizationLabelToTypes = new HashMap<String, Set<String>>();
// Map<String, Set<String>> personLabelToTypes = new HashMap<String, Set<String>>();
Map<String, Set<String>> subEntityLabelToTypes = new HashMap<String, Set<String>>(); Map<String, Set<String>> subEntityLabelToTypes = new HashMap<String, Set<String>>();
while (resultSet.hasNext()) { while (resultSet.hasNext()) {
@ -166,19 +159,12 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
} }
} }
// System.out.println("\n\nSub Organization Label Types Size --> " + subOrganizationLabelToTypes.size());
// System.out.println("\n\nPeople Label Types Size --> " + personLabelToTypes.size());
// log.debug("Sub Organization Label Types Size : " + subEntityLabelToTypes.size());
return subEntityLabelToTypes; return subEntityLabelToTypes;
//return (subOrganizationLabelToTypes.size() != 0 )? subOrganizationLabelToTypes : personLabelToTypes ;
} }
public Map<String, Set<String>> getQueryResult() throws MalformedQueryParametersException { public Map<String, Set<String>> getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) { if (StringUtils.isNotBlank(this.entityURI)) {
/* /*
* To test for the validity of the URI submitted. * To test for the validity of the URI submitted.
*/ */
@ -191,16 +177,13 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
throw new MalformedQueryParametersException( throw new MalformedQueryParametersException(
"URI provided for an entity is malformed."); "URI provided for an entity is malformed.");
} }
} else { } else {
throw new MalformedQueryParametersException( throw new MalformedQueryParametersException(
"URL parameter is either null or empty."); "URL parameter is either null or empty.");
} }
ResultSet resultSet = executeQuery(this.entityURI, this.dataSource); ResultSet resultSet = executeQuery(this.entityURI, this.dataSource);
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }
} }

View file

@ -31,77 +31,73 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
private String egoURI; private String egoURI;
private Dataset Dataset; private Dataset dataset;
private long before, after; private long before, after;
private Log log = LogFactory.getLog(EntityGrantCountConstructQueryRunner.class.getName()); private Log log = LogFactory
.getLog(EntityGrantCountConstructQueryRunner.class.getName());
public EntityGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){ public EntityGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
Log log) {
this.egoURI = egoURI; this.egoURI = egoURI;
this.Dataset = Dataset; this.dataset = dataset;
// this.log = log; // this.log = log;
} }
private String generateConstructQueryForOrganizationLabel(String queryURI) { private String generateConstructQueryForOrganizationLabel(String queryURI) {
String sparqlQuery = String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
"CONSTRUCT { " + "> rdfs:label ?organizationLabel ." + "}" + "WHERE {" + "<"
+ "<"+queryURI+ "> rdfs:label ?organizationLabel ." + queryURI + "> rdfs:label ?organizationLabel " + "}";
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?organizationLabel "
+ "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(String queryURI, String preboundProperty){ private String generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(
String queryURI, String preboundProperty) {
String sparqlQuery = String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
"CONSTRUCT { " + "> core:hasSubOrganization ?subOrganization . "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . " + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . " + "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . " + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " + "?endDate core:dateTime ?endDateTimeValue . " + "}"
+ "}" + "WHERE { " + "{" + "<" + queryURI
+ "WHERE { " + "> core:hasSubOrganization ?subOrganization . "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . " + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . " + "?startDate core:dateTime ?startDateTimeValue . "
+ "} UNION " + "} UNION " + "{" + "<" + queryURI
+ "{" + "> core:hasSubOrganization ?subOrganization . "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . " + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . " + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " + "?endDate core:dateTime ?endDateTimeValue . " + "}" + "}";
+ "}"
+ "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(String queryURI, String preboundProperty){ private String generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(
String queryURI, String preboundProperty) {
String sparqlQuery = String sparqlQuery = "CONSTRUCT { " + "<"
"CONSTRUCT { " + queryURI
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
@ -111,72 +107,77 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "<"
+ queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION " + "} UNION "
+ "{" + "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "<"
+ queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant " + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}" + "}" + "}";
+ "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForDateTimeValueofRole(String queryURI, String preboundProperty){ private String generateConstructQueryForDateTimeValueofRole(
String queryURI, String preboundProperty) {
String sparqlQuery = String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
"CONSTRUCT { " + "> core:organizationForPosition ?Position . "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "?Position core:positionForPerson ?Person . " + "?Person "
+ "?Position core:positionForPerson ?Person . " + preboundProperty + " ?Role . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . " + "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . " + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue " + "?endDate core:dateTime ?endDateTimeValue " + "}"
+ "}" + "WHERE { " + "{" + "<" + queryURI
+ "WHERE { " + "> core:organizationForPosition ?Position . "
+ "{" + "?Position core:positionForPerson ?Person . " + "?Person "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + preboundProperty + " ?Role . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . " + "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue " + "?startDate core:dateTime ?startDateTimeValue " + "} UNION "
+ "} UNION " + "{" + "<" + queryURI
+ "{" + "> core:organizationForPosition ?Position . "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "?Position core:positionForPerson ?Person . " + "?Person "
+ "?Position core:positionForPerson ?Person . " + preboundProperty + " ?Role . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . " + "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . " + "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue " + "?endDate core:dateTime ?endDateTimeValue " + "}" + "}";
+ "}"
+ "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForDateTimeValueofGrant(String queryURI, String preboundProperty){ private String generateConstructQueryForDateTimeValueofGrant(
String queryURI, String preboundProperty) {
String sparqlQuery = String sparqlQuery = "CONSTRUCT { " + "<"
"CONSTRUCT { " + queryURI
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
@ -186,87 +187,82 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
+ "}" + "}"
+ "WHERE { " + "WHERE { "
+ "{" + "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "<"
+ queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . " + "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant " + "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION " + "} UNION "
+ "{" + "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "<"
+ queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . " + "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ." + "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . " + "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . " + "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant " + "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}" + "}" + "}";
+ "}";
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForSubOrganizations(String queryURI, String preboundProperty){ private String generateConstructQueryForSubOrganizations(String queryURI,
String preboundProperty) {
String sparqlQuery = String sparqlQuery =
"CONSTRUCT { " "CONSTRUCT { " + "<" + queryURI
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . " + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . " + "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person rdfs:label ?PersonLabel ." + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Role core:roleIn ?Grant ." + "?Grant rdfs:label ?GrantLabel " + "}" + "WHERE { " + "<"
+ "?Grant rdfs:label ?GrantLabel " + queryURI + "> core:hasSubOrganization ?subOrganization . "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . " + "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . " + "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person rdfs:label ?PersonLabel ." + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Role core:roleIn ?Grant ." + "?Grant rdfs:label ?GrantLabel " + "}";
+ "?Grant rdfs:label ?GrantLabel "
+ "}" ;
return sparqlQuery; return sparqlQuery;
} }
private String generateConstructQueryForPersons(String queryURI, String preboundProperty){ private String generateConstructQueryForPersons(String queryURI,
String preboundProperty) {
String sparqlQuery = String sparqlQuery =
"CONSTRUCT { " "CONSTRUCT { " + "<" + queryURI
+ "<"+queryURI+ "> core:organizationForPosition ?Position . " + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person rdfs:label ?PersonLabel ." + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Role core:roleIn ?Grant ." + "?Grant rdfs:label ?GrantLabel " + "}" + "WHERE { " + "<"
+ "?Grant rdfs:label ?GrantLabel " + queryURI + "> core:organizationForPosition ?Position . "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person rdfs:label ?PersonLabel ." + "?Person "
+ "?Person " + preboundProperty + " ?Role . " + preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Role core:roleIn ?Grant ." + "?Grant rdfs:label ?GrantLabel " + "}";
+ "?Grant rdfs:label ?GrantLabel "
+ "}" ;
return sparqlQuery; return sparqlQuery;
} }
private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel(); Model constructedModel = ModelFactory.createDefaultModel();
@ -279,16 +275,17 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
Query query = null; Query query = null;
try { try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX); query = QueryFactory.create(QueryConstants
.getSparqlPrefixQuery()
+ queryString, SYNTAX);
// log.debug("query: "+ queryString); // log.debug("query: "+ queryString);
} catch (Throwable th) { } catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query " + log.error("Could not create CONSTRUCT SPARQL query for query "
"string. " + th.getMessage()); + "string. " + th.getMessage());
log.error(queryString); log.error(queryString);
} }
QueryExecution qe = QueryExecutionFactory.create( QueryExecution qe = QueryExecutionFactory.create(query, dataset);
query, Dataset);
try { try {
qe.execConstruct(constructedModel); qe.execConstruct(constructedModel);
} finally { } finally {
@ -299,37 +296,40 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
after = System.currentTimeMillis(); after = System.currentTimeMillis();
// log.debug("Statements for constructed model of EntityGrantCount : "+ constructedModel.listStatements().toString()); // log.debug("Statements for constructed model of EntityGrantCount : "+
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) ); // constructedModel.listStatements().toString());
log
.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
+ (after - before));
// constructedModel.write(System.out); // constructedModel.write(System.out);
return constructedModel; return constructedModel;
} }
public Model getConstructedModel() public Model getConstructedModel() throws MalformedQueryParametersException {
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) { if (StringUtils.isNotBlank(this.egoURI)) {
/* /*
* To test for the validity of the URI submitted. * To test for the validity of the URI submitted.
* */ */
IRIFactory iRIFactory = IRIFactory.jenaImplementation(); IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.egoURI); IRI iri = iRIFactory.create(this.egoURI);
if (iri.hasViolation(false)) { if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage(); String errorMsg = ((Violation) iri.violations(false).next())
.getShortMessage();
log.error("Entity Grant Count Construct Query " + errorMsg); log.error("Entity Grant Count Construct Query " + errorMsg);
throw new MalformedQueryParametersException( throw new MalformedQueryParametersException(
"URI provided for an individual is malformed."); "URI provided for an individual is malformed.");
} }
} else { } else {
throw new MalformedQueryParametersException("URI parameter is either null or empty."); throw new MalformedQueryParametersException(
"URI parameter is either null or empty.");
} }
Set<String> constructQueries = new LinkedHashSet<String>(); Set<String> constructQueries = new LinkedHashSet<String>();
populateConstructQueries(constructQueries); populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, Model model = executeQuery(constructQueries, this.dataset);
this.Dataset);
return model; return model;
@ -337,28 +337,53 @@ public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
private void populateConstructQueries(Set<String> constructQueries) { private void populateConstructQueries(Set<String> constructQueries) {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI)); constructQueries
.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI, "core:hasInvestigatorRole")); constructQueries.add(generateConstructQueryForSubOrganizations(
constructQueries.add(generateConstructQueryForPersons(this.egoURI, "core:hasInvestigatorRole")); this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(this.egoURI, "core:hasInvestigatorRole")); constructQueries.add(generateConstructQueryForPersons(this.egoURI,
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasInvestigatorRole")); "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(this.egoURI, "core:hasInvestigatorRole")); constructQueries
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasInvestigatorRole")); .add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(
this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasInvestigatorRole"));
constructQueries
.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(
this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI, "core:hasPrincipalInvestigatorRole")); constructQueries.add(generateConstructQueryForSubOrganizations(
constructQueries.add(generateConstructQueryForPersons(this.egoURI, "core:hasPrincipalInvestigatorRole")); this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(this.egoURI, "core:hasPrincipalInvestigatorRole")); constructQueries.add(generateConstructQueryForPersons(this.egoURI,
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasPrincipalInvestigatorRole")); "core:hasPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(this.egoURI, "core:hasPrincipalInvestigatorRole")); constructQueries
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasPrincipalInvestigatorRole")); .add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); constructQueries.add(generateConstructQueryForSubOrganizations(
constructQueries.add(generateConstructQueryForPersons(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); constructQueries.add(generateConstructQueryForPersons(this.egoURI,
constructQueries.add(generateConstructQueryForDateTimeValueofRole(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); constructQueries
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(this.egoURI, "core:hasCo-PrincipalInvestigatorRole")); .add(generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
} }

View file

@ -89,10 +89,10 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "}"; + "}";
private static String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL; private static final String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
private static String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL; private static final String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
private static String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL ; private static final String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL;
private static String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL; private static final String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
public EntityGrantCountQueryRunner(String entityURI, public EntityGrantCountQueryRunner(String entityURI,
@ -113,7 +113,6 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
before = System.currentTimeMillis(); before = System.currentTimeMillis();
while (resultSet.hasNext()) { while (resultSet.hasNext()) {
// log.debug("Checking whether EntityGrantCount produced any resultset against the Constructed Model");
QuerySolution solution = resultSet.nextSolution(); QuerySolution solution = resultSet.nextSolution();
if (entity == null) { if (entity == null) {
@ -207,15 +206,13 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
/* /*
* This makes sure that either, * This makes sure that either,
* 1. the parent organization is a department-like organization with no organizations * 1. the parent organization is a department-like organization with no
* beneath it, or * organizations beneath it, or
* 2. the parent organizations has both sub-organizations and people directly * 2. the parent organizations has both sub-organizations and people directly
* attached to that organizations e.g. president of a university. * attached to that organizations e.g. president of a university.
* */ * */
if (subEntityURLNode == null) { if (subEntityURLNode == null) {
entity.addSubEntity(person); entity.addSubEntity(person);
} }
person.addActivity(grant); person.addActivity(grant);
@ -225,16 +222,13 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
entity.addActivity(grant); entity.addActivity(grant);
} }
/*if (subentityURLToVO.size() == 0 && personURLToVO.size() != 0) { if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0) {
for (SubEntity person : personURLToVO.values()) {
entity.addSubEntity(person);
}
} else */if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0) {
entity = new Entity(this.entityURI, "no-label"); entity = new Entity(this.entityURI, "no-label");
} }
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to iterate through the ResultSet of SELECT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to iterate through the ResultSet of SELECT queries is in ms: "
+ (after - before));
return entity; return entity;
} }
@ -255,7 +249,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ." + "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization ." + "<" + queryURI + "> core:hasSubOrganization ?subOrganization ."
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . " + " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ." + " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasCo-PrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel ." + " ?Person core:hasCo-PrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel ."
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
@ -263,7 +258,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "UNION " + "UNION "
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . " + "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . " + " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ." + " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasPrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel . " + " ?Person core:hasPrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
@ -271,7 +267,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "UNION " + "UNION "
+ "{ " + "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . " + "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . " + " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ." + " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasInvestigatorRole ?Role ; rdfs:label ?PersonLabel . " + " ?Person core:hasInvestigatorRole ?Role ; rdfs:label ?PersonLabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
@ -299,18 +296,12 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME + "}" + SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME + "}"
+ " } "; + " } ";
//System.out.println("\n\nEntity Activity Count query is: "+ sparqlQuery);
// log.debug("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery; return sparqlQuery;
} }
public Entity getQueryResult() throws MalformedQueryParametersException { public Entity getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) { if (StringUtils.isNotBlank(this.entityURI)) {
/* /*
* To test for the validity of the URI submitted. * To test for the validity of the URI submitted.
*/ */
@ -335,7 +326,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
after = System.currentTimeMillis(); after = System.currentTimeMillis();
log.debug("Time taken to execute the SELECT queries is in milliseconds: " + (after - before) ); log.debug("Time taken to execute the SELECT queries is in milliseconds: "
+ (after - before));
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }

View file

@ -40,7 +40,7 @@ public class EntityGrantCountRequestHandler implements
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String entityURI = vitroRequest String entityURI = vitroRequest
@ -49,7 +49,10 @@ public class EntityGrantCountRequestHandler implements
if (StringUtils.isBlank(entityURI)) { if (StringUtils.isBlank(entityURI)) {
entityURI = EntityComparisonUtilityFunctions entityURI = EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset, vitroRequest); .getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
} }
return prepareStandaloneMarkupResponse(vitroRequest, entityURI); return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
@ -57,7 +60,7 @@ public class EntityGrantCountRequestHandler implements
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String entityURI = vitroRequest String entityURI = vitroRequest
@ -67,25 +70,26 @@ public class EntityGrantCountRequestHandler implements
* This will provide the data in json format mainly used for standalone temporal vis. * This will provide the data in json format mainly used for standalone temporal vis.
* */ * */
if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE if (VisualizationFrameworkConstants.TEMPORAL_GRAPH_JSON_DATA_VIS_MODE
.equalsIgnoreCase(vitroRequest.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) { .equalsIgnoreCase(vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_MODE_KEY))) {
if (StringUtils.isNotBlank(entityURI)) { if (StringUtils.isNotBlank(entityURI)) {
return getSubjectEntityAndGenerateDataResponse( return getSubjectEntityAndGenerateDataResponse(
vitroRequest, vitroRequest,
log, log,
Dataset, dataset,
entityURI); entityURI);
} else { } else {
return getSubjectEntityAndGenerateDataResponse( return getSubjectEntityAndGenerateDataResponse(
vitroRequest, vitroRequest,
log, log,
Dataset, dataset,
EntityComparisonUtilityFunctions EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization( .getStaffProvidedOrComputedHighestLevelOrganization(
log, log,
Dataset, dataset,
vitroRequest)); vitroRequest));
} }
@ -93,8 +97,9 @@ public class EntityGrantCountRequestHandler implements
/* /*
* This provides csv download files for the content in the tables. * This provides csv download files for the content in the tables.
* */ * */
ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(entityURI, dataset, log);
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(entityURI, Dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner( QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
@ -103,8 +108,9 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult(); Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( Map<String, Set<String>> subOrganizationTypesResult =
log, Dataset, entityURI); EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, entityURI);
return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult); return prepareDataResponse(entity, entity.getSubEntities(), subOrganizationTypesResult);
@ -114,16 +120,20 @@ public class EntityGrantCountRequestHandler implements
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Entity Grant Count does not provide Ajax Response.");
throw new UnsupportedOperationException("Entity Grant Count "
+ "does not provide Ajax response.");
} }
private Map<String, String> getSubjectEntityAndGenerateDataResponse( private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI) String subjectEntityURI)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(subjectEntityURI, Dataset, log); ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner( QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
@ -136,18 +146,19 @@ public class EntityGrantCountRequestHandler implements
} else { } else {
return getSubEntityTypesAndComputeDataResponse( return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset, vitroRequest, log, dataset,
subjectEntityURI, entity); subjectEntityURI, entity);
} }
} }
private Map<String, String> getSubEntityTypesAndComputeDataResponse( private Map<String, String> getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset, VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectOrganization, Entity entity) String subjectOrganization, Entity entity)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes( Map<String, Set<String>> subOrganizationTypesResult =
log, Dataset, subjectOrganization); EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, subjectOrganization);
return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult); return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
} }
@ -160,7 +171,8 @@ public class EntityGrantCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream"); "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Grants for this Organization found in VIVO.\"}"); fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
"{\"error\" : \"No Grants for this Organization found in VIVO.\"}");
return fileData; return fileData;
} }
@ -175,7 +187,9 @@ public class EntityGrantCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream"); "application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult)); writeGrantsOverTimeJSON(vitroRequest,
entity.getSubEntities(),
subOrganizationTypesResult));
return fileData; return fileData;
} }
@ -234,12 +248,14 @@ public class EntityGrantCountRequestHandler implements
} }
/** /**
* function to generate a json file for year <-> grant count mapping * Function to generate a json file for year <-> grant count mapping.
* @param vreq * @param vreq
* @param subentities * @param subentities
* @param subOrganizationTypesResult * @param subOrganizationTypesResult
*/ */
private String writeGrantsOverTimeJSON(VitroRequest vreq, Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) { private String writeGrantsOverTimeJSON(VitroRequest vreq,
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
Gson json = new Gson(); Gson json = new Gson();
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>(); Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
@ -267,13 +283,12 @@ public class EntityGrantCountRequestHandler implements
} }
entityJson.setYearToActivityCount(yearGrantCount); entityJson.setYearToActivityCount(yearGrantCount);
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel())); entityJson.getOrganizationType().addAll(
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI()); entityJson.setEntityURI(subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity); if (UtilityFunctions.isEntityAPerson(vreq, subentity)) {
if(isPerson){
entityJson.setVisMode("PERSON"); entityJson.setVisMode("PERSON");
} else { } else {
entityJson.setVisMode("ORGANIZATION"); entityJson.setVisMode("ORGANIZATION");
@ -286,8 +301,9 @@ public class EntityGrantCountRequestHandler implements
} }
private String getEntityGrantsPerYearCSVContent(
private String getEntityGrantsPerYearCSVContent(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) { Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder(); StringBuilder csvFileContent = new StringBuilder();
@ -302,7 +318,8 @@ public class EntityGrantCountRequestHandler implements
StringBuilder joinedTypes = new StringBuilder(); StringBuilder joinedTypes = new StringBuilder();
for(String subOrganizationType : subOrganizationTypesResult.get(subEntity.getIndividualLabel())){ for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; "); joinedTypes.append(subOrganizationType + "; ");
} }
@ -312,6 +329,4 @@ public class EntityGrantCountRequestHandler implements
return csvFileContent.toString(); return csvFileContent.toString();
} }
} }

View file

@ -30,7 +30,8 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryR
/** /**
* This query runner is used to execute Sparql query that will fetch all the grants for an individual * This query runner is used to execute Sparql query that will fetch all the grants for an
* individual.
* @author bkoniden * @author bkoniden
* Deepak Konidena * Deepak Konidena
* *
@ -40,7 +41,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
protected static final Syntax SYNTAX = Syntax.syntaxARQ; protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI; private String personURI;
private Dataset Dataset; private Dataset dataset;
private Individual principalInvestigator; private Individual principalInvestigator;
public Individual getPrincipalInvestigator() { public Individual getPrincipalInvestigator() {
@ -83,15 +84,15 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "}"; + "}";
public PersonGrantCountQueryRunner(String personURI, Dataset Dataset, Log log){ public PersonGrantCountQueryRunner(String personURI, Dataset dataset, Log log) {
this.personURI = personURI; this.personURI = personURI;
this.Dataset = Dataset; this.dataset = dataset;
this.log = log; this.log = log;
} }
private Set<Activity> createJavaValueObjects(ResultSet resultSet) { private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
Set<Activity> PIGrant = new HashSet<Activity>(); Set<Activity> grants = new HashSet<Activity>();
while (resultSet.hasNext()) { while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution(); QuerySolution solution = resultSet.nextSolution();
@ -131,26 +132,26 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
* to create only one "Individual" instance. We test against the null for "PI" to * to create only one "Individual" instance. We test against the null for "PI" to
* make sure that it has not already been instantiated. * make sure that it has not already been instantiated.
* */ * */
RDFNode PIURLNode = solution.get(QueryFieldLabels.PI_URL); RDFNode investigatorURINode = solution.get(QueryFieldLabels.PI_URL);
if (PIURLNode != null && principalInvestigator == null) { if (investigatorURINode != null && principalInvestigator == null) {
principalInvestigator = new Individual(PIURLNode.toString()); principalInvestigator = new Individual(investigatorURINode.toString());
RDFNode PILabelNode = solution.get(QueryFieldLabels.PI_LABEL); RDFNode investigatorLabelNode = solution.get(QueryFieldLabels.PI_LABEL);
if (PILabelNode != null) { if (investigatorLabelNode != null) {
principalInvestigator.setIndividualLabel(PILabelNode.toString()); principalInvestigator.setIndividualLabel(investigatorLabelNode.toString());
} }
} }
PIGrant.add(grant); grants.add(grant);
} }
return PIGrant; return grants;
} }
private ResultSet executeQuery(String queryURI, Dataset Dataset){ private ResultSet executeQuery(String queryURI, Dataset dataset) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX); Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query,Dataset); queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
@ -244,7 +245,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
throw new MalformedQueryParametersException("URL parameter is either null or empty."); throw new MalformedQueryParametersException("URL parameter is either null or empty.");
} }
ResultSet resultSet = executeQuery(this.personURI, this.Dataset); ResultSet resultSet = executeQuery(this.personURI, this.dataset);
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }

View file

@ -47,13 +47,14 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String personURI = vitroRequest String personURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); .getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(personURI, Dataset, log ); QueryRunner<Set<Activity>> queryManager =
new PersonGrantCountQueryRunner(personURI, dataset, log);
Set<Activity> piGrants = queryManager.getQueryResult(); Set<Activity> piGrants = queryManager.getQueryResult();
@ -64,7 +65,8 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
Map<String, Integer> yearToGrantCount = Map<String, Integer> yearToGrantCount =
UtilityFunctions.getYearToActivityCount(piGrants); UtilityFunctions.getYearToActivityCount(piGrants);
Individual investigator = ((PersonGrantCountQueryRunner) queryManager).getPrincipalInvestigator(); Individual investigator = ((PersonGrantCountQueryRunner) queryManager)
.getPrincipalInvestigator();
return prepareDataResponse(investigator, return prepareDataResponse(investigator,
piGrants, piGrants,
@ -76,7 +78,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
String personURI = vitroRequest String personURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY); .getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
@ -87,7 +89,8 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
String visContainer = vitroRequest String visContainer = vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY); .getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(personURI, Dataset, log ); QueryRunner<Set<Activity>> queryManager =
new PersonGrantCountQueryRunner(personURI, dataset, log);
Set<Activity> piGrants = queryManager.getQueryResult(); Set<Activity> piGrants = queryManager.getQueryResult();
@ -99,8 +102,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
UtilityFunctions.getYearToActivityCount(piGrants); UtilityFunctions.getYearToActivityCount(piGrants);
boolean shouldVIVOrenderVis = boolean shouldVIVOrenderVis = yearToGrantCount.size() > 0 ? true : false;
yearToGrantCount.size() > 0 ? true : false;
/* /*
* Computations required to generate HTML for the sparkline & related context. * Computations required to generate HTML for the sparkline & related context.
@ -125,7 +127,7 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String personURI = vitroRequest String personURI = vitroRequest
@ -137,7 +139,8 @@ public class PersonGrantCountRequestHandler implements VisualizationRequestHandl
String visContainer = vitroRequest String visContainer = vitroRequest
.getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY); .getParameter(VisualizationFrameworkConstants.VIS_CONTAINER_KEY);
QueryRunner<Set<Activity>> queryManager = new PersonGrantCountQueryRunner(personURI, Dataset, log ); QueryRunner<Set<Activity>> queryManager =
new PersonGrantCountQueryRunner(personURI, dataset, log);
Set<Activity> piGrants = queryManager.getQueryResult(); Set<Activity> piGrants = queryManager.getQueryResult();

View file

@ -136,7 +136,8 @@ public class PersonGrantCountVisCodeGenerator {
*/ */
int renderedFullSparks = 0; int renderedFullSparks = 0;
List<YearToEntityCountDataElement> yearToGrantCountDataTable = new ArrayList<YearToEntityCountDataElement>(); List<YearToEntityCountDataElement> yearToGrantCountDataTable =
new ArrayList<YearToEntityCountDataElement>();
for (int grantYear = minGrantYearConsidered; grantYear <= currentYear; grantYear++) { for (int grantYear = minGrantYearConsidered; grantYear <= currentYear; grantYear++) {
@ -205,24 +206,22 @@ public class PersonGrantCountVisCodeGenerator {
sparklineData.setShortVisMode(true); sparklineData.setShortVisMode(true);
} else { } else {
sparklineData.setShortVisMode(false); sparklineData.setShortVisMode(false);
} }
if (yearToGrantCount.size() > 0) { if (yearToGrantCount.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COPI_VIS_MODE)); VisualizationFrameworkConstants.COPI_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions sparklineData.setDownloadDataLink(
.getCSVDownloadURL( UtilityFunctions.getCSVDownloadURL(
individualURI, individualURI,
VisualizationFrameworkConstants.PERSON_GRANT_COUNT_VIS, VisualizationFrameworkConstants.PERSON_GRANT_COUNT_VIS,
"")); ""));
} }
return sparklineData; return sparklineData;
} }

View file

@ -55,13 +55,13 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
@Override @Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException { Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Person Level does not provide Ajax Response."); throw new UnsupportedOperationException("Person Level does not provide Ajax Response.");
} }
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Person Level does not provide Data Response."); throw new UnsupportedOperationException("Person Level does not provide Data Response.");
} }
@ -69,7 +69,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String egoURI = vitroRequest.getParameter( String egoURI = vitroRequest.getParameter(
@ -81,12 +81,15 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
if (VisualizationFrameworkConstants.COPI_VIS_MODE.equalsIgnoreCase(visMode)) { if (VisualizationFrameworkConstants.COPI_VIS_MODE.equalsIgnoreCase(visMode)) {
ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log); ModelConstructor constructQueryRunner =
new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel(); Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<CollaborationData> coPIQueryManager = new CoPIGrantCountQueryRunner(egoURI, constructedModel, log); QueryRunner<CollaborationData> coPIQueryManager =
new CoPIGrantCountQueryRunner(egoURI, constructedModel, log);
QueryRunner<Set<Activity>> grantQueryManager = new PersonGrantCountQueryRunner(egoURI, Dataset, log); QueryRunner<Set<Activity>> grantQueryManager =
new PersonGrantCountQueryRunner(egoURI, dataset, log);
CollaborationData coPIData = coPIQueryManager.getQueryResult(); CollaborationData coPIData = coPIQueryManager.getQueryResult();
@ -140,9 +143,11 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
} else { } else {
QueryRunner<CollaborationData> coAuthorshipQueryManager = new CoAuthorshipQueryRunner(egoURI, Dataset, log); QueryRunner<CollaborationData> coAuthorshipQueryManager =
new CoAuthorshipQueryRunner(egoURI, dataset, log);
QueryRunner<Set<Activity>> publicationQueryManager = new PersonPublicationCountQueryRunner(egoURI, Dataset, log); QueryRunner<Set<Activity>> publicationQueryManager =
new PersonPublicationCountQueryRunner(egoURI, dataset, log);
CollaborationData coAuthorshipData = coAuthorshipQueryManager.getQueryResult(); CollaborationData coAuthorshipData = coAuthorshipQueryManager.getQueryResult();
@ -212,12 +217,14 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
String title = ""; String title = "";
if (coAuthorshipVO.getCollaborators() != null && coAuthorshipVO.getCollaborators().size() > 0) { if (coAuthorshipVO.getCollaborators() != null
&& coAuthorshipVO.getCollaborators().size() > 0) {
body.put("numOfAuthors", coAuthorshipVO.getCollaborators().size()); body.put("numOfAuthors", coAuthorshipVO.getCollaborators().size());
title = coAuthorshipVO.getEgoCollaborator().getCollaboratorName() + " - "; title = coAuthorshipVO.getEgoCollaborator().getCollaboratorName() + " - ";
} }
if (coAuthorshipVO.getCollaborations() != null && coAuthorshipVO.getCollaborations().size() > 0) { if (coAuthorshipVO.getCollaborations() != null
&& coAuthorshipVO.getCollaborations().size() > 0) {
body.put("numOfCoAuthorShips", coAuthorshipVO.getCollaborations().size()); body.put("numOfCoAuthorShips", coAuthorshipVO.getCollaborations().size());
} }

View file

@ -41,7 +41,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
protected static final Syntax SYNTAX = Syntax.syntaxARQ; protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI; private String personURI;
private Dataset Dataset; private Dataset dataset;
private Individual author; private Individual author;
@ -62,10 +62,10 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"; + " ?dateTimeValue core:dateTime ?publicationDate } .\n";
public PersonPublicationCountQueryRunner(String personURI, public PersonPublicationCountQueryRunner(String personURI,
Dataset Dataset, Log log) { Dataset dataset, Log log) {
this.personURI = personURI; this.personURI = personURI;
this.Dataset = Dataset; this.dataset = dataset;
this.log = log; this.log = log;
} }
@ -105,11 +105,11 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
} }
private ResultSet executeQuery(String queryURI, private ResultSet executeQuery(String queryURI,
Dataset Dataset) { Dataset dataset) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX); Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, Dataset); queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
@ -154,7 +154,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
} }
ResultSet resultSet = executeQuery(this.personURI, ResultSet resultSet = executeQuery(this.personURI,
this.Dataset); this.dataset);
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }

View file

@ -126,7 +126,7 @@ VisualizationRequestHandler {
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String personURI = vitroRequest.getParameter( String personURI = vitroRequest.getParameter(
@ -140,7 +140,7 @@ VisualizationRequestHandler {
QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner( QueryRunner<Set<Activity>> queryManager = new PersonPublicationCountQueryRunner(
personURI, personURI,
Dataset, dataset,
log); log);
Set<Activity> authorDocuments = queryManager.getQueryResult(); Set<Activity> authorDocuments = queryManager.getQueryResult();

View file

@ -135,7 +135,8 @@ public class PersonPublicationCountVisCodeGenerator {
* */ * */
int renderedFullSparks = 0; int renderedFullSparks = 0;
List<YearToEntityCountDataElement> yearToPublicationCountDataTable = new ArrayList<YearToEntityCountDataElement>(); List<YearToEntityCountDataElement> yearToPublicationCountDataTable =
new ArrayList<YearToEntityCountDataElement>();
for (int publicationYear = minPubYearConsidered; for (int publicationYear = minPubYearConsidered;
publicationYear <= currentYear; publicationYear <= currentYear;
@ -159,13 +160,11 @@ public class PersonPublicationCountVisCodeGenerator {
* */ * */
renderedFullSparks += currentPublications; renderedFullSparks += currentPublications;
publicationCounter++; publicationCounter++;
} }
sparklineData.setYearToEntityCountDataTable(yearToPublicationCountDataTable); sparklineData.setYearToEntityCountDataTable(yearToPublicationCountDataTable);
sparklineData.setRenderedSparks(renderedFullSparks); sparklineData.setRenderedSparks(renderedFullSparks);
/* /*
* Total publications will also consider publications that have no year associated with * Total publications will also consider publications that have no year associated with
* it. Hence. * it. Hence.
@ -176,7 +175,6 @@ public class PersonPublicationCountVisCodeGenerator {
.get(VOConstants.DEFAULT_PUBLICATION_YEAR); .get(VOConstants.DEFAULT_PUBLICATION_YEAR);
} }
sparklineData.setUnknownYearPublications(unknownYearPublications); sparklineData.setUnknownYearPublications(unknownYearPublications);
if (providedVisContainerID != null) { if (providedVisContainerID != null) {
@ -196,19 +194,19 @@ public class PersonPublicationCountVisCodeGenerator {
sparklineData.setEarliestRenderedPublicationYear(minPublishedYear); sparklineData.setEarliestRenderedPublicationYear(minPublishedYear);
sparklineData.setLatestRenderedPublicationYear(currentYear); sparklineData.setLatestRenderedPublicationYear(currentYear);
if (yearToPublicationCount.size() > 0) { if (yearToPublicationCount.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI, sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(
individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE)); VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions sparklineData.setDownloadDataLink(
.getCSVDownloadURL( UtilityFunctions.getCSVDownloadURL(
individualURI, individualURI,
VisualizationFrameworkConstants.PERSON_PUBLICATION_COUNT_VIS, VisualizationFrameworkConstants.PERSON_PUBLICATION_COUNT_VIS,
"")); ""));
} }
/* /*
@ -224,7 +222,6 @@ public class PersonPublicationCountVisCodeGenerator {
sparklineData.setShortVisMode(false); sparklineData.setShortVisMode(false);
} }
return sparklineData; return sparklineData;
} }

View file

@ -46,7 +46,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
public Object generateAjaxVisualization(VitroRequest vitroRequest, public Object generateAjaxVisualization(VitroRequest vitroRequest,
Log log, Log log,
Dataset Dataset) Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
String individualURI = vitroRequest.getParameter( String individualURI = vitroRequest.getParameter(
@ -70,7 +70,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
QueryRunner<GenericQueryMap> profileQueryHandler = QueryRunner<GenericQueryMap> profileQueryHandler =
new AllPropertiesQueryRunner(individualURI, new AllPropertiesQueryRunner(individualURI,
filterRule, filterRule,
Dataset, dataset,
log); log);
GenericQueryMap profilePropertiesToValues = GenericQueryMap profilePropertiesToValues =
@ -105,7 +105,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
"", "",
whereClause, whereClause,
"", "",
Dataset, log); dataset, log);
return getThumbnailInformation(imageQueryHandler.getQueryResult(), return getThumbnailInformation(imageQueryHandler.getQueryResult(),
fieldLabelToOutputFieldLabel, vitroRequest); fieldLabelToOutputFieldLabel, vitroRequest);
@ -117,8 +117,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
String aggregationRules = "(count(DISTINCT ?document) AS ?numOfPublications)"; String aggregationRules = "(count(DISTINCT ?document) AS ?numOfPublications)";
String whereClause = "<" + individualURI + "> rdf:type foaf:Person ; core:authorInAuthorship ?authorshipNode . \n" String whereClause =
+ "?authorshipNode rdf:type core:Authorship ; core:linkedInformationResource ?document ."; "<" + individualURI + "> rdf:type foaf:Person ;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document .";
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n"; String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
@ -127,7 +130,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
aggregationRules, aggregationRules,
whereClause, whereClause,
groupOrderClause, groupOrderClause,
Dataset, log); dataset, log);
Gson publicationsInformation = new Gson(); Gson publicationsInformation = new Gson();
@ -141,13 +144,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
String aggregationRules = "(count(DISTINCT ?Grant) AS ?numOfGrants)"; String aggregationRules = "(count(DISTINCT ?Grant) AS ?numOfGrants)";
String whereClause = "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasCo-PrincipalInvestigatorRole ?Role . \n" String whereClause = "{ <" + individualURI + "> rdf:type foaf:Person ;"
+ " core:hasCo-PrincipalInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }" + "?Role core:roleIn ?Grant . }"
+ "UNION \n" + "UNION \n"
+ "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasPrincipalInvestigatorRole ?Role . \n" + "{ <" + individualURI + "> rdf:type foaf:Person ;"
+ " core:hasPrincipalInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }" + "?Role core:roleIn ?Grant . }"
+ "UNION \n" + "UNION \n"
+ "{ <" + individualURI + "> rdf:type foaf:Person ; core:hasInvestigatorRole ?Role . \n" + "{ <" + individualURI + "> rdf:type foaf:Person ;"
+ " core:hasInvestigatorRole ?Role . \n"
+ "?Role core:roleIn ?Grant . }"; + "?Role core:roleIn ?Grant . }";
QueryRunner<ResultSet> numberOfGrantsQueryHandler = QueryRunner<ResultSet> numberOfGrantsQueryHandler =
@ -155,7 +161,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
aggregationRules, aggregationRules,
whereClause, whereClause,
"", "",
Dataset, log); dataset, log);
Gson grantsInformation = new Gson(); Gson grantsInformation = new Gson();
@ -169,14 +175,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
* By default we will be generating profile url else some specific url like * By default we will be generating profile url else some specific url like
* coAuthorShip vis url for that individual. * coAuthorShip vis url for that individual.
* */ * */
ParamMap coAuthorProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap coAuthorProfileURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
VisualizationFrameworkConstants.COAUTHORSHIP_VIS, VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
VisualizationFrameworkConstants.RENDER_MODE_KEY, VisualizationFrameworkConstants.RENDER_MODE_KEY,
VisualizationFrameworkConstants.STANDALONE_RENDER_MODE); VisualizationFrameworkConstants.STANDALONE_RENDER_MODE);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX, return UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
coAuthorProfileURLParams); coAuthorProfileURLParams);
} else if (VisualizationFrameworkConstants.COPI_UTILS_VIS_MODE } else if (VisualizationFrameworkConstants.COPI_UTILS_VIS_MODE
@ -186,14 +194,16 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
* By default we will be generating profile url else some specific url like * By default we will be generating profile url else some specific url like
* coPI vis url for that individual. * coPI vis url for that individual.
* */ * */
ParamMap coInvestigatorProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap coInvestigatorProfileURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.VIS_MODE_KEY, VisualizationFrameworkConstants.VIS_MODE_KEY,
VisualizationFrameworkConstants.COPI_VIS_MODE); VisualizationFrameworkConstants.COPI_VIS_MODE);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX, return UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
coInvestigatorProfileURLParams); coInvestigatorProfileURLParams);
} else if (VisualizationFrameworkConstants.PERSON_LEVEL_UTILS_VIS_MODE } else if (VisualizationFrameworkConstants.PERSON_LEVEL_UTILS_VIS_MODE
@ -202,24 +212,27 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
* By default we will be generating profile url else some specific url like * By default we will be generating profile url else some specific url like
* coAuthorShip vis url for that individual. * coAuthorShip vis url for that individual.
* */ * */
ParamMap personLevelURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap personLevelURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS, VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.RENDER_MODE_KEY, VisualizationFrameworkConstants.RENDER_MODE_KEY,
VisualizationFrameworkConstants.STANDALONE_RENDER_MODE); VisualizationFrameworkConstants.STANDALONE_RENDER_MODE);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX, return UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
personLevelURLParams); personLevelURLParams);
} else if (VisualizationFrameworkConstants.HIGHEST_LEVEL_ORGANIZATION_VIS_MODE } else if (VisualizationFrameworkConstants.HIGHEST_LEVEL_ORGANIZATION_VIS_MODE
.equalsIgnoreCase(visMode)) { .equalsIgnoreCase(visMode)) {
String staffProvidedHighestLevelOrganization = ConfigurationProperties.getBean(vitroRequest).getProperty("visualization.topLevelOrg"); String staffProvidedHighestLevelOrganization = ConfigurationProperties
.getBean(vitroRequest).getProperty("visualization.topLevelOrg");
/* /*
* First checking if the staff has provided highest level organization in deploy.properties * First checking if the staff has provided highest level organization in
* if so use to temporal graph vis. * deploy.properties if so use to temporal graph vis.
* */ * */
if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) { if (StringUtils.isNotBlank(staffProvidedHighestLevelOrganization)) {
@ -236,12 +249,14 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
} else { } else {
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
staffProvidedHighestLevelOrganization, staffProvidedHighestLevelOrganization,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS); VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX, return UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
highestLevelOrganizationTemporalGraphVisURLParams); highestLevelOrganizationTemporalGraphVisURLParams);
} }
@ -250,11 +265,13 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>(); Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
fieldLabelToOutputFieldLabel.put("organization", fieldLabelToOutputFieldLabel.put("organization",
QueryFieldLabels.ORGANIZATION_URL); QueryFieldLabels.ORGANIZATION_URL);
fieldLabelToOutputFieldLabel.put("organizationLabel", QueryFieldLabels.ORGANIZATION_LABEL); fieldLabelToOutputFieldLabel.put("organizationLabel",
QueryFieldLabels.ORGANIZATION_LABEL);
String aggregationRules = "(count(?organization) AS ?numOfChildren)"; String aggregationRules = "(count(?organization) AS ?numOfChildren)";
String whereClause = "?organization rdf:type foaf:Organization ; rdfs:label ?organizationLabel . \n" String whereClause = "?organization rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel . \n"
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n" + "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n" + "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
+ "FILTER ( !bound(?parent) ). \n"; + "FILTER ( !bound(?parent) ). \n";
@ -268,7 +285,7 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
aggregationRules, aggregationRules,
whereClause, whereClause,
groupOrderClause, groupOrderClause,
Dataset, log); dataset, log);
return getHighestLevelOrganizationTemporalGraphVisURL( return getHighestLevelOrganizationTemporalGraphVisURL(
highestLevelOrganizationQueryHandler.getQueryResult(), highestLevelOrganizationQueryHandler.getQueryResult(),
@ -276,7 +293,8 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
} else { } else {
ParamMap individualProfileURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap individualProfileURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI); individualURI);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX, return UrlBuilder.getUrl(VisualizationFrameworkConstants.INDIVIDUAL_URL_PREFIX,
@ -300,14 +318,17 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
.get("organization")); .get("organization"));
if (organizationNode != null) { if (organizationNode != null) {
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"), organizationNode.toString()); queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organization"),
organizationNode.toString());
ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap highestLevelOrganizationTemporalGraphVisURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
organizationNode.toString(), organizationNode.toString(),
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS); VisualizationFrameworkConstants.ENTITY_COMPARISON_VIS);
return UrlBuilder.getUrl(VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX, return UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
highestLevelOrganizationTemporalGraphVisURLParams); highestLevelOrganizationTemporalGraphVisURLParams);
@ -318,13 +339,15 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
.get("organizationLabel")); .get("organizationLabel"));
if (organizationLabelNode != null) { if (organizationLabelNode != null) {
queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"), organizationLabelNode.toString()); queryResult.addEntry(fieldLabelToOutputFieldLabel.get("organizationLabel"),
organizationLabelNode.toString());
} }
RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren"); RDFNode numberOfChildrenNode = solution.getLiteral("numOfChildren");
if (numberOfChildrenNode != null) { if (numberOfChildrenNode != null) {
queryResult.addEntry("numOfChildren", String.valueOf(numberOfChildrenNode.asLiteral().getInt())); queryResult.addEntry("numOfChildren",
String.valueOf(numberOfChildrenNode.asLiteral().getInt()));
} }
} }
@ -342,7 +365,8 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
RDFNode numberOfGrantsNode = solution.getLiteral("numOfGrants"); RDFNode numberOfGrantsNode = solution.getLiteral("numOfGrants");
if (numberOfGrantsNode != null) { if (numberOfGrantsNode != null) {
queryResult.addEntry("numOfGrants", String.valueOf(numberOfGrantsNode.asLiteral().getInt())); queryResult.addEntry("numOfGrants",
String.valueOf(numberOfGrantsNode.asLiteral().getInt()));
} }
} }
@ -361,7 +385,9 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
RDFNode numberOfPublicationsNode = solution.getLiteral("numOfPublications"); RDFNode numberOfPublicationsNode = solution.getLiteral("numOfPublications");
if (numberOfPublicationsNode != null) { if (numberOfPublicationsNode != null) {
queryResult.addEntry("numOfPublications", String.valueOf(numberOfPublicationsNode.asLiteral().getInt())); queryResult.addEntry(
"numOfPublications",
String.valueOf(numberOfPublicationsNode.asLiteral().getInt()));
} }
} }
@ -397,14 +423,14 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
@Override @Override
public Map<String, String> generateDataVisualization( public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Utilities does not provide Data Response."); throw new UnsupportedOperationException("Utilities does not provide Data Response.");
} }
@Override @Override
public ResponseValues generateStandardVisualization( public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset) VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Utilities does not provide Standard Response."); throw new UnsupportedOperationException("Utilities does not provide Standard Response.");
} }

View file

@ -80,7 +80,8 @@ public class Collaboration {
* We do not want to consider the default Activity year when we are checking * We do not want to consider the default Activity year when we are checking
* for the min or max Activity year. * for the min or max Activity year.
* */ * */
Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount().keySet()); Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount()
.keySet());
yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR); yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR);
/* /*
@ -92,7 +93,8 @@ public class Collaboration {
* */ * */
if (yearsToBeConsidered.size() > 0) { if (yearsToBeConsidered.size() > 0) {
final String earliestYear = Collections.min(yearsToBeConsidered); final String earliestYear = Collections.min(yearsToBeConsidered);
final Integer earliestYearActivityCount = this.getYearToActivityCount().get(earliestYear); final Integer earliestYearActivityCount = this.getYearToActivityCount()
.get(earliestYear);
return new HashMap<String, Integer>() { { return new HashMap<String, Integer>() { {
put(earliestYear, earliestYearActivityCount); put(earliestYear, earliestYearActivityCount);
@ -109,7 +111,8 @@ public class Collaboration {
* We do not want to consider the default Activity year when we are checking * We do not want to consider the default Activity year when we are checking
* for the min or max Activity year. * for the min or max Activity year.
* */ * */
Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount().keySet()); Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount()
.keySet());
yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR); yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR);
/* /*

View file

@ -79,7 +79,8 @@ public class Collaborator extends Individual {
* We do not want to consider the default activity year when we are checking * We do not want to consider the default activity year when we are checking
* for the min or max activity year. * for the min or max activity year.
* */ * */
Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount().keySet()); Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount()
.keySet());
yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR); yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR);
/* /*
@ -91,7 +92,8 @@ public class Collaborator extends Individual {
* */ * */
if (yearsToBeConsidered.size() > 0) { if (yearsToBeConsidered.size() > 0) {
final String earliestYear = Collections.min(yearsToBeConsidered); final String earliestYear = Collections.min(yearsToBeConsidered);
final Integer earliestYearActivityCount = this.getYearToActivityCount().get(earliestYear); final Integer earliestYearActivityCount = this.getYearToActivityCount()
.get(earliestYear);
return new HashMap<String, Integer>() { { return new HashMap<String, Integer>() { {
put(earliestYear, earliestYearActivityCount); put(earliestYear, earliestYearActivityCount);
@ -108,7 +110,8 @@ public class Collaborator extends Individual {
* We do not want to consider the default Activity year when we are checking * We do not want to consider the default Activity year when we are checking
* for the min or max Activity year. * for the min or max Activity year.
* */ * */
Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount().keySet()); Set<String> yearsToBeConsidered = new HashSet<String>(this.getYearToActivityCount()
.keySet());
yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR); yearsToBeConsidered.remove(VOConstants.DEFAULT_ACTIVITY_YEAR);
/* /*

View file

@ -13,8 +13,8 @@ import java.util.LinkedHashSet;
*/ */
public class Entity extends Individual { public class Entity extends Individual {
Set<Activity> activities = new HashSet<Activity>(); private Set<Activity> activities = new HashSet<Activity>();
Set<SubEntity> children = new LinkedHashSet<SubEntity>(); private Set<SubEntity> children = new LinkedHashSet<SubEntity>();
public Entity(String departmentURI, String departmentLabel) { public Entity(String departmentURI, String departmentLabel) {
super(departmentURI, departmentLabel); super(departmentURI, departmentLabel);

View file

@ -12,8 +12,9 @@ import java.util.HashSet;
*/ */
public class SubEntity extends Individual { public class SubEntity extends Individual {
Set<Activity> activities = new HashSet<Activity>(); private Set<Activity> activities = new HashSet<Activity>();
Map<String, Map<String, String>> personToPositionAndStartYear = new HashMap<String, Map<String, String>>(); private Map<String, Map<String, String>> personToPositionAndStartYear =
new HashMap<String, Map<String, String>>();
public SubEntity(String individualURI) { public SubEntity(String individualURI) {
super(individualURI); super(individualURI);

View file

@ -36,18 +36,18 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ; protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String filterRule, individualURI; private String filterRule, individualURI;
private Dataset Dataset; private Dataset dataset;
private Log log; private Log log;
public AllPropertiesQueryRunner(String individualURI, public AllPropertiesQueryRunner(String individualURI,
String filterRule, String filterRule,
Dataset Dataset, Dataset dataset,
Log log) { Log log) {
this.individualURI = individualURI; this.individualURI = individualURI;
this.filterRule = filterRule; this.filterRule = filterRule;
this.Dataset = Dataset; this.dataset = dataset;
this.log = log; this.log = log;
} }
@ -74,12 +74,12 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
} }
private ResultSet executeQuery(String queryText, private ResultSet executeQuery(String queryText,
Dataset Dataset) { Dataset dataset) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX); Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, Dataset); queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
@ -127,7 +127,7 @@ public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery( ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
this.individualURI, this.individualURI,
this.filterRule), this.filterRule),
this.Dataset); this.dataset);
return createJavaValueObjects(resultSet); return createJavaValueObjects(resultSet);
} }

View file

@ -30,9 +30,7 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ; protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String whereClause; private String whereClause;
private Dataset Dataset; private Dataset dataset;
private Log log;
private Map<String, String> fieldLabelToOutputFieldLabel; private Map<String, String> fieldLabelToOutputFieldLabel;
@ -44,23 +42,21 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
String aggregationRules, String aggregationRules,
String whereClause, String whereClause,
String groupOrderClause, String groupOrderClause,
Dataset Dataset, Log log) { Dataset dataset, Log log) {
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel; this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
this.aggregationRules = aggregationRules; this.aggregationRules = aggregationRules;
this.whereClause = whereClause; this.whereClause = whereClause;
this.groupOrderClause = groupOrderClause; this.groupOrderClause = groupOrderClause;
this.Dataset = Dataset; this.dataset = dataset;
this.log = log;
} }
private ResultSet executeQuery(String queryText, private ResultSet executeQuery(String queryText,
Dataset Dataset) { Dataset dataset) {
QueryExecution queryExecution = null; QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX); Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, Dataset); queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect(); return queryExecution.execSelect();
} }
@ -96,7 +92,7 @@ public class GenericQueryRunner implements QueryRunner<ResultSet> {
throws MalformedQueryParametersException { throws MalformedQueryParametersException {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(), ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.Dataset); this.dataset);
return resultSet; return resultSet;
} }

View file

@ -77,7 +77,8 @@ public class UtilityFunctions {
public static Map<String, Set<Collaborator>> getActivityYearToCollaborators( public static Map<String, Set<Collaborator>> getActivityYearToCollaborators(
CollaborationData collaborationData) { CollaborationData collaborationData) {
Map<String, Set<Collaborator>> yearToCollaborators = new TreeMap<String, Set<Collaborator>>(); Map<String, Set<Collaborator>> yearToCollaborators = new TreeMap<String,
Set<Collaborator>>();
Collaborator egoCollaborator = collaborationData.getEgoCollaborator(); Collaborator egoCollaborator = collaborationData.getEgoCollaborator();
@ -218,18 +219,18 @@ public class UtilityFunctions {
public static String getCSVDownloadURL(String individualURI, String visType, String visMode) { public static String getCSVDownloadURL(String individualURI, String visType, String visMode) {
ParamMap CSVDownloadURLParams = null; ParamMap csvDownloadURLParams = null;
if (StringUtils.isBlank(visMode)) { if (StringUtils.isBlank(visMode)) {
CSVDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, csvDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType); visType);
} else { } else {
CSVDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, csvDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType, visType,
@ -238,16 +239,21 @@ public class UtilityFunctions {
} }
String csvDownloadLink = UrlBuilder.getUrl(VisualizationFrameworkConstants.DATA_VISUALIZATION_SERVICE_URL_PREFIX, String csvDownloadLink = UrlBuilder.getUrl(
CSVDownloadURLParams); VisualizationFrameworkConstants
.DATA_VISUALIZATION_SERVICE_URL_PREFIX,
csvDownloadURLParams);
return csvDownloadLink != null ? csvDownloadLink : "" ; return csvDownloadLink != null ? csvDownloadLink : "" ;
} }
public static String getCollaboratorshipNetworkLink(String individualURI, String visType, String visMode) { public static String getCollaboratorshipNetworkLink(String individualURI,
String visType,
String visMode) {
ParamMap collaboratorshipNetworkURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY, ParamMap collaboratorshipNetworkURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI, individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY, VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType, visType,
@ -262,7 +268,10 @@ public class UtilityFunctions {
} }
public static boolean isEntityAPerson(VitroRequest vreq, SubEntity subentity) { public static boolean isEntityAPerson(VitroRequest vreq, SubEntity subentity) {
return vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person"); return vreq.getWebappDaoFactory()
.getIndividualDao()
.getIndividualByURI(subentity.getIndividualURI())
.isVClass("http://xmlns.com/foaf/0.1/Person");
} }
} }