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

View file

@ -58,7 +58,7 @@ public class DataVisualizationController extends VitroHttpServlet {
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-
* effecting this method.
* */
@ -92,12 +92,13 @@ public class DataVisualizationController extends VitroHttpServlet {
} else {
UtilityFunctions.handleMalformedParameters("Visualization Query Error",
"Inappropriate query parameters were submitted.",
vreq,
request,
response,
log);
UtilityFunctions.handleMalformedParameters(
"Visualization Query Error",
"Inappropriate query parameters were submitted.",
vreq,
request,
response,
log);
}

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;
/**
* Services a standard visualization request, which involves templates. This will return a simple error message and a 501 if
* there is no jena Model.
* Services a standard visualization request, which involves templates. This will return a simple
* error message and a 501 if there is no jena Model.
*
* @author cdtank
*/
@ -45,16 +45,17 @@ public class StandardVisualizationController extends FreemarkerHttpServlet {
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-
* effecting this method.
* */
return renderVisualization(vreq, visRequestHandler);
} else {
return UtilityFunctions.handleMalformedParameters("Visualization Query Error",
"Inappropriate query parameters were submitted.",
vreq);
return UtilityFunctions.handleMalformedParameters(
"Visualization Query Error",
"Inappropriate query parameters were submitted.",
vreq);
}

View file

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

View file

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

View file

@ -40,13 +40,13 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
@Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException {
Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("CoAuthorship does not provide Ajax Response.");
}
@Override
public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
@ -59,7 +59,7 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
.VIS_MODE_KEY);
QueryRunner<CollaborationData> queryManager =
new CoAuthorshipQueryRunner(egoURI, Dataset, log);
new CoAuthorshipQueryRunner(egoURI, dataset, log);
CollaborationData authorNodesAndEdges =
queryManager.getQueryResult();
@ -105,43 +105,20 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
public ResponseValues generateStandardVisualization(VitroRequest vitroRequest,
Log log,
Dataset Dataset)
Dataset dataset)
throws MalformedQueryParametersException {
/*
* Support for this has ceased to exist. Standalone mode was created only for demo
* 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.");
throw new UnsupportedOperationException("CoAuthorship Visualization "
+ "does not provide Standalone response.");
}
private String getCoauthorsListCSVContent(CollaborationData coAuthorshipData) {
StringBuilder csvFileContent = new StringBuilder();
csvFileContent.append("Co-author, Count\n");
//for (Entry<String, Integer> currentEntry : coAuthorsToCount.entrySet()) {
for (Collaborator currNode : coAuthorshipData.getCollaborators()) {
/*
* We have already printed the Ego Node info.
* */
@ -157,7 +134,6 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
}
return csvFileContent.toString();
}
private String getCoauthorsPerYearCSVContent(Map<String, Set<Collaborator>> yearToCoauthors) {
@ -171,7 +147,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
csvFileContent.append(",");
csvFileContent.append(currentEntry.getValue().size());
csvFileContent.append(",");
csvFileContent.append(StringEscapeUtils.escapeCsv(getCoauthorNamesAsString(currentEntry.getValue())));
csvFileContent.append(StringEscapeUtils.escapeCsv(
getCoauthorNamesAsString(currentEntry.getValue())));
csvFileContent.append("\n");
}
@ -197,12 +174,14 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges
* @param response
*/
private Map<String, String> prepareCoauthorsCountPerYearDataResponse(CollaborationData authorNodesAndEdges) {
private Map<String, String> prepareCoauthorsCountPerYearDataResponse(
CollaborationData authorNodesAndEdges) {
String outputFileName;
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
.getEgoCollaborator().getCollaboratorName())
@ -232,13 +211,16 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges
* @param response
*/
private Map<String, String> prepareCoauthorsListDataResponse(CollaborationData coAuthorshipData) {
private Map<String, String> prepareCoauthorsListDataResponse(
CollaborationData coAuthorshipData) {
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";
} else {
outputFileName = "no_co-authors" + ".csv";
@ -261,7 +243,8 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
* @param authorNodesAndEdges
* @param response
*/
private Map<String, String> prepareNetworkStreamDataResponse(CollaborationData authorNodesAndEdges) {
private Map<String, String> prepareNetworkStreamDataResponse(
CollaborationData authorNodesAndEdges) {
CoAuthorshipGraphMLWriter coAuthorshipGraphMLWriter =
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 = "";
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";
} else {
@ -301,47 +287,5 @@ public class CoAuthorshipRequestHandler implements VisualizationRequestHandler {
coAuthorshipGraphMLWriter.getCoAuthorshipGraphMLContent().toString());
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;
Set<Collaborator> allCoAuthorsWithKnownAuthorshipYears = new HashSet<Collaborator>();
List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable = new ArrayList<YearToEntityCountDataElement>();
List<YearToEntityCountDataElement> yearToUniqueCoauthorsCountDataTable =
new ArrayList<YearToEntityCountDataElement>();
for (int publicationYear = minPubYearConsidered;
publicationYear <= currentYear;
publicationYear++) {
String publicationYearAsString = String.valueOf(publicationYear);
Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors.get(publicationYearAsString);
Set<Collaborator> currentCoAuthors = yearToUniqueCoauthors
.get(publicationYearAsString);
Integer currentUniqueCoAuthors = null;
@ -142,9 +144,10 @@ public class CoAuthorshipVisCodeGenerator {
currentUniqueCoAuthors = 0;
}
yearToUniqueCoauthorsCountDataTable.add(new YearToEntityCountDataElement(uniqueCoAuthorCounter,
publicationYearAsString,
currentUniqueCoAuthors));
yearToUniqueCoauthorsCountDataTable.add(
new YearToEntityCountDataElement(uniqueCoAuthorCounter,
publicationYearAsString,
currentUniqueCoAuthors));
uniqueCoAuthorCounter++;
}
@ -159,12 +162,13 @@ public class CoAuthorshipVisCodeGenerator {
sparklineData.setYearToEntityCountDataTable(yearToUniqueCoauthorsCountDataTable);
/*
* This is required only for the sparklines which convey collaborationships like coinvestigatorships
* and coauthorship. There are edge cases where a collaborator can be present for in a collaboration
* with known & unknown year. We do not want to repeat the count for this collaborator when we present
* it in the front-end.
* This is required only for the sparklines which convey collaborationships like
* coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
* present for in a collaboration with known & unknown year. We do not want to repeat the
* 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
@ -175,7 +179,8 @@ public class CoAuthorshipVisCodeGenerator {
unknownYearCoauthors = yearToUniqueCoauthors
.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);
@ -214,19 +219,22 @@ public class CoAuthorshipVisCodeGenerator {
if (yearToUniqueCoauthors.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(
individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COAUTHOR_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions
.getCSVDownloadURL(
individualURI,
VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE));
sparklineData.setDownloadDataLink(
UtilityFunctions.getCSVDownloadURL(
individualURI,
VisualizationFrameworkConstants.COAUTHORSHIP_VIS,
VisualizationFrameworkConstants.COAUTHORS_COUNT_PER_YEAR_VIS_MODE));
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(),
currentYearToCoAuthors.getValue().size());
}

View file

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

View file

@ -69,7 +69,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "} . " ;
+ "} . ";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = ""
+ "OPTIONAL {"
@ -80,7 +80,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}"
+ "}" ;
+ "}";
public CoPIGrantCountQueryRunner(String egoURI,
@ -92,12 +92,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
this.nodeIDGenerator = new UniqueIDGenerator();
this.edgeIDGenerator = new UniqueIDGenerator();
}
private String generateEgoCoPIquery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT "
+ " (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");
return sparqlQuery;
}
private ResultSet executeQuery(String queryText, Model dataSource) {
QueryExecution queryExecution = null;
@ -336,7 +331,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
public CollaborationData getQueryResult()
throws MalformedQueryParametersException {
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) {
/*
@ -360,7 +355,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
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 createQueryResult(resultSet);
}
@ -371,7 +366,8 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
Collaborator collaboratingNode2,
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(collaboratingNode1.getCollaboratorID(),
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
collaboratingNode1.getCollaboratorID(),
collaboratingNode2.getCollaboratorID());
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
@ -428,7 +424,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
egoNode.setCollaboratorName(authorLabelNode.toString());
}
}
log.debug("PI: "+ egoNode.getIndividualLabel());
log.debug("PI: " + egoNode.getIndividualLabel());
RDFNode grantNode = solution.get(QueryFieldLabels.GRANT_URL);
Activity grant;
@ -441,7 +437,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
egoNode.addActivity(grant);
log.debug("Adding grant: "+ grant.getIndividualLabel());
log.debug("Adding grant: " + grant.getIndividualLabel());
/*
* After some discussion we concluded that for the purpose of this visualization
@ -486,9 +482,10 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
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
* & current coPINode. Else create a new edge, add it to the edges set & add
@ -506,13 +503,11 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
}
/*
* 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
* insight. However, we have left the grants be.
*
* This method side-effects "nodes" & "edges".
* */
removeLowQualityNodesAndEdges(nodes,
@ -527,20 +522,20 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
* The below sub-routine will take care of,
* A - B
*
* We are side-effecting "edges" here. The only reason to do this is because we are 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
* & co-PI edges created during the course of this method) when we are creating a new
* edge.
* We are side-effecting "edges" here. The only reason to do this is because we are
* 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 & co-PI edges created during the course of this method) when we are creating
* a new edge.
* */
createCoPIEdges(grantURLToVO,
grantURLToCoPIs,
edges,
edgeUniqueIdentifierToVO);
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);
}
@ -564,14 +559,14 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
&& currentGrantEntry.getValue().size()
<= MAX_PI_PER_GRANT_ALLOWED) {
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
/*
* 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.
* */
List<Collaborator> coPINodes = new ArrayList<Collaborator>(currentGrantEntry.getValue());
List<Collaborator> coPINodes =
new ArrayList<Collaborator>(currentGrantEntry.getValue());
Collections.sort(coPINodes, new CollaboratorComparator());
int numOfCoPIs = coPINodes.size();
@ -605,9 +600,7 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
}
edges.addAll(newlyAddedEdges);
}
}
}
private void removeLowQualityNodesAndEdges(Set<Collaborator> nodes,
@ -663,9 +656,9 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
RDFNode grantStartYear = solution.get(QueryFieldLabels.ROLE_START_DATE);
if (grantStartYear != null) {
grant.setActivityDate(grantStartYear.toString());
}else{
} else {
grantStartYear = solution.get(QueryFieldLabels.GRANT_START_DATE);
if(grantStartYear != null){
if (grantStartYear != null) {
grant.setActivityDate(grantStartYear.toString());
}
}

View file

@ -28,29 +28,33 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Visual
* @author bkoniden
* Deepak Konidena
*/
public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler{
public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler {
@Override
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Co-PI Grant Count does not provide Ajax Response.");
Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Co-PI Grant Count"
+ " does not provide Ajax response.");
}
@Override
public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
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);
ModelConstructor constructQueryRunner = new CoPIGrantCountConstructQueryRunner(egoURI, Dataset, log);
ModelConstructor constructQueryRunner =
new CoPIGrantCountConstructQueryRunner(egoURI, dataset, log);
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
@ -63,7 +67,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will
* be rendered.
* */
return prepareCoPIsCountPerYearDataResponse(PINodesAndEdges);
return prepareCoPIsCountPerYearDataResponse(investigatorNodesAndEdges);
} else if (VisualizationFrameworkConstants.COPIS_LIST_VIS_MODE
.equalsIgnoreCase(visMode)) {
@ -71,7 +75,7 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will
* be rendered.
* */
return prepareCoPIsListDataResponse(PINodesAndEdges);
return prepareCoPIsListDataResponse(investigatorNodesAndEdges);
} else if (VisualizationFrameworkConstants.COPI_NETWORK_DOWNLOAD_VIS_MODE
.equalsIgnoreCase(visMode)) {
@ -79,28 +83,27 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* When the csv file is required - based on which sparkline visualization will
* be rendered.
* */
return prepareNetworkDownloadDataResponse(PINodesAndEdges);
return prepareNetworkDownloadDataResponse(investigatorNodesAndEdges);
} else {
/*
* When the graphML file is required - based on which co-pi network
* visualization will be rendered.
* */
return prepareNetworkStreamDataResponse(PINodesAndEdges);
return prepareNetworkStreamDataResponse(investigatorNodesAndEdges);
}
}
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
/*
* Support for this has ceased to exist. Standalone mode was created only for demo
* 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) {
@ -141,19 +144,20 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
csvFileContent.append(",");
csvFileContent.append(currentEntry.getValue().size());
csvFileContent.append(",");
csvFileContent.append(StringEscapeUtils.escapeCsv(getCoPINamesAsString(currentEntry.getValue())));
csvFileContent.append(StringEscapeUtils.escapeCsv(
getCoPINamesAsString(currentEntry.getValue())));
csvFileContent.append("\n");
}
return csvFileContent.toString();
}
private String getCoPINamesAsString(Set<Collaborator> CoPIs) {
private String getCoPINamesAsString(Set<Collaborator> coInvestigators) {
StringBuilder coPIsMerged = new StringBuilder();
String coPISeparator = ";";
for(Collaborator currentCoPI : CoPIs){
for (Collaborator currentCoPI : coInvestigators) {
coPIsMerged.append(currentCoPI.getCollaboratorName() + coPISeparator);
}
@ -167,12 +171,14 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
* @param piNodesAndEdges
* @param response
*/
private Map<String, String> prepareCoPIsCountPerYearDataResponse(CollaborationData piNodesAndEdges) {
private Map<String, String> prepareCoPIsCountPerYearDataResponse(
CollaborationData piNodesAndEdges) {
String outputFileName;
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
.getEgoCollaborator().getCollaboratorName())
@ -208,7 +214,8 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
if (coPIData.getCollaborators() != null && coPIData.getCollaborators().size() > 0) {
outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator().getCollaboratorName())
outputFileName = UtilityFunctions.slugify(coPIData.getEgoCollaborator()
.getCollaboratorName())
+ "_co-investigators" + ".csv";
} else {
@ -253,7 +260,8 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
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";
} else {
@ -274,8 +282,4 @@ public class CoPIGrantCountRequestHandler implements VisualizationRequestHandler
return fileData;
}
}
}

View file

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

View file

@ -39,7 +39,8 @@ public class CoPIVisCodeGenerator {
* 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.
* */
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;
@ -134,7 +135,8 @@ public class CoPIVisCodeGenerator {
int uniqueCoPICounter = 0;
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++) {
@ -151,7 +153,8 @@ public class CoPIVisCodeGenerator {
currentUniqueCoPIs = 0;
}
yearToUniqueInvestigatorsCountDataTable.add(new YearToEntityCountDataElement(uniqueCoPICounter,
yearToUniqueInvestigatorsCountDataTable.add(new YearToEntityCountDataElement(
uniqueCoPICounter,
grantYearAsString,
currentUniqueCoPIs));
@ -169,12 +172,13 @@ public class CoPIVisCodeGenerator {
sparklineData.setYearToEntityCountDataTable(yearToUniqueInvestigatorsCountDataTable);
/*
* This is required only for the sparklines which convey collaborationships like coinvestigatorships
* and coauthorship. There are edge cases where a collaborator can be present for in a collaboration
* with known & unknown year. We do not want to repeat the count for this collaborator when we present
* it in the front-end.
* This is required only for the sparklines which convey collaborationships like
* coinvestigatorships and coauthorship. There are edge cases where a collaborator can be
* present for in a collaboration with known & unknown year. We do not want to repeat the
* 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
@ -184,9 +188,8 @@ public class CoPIVisCodeGenerator {
if (yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR) != null) {
unknownYearGrants = yearToUniqueCoPIs.get(
VOConstants.DEFAULT_GRANT_YEAR).size();
totalUniqueCoInvestigators.addAll(yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR));
totalUniqueCoInvestigators.addAll(
yearToUniqueCoPIs.get(VOConstants.DEFAULT_GRANT_YEAR));
}
sparklineData.setTotalCollaborationshipCount(totalUniqueCoInvestigators.size());
@ -227,18 +230,22 @@ public class CoPIVisCodeGenerator {
if (yearToUniqueCoPIs.size() > 0) {
sparklineData.setFullTimelineNetworkLink(UtilityFunctions.getCollaboratorshipNetworkLink(individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COPI_VIS_MODE));
sparklineData.setFullTimelineNetworkLink(
UtilityFunctions.getCollaboratorshipNetworkLink(
individualURI,
VisualizationFrameworkConstants.PERSON_LEVEL_VIS,
VisualizationFrameworkConstants.COPI_VIS_MODE));
sparklineData.setDownloadDataLink(UtilityFunctions
.getCSVDownloadURL(
individualURI,
VisualizationFrameworkConstants.CO_PI_VIS,
VisualizationFrameworkConstants.COPIS_COUNT_PER_YEAR_VIS_MODE));
sparklineData.setDownloadDataLink(
UtilityFunctions.getCSVDownloadURL(
individualURI,
VisualizationFrameworkConstants.CO_PI_VIS,
VisualizationFrameworkConstants.COPIS_COUNT_PER_YEAR_VIS_MODE));
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(),
currentYearToUniqueCoPIsCount.getValue().size());
}

View file

@ -69,7 +69,7 @@ public class EntityComparisonUtilityFunctions {
return "";
}
public static String getHighestLevelOrganizationURI(Log log, Dataset Dataset)
public static String getHighestLevelOrganizationURI(Log log, Dataset dataset)
throws MalformedQueryParametersException {
Map<String, String> fieldLabelToOutputFieldLabel = new HashMap<String, String>();
@ -80,7 +80,8 @@ public class EntityComparisonUtilityFunctions {
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:subOrganizationWithin ?parent } . \n"
+ "FILTER ( !bound(?parent) ). \n";
@ -90,7 +91,7 @@ public class EntityComparisonUtilityFunctions {
QueryRunner<ResultSet> highestLevelOrganizationQueryHandler = new GenericQueryRunner(
fieldLabelToOutputFieldLabel, aggregationRules, whereClause,
groupOrderClause, Dataset, log);
groupOrderClause, dataset, log);
String highestLevelOrgURI = EntityComparisonUtilityFunctions
.getHighestLevelOrganizationURI(
@ -100,14 +101,20 @@ public class EntityComparisonUtilityFunctions {
}
public static Map<String, Set<String>> getSubEntityTypes(Log log,
Dataset Dataset, String subjectOrganization)
Dataset dataset, String subjectOrganization)
throws MalformedQueryParametersException {
ModelConstructor constructQueryRunnerForSubOrganizationTypes = new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization, Dataset, log) ;
Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes.getConstructedModel();
ModelConstructor constructQueryRunnerForSubOrganizationTypes =
new EntitySubOrganizationTypesConstructQueryRunner(subjectOrganization,
dataset,
log);
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes = new EntitySubOrganizationTypesQueryRunner(
subjectOrganization, constructedModelForSubOrganizationTypes, log);
Model constructedModelForSubOrganizationTypes = constructQueryRunnerForSubOrganizationTypes
.getConstructedModel();
QueryRunner<Map<String, Set<String>>> queryManagerForsubOrganisationTypes =
new EntitySubOrganizationTypesQueryRunner(
subjectOrganization, constructedModelForSubOrganizationTypes, log);
Map<String, Set<String>> subOrganizationTypesResult = queryManagerForsubOrganisationTypes
.getQueryResult();
@ -130,12 +137,13 @@ public class EntityComparisonUtilityFunctions {
}
public static String getStaffProvidedOrComputedHighestLevelOrganization(Log log,
Dataset Dataset, VitroRequest vitroRequest)
Dataset dataset, VitroRequest vitroRequest)
throws MalformedQueryParametersException {
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
@ -150,12 +158,12 @@ public class EntityComparisonUtilityFunctions {
IRI iri = iRIFactory.create(staffProvidedHighestLevelOrganization);
if (iri.hasViolation(false)) {
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions.getHighestLevelOrganizationURI(log, Dataset);
finalHighestLevelOrganizationURI = EntityComparisonUtilityFunctions
.getHighestLevelOrganizationURI(log, dataset);
} else {
finalHighestLevelOrganizationURI = staffProvidedHighestLevelOrganization;
}
}
return finalHighestLevelOrganizationURI;
}
}

View file

@ -24,21 +24,21 @@ import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
public class EntityPublicationCountConstructQueryRunner implements ModelConstructor{
public class EntityPublicationCountConstructQueryRunner implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private Dataset Dataset;
private Dataset dataset;
private Log log = LogFactory.getLog(EntityPublicationCountConstructQueryRunner.class.getName());
private long before, after;
public EntityPublicationCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
public EntityPublicationCountConstructQueryRunner(String egoURI, Dataset dataset, Log log) {
this.egoURI = egoURI;
this.Dataset = Dataset;
this.dataset = dataset;
//this.log = log;
}
@ -46,21 +46,21 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> rdfs:label ?organizationLabel ."
+ "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?organizationLabel "
+ "<" + queryURI + "> rdfs:label ?organizationLabel "
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForSubOrganizations(String queryURI){
private String generateConstructQueryForSubOrganizations(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
@ -71,18 +71,16 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property "
+"}"
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "}"
+ "UNION "
@ -90,24 +88,17 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}" ;
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForPersons(String queryURI){
private String generateConstructQueryForPersons(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "<" + queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
@ -116,16 +107,14 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document rdfs:label ?DocumentLabel . "
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate . "
// + "?Document core:year ?publicationYearUsing_1_1_property ."
+"}"
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "<" + queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person core:authorInAuthorship ?Resource . "
+ "?Person rdfs:label ?PersonLabel . "
+ "?Resource core:linkedInformationResource ?Document . "
// + "?Document rdf:type bibo:Document . "
+ "?Document rdfs:label ?DocumentLabel "
+ "}"
+ "UNION"
@ -133,16 +122,9 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
+ "?Document core:dateTimeValue ?dateTimeValue . "
+ "?dateTimeValue core:dateTime ?publicationDate "
+ "}"
// + "UNION "
// + "{"
// + "?Document core:year ?publicationYearUsing_1_1_property "
// + "}"
+ "}" ;
+ "}";
return sparqlQuery;
}
// 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();
@ -227,16 +209,17 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
Query query = null;
try{
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
}catch(Throwable th){
log.error("Could not create CONSTRUCT SPARQL query for query " +
"string. " + th.getMessage());
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
+ queryString, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(queryString);
}
QueryExecution qe = QueryExecutionFactory.create(
query, Dataset);
query, dataset);
try {
qe.execConstruct(constructedModel);
@ -245,9 +228,9 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
}
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;
}
@ -275,7 +258,7 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries,
this.Dataset);
this.dataset);
return model;
@ -286,8 +269,7 @@ public class EntityPublicationCountConstructQueryRunner implements ModelConstruc
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI));
constructQueries.add(generateConstructQueryForPersons(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValueOneLevelDeep(this.egoURI));
// constructQueries.add(generateConstructQueryForDocumentDateTimeValue(this.egoURI));
}
}

View file

@ -54,8 +54,7 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?PersonLabel) as ?personLabelLit) "
+ " (str(?Document) as ?documentLit) "
+ " (str(?DocumentLabel) as ?documentLabelLit) "
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") "
+ " (str(?publicationYearUsing_1_1_property) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_YEAR_USING_1_1_PROPERTY + ") ";
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
@ -63,13 +62,13 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " rdfs:label ?DocumentLabel ."
+ "OPTIONAL { ?Document core:dateTimeValue ?dateTimeValue . "
+ " ?dateTimeValue core:dateTime ?publicationDate } ."
+ "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } ." ;
private static String ENTITY_LABEL;
private static String ENTITY_URL;
private static String SUBENTITY_LABEL;
private static String SUBENTITY_URL;
+ "OPTIONAL { ?Document core:year ?publicationYearUsing_1_1_property } .";
private static final String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
private static final String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
private static final String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL;
private static final String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
public EntityPublicationCountQueryRunner(String entityURI,
Model dataSource, Log log) {
@ -108,13 +107,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
biboDocument = new Activity(documentNode.toString());
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
// RDFNode documentLabelNode = solution
// .get(QueryFieldLabels.DOCUMENT_LABEL);
// if (documentLabelNode != null) {
// biboDocument.setDocumentLabel(documentLabelNode.toString());
// }
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
RDFNode publicationDateNode = solution.get(QueryFieldLabels
.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString());
}
@ -163,8 +157,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
/*
* This makes sure that either,
* 1. the parent organization is a department-like organization with no organizations
* beneath it, or
* 1. the parent organization is a department-like organization with no
* organizations beneath it, or
* 2. the parent organizations has both sub-organizations and people directly
* 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();
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;
}
@ -198,27 +192,12 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(
getSparqlQuery(queryURI), SYNTAX);
getSparqlQueryForOrganization(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataSource);
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()
+ "SELECT (str(?organizationLabel) as ?organizationLabelLit) "
@ -229,7 +208,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization ."
+ "?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . "
+ "?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ."
+ " ?Person core:authorInAuthorship ?Resource ; rdfs:label ?PersonLabel . "
+ " ?Resource core:linkedInformationResource ?Document . "
@ -242,10 +222,8 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
+ " ?Resource core:linkedInformationResource ?Document ."
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE + "}"
+ "}";
//System.out.println("\n\nEntity Pub Count query is: "+ sparqlQuery);
log.debug("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery;
}
@ -253,7 +231,6 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
public Entity getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) {
/*
* To test for the validity of the URI submitted.
*/
@ -278,12 +255,9 @@ public class EntityPublicationCountQueryRunner implements QueryRunner<Entity> {
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);
}
}
}

View file

@ -38,26 +38,31 @@ public class EntityPublicationCountRequestHandler implements
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
if (StringUtils.isBlank(entityURI)){
if (StringUtils.isBlank(entityURI)) {
entityURI = EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset, vitroRequest);
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
}
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
}
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityPublicationCountConstructQueryRunner(subjectEntityURI, Dataset, log);
ModelConstructor constructQueryRunner =
new EntityPublicationCountConstructQueryRunner(subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
@ -72,7 +77,7 @@ public class EntityPublicationCountRequestHandler implements
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset,
vitroRequest, log, dataset,
subjectEntityURI, entity);
}
}
@ -84,17 +89,19 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
"{\"error\" : \"No Publications for this Organization found in VIVO.\"}");
return fileData;
}
private Map<String, String> getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, subjectEntityURI);
Map<String, Set<String>> subOrganizationTypesResult =
EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, subjectEntityURI);
return prepareStandaloneDataResponse(vitroRequest, entity, entity.getSubEntities(),
subOrganizationTypesResult);
@ -102,7 +109,7 @@ public class EntityPublicationCountRequestHandler implements
@Override
public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
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.
* */
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(
vitroRequest,
log,
Dataset,
dataset,
entityURI);
} else {
return getSubjectEntityAndGenerateDataResponse(
vitroRequest,
log,
Dataset,
dataset,
EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
Dataset,
dataset,
vitroRequest));
}
@ -139,7 +147,9 @@ public class EntityPublicationCountRequestHandler implements
* 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();
QueryRunner<Entity> queryManager = new EntityPublicationCountQueryRunner(
@ -147,10 +157,11 @@ public class EntityPublicationCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, entityURI);
Map<String, Set<String>> subOrganizationTypesResult =
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
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.");
}
@ -208,8 +219,10 @@ public class EntityPublicationCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writePublicationsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writePublicationsOverTimeJSON(vitroRequest,
entity.getSubEntities(),
subOrganizationTypesResult));
return fileData;
}
@ -219,8 +232,9 @@ public class EntityPublicationCountRequestHandler implements
Portal portal = vreq.getPortal();
String standaloneTemplate = "entityComparisonOnPublicationsStandalone.ftl";
String organizationLabel = EntityComparisonUtilityFunctions.getEntityLabelFromDAO(vreq,
entityURI);
String organizationLabel = EntityComparisonUtilityFunctions
.getEntityLabelFromDAO(vreq,
entityURI);
Map<String, Object> body = new HashMap<String, Object>();
body.put("portalBean", portal);
@ -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 subentities
* @param subOrganizationTypesResult
@ -266,35 +280,33 @@ public class EntityPublicationCountRequestHandler implements
yearPubCount.add(currentPubYear);
}
//log.info("entityJson.getLabel() : " + entityJson.getLabel() + " subOrganizationTypesResult " + subOrganizationTypesResult.toString());
entityJson.setYearToActivityCount(yearPubCount);
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.getOrganizationType().addAll(
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
if(isPerson){
if (isPerson) {
entityJson.setVisMode("PERSON");
} else{
} else {
entityJson.setVisMode("ORGANIZATION");
}
// setEntityVisMode(entityJson);
subEntitiesJson.add(entityJson);
}
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();
csvFileContent.append("Entity Name, Publication Count, Entity Type\n");
for(SubEntity subEntity : subentities){
for (SubEntity subEntity : subentities) {
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity.getIndividualLabel()));
csvFileContent.append(", ");
@ -303,17 +315,14 @@ public class EntityPublicationCountRequestHandler implements
StringBuilder joinedTypes = new StringBuilder();
for(String subOrganizationType : subOrganizationTypesResult.get(subEntity.getIndividualLabel())){
for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; ");
}
csvFileContent.append(StringEscapeUtils.escapeCsv(joinedTypes.toString()));
csvFileContent.append("\n");
}
return csvFileContent.toString();
}
}

View file

@ -30,13 +30,14 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
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.Dataset = Dataset;
this.dataset = dataset;
//this.log = log;
}
@ -44,20 +45,20 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> rdfs:label ?organizationLabel ."
+ "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?organizationLabel "
+ "<" + queryURI + "> rdfs:label ?organizationLabel "
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForSubOrganizationTypes(String queryURI){
private String generateConstructQueryForSubOrganizationTypes(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization rdf:type ?subOrganizationType . "
+ "?subOrganization core:organizationForPosition ?Position . "
@ -66,9 +67,9 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel "
+"}"
+ "}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization rdf:type ?subOrganizationType . "
+ "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
@ -77,39 +78,34 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel "
+ "}" ;
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForPersonTypes(String queryURI){
private String generateConstructQueryForPersonTypes(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "<" + queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person ."
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel "
+"}"
+ "}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "<" + queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person ."
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel "
+ "}" ;
+ "}";
return sparqlQuery;
}
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
Model constructedModel = ModelFactory.createDefaultModel();
long before = 0;
@ -121,30 +117,31 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
Query query = null;
try{
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
}catch(Throwable th){
log.error("Could not create CONSTRUCT SPARQL query for query " +
"string. " + th.getMessage());
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery()
+ queryString, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(queryString);
}
QueryExecution qe = QueryExecutionFactory.create(
query, Dataset);
query, dataset);
try {
qe.execConstruct(constructedModel);
} finally {
qe.close();
}
log.debug("Time to run " + (before - System.currentTimeMillis()) );
log.debug("Time to run " + (before - System.currentTimeMillis()));
}
return constructedModel;
}
public Model getConstructedModel()
throws MalformedQueryParametersException {
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) {
/*
@ -167,19 +164,14 @@ public class EntitySubOrganizationTypesConstructQueryRunner implements ModelCons
populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries,
this.Dataset);
this.dataset);
//model.write(System.out);
return model;
}
private void populateConstructQueries(Set<String> constructQueries) {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizationTypes(this.egoURI));
constructQueries.add(generateConstructQueryForPersonTypes(this.egoURI));
}
}

View file

@ -2,7 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.visualization.freemarker.entitycomparison;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
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.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.DataSource;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
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.ResultSet;
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.RDFNode;
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.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.QueryRunner;
import java.util.Set;
import java.util.HashSet;
/**
* @author bkoniden
* 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;
@ -45,17 +43,18 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
private Log log = LogFactory.getLog(EntitySubOrganizationTypesQueryRunner.class.getName());
private static final String SPARQL_QUERY_SELECT_CLAUSE = ""
+ " (str(?organizationLabel) as ?"+QueryFieldLabels.ORGANIZATION_LABEL+") "
+ " (str(?subOrganizationLabel) as ?"+QueryFieldLabels.SUBORGANIZATION_LABEL+") "
+ " (str(?subOrganizationType) as ?"+QueryFieldLabels.SUBORGANIZATION_TYPE +")"
+ " (str(?subOrganizationTypeLabel) as ?"+QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL+") "
+ " (str(?organizationLabel) as ?" + QueryFieldLabels.ORGANIZATION_LABEL + ") "
+ " (str(?subOrganizationLabel) as ?" + QueryFieldLabels.SUBORGANIZATION_LABEL + ") "
+ " (str(?subOrganizationType) as ?" + QueryFieldLabels.SUBORGANIZATION_TYPE + ")"
+ " (str(?subOrganizationTypeLabel) as ?"
+ QueryFieldLabels.SUBORGANIZATION_TYPE_LABEL + ") "
+ " (str(?Person) as ?personLit) "
+ " (str(?PersonLabel) as ?personLabelLit) "
+ " (str(?PersonTypeLabel) as ?personTypeLabelLit) ";
public EntitySubOrganizationTypesQueryRunner(String entityURI,
Model dataSource, Log log){
Model dataSource, Log log) {
this.entityURI = entityURI;
this.dataSource = dataSource;
@ -83,35 +82,29 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
+ queryURI
+ "> rdfs:label ?organizationLabel . "
+ "{ "
+ "<"+ queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel ; rdf:type ?subOrganizationType ;"
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " rdf:type ?subOrganizationType ;"
+ " core:organizationForPosition ?Position . "
+ "?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
+ "?Position core:positionForPerson ?Person ."
+ "}"
+ "UNION "
+ "{ "
+ "<"+ queryURI + "> core:organizationForPosition ?Position . "
+ "<" + queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ; rdf:type ?PersonType . "
+ "?PersonType rdfs:label ?PersonTypeLabel . "
+ "}"
+ "}";
// log.debug("\n SubOrganizationTypesQuery :" + sparqlQuery);
return sparqlQuery;
}
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>>();
while(resultSet.hasNext()){
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
@ -165,20 +158,13 @@ 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 (subOrganizationLabelToTypes.size() != 0 )? subOrganizationLabelToTypes : personLabelToTypes ;
}
public Map<String, Set<String>> getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) {
/*
* To test for the validity of the URI submitted.
*/
@ -191,16 +177,13 @@ public class EntitySubOrganizationTypesQueryRunner implements QueryRunner<Map<St
throw new MalformedQueryParametersException(
"URI provided for an entity is malformed.");
}
} else {
throw new MalformedQueryParametersException(
"URL parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(this.entityURI, this.dataSource);
return createJavaValueObjects(resultSet);
}
}

View file

@ -26,340 +26,365 @@ import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryP
import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.ModelConstructor;
public class EntityGrantCountConstructQueryRunner implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private Dataset Dataset;
private Dataset dataset;
private long before, after;
private Log log = LogFactory.getLog(EntityGrantCountConstructQueryRunner.class.getName());
public EntityGrantCountConstructQueryRunner(String egoURI, Dataset Dataset, Log log){
private Log log = LogFactory
.getLog(EntityGrantCountConstructQueryRunner.class.getName());
public EntityGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
Log log) {
this.egoURI = egoURI;
this.Dataset = Dataset;
//this.log = log;
this.dataset = dataset;
// this.log = log;
}
private String generateConstructQueryForOrganizationLabel(String queryURI) {
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> rdfs:label ?organizationLabel ."
+ "}"
+ "WHERE {"
+ "<"+queryURI+ "> rdfs:label ?organizationLabel "
+ "}";
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
+ "> rdfs:label ?organizationLabel ." + "}" + "WHERE {" + "<"
+ queryURI + "> rdfs:label ?organizationLabel " + "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "} UNION "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION "
+ "{"
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofRole(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue "
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue "
+ "} UNION "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue "
+ "}"
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofGrant(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "WHERE { "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION "
+ "{"
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "}";
return sparqlQuery;
}
private String generateConstructQueryForSubOrganizations(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel "
+ "}" ;
return sparqlQuery;
}
private String generateConstructQueryForPersons(String queryURI, String preboundProperty){
String sparqlQuery =
"CONSTRUCT { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel "
+"}"
+ "WHERE { "
+ "<"+queryURI+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ."
+ "?Person " + preboundProperty + " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel "
+ "}" ;
return sparqlQuery;
}
private Model executeQuery(Set<String> constructQueries, Dataset Dataset) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
for (String queryString : constructQueries) {
log.debug("CONSTRUCT query string : " + queryString);
Query query = null;
try{
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + queryString, SYNTAX);
// log.debug("query: "+ queryString);
}catch(Throwable th){
log.error("Could not create CONSTRUCT SPARQL query for query " +
"string. " + th.getMessage());
log.error(queryString);
}
QueryExecution qe = QueryExecutionFactory.create(
query, Dataset);
try {
qe.execConstruct(constructedModel);
} finally {
qe.close();
}
}
after = System.currentTimeMillis();
// log.debug("Statements for constructed model of EntityGrantCount : "+ constructedModel.listStatements().toString());
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: " + (after - before) );
// constructedModel.write(System.out);
return constructedModel;
}
public Model getConstructedModel()
throws MalformedQueryParametersException {
private String generateConstructQueryForDateTimeValueofRoleForOneLevelDeep(
String queryURI, String preboundProperty) {
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " + "}"
+ "WHERE { " + "{" + "<" + queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "} UNION " + "{" + "<" + queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . " + "}" + "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofGrantForOneLevelDeep(
String queryURI, String preboundProperty) {
String sparqlQuery = "CONSTRUCT { " + "<"
+ queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "WHERE { "
+ "{"
+ "<"
+ queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION "
+ "{"
+ "<"
+ queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}" + "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofRole(
String queryURI, String preboundProperty) {
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue " + "}"
+ "WHERE { " + "{" + "<" + queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue " + "} UNION "
+ "{" + "<" + queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . " + "?Person "
+ preboundProperty + " ?Role . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue " + "}" + "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofGrant(
String queryURI, String preboundProperty) {
String sparqlQuery = "CONSTRUCT { " + "<"
+ queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}"
+ "WHERE { "
+ "{"
+ "<"
+ queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant "
+ "} UNION "
+ "{"
+ "<"
+ queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person "
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleIn ?Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
+ "}" + "}";
return sparqlQuery;
}
private String generateConstructQueryForSubOrganizations(String queryURI,
String preboundProperty) {
String sparqlQuery =
"CONSTRUCT { " + "<" + queryURI
+ "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person "
+ preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "}" + "WHERE { " + "<"
+ queryURI + "> core:hasSubOrganization ?subOrganization . "
+ "?subOrganization rdfs:label ?subOrganizationLabel . "
+ "?subOrganization core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person "
+ preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "}";
return sparqlQuery;
}
private String generateConstructQueryForPersons(String queryURI,
String preboundProperty) {
String sparqlQuery =
"CONSTRUCT { " + "<" + queryURI
+ "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person "
+ preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "}" + "WHERE { " + "<"
+ queryURI + "> core:organizationForPosition ?Position . "
+ "?Position core:positionForPerson ?Person . "
+ "?Person rdfs:label ?PersonLabel ." + "?Person "
+ preboundProperty + " ?Role . " + "?Role core:roleIn ?Grant ."
+ "?Grant rdfs:label ?GrantLabel " + "}";
return sparqlQuery;
}
private Model executeQuery(Set<String> constructQueries, Dataset dataset) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
for (String queryString : constructQueries) {
log.debug("CONSTRUCT query string : " + queryString);
Query query = null;
try {
query = QueryFactory.create(QueryConstants
.getSparqlPrefixQuery()
+ queryString, SYNTAX);
// log.debug("query: "+ queryString);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(queryString);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
try {
qe.execConstruct(constructedModel);
} finally {
qe.close();
}
}
after = System.currentTimeMillis();
// log.debug("Statements for constructed model of EntityGrantCount : "+
// constructedModel.listStatements().toString());
log
.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
+ (after - before));
// constructedModel.write(System.out);
return constructedModel;
}
public Model getConstructedModel() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) {
/*
* To test for the validity of the URI submitted.
*/
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.egoURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next())
.getShortMessage();
log.error("Entity Grant Count Construct Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException(
"URI parameter is either null or empty.");
}
Set<String> constructQueries = new LinkedHashSet<String>();
populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries, this.dataset);
return model;
if (StringUtils.isNotBlank(this.egoURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.egoURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Entity Grant Count Construct Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
}
Set<String> constructQueries = new LinkedHashSet<String>();
populateConstructQueries(constructQueries);
Model model = executeQuery(constructQueries,
this.Dataset);
return model;
}
private void populateConstructQueries(Set<String> constructQueries) {
constructQueries.add(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForPersons(this.egoURI, "core:hasInvestigatorRole"));
constructQueries.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(generateConstructQueryForPersons(this.egoURI, "core:hasPrincipalInvestigatorRole"));
constructQueries.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(generateConstructQueryForOrganizationLabel(this.egoURI));
constructQueries.add(generateConstructQueryForSubOrganizations(
this.egoURI, "core:hasInvestigatorRole"));
constructQueries.add(generateConstructQueryForPersons(this.egoURI,
"core:hasInvestigatorRole"));
constructQueries
.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(generateConstructQueryForPersons(this.egoURI,
"core:hasPrincipalInvestigatorRole"));
constructQueries
.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(generateConstructQueryForPersons(this.egoURI,
"core:hasCo-PrincipalInvestigatorRole"));
constructQueries
.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"));
}
constructQueries.add(generateConstructQueryForSubOrganizations(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForPersons(this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
constructQueries.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

@ -60,7 +60,7 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ " (str(?startDateTimeValue) as ?grantStartDateLit) "
+ " (str(?endDateTimeValue) as ?grantEndDateLit) "
+ " (str(?startDateTimeValueForGrant) as ?grantStartDateForGrantLit) "
+ " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit) " ;
+ " (str(?endDateTimeValueForGrant) as ?grantEndDateForGrantLit)";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME = " "
+ " ?Role core:roleIn ?Grant . "
@ -73,7 +73,7 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "}" ;
+ "}";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = " "
+ " ?Role core:roleIn ?Grant . "
@ -86,13 +86,13 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}"
+ "}" ;
+ "}";
private static String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
private static String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
private static String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL ;
private static String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
private static final String ENTITY_LABEL = QueryFieldLabels.ORGANIZATION_LABEL;
private static final String ENTITY_URL = QueryFieldLabels.ORGANIZATION_URL;
private static final String SUBENTITY_LABEL = QueryFieldLabels.SUBORGANIZATION_LABEL;
private static final String SUBENTITY_URL = QueryFieldLabels.SUBORGANIZATION_URL;
public EntityGrantCountQueryRunner(String entityURI,
@ -113,7 +113,6 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
before = System.currentTimeMillis();
while (resultSet.hasNext()) {
// log.debug("Checking whether EntityGrantCount produced any resultset against the Constructed Model");
QuerySolution solution = resultSet.nextSolution();
if (entity == null) {
@ -207,15 +206,13 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
/*
* This makes sure that either,
* 1. the parent organization is a department-like organization with no organizations
* beneath it, or
* 1. the parent organization is a department-like organization with no
* organizations beneath it, or
* 2. the parent organizations has both sub-organizations and people directly
* attached to that organizations e.g. president of a university.
* */
if (subEntityURLNode == null) {
entity.addSubEntity(person);
}
person.addActivity(grant);
@ -225,16 +222,13 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
entity.addActivity(grant);
}
/*if (subentityURLToVO.size() == 0 && personURLToVO.size() != 0) {
for (SubEntity person : personURLToVO.values()) {
entity.addSubEntity(person);
}
} else */if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0) {
if (subentityURLToVO.size() == 0 && personURLToVO.size() == 0) {
entity = new Entity(this.entityURI, "no-label");
}
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;
}
@ -247,7 +241,7 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
return queryExecution.execSelect();
}
private String getSparqlQuery(String queryURI){
private String getSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE + " (str(<" + queryURI
@ -255,7 +249,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "WHERE { " + "<" + queryURI + "> rdfs:label ?organizationLabel ."
+ "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization ."
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasCo-PrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel ."
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
@ -263,7 +258,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasPrincipalInvestigatorRole ?Role ; rdfs:label ?PersonLabel . "
+ SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_ROLE_DATE_TIME
@ -271,7 +267,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
+ "UNION "
+ "{ "
+ "<" + queryURI + "> core:hasSubOrganization ?subOrganization . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ; core:organizationForPosition ?Position . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel ;"
+ " core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person ."
+ " ?Person core:hasInvestigatorRole ?Role ; rdfs:label ?PersonLabel . "
+ 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 + "}"
+ " } ";
//System.out.println("\n\nEntity Activity Count query is: "+ sparqlQuery);
// log.debug("\nThe sparql query is :\n" + sparqlQuery);
return sparqlQuery;
}
public Entity getQueryResult() throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.entityURI)) {
/*
* To test for the validity of the URI submitted.
*/
@ -335,7 +326,8 @@ public class EntityGrantCountQueryRunner implements QueryRunner<Entity> {
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);
}

View file

@ -40,16 +40,19 @@ public class EntityGrantCountRequestHandler implements
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
String entityURI = vitroRequest
.getParameter(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY);
if (StringUtils.isBlank(entityURI)){
if (StringUtils.isBlank(entityURI)) {
entityURI = EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(log, Dataset, vitroRequest);
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
dataset,
vitroRequest);
}
return prepareStandaloneMarkupResponse(vitroRequest, entityURI);
@ -57,7 +60,7 @@ public class EntityGrantCountRequestHandler implements
@Override
public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
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.
* */
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(
vitroRequest,
log,
Dataset,
dataset,
entityURI);
} else {
return getSubjectEntityAndGenerateDataResponse(
vitroRequest,
log,
Dataset,
dataset,
EntityComparisonUtilityFunctions
.getStaffProvidedOrComputedHighestLevelOrganization(
log,
Dataset,
dataset,
vitroRequest));
}
@ -93,8 +97,9 @@ public class EntityGrantCountRequestHandler implements
/*
* 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();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
@ -103,10 +108,11 @@ public class EntityGrantCountRequestHandler implements
Entity entity = queryManager.getQueryResult();
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, entityURI);
Map<String, Set<String>> subOrganizationTypesResult =
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
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log,
Dataset Dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Entity Grant Count does not provide Ajax Response.");
Dataset dataset) throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Entity Grant Count "
+ "does not provide Ajax response.");
}
private Map<String, String> getSubjectEntityAndGenerateDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectEntityURI)
throws MalformedQueryParametersException {
ModelConstructor constructQueryRunner = new EntityGrantCountConstructQueryRunner(subjectEntityURI, Dataset, log);
ModelConstructor constructQueryRunner =
new EntityGrantCountConstructQueryRunner(subjectEntityURI, dataset, log);
Model constructedModel = constructQueryRunner.getConstructedModel();
QueryRunner<Entity> queryManager = new EntityGrantCountQueryRunner(
@ -136,18 +146,19 @@ public class EntityGrantCountRequestHandler implements
} else {
return getSubEntityTypesAndComputeDataResponse(
vitroRequest, log, Dataset,
vitroRequest, log, dataset,
subjectEntityURI, entity);
}
}
private Map<String, String> getSubEntityTypesAndComputeDataResponse(
VitroRequest vitroRequest, Log log, Dataset Dataset,
VitroRequest vitroRequest, Log log, Dataset dataset,
String subjectOrganization, Entity entity)
throws MalformedQueryParametersException {
Map<String, Set<String>> subOrganizationTypesResult = EntityComparisonUtilityFunctions.getSubEntityTypes(
log, Dataset, subjectOrganization);
Map<String, Set<String>> subOrganizationTypesResult =
EntityComparisonUtilityFunctions.getSubEntityTypes(
log, dataset, subjectOrganization);
return prepareStandaloneDataResponse(vitroRequest, entity, subOrganizationTypesResult);
}
@ -160,7 +171,8 @@ public class EntityGrantCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY, "{\"error\" : \"No Grants for this Organization found in VIVO.\"}");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
"{\"error\" : \"No Grants for this Organization found in VIVO.\"}");
return fileData;
}
@ -175,7 +187,9 @@ public class EntityGrantCountRequestHandler implements
fileData.put(DataVisualizationController.FILE_CONTENT_TYPE_KEY,
"application/octet-stream");
fileData.put(DataVisualizationController.FILE_CONTENT_KEY,
writeGrantsOverTimeJSON(vitroRequest, entity.getSubEntities(), subOrganizationTypesResult));
writeGrantsOverTimeJSON(vitroRequest,
entity.getSubEntities(),
subOrganizationTypesResult));
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 subentities
* @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();
Set<JsonObject> subEntitiesJson = new HashSet<JsonObject>();
@ -267,15 +283,14 @@ public class EntityGrantCountRequestHandler implements
}
entityJson.setYearToActivityCount(yearGrantCount);
entityJson.getOrganizationType().addAll(subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.getOrganizationType().addAll(
subOrganizationTypesResult.get(entityJson.getLabel()));
entityJson.setEntityURI(subentity.getIndividualURI());
boolean isPerson = UtilityFunctions.isEntityAPerson(vreq, subentity);
if(isPerson){
if (UtilityFunctions.isEntityAPerson(vreq, subentity)) {
entityJson.setVisMode("PERSON");
} else{
} else {
entityJson.setVisMode("ORGANIZATION");
}
@ -285,15 +300,16 @@ public class EntityGrantCountRequestHandler implements
return json.toJson(subEntitiesJson);
}
private String getEntityGrantsPerYearCSVContent(Set<SubEntity> subentities, Map<String, Set<String>> subOrganizationTypesResult) {
private String getEntityGrantsPerYearCSVContent(
Set<SubEntity> subentities,
Map<String, Set<String>> subOrganizationTypesResult) {
StringBuilder csvFileContent = new StringBuilder();
csvFileContent.append("Entity Name, Grant Count, Entity Type\n");
for(SubEntity subEntity : subentities){
for (SubEntity subEntity : subentities) {
csvFileContent.append(StringEscapeUtils.escapeCsv(subEntity.getIndividualLabel()));
csvFileContent.append(", ");
@ -302,7 +318,8 @@ public class EntityGrantCountRequestHandler implements
StringBuilder joinedTypes = new StringBuilder();
for(String subOrganizationType : subOrganizationTypesResult.get(subEntity.getIndividualLabel())){
for (String subOrganizationType : subOrganizationTypesResult
.get(subEntity.getIndividualLabel())) {
joinedTypes.append(subOrganizationType + "; ");
}
@ -312,6 +329,4 @@ public class EntityGrantCountRequestHandler implements
return csvFileContent.toString();
}
}

View file

@ -30,20 +30,21 @@ 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
* Deepak Konidena
*
*/
public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI;
private Dataset Dataset;
private Dataset dataset;
private Individual principalInvestigator;
public Individual getPrincipalInvestigator(){
public Individual getPrincipalInvestigator() {
return principalInvestigator;
}
@ -69,7 +70,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "?dateTimeIntervalValue core:end ?endDate . "
+ "?endDate core:dateTime ?endDateTimeValue . "
+ "}"
+ "} . " ;
+ "} . ";
private static final String SPARQL_QUERY_COMMON_OPTIONAL_BLOCK_FOR_GRANT_DATE_TIME = ""
+ "OPTIONAL {"
@ -80,35 +81,35 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
+ "?endDateForGrant core:dateTime ?endDateTimeValueForGrant . "
+ "}"
+ "}" ;
+ "}";
public PersonGrantCountQueryRunner(String personURI, Dataset Dataset, Log log){
public PersonGrantCountQueryRunner(String personURI, Dataset dataset, Log log) {
this.personURI = personURI;
this.Dataset = Dataset;
this.dataset = dataset;
this.log = log;
}
private Set<Activity> createJavaValueObjects(ResultSet resultSet){
Set<Activity> PIGrant = new HashSet<Activity>();
private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
Set<Activity> grants = new HashSet<Activity>();
while(resultSet.hasNext()){
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
Activity grant = new Activity(solution.get(QueryFieldLabels.GRANT_URL).toString());
RDFNode grantLabelNode = solution.get(QueryFieldLabels.GRANT_LABEL);
if(grantLabelNode != null){
if (grantLabelNode != null) {
grant.setIndividualLabel(grantLabelNode.toString());
}
RDFNode grantStartDateNode = solution.get(QueryFieldLabels.ROLE_START_DATE);
if(grantStartDateNode != null){
if (grantStartDateNode != null) {
grant.setActivityDate(grantStartDateNode.toString());
}else {
} else {
grantStartDateNode = solution.get(QueryFieldLabels.GRANT_START_DATE);
if(grantStartDateNode != null){
if (grantStartDateNode != null) {
grant.setActivityDate(grantStartDateNode.toString());
}
}
@ -131,33 +132,33 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
* to create only one "Individual" instance. We test against the null for "PI" to
* make sure that it has not already been instantiated.
* */
RDFNode PIURLNode = solution.get(QueryFieldLabels.PI_URL);
if (PIURLNode != null && principalInvestigator == null) {
principalInvestigator = new Individual(PIURLNode.toString());
RDFNode PILabelNode = solution.get(QueryFieldLabels.PI_LABEL);
if (PILabelNode != null) {
principalInvestigator.setIndividualLabel(PILabelNode.toString());
RDFNode investigatorURINode = solution.get(QueryFieldLabels.PI_URL);
if (investigatorURINode != null && principalInvestigator == null) {
principalInvestigator = new Individual(investigatorURINode.toString());
RDFNode investigatorLabelNode = solution.get(QueryFieldLabels.PI_LABEL);
if (investigatorLabelNode != null) {
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;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query,Dataset);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String getSparqlQuery(String queryURI){
private String getSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
@ -170,7 +171,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "<" + queryURI + "> rdfs:label ?PILabel . "
+ "{ "
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
@ -186,7 +187,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "{ "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
+ "?Role core:roleIn ?Grant . "
@ -218,15 +219,15 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
+ "} ";
log.debug("SPARQL query for person grant count -> \n"+ sparqlQuery);
log.debug("SPARQL query for person grant count -> \n" + sparqlQuery);
//System.out.println("SPARQL query for person grant count -> \n"+ sparqlQuery);
return sparqlQuery;
}
public Set<Activity> getQueryResult() throws MalformedQueryParametersException{
public Set<Activity> getQueryResult() throws MalformedQueryParametersException {
if(StringUtils.isNotBlank(this.personURI)){
if (StringUtils.isNotBlank(this.personURI)) {
/*
* To test the validity of the URI submitted
@ -234,7 +235,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
IRIFactory iriFactory = IRIFactory.jenaImplementation();
IRI iri = iriFactory.create(this.personURI);
if(iri.hasViolation(false)){
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Grant Count vis Query " + errorMsg);
throw new MalformedQueryParametersException(
@ -244,7 +245,7 @@ public class PersonGrantCountQueryRunner implements QueryRunner<Set<Activity>>{
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);
}

View file

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

View file

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

View file

@ -55,13 +55,13 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
@Override
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.");
}
@Override
public Map<String, String> generateDataVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
throw new UnsupportedOperationException("Person Level does not provide Data Response.");
}
@ -69,7 +69,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
@Override
public ResponseValues generateStandardVisualization(
VitroRequest vitroRequest, Log log, Dataset Dataset)
VitroRequest vitroRequest, Log log, Dataset dataset)
throws MalformedQueryParametersException {
String egoURI = vitroRequest.getParameter(
@ -79,14 +79,17 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
VisualizationFrameworkConstants.VIS_MODE_KEY);
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();
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();
@ -140,9 +143,11 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
} 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();
@ -196,7 +201,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
}
private TemplateResponseValues prepareCoAuthorStandaloneResponse (
private TemplateResponseValues prepareCoAuthorStandaloneResponse(
String egoURI,
SparklineData egoPubSparklineVO,
SparklineData uniqueCoauthorsSparklineVO,
@ -212,12 +217,14 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
String title = "";
if (coAuthorshipVO.getCollaborators() != null && coAuthorshipVO.getCollaborators().size() > 0) {
if (coAuthorshipVO.getCollaborators() != null
&& coAuthorshipVO.getCollaborators().size() > 0) {
body.put("numOfAuthors", coAuthorshipVO.getCollaborators().size());
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());
}
@ -231,7 +238,7 @@ public class PersonLevelRequestHandler implements VisualizationRequestHandler {
}
private TemplateResponseValues prepareCoPIStandaloneResponse (
private TemplateResponseValues prepareCoPIStandaloneResponse(
String egoURI,
SparklineData egoGrantSparklineVO,
SparklineData uniqueCopisSparklineVO,

View file

@ -41,7 +41,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI;
private Dataset Dataset;
private Dataset dataset;
private Individual author;
@ -52,20 +52,20 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n";
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")\n";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n" ;
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n";
public PersonPublicationCountQueryRunner(String personURI,
Dataset Dataset, Log log) {
Dataset dataset, Log log) {
this.personURI = personURI;
this.Dataset = Dataset;
this.dataset = dataset;
this.log = log;
}
@ -105,11 +105,11 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
}
private ResultSet executeQuery(String queryURI,
Dataset Dataset) {
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, Dataset);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
@ -154,7 +154,7 @@ public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activi
}
ResultSet resultSet = executeQuery(this.personURI,
this.Dataset);
this.dataset);
return createJavaValueObjects(resultSet);
}

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ import edu.cornell.mannlib.vitro.webapp.visualization.freemarker.visutils.Utilit
* published (or started).
* @author cdtank
*/
public class Activity extends Individual{
public class Activity extends Individual {
private String activityDate;

View file

@ -80,7 +80,8 @@ public class Collaboration {
* We do not want to consider the default Activity year when we are checking
* 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);
/*
@ -92,7 +93,8 @@ public class Collaboration {
* */
if (yearsToBeConsidered.size() > 0) {
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>() { {
put(earliestYear, earliestYearActivityCount);
@ -109,7 +111,8 @@ public class Collaboration {
* We do not want to consider the default Activity year when we are checking
* 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);
/*

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
* 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);
/*
@ -91,7 +92,8 @@ public class Collaborator extends Individual {
* */
if (yearsToBeConsidered.size() > 0) {
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>() { {
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
* 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);
/*

View file

@ -11,20 +11,20 @@ import java.util.LinkedHashSet;
* Deepak Konidena
*
*/
public class Entity extends Individual{
public class Entity extends Individual {
Set<Activity> activities = new HashSet<Activity>();
Set<SubEntity> children = new LinkedHashSet<SubEntity>();
private Set<Activity> activities = new HashSet<Activity>();
private Set<SubEntity> children = new LinkedHashSet<SubEntity>();
public Entity(String departmentURI, String departmentLabel){
public Entity(String departmentURI, String departmentLabel) {
super(departmentURI, departmentLabel);
}
public void setDepartmentLabel(String departmentURI){
public void setDepartmentLabel(String departmentURI) {
this.setIndividualLabel(departmentURI);
}
public String getEntityURI(){
public String getEntityURI() {
return this.getIndividualURI();
}
@ -32,7 +32,7 @@ public class Entity extends Individual{
return activities;
}
public String getEntityLabel(){
public String getEntityLabel() {
return this.getIndividualLabel();
}

View file

@ -63,11 +63,11 @@ public class JsonObject {
return data;
}
public JsonObject(String label){
public JsonObject(String label) {
this.label = label;
}
public void setYearToActivityCount(List<List<Integer>> yearToPublicationCount){
public void setYearToActivityCount(List<List<Integer>> yearToPublicationCount) {
this.data = yearToPublicationCount;
}

View file

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

View file

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

View file

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

View file

@ -77,7 +77,8 @@ public class UtilityFunctions {
public static Map<String, Set<Collaborator>> getActivityYearToCollaborators(
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();
@ -218,18 +219,18 @@ public class UtilityFunctions {
public static String getCSVDownloadURL(String individualURI, String visType, String visMode) {
ParamMap CSVDownloadURLParams = null;
ParamMap csvDownloadURLParams = null;
if (StringUtils.isBlank(visMode)) {
CSVDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
csvDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType);
} else {
CSVDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
csvDownloadURLParams = new ParamMap(VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType,
@ -238,31 +239,39 @@ public class UtilityFunctions {
}
String csvDownloadLink = UrlBuilder.getUrl(VisualizationFrameworkConstants.DATA_VISUALIZATION_SERVICE_URL_PREFIX,
CSVDownloadURLParams);
String csvDownloadLink = UrlBuilder.getUrl(
VisualizationFrameworkConstants
.DATA_VISUALIZATION_SERVICE_URL_PREFIX,
csvDownloadURLParams);
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,
individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType,
VisualizationFrameworkConstants.VIS_MODE_KEY,
visMode);
ParamMap collaboratorshipNetworkURLParams = new ParamMap(
VisualizationFrameworkConstants.INDIVIDUAL_URI_KEY,
individualURI,
VisualizationFrameworkConstants.VIS_TYPE_KEY,
visType,
VisualizationFrameworkConstants.VIS_MODE_KEY,
visMode);
String collaboratorshipNetworkURL = UrlBuilder.getUrl(
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
collaboratorshipNetworkURLParams);
VisualizationFrameworkConstants.FREEMARKERIZED_VISUALIZATION_URL_PREFIX,
collaboratorshipNetworkURLParams);
return collaboratorshipNetworkURL != null ? collaboratorshipNetworkURL : "" ;
}
public static boolean isEntityAPerson(VitroRequest vreq, SubEntity subentity) {
return vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subentity.getIndividualURI()).isVClass("http://xmlns.com/foaf/0.1/Person");
return vreq.getWebappDaoFactory()
.getIndividualDao()
.getIndividualByURI(subentity.getIndividualURI())
.isVClass("http://xmlns.com/foaf/0.1/Person");
}
}