VIVO-285: visualization updates for ISF
This commit is contained in:
parent
d71c995e0e
commit
83b3f755d5
27 changed files with 2743 additions and 2524 deletions
|
@ -25,11 +25,14 @@
|
||||||
?dateTimeEnd
|
?dateTimeEnd
|
||||||
|
|
||||||
WHERE {
|
WHERE {
|
||||||
?subject ?property ?advisory
|
?subject ?property ?advisory .
|
||||||
|
?advisory core:relates ?advisor .
|
||||||
|
?advisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole .
|
||||||
LET ( ?localName := afn:localname(?advisory) )
|
LET ( ?localName := afn:localname(?advisory) )
|
||||||
OPTIONAL { ?advisory rdfs:label ?advisoryLabel }
|
OPTIONAL { ?advisory rdfs:label ?advisoryLabel }
|
||||||
OPTIONAL { ?advisory core:relates ?advisee .
|
OPTIONAL { ?advisory core:relates ?advisee .
|
||||||
?advisee a foaf:Person .
|
?advisee a foaf:Person .
|
||||||
|
?advisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole
|
||||||
OPTIONAL { ?advisee rdfs:label ?adviseeLabel }
|
OPTIONAL { ?advisee rdfs:label ?adviseeLabel }
|
||||||
}
|
}
|
||||||
OPTIONAL { ?advisory core:relates ?degree .
|
OPTIONAL { ?advisory core:relates ?degree .
|
||||||
|
@ -74,7 +77,10 @@
|
||||||
?subject ?property ?advisory .
|
?subject ?property ?advisory .
|
||||||
?advisory a core:AdvisingRelationship .
|
?advisory a core:AdvisingRelationship .
|
||||||
?advisory ?advisoryProperty ?advisoryValue .
|
?advisory ?advisoryProperty ?advisoryValue .
|
||||||
?advisory rdfs:label ?advisoryLabel
|
?advisory rdfs:label ?advisoryLabel .
|
||||||
|
?advisory core:relates ?advisor .
|
||||||
|
?advisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole .
|
||||||
|
?advisorRole a core:AdvisorRole
|
||||||
} WHERE {
|
} WHERE {
|
||||||
{
|
{
|
||||||
?subject ?property ?advisory .
|
?subject ?property ?advisory .
|
||||||
|
@ -88,10 +94,23 @@
|
||||||
?advisory a core:AdvisingRelationship .
|
?advisory a core:AdvisingRelationship .
|
||||||
?advisory ?advisoryProperty ?advisoryValue .
|
?advisory ?advisoryProperty ?advisoryValue .
|
||||||
?advisory rdfs:label ?advisoryLabel
|
?advisory rdfs:label ?advisoryLabel
|
||||||
|
} UNION {
|
||||||
|
?subject ?property ?advisory .
|
||||||
|
?advisory a core:AdvisingRelationship .
|
||||||
|
?advisory ?advisoryProperty ?advisoryValue .
|
||||||
|
?advisory core:relates ?advisor .
|
||||||
|
?advisor <http://purl.obolibrary.org/obo/RO_0000053> ?advisorRole .
|
||||||
|
?advisorRole a core:AdvisorRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</query-construct>
|
</query-construct>
|
||||||
|
|
||||||
|
OPTIONAL { ?advisory core:relates ?advisee .
|
||||||
|
?advisee a foaf:Person .
|
||||||
|
?advisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<query-construct>
|
<query-construct>
|
||||||
PREFIX bibo: <http://purl.org/ontology/bibo/>
|
PREFIX bibo: <http://purl.org/ontology/bibo/>
|
||||||
PREFIX core: <http://vivoweb.org/ontology/core#>
|
PREFIX core: <http://vivoweb.org/ontology/core#>
|
||||||
|
@ -104,6 +123,8 @@
|
||||||
?advisory core:relates ?advisee .
|
?advisory core:relates ?advisee .
|
||||||
?advisee a foaf:Person .
|
?advisee a foaf:Person .
|
||||||
?advisee rdfs:label ?adviseeLabel .
|
?advisee rdfs:label ?adviseeLabel .
|
||||||
|
?advisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole .
|
||||||
|
?adviseeRole a core:AdviseeRole .
|
||||||
?advisory core:relates ?degree .
|
?advisory core:relates ?degree .
|
||||||
?degree a core:AcademicDegree .
|
?degree a core:AcademicDegree .
|
||||||
?degree rdfs:label ?degreeLabel .
|
?degree rdfs:label ?degreeLabel .
|
||||||
|
@ -117,11 +138,15 @@
|
||||||
?advisory a core:AdvisingRelationship .
|
?advisory a core:AdvisingRelationship .
|
||||||
?advisory core:relates ?advisee .
|
?advisory core:relates ?advisee .
|
||||||
?advisee a foaf:Person .
|
?advisee a foaf:Person .
|
||||||
|
?advisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole .
|
||||||
|
?adviseeRole a core:AdviseeRole
|
||||||
} UNION {
|
} UNION {
|
||||||
?subject ?property ?advisory .
|
?subject ?property ?advisory .
|
||||||
?advisory a core:AdvisingRelationship .
|
?advisory a core:AdvisingRelationship .
|
||||||
?advisory core:relates ?advisee .
|
?advisory core:relates ?advisee .
|
||||||
?advisee a foaf:Person .
|
?advisee a foaf:Person .
|
||||||
|
?advisee <http://purl.obolibrary.org/obo/RO_0000053> ?adviseeRole .
|
||||||
|
?adviseeRole a core:AdviseeRole .
|
||||||
?advisee rdfs:label ?adviseeLabel
|
?advisee rdfs:label ?adviseeLabel
|
||||||
} UNION {
|
} UNION {
|
||||||
?subject ?property ?advisory .
|
?subject ?property ?advisory .
|
||||||
|
|
|
@ -3,12 +3,14 @@
|
||||||
<#-- Template for sparkline visualization on individual profile page -->
|
<#-- Template for sparkline visualization on individual profile page -->
|
||||||
|
|
||||||
<#-- Determine whether this person is an author -->
|
<#-- Determine whether this person is an author -->
|
||||||
<#assign isAuthor = p.hasStatements(propertyGroups, "${core}authorInAuthorship") />
|
<#assign isAuthor = p.hasVisualizationStatements(propertyGroups, "${core}relatedBy", "${core}Authorship") />
|
||||||
|
|
||||||
<#-- Determine whether this person is involved in any grants -->
|
<#-- Determine whether this person is involved in any grants -->
|
||||||
<#assign isInvestigator = ( p.hasStatements(propertyGroups, "${core}hasInvestigatorRole") ||
|
<#assign obo_RO53 = "http://purl.obolibrary.org/obo/RO_0000053">
|
||||||
p.hasStatements(propertyGroups, "${core}hasPrincipalInvestigatorRole") ||
|
|
||||||
p.hasStatements(propertyGroups, "${core}hasCo-PrincipalInvestigatorRole") ) >
|
<#assign isInvestigator = ( p.hasVisualizationStatements(propertyGroups, "${obo_RO53}", "${core}InvestigatorRole") ||
|
||||||
|
p.hasVisualizationStatements(propertyGroups, "${obo_RO53}", "${core}PrincipalInvestigatorRole") ||
|
||||||
|
p.hasVisualizationStatements(propertyGroups, "${obo_RO53}", "${core}CoPrincipalInvestigatorRole") ) >
|
||||||
|
|
||||||
<#if (isAuthor || isInvestigator)>
|
<#if (isAuthor || isInvestigator)>
|
||||||
|
|
||||||
|
@ -70,4 +72,4 @@
|
||||||
<div class="collaboratorship-link"><a href="${coInvestigatorVisUrl}" title="${i18n().co_investigator_network}">${i18n().co_investigator_network_capitalized}</a></div>
|
<div class="collaboratorship-link"><a href="${coInvestigatorVisUrl}" title="${i18n().co_investigator_network}">${i18n().co_investigator_network_capitalized}</a></div>
|
||||||
</div>
|
</div>
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<h1 id="noPubsOrGrants-header">${organizationLabel}</h1>
|
<h1 id="noPubsOrGrants-header">${organizationLabel}</h1>
|
||||||
|
|
||||||
<h3 id="alternative-vis-info">${textForCurrentEntityComparisonType?capitalize} ${i18n().temporal_graph_capitalized}
|
<h3 id="alternative-vis-info">${textForCurrentEntityComparisonType?capitalize} ${i18n().temporal_graph_capitalized}
|
||||||
<span id="noPubsOrGrants-span">| <a href="${temporalGraphURL}" title="${i18n().view}">${i18n().view} ${textForOtherEntityComparisonType} ${i18n().temporal_graph}</a></span>
|
<span id="noPubsOrGrants-span">| <a href="${temporalGraphURL}" title="${i18n().view}">${i18n().view} ${textForOtherEntityComparisonType} ${i18n().temporal_graph}</a></span>
|
||||||
</h3>
|
</h3>
|
||||||
<div id="error-body">
|
<div id="error-body">
|
||||||
<p>${i18n().entity_comp_error_text1}
|
<p>${i18n().entity_comp_error_text1}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<h2>${i18n().visualization_tools}</h2>
|
<h2>${i18n().visualization_tools}</h2>
|
||||||
|
|
||||||
<a href="${refreshCacheURL}">${i18n().refresh_cached_vis_model}</a>
|
<a href="${refreshCacheURL}">${i18n().refresh_cached_vis_models}</a>
|
||||||
<section class="visualizationTools">
|
<section class="visualizationTools">
|
||||||
<h3>${i18n().why_needed}</h3>
|
<h3>${i18n().why_needed}</h3>
|
||||||
<p>${i18n().vis_tools_note_one}</p>
|
<p>${i18n().vis_tools_note_one}</p>
|
||||||
|
|
|
@ -453,7 +453,7 @@ local:eventWithinConfig a :ObjectPropertyDisplayConfig ;
|
||||||
|
|
||||||
local:includesEventContext a :ConfigContext ;
|
local:includesEventContext a :ConfigContext ;
|
||||||
:hasConfiguration local:includesEventConfig ;
|
:hasConfiguration local:includesEventConfig ;
|
||||||
:configContextFor <http://purl.obolibrary.org/obo/BFO_0000050> ;
|
:configContextFor <http://purl.obolibrary.org/obo/BFO_0000051> ;
|
||||||
:qualifiedByDomain <http://purl.org/NET/c4dm/event.owl#Event> ;
|
:qualifiedByDomain <http://purl.org/NET/c4dm/event.owl#Event> ;
|
||||||
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#Event> .
|
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#Event> .
|
||||||
|
|
||||||
|
@ -467,11 +467,11 @@ local:includesEventConfig a :ObjectPropertyDisplayConfig ;
|
||||||
|
|
||||||
local:inEventSeriesContext a :ConfigContext ;
|
local:inEventSeriesContext a :ConfigContext ;
|
||||||
:hasConfiguration local:inEventSeriesConfig ;
|
:hasConfiguration local:inEventSeriesConfig ;
|
||||||
:configContextFor <http://purl.obolibrary.org/obo/BFO_0000051> ;
|
:configContextFor <http://purl.obolibrary.org/obo/BFO_0000050> ;
|
||||||
:qualifiedByDomain <http://purl.org/NET/c4dm/event.owl#Event> ;
|
:qualifiedByDomain <http://purl.org/NET/c4dm/event.owl#Event> ;
|
||||||
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#EventSeries> .
|
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#EventSeries> .
|
||||||
|
|
||||||
local:includesEventConfig a :ObjectPropertyDisplayConfig ;
|
local:inEventSeriesConfig a :ObjectPropertyDisplayConfig ;
|
||||||
:listViewConfigFile "listViewConfig-default.xml"^^xsd:string ;
|
:listViewConfigFile "listViewConfig-default.xml"^^xsd:string ;
|
||||||
:displayName "in event series" ;
|
:displayName "in event series" ;
|
||||||
vitro:displayRankAnnot 3;
|
vitro:displayRankAnnot 3;
|
||||||
|
@ -479,3 +479,16 @@ local:includesEventConfig a :ObjectPropertyDisplayConfig ;
|
||||||
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
|
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
|
||||||
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> .
|
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> .
|
||||||
|
|
||||||
|
local:awardAssignedByContext a :ConfigContext ;
|
||||||
|
:hasConfiguration local:awardAssignedByConfig ;
|
||||||
|
:configContextFor <http://vivoweb.org/ontology/core#assignedBy> ;
|
||||||
|
:qualifiedByDomain <http://vivoweb.org/ontology/core#Award> ;
|
||||||
|
:qualifiedBy <http://vivoweb.org/ontology/core#Award> .
|
||||||
|
|
||||||
|
local:awardAssignedByConfig a :ObjectPropertyDisplayConfig ;
|
||||||
|
:listViewConfigFile "listViewConfig-default.xml"^^xsd:string ;
|
||||||
|
:displayName "award conferred by" ;
|
||||||
|
vitro:displayRankAnnot 3;
|
||||||
|
vitro:hiddenFromDisplayBelowRoleLevelAnnot role:public ;
|
||||||
|
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
|
||||||
|
:propertyGroup <http://vivoweb.org/ontology#vitroPropertyGroupoverview> .
|
||||||
|
|
|
@ -65,12 +65,14 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
||||||
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
|
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
|
||||||
|
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
||||||
+ "SELECT DISTINCT ?subclass ?position (str(?label) as ?name) ?person ?hideThis WHERE { \n"
|
+ "SELECT DISTINCT ?subclass ?position (str(?label) as ?name) ?person ?hideThis WHERE { \n"
|
||||||
+ " ?subject core:organizationForPosition ?position . \n"
|
+ " ?subject core:relatedBy ?position . \n"
|
||||||
+ " OPTIONAL { ?position core:positionForPerson ?person . "
|
+ " ?position a core:Position . \n"
|
||||||
|
+ " OPTIONAL { ?position core:relates ?person . "
|
||||||
|
+ " ?person a foaf:Person . \n"
|
||||||
+ " ?person rdfs:label ?label } \n"
|
+ " ?person rdfs:label ?label } \n"
|
||||||
+ " OPTIONAL { ?position vitro:mostSpecificType ?subclass . \n"
|
+ " OPTIONAL { ?position vitro:mostSpecificType ?subclass } \n"
|
||||||
+ " ?subclass rdfs:subClassOf core:Position } \n"
|
|
||||||
+ " OPTIONAL { ?position core:hideFromDisplay ?hideThis } \n "
|
+ " OPTIONAL { ?position core:hideFromDisplay ?hideThis } \n "
|
||||||
+ "} ORDER BY ?subclass ?name";
|
+ "} ORDER BY ?subclass ?name";
|
||||||
|
|
||||||
|
|
|
@ -209,25 +209,25 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
|
||||||
"?awardReceipt <"+ descriptionPred +"> ?description .";
|
"?awardReceipt <"+ descriptionPred +"> ?description .";
|
||||||
|
|
||||||
final static String n3ForExistingOrgNewAwardAssertion =
|
final static String n3ForExistingOrgNewAwardAssertion =
|
||||||
"?award <" + awardConferredByPred +"> ?existingOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||||
"?existingOrg <" + awardConferredPred + "> ?award . \n" +
|
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?award <"+ label + "> ?awardLabel .";
|
"?award <"+ label + "> ?awardLabel .";
|
||||||
|
|
||||||
final static String n3ForExistingOrgExistingAwardAssertion =
|
final static String n3ForExistingOrgExistingAwardAssertion =
|
||||||
"?existingAward <" + awardConferredByPred +"> ?existingOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
|
||||||
"?existingOrg <" + awardConferredPred + "> ?existingAward . ";
|
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . ";
|
||||||
|
|
||||||
final static String n3ForNewOrgNewAwardAssertion =
|
final static String n3ForNewOrgNewAwardAssertion =
|
||||||
"?newOrg a <" + orgClass + "> . \n" +
|
"?newOrg a <" + orgClass + "> . \n" +
|
||||||
"?award <" + awardConferredByPred +"> ?newOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||||
"?newOrg <" + awardConferredPred + "> ?award . \n" +
|
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?award <"+ label + "> ?awardLabel . \n" +
|
"?award <"+ label + "> ?awardLabel . \n" +
|
||||||
"?newOrg <"+ label + "> ?orgLabel .";
|
"?newOrg <"+ label + "> ?orgLabel .";
|
||||||
|
|
||||||
final static String n3ForNewOrgExistingAwardAssertion =
|
final static String n3ForNewOrgExistingAwardAssertion =
|
||||||
"?newOrg a <" + orgClass + "> . \n" +
|
"?newOrg a <" + orgClass + "> . \n" +
|
||||||
"?existingAward <" + awardConferredByPred +"> ?newOrg . \n" +
|
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
|
||||||
"?newOrg <" + awardConferredPred + "> ?existingAward . \n" +
|
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
|
||||||
"?newOrg <"+ label + "> ?orgLabel .";
|
"?newOrg <"+ label + "> ?orgLabel .";
|
||||||
|
|
||||||
final static String n3ForYearAwarded =
|
final static String n3ForYearAwarded =
|
||||||
|
|
|
@ -240,6 +240,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?newOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
|
"?newOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
|
||||||
"?newOrg a ?orgType . \n" +
|
"?newOrg a ?orgType . \n" +
|
||||||
"?newOrg <"+ label +"> ?orgLabel . \n" +
|
"?newOrg <"+ label +"> ?orgLabel . \n" +
|
||||||
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?newOrg . \n" +
|
||||||
|
"?newOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
"?newAwardedDegree <http://vivoweb.org/ontology/core#relates> ?degreeType .\n"+
|
"?newAwardedDegree <http://vivoweb.org/ontology/core#relates> ?degreeType .\n"+
|
||||||
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?newAwardedDegree . \n"+
|
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?newAwardedDegree . \n"+
|
||||||
"?newAwardedDegree a core:AwardedDegree .";
|
"?newAwardedDegree a core:AwardedDegree .";
|
||||||
|
@ -254,6 +256,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
|
||||||
"?existingOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
|
"?existingOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
|
||||||
"?newAwardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?existingOrg . \n" +
|
"?newAwardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?existingOrg . \n" +
|
||||||
"?newAwardedDegree <http://vivoweb.org/ontology/core#relates> ?degreeType .\n"+
|
"?newAwardedDegree <http://vivoweb.org/ontology/core#relates> ?degreeType .\n"+
|
||||||
|
"?edTraining <http://purl.obolibrary.org/obo/RO_0000057> ?existingOrg . \n" +
|
||||||
|
"?existingOrg <http://purl.obolibrary.org/obo/RO_0000056> ?edTraining . \n" +
|
||||||
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?newAwardedDegree . \n"+
|
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?newAwardedDegree . \n"+
|
||||||
"?newAwardedDegree a core:AwardedDegree .";
|
"?newAwardedDegree a core:AwardedDegree .";
|
||||||
|
|
||||||
|
|
|
@ -1,442 +1,445 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.hp.hpl.jena.iri.IRI;
|
import com.hp.hpl.jena.iri.IRI;
|
||||||
import com.hp.hpl.jena.iri.IRIFactory;
|
import com.hp.hpl.jena.iri.IRIFactory;
|
||||||
import com.hp.hpl.jena.iri.Violation;
|
import com.hp.hpl.jena.iri.Violation;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CoAuthorshipData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaborationData;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaboratorComparator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.collaborationutils.CollaboratorComparator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaboration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Collaborator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This query runner is used to execute a sparql query to get all the publications
|
* This query runner is used to execute a sparql query to get all the publications
|
||||||
* for a particular individual. It will also fetch all the authors that worked
|
* for a particular individual. It will also fetch all the authors that worked
|
||||||
* on that particular publication.
|
* on that particular publication.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
|
||||||
|
|
||||||
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
|
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private String egoURI;
|
private String egoURI;
|
||||||
|
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
private UniqueIDGenerator nodeIDGenerator;
|
private UniqueIDGenerator nodeIDGenerator;
|
||||||
|
|
||||||
private UniqueIDGenerator edgeIDGenerator;
|
private UniqueIDGenerator edgeIDGenerator;
|
||||||
|
|
||||||
public CoAuthorshipQueryRunner(String egoURI,
|
public CoAuthorshipQueryRunner(String egoURI,
|
||||||
Dataset dataset, Log log) {
|
Dataset dataset, Log log) {
|
||||||
|
|
||||||
this.egoURI = egoURI;
|
this.egoURI = egoURI;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
this.nodeIDGenerator = new UniqueIDGenerator();
|
this.nodeIDGenerator = new UniqueIDGenerator();
|
||||||
this.edgeIDGenerator = new UniqueIDGenerator();
|
this.edgeIDGenerator = new UniqueIDGenerator();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollaborationData createQueryResult(ResultSet resultSet) {
|
private CollaborationData createQueryResult(ResultSet resultSet) {
|
||||||
|
|
||||||
Set<Collaborator> nodes = new HashSet<Collaborator>();
|
Set<Collaborator> nodes = new HashSet<Collaborator>();
|
||||||
|
|
||||||
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
|
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
|
||||||
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors =
|
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors =
|
||||||
new HashMap<String, Set<Collaborator>>();
|
new HashMap<String, Set<Collaborator>>();
|
||||||
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
|
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
|
||||||
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
|
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
|
||||||
|
|
||||||
Collaborator egoNode = null;
|
Collaborator egoNode = null;
|
||||||
|
|
||||||
Set<Collaboration> edges = new HashSet<Collaboration>();
|
Set<Collaboration> edges = new HashSet<Collaboration>();
|
||||||
|
|
||||||
while (resultSet.hasNext()) {
|
while (resultSet.hasNext()) {
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
QuerySolution solution = resultSet.nextSolution();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We only want to create only ONE ego node.
|
* We only want to create only ONE ego node.
|
||||||
* */
|
* */
|
||||||
RDFNode egoAuthorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
|
RDFNode egoAuthorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
|
||||||
if (nodeURLToVO.containsKey(egoAuthorURLNode.toString())) {
|
if (nodeURLToVO.containsKey(egoAuthorURLNode.toString())) {
|
||||||
|
|
||||||
egoNode = nodeURLToVO.get(egoAuthorURLNode.toString());
|
egoNode = nodeURLToVO.get(egoAuthorURLNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
egoNode = new Collaborator(egoAuthorURLNode.toString(), nodeIDGenerator);
|
egoNode = new Collaborator(egoAuthorURLNode.toString(), nodeIDGenerator);
|
||||||
nodes.add(egoNode);
|
nodes.add(egoNode);
|
||||||
nodeURLToVO.put(egoAuthorURLNode.toString(), egoNode);
|
nodeURLToVO.put(egoAuthorURLNode.toString(), egoNode);
|
||||||
|
|
||||||
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
|
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
|
||||||
if (authorLabelNode != null) {
|
if (authorLabelNode != null) {
|
||||||
egoNode.setCollaboratorName(authorLabelNode.toString());
|
egoNode.setCollaboratorName(authorLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
|
||||||
Activity biboDocument;
|
Activity biboDocument;
|
||||||
|
|
||||||
if (biboDocumentURLToVO.containsKey(documentNode.toString())) {
|
if (biboDocumentURLToVO.containsKey(documentNode.toString())) {
|
||||||
biboDocument = biboDocumentURLToVO.get(documentNode.toString());
|
biboDocument = biboDocumentURLToVO.get(documentNode.toString());
|
||||||
} else {
|
} else {
|
||||||
biboDocument = createDocumentVO(solution, documentNode.toString());
|
biboDocument = createDocumentVO(solution, documentNode.toString());
|
||||||
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
|
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
egoNode.addActivity(biboDocument);
|
egoNode.addActivity(biboDocument);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* After some discussion we concluded that for the purpose of this visualization
|
* After some discussion we concluded that for the purpose of this visualization
|
||||||
* we do not want a co-author node or Collaboration if the publication has only one
|
* we do not want a co-author node or Collaboration if the publication has only one
|
||||||
* author and that happens to be the ego.
|
* author and that happens to be the ego.
|
||||||
* */
|
* */
|
||||||
if (solution.get(QueryFieldLabels.AUTHOR_URL).toString().equalsIgnoreCase(
|
if (solution.get(QueryFieldLabels.AUTHOR_URL).toString().equalsIgnoreCase(
|
||||||
solution.get(QueryFieldLabels.CO_AUTHOR_URL).toString())) {
|
solution.get(QueryFieldLabels.CO_AUTHOR_URL).toString())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Collaborator coAuthorNode;
|
Collaborator coAuthorNode;
|
||||||
|
|
||||||
RDFNode coAuthorURLNode = solution.get(QueryFieldLabels.CO_AUTHOR_URL);
|
RDFNode coAuthorURLNode = solution.get(QueryFieldLabels.CO_AUTHOR_URL);
|
||||||
if (nodeURLToVO.containsKey(coAuthorURLNode.toString())) {
|
if (nodeURLToVO.containsKey(coAuthorURLNode.toString())) {
|
||||||
|
|
||||||
coAuthorNode = nodeURLToVO.get(coAuthorURLNode.toString());
|
coAuthorNode = nodeURLToVO.get(coAuthorURLNode.toString());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
coAuthorNode = new Collaborator(coAuthorURLNode.toString(), nodeIDGenerator);
|
coAuthorNode = new Collaborator(coAuthorURLNode.toString(), nodeIDGenerator);
|
||||||
nodes.add(coAuthorNode);
|
nodes.add(coAuthorNode);
|
||||||
nodeURLToVO.put(coAuthorURLNode.toString(), coAuthorNode);
|
nodeURLToVO.put(coAuthorURLNode.toString(), coAuthorNode);
|
||||||
|
|
||||||
RDFNode coAuthorLabelNode = solution.get(QueryFieldLabels.CO_AUTHOR_LABEL);
|
RDFNode coAuthorLabelNode = solution.get(QueryFieldLabels.CO_AUTHOR_LABEL);
|
||||||
if (coAuthorLabelNode != null) {
|
if (coAuthorLabelNode != null) {
|
||||||
coAuthorNode.setCollaboratorName(coAuthorLabelNode.toString());
|
coAuthorNode.setCollaboratorName(coAuthorLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
coAuthorNode.addActivity(biboDocument);
|
coAuthorNode.addActivity(biboDocument);
|
||||||
|
|
||||||
Set<Collaborator> coAuthorsForCurrentBiboDocument;
|
Set<Collaborator> coAuthorsForCurrentBiboDocument;
|
||||||
|
|
||||||
if (biboDocumentURLToCoAuthors.containsKey(biboDocument.getActivityURI())) {
|
if (biboDocumentURLToCoAuthors.containsKey(biboDocument.getActivityURI())) {
|
||||||
coAuthorsForCurrentBiboDocument = biboDocumentURLToCoAuthors
|
coAuthorsForCurrentBiboDocument = biboDocumentURLToCoAuthors
|
||||||
.get(biboDocument.getActivityURI());
|
.get(biboDocument.getActivityURI());
|
||||||
} else {
|
} else {
|
||||||
coAuthorsForCurrentBiboDocument = new HashSet<Collaborator>();
|
coAuthorsForCurrentBiboDocument = new HashSet<Collaborator>();
|
||||||
biboDocumentURLToCoAuthors.put(biboDocument.getActivityURI(),
|
biboDocumentURLToCoAuthors.put(biboDocument.getActivityURI(),
|
||||||
coAuthorsForCurrentBiboDocument);
|
coAuthorsForCurrentBiboDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
coAuthorsForCurrentBiboDocument.add(coAuthorNode);
|
coAuthorsForCurrentBiboDocument.add(coAuthorNode);
|
||||||
|
|
||||||
Collaboration egoCoAuthorEdge =
|
Collaboration egoCoAuthorEdge =
|
||||||
getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO);
|
getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If "egoCoAuthorEdge" is null it means that no Collaboration exists in between the
|
* 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
|
* egoNode & current coAuthorNode. Else create a new Collaboration, add it to the edges
|
||||||
* set & add the collaborator document to it.
|
* set & add the collaborator document to it.
|
||||||
* */
|
* */
|
||||||
if (egoCoAuthorEdge != null) {
|
if (egoCoAuthorEdge != null) {
|
||||||
egoCoAuthorEdge.addActivity(biboDocument);
|
egoCoAuthorEdge.addActivity(biboDocument);
|
||||||
} else {
|
} else {
|
||||||
egoCoAuthorEdge =
|
egoCoAuthorEdge =
|
||||||
new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
|
new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
|
||||||
edges.add(egoCoAuthorEdge);
|
edges.add(egoCoAuthorEdge);
|
||||||
edgeUniqueIdentifierToVO.put(
|
edgeUniqueIdentifierToVO.put(
|
||||||
getEdgeUniqueIdentifier(egoNode.getCollaboratorID(),
|
getEdgeUniqueIdentifier(egoNode.getCollaboratorID(),
|
||||||
coAuthorNode.getCollaboratorID()),
|
coAuthorNode.getCollaboratorID()),
|
||||||
egoCoAuthorEdge);
|
egoCoAuthorEdge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method takes out all the authors & edges between authors that belong to documents
|
* This method takes out all the authors & edges between authors that belong to documents
|
||||||
* that have more than 100 authors. We conjecture that these papers do not provide much
|
* that have more than 100 authors. We conjecture that these papers do not provide much
|
||||||
* insight. However, we have left the documents be.
|
* insight. However, we have left the documents be.
|
||||||
*
|
*
|
||||||
* This method side-effects "nodes" & "edges".
|
* This method side-effects "nodes" & "edges".
|
||||||
* */
|
* */
|
||||||
removeLowQualityNodesAndEdges(nodes,
|
removeLowQualityNodesAndEdges(nodes,
|
||||||
biboDocumentURLToVO,
|
biboDocumentURLToVO,
|
||||||
biboDocumentURLToCoAuthors,
|
biboDocumentURLToCoAuthors,
|
||||||
edges);
|
edges);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to create edges between 2 co-authors. E.g. On a paper there were 3 authors
|
* We need to create edges between 2 co-authors. E.g. On a paper there were 3 authors
|
||||||
* ego, A & B then we have already created edges like,
|
* ego, A & B then we have already created edges like,
|
||||||
* ego - A
|
* ego - A
|
||||||
* ego - B
|
* ego - B
|
||||||
* The below sub-routine will take care of,
|
* The below sub-routine will take care of,
|
||||||
* A - B
|
* A - B
|
||||||
*
|
*
|
||||||
* We are side-effecting "edges" here. The only reason to do this is because we are adding
|
* We are side-effecting "edges" here. The only reason to do this is because we are adding
|
||||||
* edges en masse for all the co-authors on all the publications considered so far. The
|
* edges en masse for all the co-authors on all the publications considered so far. The
|
||||||
* other reason being we dont want to compare against 2 sets of edges (edges created before
|
* other reason being we dont want to compare against 2 sets of edges (edges created before
|
||||||
* & co-author edges created during the course of this method) when we are creating a new
|
* & co-author edges created during the course of this method) when we are creating a new
|
||||||
* Collaboration.
|
* Collaboration.
|
||||||
* */
|
* */
|
||||||
createCoAuthorEdges(biboDocumentURLToVO,
|
createCoAuthorEdges(biboDocumentURLToVO,
|
||||||
biboDocumentURLToCoAuthors,
|
biboDocumentURLToCoAuthors,
|
||||||
edges,
|
edges,
|
||||||
edgeUniqueIdentifierToVO);
|
edgeUniqueIdentifierToVO);
|
||||||
|
|
||||||
|
|
||||||
return new CoAuthorshipData(egoNode, nodes, edges);
|
return new CoAuthorshipData(egoNode, nodes, edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeLowQualityNodesAndEdges(
|
private void removeLowQualityNodesAndEdges(
|
||||||
Set<Collaborator> nodes,
|
Set<Collaborator> nodes,
|
||||||
Map<String, Activity> biboDocumentURLToVO,
|
Map<String, Activity> biboDocumentURLToVO,
|
||||||
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors,
|
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors,
|
||||||
Set<Collaboration> edges) {
|
Set<Collaboration> edges) {
|
||||||
|
|
||||||
Set<Collaborator> nodesToBeRemoved = new HashSet<Collaborator>();
|
Set<Collaborator> nodesToBeRemoved = new HashSet<Collaborator>();
|
||||||
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
|
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
|
||||||
: biboDocumentURLToCoAuthors.entrySet()) {
|
: biboDocumentURLToCoAuthors.entrySet()) {
|
||||||
|
|
||||||
if (currentBiboDocumentEntry.getValue().size() > MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
if (currentBiboDocumentEntry.getValue().size() > MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
||||||
|
|
||||||
Activity currentBiboDocument = biboDocumentURLToVO
|
Activity currentBiboDocument = biboDocumentURLToVO
|
||||||
.get(currentBiboDocumentEntry.getKey());
|
.get(currentBiboDocumentEntry.getKey());
|
||||||
|
|
||||||
Set<Collaboration> edgesToBeRemoved = new HashSet<Collaboration>();
|
Set<Collaboration> edgesToBeRemoved = new HashSet<Collaboration>();
|
||||||
|
|
||||||
for (Collaboration currentEdge : edges) {
|
for (Collaboration currentEdge : edges) {
|
||||||
Set<Activity> currentCollaboratorDocuments =
|
Set<Activity> currentCollaboratorDocuments =
|
||||||
currentEdge.getCollaborationActivities();
|
currentEdge.getCollaborationActivities();
|
||||||
|
|
||||||
if (currentCollaboratorDocuments.contains(currentBiboDocument)) {
|
if (currentCollaboratorDocuments.contains(currentBiboDocument)) {
|
||||||
currentCollaboratorDocuments.remove(currentBiboDocument);
|
currentCollaboratorDocuments.remove(currentBiboDocument);
|
||||||
if (currentCollaboratorDocuments.isEmpty()) {
|
if (currentCollaboratorDocuments.isEmpty()) {
|
||||||
edgesToBeRemoved.add(currentEdge);
|
edgesToBeRemoved.add(currentEdge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edges.removeAll(edgesToBeRemoved);
|
edges.removeAll(edgesToBeRemoved);
|
||||||
|
|
||||||
for (Collaborator currentCoAuthor : currentBiboDocumentEntry.getValue()) {
|
for (Collaborator currentCoAuthor : currentBiboDocumentEntry.getValue()) {
|
||||||
currentCoAuthor.getCollaboratorActivities().remove(currentBiboDocument);
|
currentCoAuthor.getCollaboratorActivities().remove(currentBiboDocument);
|
||||||
if (currentCoAuthor.getCollaboratorActivities().isEmpty()) {
|
if (currentCoAuthor.getCollaboratorActivities().isEmpty()) {
|
||||||
nodesToBeRemoved.add(currentCoAuthor);
|
nodesToBeRemoved.add(currentCoAuthor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodes.removeAll(nodesToBeRemoved);
|
nodes.removeAll(nodesToBeRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCoAuthorEdges(
|
private void createCoAuthorEdges(
|
||||||
Map<String, Activity> biboDocumentURLToVO,
|
Map<String, Activity> biboDocumentURLToVO,
|
||||||
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors, Set<Collaboration> edges,
|
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors, Set<Collaboration> edges,
|
||||||
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
|
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
|
||||||
|
|
||||||
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
|
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
|
||||||
: biboDocumentURLToCoAuthors.entrySet()) {
|
: biboDocumentURLToCoAuthors.entrySet()) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there was only one co-author (other than ego) then we dont have to create any
|
* If there was only one co-author (other than ego) then we dont have to create any
|
||||||
* edges. so the below condition will take care of that.
|
* edges. so the below condition will take care of that.
|
||||||
*
|
*
|
||||||
* We are restricting edges between co-author if a particular document has more than
|
* We are restricting edges between co-author if a particular document has more than
|
||||||
* 100 co-authors. Our conjecture is that such edges do not provide any good insight
|
* 100 co-authors. Our conjecture is that such edges do not provide any good insight
|
||||||
* & causes unnecessary computations causing the server to time-out.
|
* & causes unnecessary computations causing the server to time-out.
|
||||||
* */
|
* */
|
||||||
if (currentBiboDocumentEntry.getValue().size() > 1
|
if (currentBiboDocumentEntry.getValue().size() > 1
|
||||||
&& currentBiboDocumentEntry.getValue().size()
|
&& currentBiboDocumentEntry.getValue().size()
|
||||||
<= MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
<= MAX_AUTHORS_PER_PAPER_ALLOWED) {
|
||||||
|
|
||||||
|
|
||||||
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
|
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In order to leverage the nested "for loop" for making edges between all the
|
* In order to leverage the nested "for loop" for making edges between all the
|
||||||
* co-authors we need to create a list out of the set first.
|
* co-authors we need to create a list out of the set first.
|
||||||
* */
|
* */
|
||||||
List<Collaborator> coAuthorNodes =
|
List<Collaborator> coAuthorNodes =
|
||||||
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
|
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
|
||||||
|
|
||||||
Collections.sort(coAuthorNodes, new CollaboratorComparator());
|
Collections.sort(coAuthorNodes, new CollaboratorComparator());
|
||||||
|
|
||||||
int numOfCoAuthors = coAuthorNodes.size();
|
int numOfCoAuthors = coAuthorNodes.size();
|
||||||
|
|
||||||
for (int ii = 0; ii < numOfCoAuthors - 1; ii++) {
|
for (int ii = 0; ii < numOfCoAuthors - 1; ii++) {
|
||||||
for (int jj = ii + 1; jj < numOfCoAuthors; jj++) {
|
for (int jj = ii + 1; jj < numOfCoAuthors; jj++) {
|
||||||
|
|
||||||
Collaborator coAuthor1 = coAuthorNodes.get(ii);
|
Collaborator coAuthor1 = coAuthorNodes.get(ii);
|
||||||
Collaborator coAuthor2 = coAuthorNodes.get(jj);
|
Collaborator coAuthor2 = coAuthorNodes.get(jj);
|
||||||
|
|
||||||
Collaboration coAuthor1_2Edge = getExistingEdge(coAuthor1,
|
Collaboration coAuthor1_2Edge = getExistingEdge(coAuthor1,
|
||||||
coAuthor2,
|
coAuthor2,
|
||||||
edgeUniqueIdentifierToVO);
|
edgeUniqueIdentifierToVO);
|
||||||
|
|
||||||
Activity currentBiboDocument = biboDocumentURLToVO
|
Activity currentBiboDocument = biboDocumentURLToVO
|
||||||
.get(currentBiboDocumentEntry
|
.get(currentBiboDocumentEntry
|
||||||
.getKey());
|
.getKey());
|
||||||
|
|
||||||
if (coAuthor1_2Edge != null) {
|
if (coAuthor1_2Edge != null) {
|
||||||
coAuthor1_2Edge.addActivity(currentBiboDocument);
|
coAuthor1_2Edge.addActivity(currentBiboDocument);
|
||||||
} else {
|
} else {
|
||||||
coAuthor1_2Edge = new Collaboration(coAuthor1,
|
coAuthor1_2Edge = new Collaboration(coAuthor1,
|
||||||
coAuthor2,
|
coAuthor2,
|
||||||
currentBiboDocument,
|
currentBiboDocument,
|
||||||
edgeIDGenerator);
|
edgeIDGenerator);
|
||||||
newlyAddedEdges.add(coAuthor1_2Edge);
|
newlyAddedEdges.add(coAuthor1_2Edge);
|
||||||
edgeUniqueIdentifierToVO.put(
|
edgeUniqueIdentifierToVO.put(
|
||||||
getEdgeUniqueIdentifier(coAuthor1.getCollaboratorID(),
|
getEdgeUniqueIdentifier(coAuthor1.getCollaboratorID(),
|
||||||
coAuthor2.getCollaboratorID()),
|
coAuthor2.getCollaboratorID()),
|
||||||
coAuthor1_2Edge);
|
coAuthor1_2Edge);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
edges.addAll(newlyAddedEdges);
|
edges.addAll(newlyAddedEdges);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collaboration getExistingEdge(
|
private Collaboration getExistingEdge(
|
||||||
Collaborator collaboratingNode1,
|
Collaborator collaboratingNode1,
|
||||||
Collaborator collaboratingNode2,
|
Collaborator collaboratingNode2,
|
||||||
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
|
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
|
||||||
|
|
||||||
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
|
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
|
||||||
collaboratingNode1.getCollaboratorID(),
|
collaboratingNode1.getCollaboratorID(),
|
||||||
collaboratingNode2.getCollaboratorID());
|
collaboratingNode2.getCollaboratorID());
|
||||||
|
|
||||||
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
|
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEdgeUniqueIdentifier(int nodeID1, int nodeID2) {
|
private String getEdgeUniqueIdentifier(int nodeID1, int nodeID2) {
|
||||||
|
|
||||||
String separator = "*";
|
String separator = "*";
|
||||||
|
|
||||||
if (nodeID1 < nodeID2) {
|
if (nodeID1 < nodeID2) {
|
||||||
return nodeID1 + separator + nodeID2;
|
return nodeID1 + separator + nodeID2;
|
||||||
} else {
|
} else {
|
||||||
return nodeID2 + separator + nodeID1;
|
return nodeID2 + separator + nodeID1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Activity createDocumentVO(QuerySolution solution, String documentURL) {
|
private Activity createDocumentVO(QuerySolution solution, String documentURL) {
|
||||||
|
|
||||||
Activity biboDocument = new Activity(documentURL);
|
Activity biboDocument = new Activity(documentURL);
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||||
if (publicationDateNode != null) {
|
if (publicationDateNode != null) {
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
biboDocument.setActivityDate(publicationDateNode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return biboDocument;
|
return biboDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultSet executeQuery(String queryText,
|
private ResultSet executeQuery(String queryText,
|
||||||
Dataset dataset) {
|
Dataset dataset) {
|
||||||
|
|
||||||
QueryExecution queryExecution = null;
|
QueryExecution queryExecution = null;
|
||||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||||
|
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||||
return queryExecution.execSelect();
|
return queryExecution.execSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
|
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
|
||||||
|
|
||||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||||
+ "SELECT \n"
|
+ "SELECT \n"
|
||||||
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
|
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
|
||||||
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
|
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
|
||||||
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
|
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
|
||||||
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
|
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
|
||||||
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
|
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
|
||||||
+ " (str(?publicationDate) as ?"
|
+ " (str(?publicationDate) as ?"
|
||||||
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
|
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
|
||||||
+ "WHERE { \n"
|
+ "WHERE { \n"
|
||||||
+ "<" + queryURI + "> rdf:type foaf:Person ;"
|
+ "<" + queryURI + "> rdf:type foaf:Person ;"
|
||||||
+ " rdfs:label ?authorLabel ;"
|
+ " rdfs:label ?authorLabel ;"
|
||||||
+ " core:authorInAuthorship ?authorshipNode . \n"
|
+ " core:relatedBy ?authorshipNode . \n"
|
||||||
+ "?authorshipNode rdf:type core:Authorship ;"
|
+ "?authorshipNode rdf:type core:Authorship ;"
|
||||||
+ " core:linkedInformationResource ?document . \n"
|
+ " core:relates ?document . \n"
|
||||||
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
|
+ "?document rdf:type bibo:Document . \n"
|
||||||
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
|
+ "?document core:relatedBy ?coAuthorshipNode . \n"
|
||||||
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
|
+ "?coAuthorshipNode rdf:type core:Authorship . \n"
|
||||||
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
|
+ "?coAuthorshipNode core:relates ?coAuthorPerson . \n"
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
|
+ "?coAuthorPerson rdf:type foaf:Person . \n"
|
||||||
+ "} \n"
|
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
|
||||||
+ "ORDER BY ?document ?coAuthorPerson\n";
|
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
|
||||||
|
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
|
||||||
log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
|
+ "} \n"
|
||||||
|
+ "ORDER BY ?document ?coAuthorPerson\n";
|
||||||
return sparqlQuery;
|
|
||||||
}
|
log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
|
||||||
|
|
||||||
|
return sparqlQuery;
|
||||||
public CollaborationData getQueryResult()
|
}
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(this.egoURI)) {
|
public CollaborationData getQueryResult()
|
||||||
/*
|
throws MalformedQueryParametersException {
|
||||||
* To test for the validity of the URI submitted.
|
|
||||||
* */
|
if (StringUtils.isNotBlank(this.egoURI)) {
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
/*
|
||||||
IRI iri = iRIFactory.create(this.egoURI);
|
* To test for the validity of the URI submitted.
|
||||||
if (iri.hasViolation(false)) {
|
* */
|
||||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
log.error("Ego Co-Authorship Vis Query " + errorMsg);
|
IRI iri = iRIFactory.create(this.egoURI);
|
||||||
throw new MalformedQueryParametersException(
|
if (iri.hasViolation(false)) {
|
||||||
"URI provided for an individual is malformed.");
|
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||||
}
|
log.error("Ego Co-Authorship Vis Query " + errorMsg);
|
||||||
} else {
|
throw new MalformedQueryParametersException(
|
||||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
"URI provided for an individual is malformed.");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI),
|
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
||||||
this.dataset);
|
}
|
||||||
return createQueryResult(resultSet);
|
|
||||||
}
|
ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI),
|
||||||
|
this.dataset);
|
||||||
}
|
return createQueryResult(resultSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
.getLog(CoPIGrantCountConstructQueryRunner.class.getName());
|
.getLog(CoPIGrantCountConstructQueryRunner.class.getName());
|
||||||
|
|
||||||
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
|
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
|
||||||
"?Role core:roleContributesTo ?Grant . "
|
"?Role core:relatedBy ?Grant . "
|
||||||
// + "?Grant rdfs:label ?GrantLabel . "
|
+ "?Grant rdf:type core:Grant ."
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . ";
|
+ "?Grant core:relates ?RelatedRole . ";
|
||||||
|
|
||||||
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
|
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
|
||||||
Log log) {
|
Log log) {
|
||||||
|
@ -59,23 +59,31 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForInvestigatorRoleOfProperty(
|
private String generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
String queryURI, String preboundProperty) {
|
String queryURI, String preboundProperty, String preboundRoleType) {
|
||||||
|
|
||||||
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
||||||
+ preboundProperty + " ?Role . "
|
+ preboundProperty + " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole rdf:type core:InvestigatorRole ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}"
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}"
|
||||||
+ "WHERE { " + "<" + queryURI + ">" + preboundProperty
|
+ "WHERE { " + "<" + queryURI + ">" + preboundProperty + " ?Role . "
|
||||||
+ " ?Role . " + SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
+ "?RelatedRole rdf:type core:InvestigatorRole ."
|
||||||
|
+ "?RelatedRole vitro:mostSpecificType ?subclass ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
||||||
|
+ "FILTER (?subclass != core:PrincipalInvestigatorRole && ?subclass != core:CoPrincipalInvestigatorRole)}";
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
private String generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
String queryURI, String preboundProperty) {
|
String queryURI, String preboundProperty, String preboundRoleType) {
|
||||||
|
|
||||||
String sparqlQuery = "CONSTRUCT { "
|
String sparqlQuery = "CONSTRUCT { "
|
||||||
+ "<"
|
+ "<"
|
||||||
|
@ -83,8 +91,11 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { "
|
+ "WHERE { "
|
||||||
|
@ -93,15 +104,18 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
private String generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
String queryURI, String preboundProperty) {
|
String queryURI, String preboundProperty, String preboundRoleType) {
|
||||||
|
|
||||||
String sparqlQuery = "CONSTRUCT { "
|
String sparqlQuery = "CONSTRUCT { "
|
||||||
+ "<"
|
+ "<"
|
||||||
|
@ -109,8 +123,11 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . "
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { "
|
+ "WHERE { "
|
||||||
|
@ -119,18 +136,22 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?coInvestigator ."
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole ."
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?coInvestigator ."
|
||||||
|
+ "?coInvestigator rdf:type foaf:Person ."
|
||||||
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
|
||||||
|
|
||||||
return sparqlQuery;
|
return sparqlQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofRole(
|
private String generateConstructQueryForDateTimeValueofRole(
|
||||||
String queryURI, String preboundProperty) {
|
String queryURI, String preboundProperty, String preboundRoleType) {
|
||||||
|
|
||||||
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
|
||||||
+ preboundProperty + " ?Role . "
|
+ preboundProperty + " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
+ "?dateTimeIntervalValue core:start ?startDate . "
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
+ "?startDate core:dateTime ?startDateTimeValue . "
|
||||||
|
@ -139,6 +160,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ "}"
|
+ "}"
|
||||||
+ "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty
|
+ "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
+ "?dateTimeIntervalValue core:start ?startDate . "
|
+ "?dateTimeIntervalValue core:start ?startDate . "
|
||||||
+ "?startDate core:dateTime ?startDateTimeValue . "
|
+ "?startDate core:dateTime ?startDateTimeValue . "
|
||||||
|
@ -153,14 +175,16 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateConstructQueryForDateTimeValueofGrant(
|
private String generateConstructQueryForDateTimeValueofGrant(
|
||||||
String queryURI, String preboundProperty) {
|
String queryURI, String preboundProperty, String preboundRoleType) {
|
||||||
|
|
||||||
String sparqlQuery = "CONSTRUCT { " + "<"
|
String sparqlQuery = "CONSTRUCT { " + "<"
|
||||||
+ queryURI
|
+ queryURI
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
+ "?Role core:roleContributesTo ?Grant ."
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
|
+ "?Role core:relatedBy ?Grant ."
|
||||||
|
+ "?Grant rdf:type core:Grant ."
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
|
@ -174,7 +198,9 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
+ ">"
|
+ ">"
|
||||||
+ preboundProperty
|
+ preboundProperty
|
||||||
+ " ?Role . "
|
+ " ?Role . "
|
||||||
+ "?Role core:roleContributesTo ?Grant ."
|
+ "?Role rdf:type " + preboundRoleType + " . "
|
||||||
|
+ "?Role core:relatedBy ?Grant ."
|
||||||
|
+ "?Grant rdf:type core:Grant ."
|
||||||
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
|
@ -268,45 +294,45 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
|
||||||
.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
|
.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
this.egoURI, "core:hasInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
|
||||||
|
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
this.egoURI, "core:hasPrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
|
||||||
|
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
|
||||||
constructQueries
|
constructQueries
|
||||||
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
|
||||||
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
|
||||||
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
|
||||||
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
|
||||||
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
|
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -113,13 +113,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
+ "<" + queryURI + "> rdfs:label ?PILabel . "
|
+ "<" + queryURI + "> rdfs:label ?PILabel . "
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -133,13 +141,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -154,13 +170,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasCo-PrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -176,13 +200,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -197,13 +229,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -218,13 +258,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasPrincipalInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -239,13 +287,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:investigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -260,13 +316,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:co-PrincipalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:CoPrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
@ -281,13 +345,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
|
||||||
|
|
||||||
+ "{ "
|
+ "{ "
|
||||||
|
|
||||||
+ "<" + queryURI + "> core:hasInvestigatorRole ?Role . "
|
+ "<" + queryURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
|
|
||||||
+ "?Role core:roleContributesTo ?Grant . "
|
+ "?Role rdf:type core:InvestigatorRole . "
|
||||||
|
|
||||||
+ "?Grant core:contributingRole ?RelatedRole . "
|
+ "?Role core:relatedBy ?Grant . "
|
||||||
|
|
||||||
+ "?RelatedRole core:principalInvestigatorRoleOf ?CoPI . "
|
+ "?Grant rdf:type core:Grant . "
|
||||||
|
|
||||||
|
+ "?Grant core:relates ?RelatedRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole rdf:type core:PrincipalInvestigatorRole . "
|
||||||
|
|
||||||
|
+ "?RelatedRole <http://purl.obolibrary.org/obo/RO_0000052> ?CoPI . "
|
||||||
|
|
||||||
|
+ "?CoPI rdf:type foaf:Person . "
|
||||||
|
|
||||||
+ "?CoPI rdfs:label ?CoPILabel . "
|
+ "?CoPI rdfs:label ?CoPILabel . "
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,9 @@ public class OrganizationAssociatedPeopleModelWithTypesConstructor implements Mo
|
||||||
+ " <" + organizationURI + "> rdf:type foaf:Organization . "
|
+ " <" + organizationURI + "> rdf:type foaf:Organization . "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " <" + organizationURI + "> core:organizationForPosition ?Position . "
|
+ " <" + organizationURI + "> core:relatedBy ?Position . "
|
||||||
+ " ?Position core:positionForPerson ?Person . "
|
+ " ?Position rdf:type core:Position . "
|
||||||
|
+ " ?Position core:relates ?Person . "
|
||||||
+ " ?Person rdfs:label ?personLabel. "
|
+ " ?Person rdfs:label ?personLabel. "
|
||||||
+ " ?Person rdf:type ?personType . "
|
+ " ?Person rdf:type ?personType . "
|
||||||
+ " ?personType rdfs:label ?personTypeLabel . "
|
+ " ?personType rdfs:label ?personTypeLabel . "
|
||||||
|
|
|
@ -50,7 +50,8 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
+ " ?organization rdf:type foaf:Organization . "
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
+ " ?organization core:hasSubOrganization ?subOrganization . "
|
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
||||||
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
||||||
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
||||||
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
||||||
|
@ -60,7 +61,8 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?organization core:hasSubOrganization ?subOrganization . "
|
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
|
||||||
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
|
||||||
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
+ " ?subOrganization rdf:type ?subOrganizationType . "
|
||||||
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
|
||||||
|
|
|
@ -1,189 +1,204 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class OrganizationToGrantsForSubOrganizationsModelConstructor implements ModelConstructor {
|
public class OrganizationToGrantsForSubOrganizationsModelConstructor implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "ORGANIZATION_TO_GRANTS_FOR_SUBORGANIZATIONS";
|
public static final String MODEL_TYPE = "ORGANIZATION_TO_GRANTS_FOR_SUBORGANIZATIONS";
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific organization via all descendants";
|
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific organization via all descendants";
|
||||||
|
|
||||||
private String organizationURI;
|
private String organizationURI;
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(OrganizationToGrantsForSubOrganizationsModelConstructor.class.getName());
|
private Log log = LogFactory.getLog(OrganizationToGrantsForSubOrganizationsModelConstructor.class.getName());
|
||||||
|
|
||||||
private long before, after;
|
private long before, after;
|
||||||
|
|
||||||
public OrganizationToGrantsForSubOrganizationsModelConstructor(String organizationURI, Dataset dataset) {
|
public OrganizationToGrantsForSubOrganizationsModelConstructor(String organizationURI, Dataset dataset) {
|
||||||
this.organizationURI = organizationURI;
|
this.organizationURI = organizationURI;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> constructOrganizationGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
|
private Set<String> constructOrganizationGrantsQueryTemplate(String constructProperty, String roleType) {
|
||||||
|
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
String justGrantsQuery = ""
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " <" + organizationURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
+ " <" + organizationURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
|
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
||||||
+ " ?subOrganization core:organizationForPosition ?Position . "
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?Position core:positionForPerson ?Person . "
|
+ " ?subOrganization core:relatedBy ?Position . "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " ?Position rdf:type core:Position . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " ?Position core:relates ?Person . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Person rdf:type foaf:Person . "
|
||||||
+ " "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " } ";
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
String justDateTimeOnGrantsQuery = ""
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " CONSTRUCT { "
|
+ " "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " LET(?now := afn:now()) "
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
+ " } ";
|
||||||
+ " "
|
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
String justDateTimeOnGrantsQuery = ""
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
+ " CONSTRUCT { "
|
||||||
+ " "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " } "
|
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " WHERE { "
|
+ " "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
||||||
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
|
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
||||||
+ " ?subOrganization core:organizationForPosition ?Position . "
|
+ " "
|
||||||
+ " ?Position core:positionForPerson ?Person . "
|
+ " } "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " WHERE { "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " "
|
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
// + " OPTIONAL { "
|
+ " ?subOrganization core:relatedBy ?Position . "
|
||||||
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ " ?Position rdf:type core:Position . "
|
||||||
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ " ?Position core:relates ?Person . "
|
||||||
// + " } "
|
+ " ?Person rdf:type foaf:Person . "
|
||||||
// + " OPTIONAL { "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
// + " } "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
+ " } ";
|
// + " OPTIONAL { "
|
||||||
|
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
String justDateTimeOnRolesQuery = ""
|
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
+ " CONSTRUCT { "
|
// + " } "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
// + " OPTIONAL { "
|
||||||
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
||||||
+ " "
|
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
// + " } "
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
+ " "
|
||||||
+ " } "
|
+ " LET(?now := afn:now()) "
|
||||||
+ " WHERE { "
|
+ " } ";
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
|
||||||
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
|
String justDateTimeOnRolesQuery = ""
|
||||||
+ " ?subOrganization core:organizationForPosition ?Position . "
|
+ " CONSTRUCT { "
|
||||||
+ " ?Position core:positionForPerson ?Person . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " ?Person core:" + roleTypeProperty + " ?Role . "
|
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " "
|
||||||
+ " "
|
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
||||||
// + " OPTIONAL { "
|
+ " } "
|
||||||
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
+ " WHERE { "
|
||||||
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
// + " } "
|
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
||||||
// + " "
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
// + " OPTIONAL { "
|
+ " ?subOrganization core:relatedBy ?Position . "
|
||||||
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
+ " ?Position rdf:type core:Position . "
|
||||||
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
+ " ?Position core:relates ?Person . "
|
||||||
// + " } "
|
+ " ?Person rdf:type foaf:Person . "
|
||||||
+ " "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " } ";
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
differentPerspectiveQueries.add(justGrantsQuery);
|
+ " "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
// + " OPTIONAL { "
|
||||||
|
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
||||||
return differentPerspectiveQueries;
|
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
||||||
}
|
// + " } "
|
||||||
|
// + " "
|
||||||
private Set<String> constructOrganizationToGrantsQuery() {
|
// + " OPTIONAL { "
|
||||||
|
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
||||||
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
||||||
|
// + " } "
|
||||||
Set<String> investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "hasInvestigatorRole");
|
+ " "
|
||||||
Set<String> piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "hasPrincipalInvestigatorRole");
|
+ " LET(?now := afn:now()) "
|
||||||
Set<String> coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "hasCo-PrincipalInvestigatorRole");
|
+ " } ";
|
||||||
|
|
||||||
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
differentPerspectiveQueries.add(justGrantsQuery);
|
||||||
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
||||||
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
||||||
|
|
||||||
return differentInvestigatorTypeQueries;
|
return differentPerspectiveQueries;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
private Set<String> constructOrganizationToGrantsQuery() {
|
||||||
|
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
||||||
|
|
||||||
before = System.currentTimeMillis();
|
Set<String> investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "InvestigatorRole");
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
Set<String> piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "PrincipalInvestigatorRole");
|
||||||
|
Set<String> coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "CoPrincipalInvestigatorRole");
|
||||||
for (String currentQuery : constructQueries) {
|
|
||||||
|
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
||||||
Query query = null;
|
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
||||||
|
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
||||||
try {
|
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
return differentInvestigatorTypeQueries;
|
||||||
} catch (Throwable th) {
|
}
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
private Model executeQuery(Set<String> constructQueries) {
|
||||||
log.error(currentQuery);
|
|
||||||
}
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
before = System.currentTimeMillis();
|
||||||
|
log.debug("CONSTRUCT query string : " + constructQueries);
|
||||||
try {
|
|
||||||
qe.execConstruct(constructedModel);
|
for (String currentQuery : constructQueries) {
|
||||||
} finally {
|
|
||||||
qe.close();
|
Query query = null;
|
||||||
}
|
|
||||||
}
|
try {
|
||||||
|
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
||||||
after = System.currentTimeMillis();
|
} catch (Throwable th) {
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
+ (after - before));
|
+ "string. " + th.getMessage());
|
||||||
|
log.error(currentQuery);
|
||||||
return constructedModel;
|
}
|
||||||
}
|
|
||||||
|
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
|
||||||
return executeQuery(constructOrganizationToGrantsQuery());
|
try {
|
||||||
}
|
qe.execConstruct(constructedModel);
|
||||||
}
|
} finally {
|
||||||
|
qe.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
after = System.currentTimeMillis();
|
||||||
|
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
||||||
|
+ (after - before));
|
||||||
|
|
||||||
|
return constructedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||||
|
return executeQuery(constructOrganizationToGrantsQuery());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -53,11 +53,16 @@ public class OrganizationToPublicationsForSubOrganizationsModelConstructor imple
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
|
||||||
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
|
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
|
||||||
+ " ?subOrganization core:organizationForPosition ?Position . "
|
+ " ?subOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?Position core:positionForPerson ?Person . "
|
+ " ?subOrganization core:relatedBy ?Position . "
|
||||||
+ " ?Person core:authorInAuthorship ?Resource . "
|
+ " ?Position rdf:type core:Position . "
|
||||||
+ " ?Resource core:linkedInformationResource ?Document . "
|
+ " ?Position core:relates ?Person . "
|
||||||
|
+ " ?Person rdf:type foaf:Person . "
|
||||||
|
+ " ?Person core:relatedBy ?Resource . "
|
||||||
|
+ " ?Resource rdf:type core:Authorship . "
|
||||||
|
+ " ?Resource core:relates ?Document . "
|
||||||
|
+ " ?Document rdf:type bibo:Document . "
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
+ " ?Document rdfs:label ?DocumentLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
|
|
|
@ -1,171 +1,177 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class PeopleToGrantsModelConstructor implements ModelConstructor {
|
public class PeopleToGrantsModelConstructor implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "PEOPLE_TO_GRANTS";
|
public static final String MODEL_TYPE = "PEOPLE_TO_GRANTS";
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for all people via all roles";
|
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for all people via all roles";
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PeopleToGrantsModelConstructor.class.getName());
|
private Log log = LogFactory.getLog(PeopleToGrantsModelConstructor.class.getName());
|
||||||
|
|
||||||
private long before, after;
|
private long before, after;
|
||||||
|
|
||||||
public PeopleToGrantsModelConstructor(Dataset dataset) {
|
public PeopleToGrantsModelConstructor(Dataset dataset) {
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
|
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
||||||
|
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
String justGrantsQuery = ""
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " ?person vivosocnet:lastCachedAt ?now . "
|
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
||||||
+ " ?person vivosocnet:" + constructProperty + " ?Grant . "
|
+ " ?Person vivosocnet:" + constructProperty + " ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " ?person core:" + roleTypeProperty + " ?Role . "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
+ " "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " } ";
|
+ " "
|
||||||
|
+ " LET(?now := afn:now()) "
|
||||||
String justDateTimeOnGrantsQuery = ""
|
+ " } ";
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " ?person vivosocnet:lastCachedAt ?now . "
|
String justDateTimeOnGrantsQuery = ""
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
+ " CONSTRUCT { "
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
||||||
+ " "
|
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
||||||
+ " } "
|
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
||||||
+ " WHERE { "
|
+ " "
|
||||||
+ " ?person core:" + roleTypeProperty + " ?Role . "
|
+ " } "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " WHERE { "
|
||||||
+ " "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
// + " OPTIONAL { "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ " "
|
||||||
// + " } "
|
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
// + " OPTIONAL { "
|
// + " OPTIONAL { "
|
||||||
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
// + " } "
|
// + " } "
|
||||||
+ " "
|
// + " OPTIONAL { "
|
||||||
+ " LET(?now := afn:now()) "
|
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
||||||
+ " } ";
|
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
||||||
|
// + " } "
|
||||||
String justDateTimeOnRolesQuery = ""
|
+ " "
|
||||||
+ " CONSTRUCT { "
|
+ " LET(?now := afn:now()) "
|
||||||
+ " ?person vivosocnet:lastCachedAt ?now . "
|
+ " } ";
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
String justDateTimeOnRolesQuery = ""
|
||||||
+ " } "
|
+ " CONSTRUCT { "
|
||||||
+ " WHERE { "
|
+ " ?Person vivosocnet:lastCachedAt ?now . "
|
||||||
+ " ?person core:" + roleTypeProperty + " ?Role . "
|
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
||||||
+ " "
|
+ " } "
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ " WHERE { "
|
||||||
// + " OPTIONAL { "
|
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
// + " } "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
// + " "
|
+ " "
|
||||||
// + " OPTIONAL { "
|
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
// + " OPTIONAL { "
|
||||||
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
||||||
// + " } "
|
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
||||||
+ " "
|
// + " } "
|
||||||
+ " LET(?now := afn:now()) "
|
// + " "
|
||||||
+ " } ";
|
// + " OPTIONAL { "
|
||||||
|
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
||||||
differentPerspectiveQueries.add(justGrantsQuery);
|
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
// + " } "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
+ " "
|
||||||
|
+ " LET(?now := afn:now()) "
|
||||||
return differentPerspectiveQueries;
|
+ " } ";
|
||||||
}
|
|
||||||
|
differentPerspectiveQueries.add(justGrantsQuery);
|
||||||
private Set<String> constructPeopleToGrantsQuery() {
|
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
||||||
|
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
||||||
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
|
||||||
|
return differentPerspectiveQueries;
|
||||||
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "hasInvestigatorRole");
|
}
|
||||||
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "hasPrincipalInvestigatorRole");
|
|
||||||
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "hasCo-PrincipalInvestigatorRole");
|
private Set<String> constructPeopleToGrantsQuery() {
|
||||||
|
|
||||||
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
||||||
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
|
||||||
|
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
|
||||||
return differentInvestigatorTypeQueries;
|
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
|
||||||
}
|
|
||||||
|
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
||||||
|
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
return differentInvestigatorTypeQueries;
|
||||||
before = System.currentTimeMillis();
|
}
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
|
||||||
|
private Model executeQuery(Set<String> constructQueries) {
|
||||||
for (String currentQuery : constructQueries) {
|
|
||||||
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
Query query = null;
|
before = System.currentTimeMillis();
|
||||||
|
log.debug("CONSTRUCT query string : " + constructQueries);
|
||||||
try {
|
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
for (String currentQuery : constructQueries) {
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
Query query = null;
|
||||||
log.error(currentQuery);
|
|
||||||
}
|
try {
|
||||||
|
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
||||||
|
} catch (Throwable th) {
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
|
+ "string. " + th.getMessage());
|
||||||
try {
|
log.error(currentQuery);
|
||||||
qe.execConstruct(constructedModel);
|
}
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||||
}
|
|
||||||
|
try {
|
||||||
after = System.currentTimeMillis();
|
qe.execConstruct(constructedModel);
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
} finally {
|
||||||
+ (after - before));
|
qe.close();
|
||||||
|
}
|
||||||
return constructedModel;
|
}
|
||||||
}
|
|
||||||
|
after = System.currentTimeMillis();
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
||||||
return executeQuery(constructPeopleToGrantsQuery());
|
+ (after - before));
|
||||||
}
|
|
||||||
}
|
return constructedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||||
|
return executeQuery(constructPeopleToGrantsQuery());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -48,8 +48,11 @@ public class PeopleToPublicationsModelConstructor implements ModelConstructor {
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
+ " ?journal rdfs:label ?journalLabel . "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " ?person core:authorInAuthorship ?Resource . "
|
+ " ?person core:relatedBy ?Resource . "
|
||||||
+ " ?Resource core:linkedInformationResource ?Document . "
|
+ " ?person rdf:type foaf:Person . "
|
||||||
|
+ " ?Resource rdf:type core:Authorship . "
|
||||||
|
+ " ?Resource core:relates ?Document . "
|
||||||
|
+ " ?Document rdf:type bibo:Document . "
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
+ " ?Document rdfs:label ?DocumentLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
|
|
|
@ -1,174 +1,180 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
import com.hp.hpl.jena.rdf.model.ModelFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.ModelConstructor;
|
||||||
|
|
||||||
public class PersonToGrantsModelConstructor implements ModelConstructor {
|
public class PersonToGrantsModelConstructor implements ModelConstructor {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
|
||||||
public static final String MODEL_TYPE = "PERSON_TO_GRANTS";
|
public static final String MODEL_TYPE = "PERSON_TO_GRANTS";
|
||||||
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
|
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
|
||||||
|
|
||||||
private String personURI;
|
private String personURI;
|
||||||
|
|
||||||
private Log log = LogFactory.getLog(PersonToGrantsModelConstructor.class.getName());
|
private Log log = LogFactory.getLog(PersonToGrantsModelConstructor.class.getName());
|
||||||
|
|
||||||
private long before, after;
|
private long before, after;
|
||||||
|
|
||||||
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
|
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
|
||||||
this.personURI = personURI;
|
this.personURI = personURI;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
|
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
|
||||||
|
|
||||||
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
Set<String> differentPerspectiveQueries = new HashSet<String>();
|
||||||
|
|
||||||
String justGrantsQuery = ""
|
String justGrantsQuery = ""
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " ?Grant rdf:type core:Grant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " ?Grant rdfs:label ?grantLabel . "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
+ " "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " LET(?now := afn:now()) "
|
+ " ?Grant rdfs:label ?grantLabel . "
|
||||||
+ " } ";
|
+ " "
|
||||||
|
+ " LET(?now := afn:now()) "
|
||||||
String justDateTimeOnGrantsQuery = ""
|
+ " } ";
|
||||||
+ " CONSTRUCT { "
|
|
||||||
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
String justDateTimeOnGrantsQuery = ""
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
+ " CONSTRUCT { "
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " "
|
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
|
||||||
+ " } "
|
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
|
||||||
+ " WHERE { "
|
+ " "
|
||||||
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
+ " } "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
+ " WHERE { "
|
||||||
+ " "
|
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
// + " OPTIONAL { "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
+ " "
|
||||||
// + " } "
|
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
|
||||||
// + " OPTIONAL { "
|
// + " OPTIONAL { "
|
||||||
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
|
||||||
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
|
||||||
// + " } "
|
// + " } "
|
||||||
+ " "
|
// + " OPTIONAL { "
|
||||||
+ " LET(?now := afn:now()) "
|
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
|
||||||
+ " } ";
|
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
|
||||||
|
// + " } "
|
||||||
String justDateTimeOnRolesQuery = ""
|
+ " "
|
||||||
+ " CONSTRUCT { "
|
+ " LET(?now := afn:now()) "
|
||||||
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
+ " } ";
|
||||||
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
|
||||||
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
String justDateTimeOnRolesQuery = ""
|
||||||
+ " } "
|
+ " CONSTRUCT { "
|
||||||
+ " WHERE { "
|
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
|
||||||
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
|
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
|
||||||
+ " ?Role core:roleContributesTo ?Grant . "
|
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
|
||||||
+ " "
|
+ " } "
|
||||||
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
+ " WHERE { "
|
||||||
// + " OPTIONAL { "
|
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
|
||||||
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
+ " ?Role rdf:type core:" + roleType + " . "
|
||||||
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
+ " ?Role core:relatedBy ?Grant . "
|
||||||
// + " } "
|
+ " ?Grant rdf:type core:Grant . "
|
||||||
// + " "
|
+ " "
|
||||||
// + " OPTIONAL { "
|
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
|
||||||
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
// + " OPTIONAL { "
|
||||||
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
+ " ?dateTimeIntervalValue core:start ?startDate . "
|
||||||
// + " } "
|
+ " ?startDate core:dateTime ?startDateTimeValue . "
|
||||||
+ " "
|
// + " } "
|
||||||
+ " LET(?now := afn:now()) "
|
// + " "
|
||||||
+ " } ";
|
// + " OPTIONAL { "
|
||||||
|
// + " ?dateTimeIntervalValue core:end ?endDate . "
|
||||||
differentPerspectiveQueries.add(justGrantsQuery);
|
// + " ?endDate core:dateTime ?endDateTimeValue . "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
// + " } "
|
||||||
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
+ " "
|
||||||
|
+ " LET(?now := afn:now()) "
|
||||||
return differentPerspectiveQueries;
|
+ " } ";
|
||||||
}
|
|
||||||
|
differentPerspectiveQueries.add(justGrantsQuery);
|
||||||
private Set<String> constructPersonToGrantsQuery() {
|
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
|
||||||
|
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
|
||||||
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
|
||||||
|
return differentPerspectiveQueries;
|
||||||
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "hasInvestigatorRole");
|
}
|
||||||
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "hasPrincipalInvestigatorRole");
|
|
||||||
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "hasCo-PrincipalInvestigatorRole");
|
private Set<String> constructPersonToGrantsQuery() {
|
||||||
|
|
||||||
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
|
||||||
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
|
||||||
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
|
||||||
|
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
|
||||||
return differentInvestigatorTypeQueries;
|
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
|
||||||
}
|
|
||||||
|
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
|
||||||
private Model executeQuery(Set<String> constructQueries) {
|
differentInvestigatorTypeQueries.addAll(piRoleQuery);
|
||||||
|
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
|
||||||
Model constructedModel = ModelFactory.createDefaultModel();
|
|
||||||
|
return differentInvestigatorTypeQueries;
|
||||||
before = System.currentTimeMillis();
|
}
|
||||||
log.debug("CONSTRUCT query string : " + constructQueries);
|
|
||||||
|
private Model executeQuery(Set<String> constructQueries) {
|
||||||
for (String currentQuery : constructQueries) {
|
|
||||||
|
Model constructedModel = ModelFactory.createDefaultModel();
|
||||||
|
|
||||||
Query query = null;
|
before = System.currentTimeMillis();
|
||||||
|
log.debug("CONSTRUCT query string : " + constructQueries);
|
||||||
try {
|
|
||||||
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
for (String currentQuery : constructQueries) {
|
||||||
} catch (Throwable th) {
|
|
||||||
log.error("Could not create CONSTRUCT SPARQL query for query "
|
|
||||||
+ "string. " + th.getMessage());
|
Query query = null;
|
||||||
log.error(currentQuery);
|
|
||||||
}
|
try {
|
||||||
|
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
|
||||||
|
} catch (Throwable th) {
|
||||||
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
log.error("Could not create CONSTRUCT SPARQL query for query "
|
||||||
|
+ "string. " + th.getMessage());
|
||||||
try {
|
log.error(currentQuery);
|
||||||
qe.execConstruct(constructedModel);
|
}
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
|
||||||
}
|
|
||||||
|
try {
|
||||||
after = System.currentTimeMillis();
|
qe.execConstruct(constructedModel);
|
||||||
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
} finally {
|
||||||
+ (after - before));
|
qe.close();
|
||||||
|
}
|
||||||
return constructedModel;
|
}
|
||||||
}
|
|
||||||
|
after = System.currentTimeMillis();
|
||||||
public Model getConstructedModel() throws MalformedQueryParametersException {
|
log.debug("Time taken to execute the CONSTRUCT queries is in milliseconds: "
|
||||||
return executeQuery(constructPersonToGrantsQuery());
|
+ (after - before));
|
||||||
}
|
|
||||||
}
|
return constructedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Model getConstructedModel() throws MalformedQueryParametersException {
|
||||||
|
return executeQuery(constructPersonToGrantsQuery());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -51,8 +51,10 @@ public class PersonToPublicationsModelConstructor implements ModelConstructor {
|
||||||
+ " ?journal rdfs:label ?journalLabel . "
|
+ " ?journal rdfs:label ?journalLabel . "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
+ " <" + personURI + "> core:authorInAuthorship ?Resource . "
|
+ " <" + personURI + "> core:relatedBy ?Resource . "
|
||||||
+ " ?Resource core:linkedInformationResource ?Document . "
|
+ " ?Resource rdf:type core:Authorship . "
|
||||||
|
+ " ?Resource core:relates ?Document . "
|
||||||
|
+ " ?Document rdf:type bibo:Document . "
|
||||||
+ " ?Document rdfs:label ?DocumentLabel . "
|
+ " ?Document rdfs:label ?DocumentLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
|
|
|
@ -50,7 +50,8 @@ public class SubOrganizationWithinModelConstructor implements ModelConstructor {
|
||||||
+ " CONSTRUCT { "
|
+ " CONSTRUCT { "
|
||||||
+ " ?organization rdf:type foaf:Organization . "
|
+ " ?organization rdf:type foaf:Organization . "
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
||||||
|
+ " ?parentOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " WHERE { "
|
+ " WHERE { "
|
||||||
|
@ -58,7 +59,8 @@ public class SubOrganizationWithinModelConstructor implements ModelConstructor {
|
||||||
+ " ?organization rdfs:label ?organizationLabel . "
|
+ " ?organization rdfs:label ?organizationLabel . "
|
||||||
+ " "
|
+ " "
|
||||||
+ " OPTIONAL { "
|
+ " OPTIONAL { "
|
||||||
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
|
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
|
||||||
|
+ " ?parentOrganization rdf:type foaf:Organization . "
|
||||||
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
|
||||||
+ " } "
|
+ " } "
|
||||||
+ " } ";
|
+ " } ";
|
||||||
|
|
|
@ -1,162 +1,163 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.personpubcount;
|
package edu.cornell.mannlib.vitro.webapp.visualization.personpubcount;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.hp.hpl.jena.iri.IRI;
|
import com.hp.hpl.jena.iri.IRI;
|
||||||
import com.hp.hpl.jena.iri.IRIFactory;
|
import com.hp.hpl.jena.iri.IRIFactory;
|
||||||
import com.hp.hpl.jena.iri.Violation;
|
import com.hp.hpl.jena.iri.Violation;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
|
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.QueryRunner;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This query runner is used to execute a sparql query that will fetch all the publications
|
* This query runner is used to execute a sparql query that will fetch all the publications
|
||||||
* defined by bibo:Document property for a particular individual.
|
* defined by bibo:Document property for a particular individual.
|
||||||
*
|
*
|
||||||
* @author cdtank
|
* @author cdtank
|
||||||
*/
|
*/
|
||||||
public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activity>> {
|
public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activity>> {
|
||||||
|
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private String personURI;
|
private String personURI;
|
||||||
private Dataset dataset;
|
private Dataset dataset;
|
||||||
|
|
||||||
private Individual author;
|
private Individual author;
|
||||||
|
|
||||||
public Individual getAuthor() {
|
public Individual getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Log log;
|
private Log log;
|
||||||
|
|
||||||
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
|
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
|
||||||
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
|
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
|
||||||
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
|
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
|
||||||
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")\n";
|
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")\n";
|
||||||
|
|
||||||
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
|
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
|
||||||
+ "?document rdfs:label ?documentLabel .\n"
|
+ "?document rdfs:label ?documentLabel .\n"
|
||||||
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
|
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
|
||||||
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n";
|
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n";
|
||||||
|
|
||||||
public PersonPublicationCountQueryRunner(String personURI,
|
public PersonPublicationCountQueryRunner(String personURI,
|
||||||
Dataset dataset, Log log) {
|
Dataset dataset, Log log) {
|
||||||
|
|
||||||
this.personURI = personURI;
|
this.personURI = personURI;
|
||||||
this.dataset = dataset;
|
this.dataset = dataset;
|
||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
|
private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
|
||||||
Set<Activity> authorDocuments = new HashSet<Activity>();
|
Set<Activity> authorDocuments = new HashSet<Activity>();
|
||||||
|
|
||||||
while (resultSet.hasNext()) {
|
while (resultSet.hasNext()) {
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
QuerySolution solution = resultSet.nextSolution();
|
||||||
|
|
||||||
Activity biboDocument = new Activity(
|
Activity biboDocument = new Activity(
|
||||||
solution.get(QueryFieldLabels.DOCUMENT_URL)
|
solution.get(QueryFieldLabels.DOCUMENT_URL)
|
||||||
.toString());
|
.toString());
|
||||||
|
|
||||||
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
|
||||||
if (publicationDateNode != null) {
|
if (publicationDateNode != null) {
|
||||||
biboDocument.setActivityDate(publicationDateNode.toString());
|
biboDocument.setActivityDate(publicationDateNode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we are getting publication count for just one author at a time we need
|
* Since we are getting publication count for just one author at a time we need
|
||||||
* to create only one "Individual" instance. We test against the null for "author" to
|
* to create only one "Individual" instance. We test against the null for "author" to
|
||||||
* make sure that it has not already been instantiated.
|
* make sure that it has not already been instantiated.
|
||||||
* */
|
* */
|
||||||
RDFNode authorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
|
RDFNode authorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
|
||||||
if (authorURLNode != null && author == null) {
|
if (authorURLNode != null && author == null) {
|
||||||
author = new Individual(authorURLNode.toString());
|
author = new Individual(authorURLNode.toString());
|
||||||
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
|
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
|
||||||
if (authorLabelNode != null) {
|
if (authorLabelNode != null) {
|
||||||
author.setIndividualLabel(authorLabelNode.toString());
|
author.setIndividualLabel(authorLabelNode.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
authorDocuments.add(biboDocument);
|
authorDocuments.add(biboDocument);
|
||||||
}
|
}
|
||||||
return authorDocuments;
|
return authorDocuments;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultSet executeQuery(String queryURI,
|
private ResultSet executeQuery(String queryURI,
|
||||||
Dataset dataset) {
|
Dataset dataset) {
|
||||||
|
|
||||||
QueryExecution queryExecution = null;
|
QueryExecution queryExecution = null;
|
||||||
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
|
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||||
return queryExecution.execSelect();
|
return queryExecution.execSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSparqlQuery(String queryURI) {
|
private String getSparqlQuery(String queryURI) {
|
||||||
|
|
||||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||||
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
|
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
|
||||||
+ "(str(<" + queryURI + ">) as ?authPersonLit)\n "
|
+ "(str(<" + queryURI + ">) as ?authPersonLit)\n "
|
||||||
+ "WHERE { \n"
|
+ "WHERE { \n"
|
||||||
+ "<" + queryURI + "> rdf:type foaf:Person ;\n"
|
+ "<" + queryURI + "> rdf:type foaf:Person ;\n"
|
||||||
+ " rdfs:label ?authorLabel \n;"
|
+ " rdfs:label ?authorLabel \n;"
|
||||||
+ " core:authorInAuthorship ?authorshipNode . \n"
|
+ " core:relatedBy ?authorshipNode . \n"
|
||||||
+ " ?authorshipNode rdf:type core:Authorship ;"
|
+ " ?authorshipNode rdf:type core:Authorship ;"
|
||||||
+ " core:linkedInformationResource ?document . \n"
|
+ " core:relates ?document . \n"
|
||||||
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
|
+ " ?document rdf:type bibo:Document . \n"
|
||||||
+ "}\n";
|
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
|
||||||
|
+ "}\n";
|
||||||
log.debug(sparqlQuery);
|
|
||||||
|
log.debug(sparqlQuery);
|
||||||
return 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 for the validity of the URI submitted.
|
/*
|
||||||
* */
|
* To test for the validity of the URI submitted.
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
* */
|
||||||
IRI iri = iRIFactory.create(this.personURI);
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
if (iri.hasViolation(false)) {
|
IRI iri = iRIFactory.create(this.personURI);
|
||||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
if (iri.hasViolation(false)) {
|
||||||
log.error("Pub Count vis Query " + errorMsg);
|
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||||
throw new MalformedQueryParametersException(
|
log.error("Pub Count vis Query " + errorMsg);
|
||||||
"URI provided for an individual is malformed.");
|
throw new MalformedQueryParametersException(
|
||||||
}
|
"URI provided for an individual is malformed.");
|
||||||
|
}
|
||||||
} else {
|
|
||||||
throw new MalformedQueryParametersException("URL parameter is either null or empty.");
|
} else {
|
||||||
}
|
throw new MalformedQueryParametersException("URL parameter is either null or empty.");
|
||||||
|
}
|
||||||
ResultSet resultSet = executeQuery(this.personURI,
|
|
||||||
this.dataset);
|
ResultSet resultSet = executeQuery(this.personURI,
|
||||||
|
this.dataset);
|
||||||
return createJavaValueObjects(resultSet);
|
|
||||||
}
|
return createJavaValueObjects(resultSet);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
|
@ -80,8 +80,10 @@ public class OrganizationUtilityFunctions {
|
||||||
|
|
||||||
String whereClause = "?organization rdf:type foaf:Organization ;"
|
String whereClause = "?organization rdf:type foaf:Organization ;"
|
||||||
+ " rdfs:label ?organizationLabel . \n"
|
+ " rdfs:label ?organizationLabel . \n"
|
||||||
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
|
+ "OPTIONAL { ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrg . \n"
|
||||||
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
|
+ " ?subOrg rdf:type foaf:Organization } . \n"
|
||||||
|
+ "OPTIONAL { ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parent . \n"
|
||||||
|
+ " ?parent rdf:type foaf:Organization } . \n"
|
||||||
+ "FILTER ( !bound(?parent) ). \n";
|
+ "FILTER ( !bound(?parent) ). \n";
|
||||||
|
|
||||||
String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"
|
String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"
|
||||||
|
|
|
@ -123,9 +123,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
String whereClause =
|
String whereClause =
|
||||||
"<" + individualURI + "> rdf:type foaf:Person ;"
|
"<" + individualURI + "> rdf:type foaf:Person ;"
|
||||||
+ " core:authorInAuthorship ?authorshipNode . \n"
|
+ " core:relatedBy ?authorshipNode . \n"
|
||||||
+ "?authorshipNode rdf:type core:Authorship ;"
|
+ "?authorshipNode rdf:type core:Authorship ;"
|
||||||
+ " core:linkedInformationResource ?document .";
|
+ " core:relates ?document . \n"
|
||||||
|
+ "?document rdf:type bibo:Document .";
|
||||||
|
|
||||||
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
|
String groupOrderClause = "GROUP BY ?" + QueryFieldLabels.AUTHOR_URL + " \n";
|
||||||
|
|
||||||
|
@ -152,16 +153,22 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(grantType, vitroRequest.getWebappDaoFactory());
|
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(grantType, vitroRequest.getWebappDaoFactory());
|
||||||
String roleToGrantPredicate = "<" + predicate.getURI() + ">";
|
String roleToGrantPredicate = "<" + predicate.getURI() + ">";
|
||||||
String whereClause = "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
String whereClause = "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
||||||
+ " core:hasCo-PrincipalInvestigatorRole ?Role . \n"
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?Role . \n"
|
||||||
|
+ "?Role rdf:type core:PrincipalInvestigatorRole . \n"
|
||||||
+ "?Role " + roleToGrantPredicate + " ?Grant . }"
|
+ "?Role " + roleToGrantPredicate + " ?Grant . }"
|
||||||
+ "UNION \n"
|
+ "UNION \n"
|
||||||
+ "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
+ "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
||||||
+ " core:hasPrincipalInvestigatorRole ?Role . \n"
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?Role . \n"
|
||||||
|
+ "?Role rdf:type core:CoPrincipalInvestigatorRole . \n"
|
||||||
+ "?Role " + roleToGrantPredicate + " ?Grant . }"
|
+ "?Role " + roleToGrantPredicate + " ?Grant . }"
|
||||||
+ "UNION \n"
|
+ "UNION \n"
|
||||||
+ "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
+ "{ <" + individualURI + "> rdf:type foaf:Person ;"
|
||||||
+ " core:hasInvestigatorRole ?Role . \n"
|
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?Role . \n"
|
||||||
+ "?Role " + roleToGrantPredicate + " ?Grant . }";
|
+ "?Role rdf:type core:InvestigatorRole. \n"
|
||||||
|
+ "?Role vitro:mostSpecificType ?subclass . \n"
|
||||||
|
+ "?Role " + roleToGrantPredicate + " ?Grant . \n"
|
||||||
|
+ "FILTER (?subclass != core:PrincipalInvestigatorRole && "
|
||||||
|
+ "?subclass != core:CoPrincipalInvestigatorRole)}";
|
||||||
|
|
||||||
QueryRunner<ResultSet> numberOfGrantsQueryHandler =
|
QueryRunner<ResultSet> numberOfGrantsQueryHandler =
|
||||||
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
|
||||||
|
@ -302,9 +309,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
|
||||||
|
|
||||||
String whereClause = "?organization rdf:type foaf:Organization ;"
|
String whereClause = "?organization rdf:type foaf:Organization ;"
|
||||||
+ " rdfs:label ?organizationLabel . \n"
|
+ " rdfs:label ?organizationLabel . \n"
|
||||||
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
|
+ "OPTIONAL { ?organization core:http://purl.obolibrary.org/obo/BFO_0000051 ?subOrg . \n"
|
||||||
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
|
+ " ?subOrg rdf:type foaf:Organization } . \n"
|
||||||
+ "FILTER ( !bound(?parent) ). \n";
|
+ "OPTIONAL { ?organization core:http://purl.obolibrary.org/obo/BFO_0000050 ?parent } . \n"
|
||||||
|
+ " ?parent rdf:type foaf:Organization } . \n"
|
||||||
|
+ "FILTER ( !bound(?parent) ). \n";
|
||||||
|
|
||||||
String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"
|
String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"
|
||||||
+ "ORDER BY DESC(?numOfChildren)\n"
|
+ "ORDER BY DESC(?numOfChildren)\n"
|
||||||
|
|
|
@ -1,134 +1,138 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
import com.hp.hpl.jena.iri.IRI;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import com.hp.hpl.jena.iri.IRIFactory;
|
|
||||||
import com.hp.hpl.jena.iri.Violation;
|
import com.hp.hpl.jena.iri.IRI;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import com.hp.hpl.jena.iri.IRIFactory;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.iri.Violation;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||||
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.constants.QueryConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
|
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.valueobjects.GenericQueryMap;
|
||||||
|
|
||||||
/**
|
|
||||||
* This query runner is used to execute a sparql query that will fetch all the
|
|
||||||
* properties available for the provided individual URI.
|
/**
|
||||||
*
|
* This query runner is used to execute a sparql query that will fetch all the
|
||||||
* @author cdtank
|
* properties available for the provided individual URI.
|
||||||
*/
|
*
|
||||||
public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
* @author cdtank
|
||||||
|
*/
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
|
||||||
|
|
||||||
private String filterRule, individualURI;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
private Dataset dataset;
|
|
||||||
|
private String filterRule, individualURI;
|
||||||
private Log log;
|
private Dataset dataset;
|
||||||
|
|
||||||
public AllPropertiesQueryRunner(String individualURI,
|
private Log log = LogFactory.getLog(AllPropertiesQueryRunner.class.getName());
|
||||||
String filterRule,
|
|
||||||
Dataset dataset,
|
public AllPropertiesQueryRunner(String individualURI,
|
||||||
Log log) {
|
String filterRule,
|
||||||
|
Dataset dataset,
|
||||||
this.individualURI = individualURI;
|
Log log) {
|
||||||
this.filterRule = filterRule;
|
|
||||||
this.dataset = dataset;
|
this.individualURI = individualURI;
|
||||||
this.log = log;
|
this.filterRule = filterRule;
|
||||||
|
this.dataset = dataset;
|
||||||
}
|
this.log = log;
|
||||||
|
|
||||||
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
|
}
|
||||||
|
|
||||||
GenericQueryMap queryResult = new GenericQueryMap();
|
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
|
||||||
|
|
||||||
while (resultSet.hasNext()) {
|
GenericQueryMap queryResult = new GenericQueryMap();
|
||||||
QuerySolution solution = resultSet.nextSolution();
|
|
||||||
|
while (resultSet.hasNext()) {
|
||||||
|
QuerySolution solution = resultSet.nextSolution();
|
||||||
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
|
|
||||||
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
|
|
||||||
|
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
|
||||||
if (predicateNode != null && objectNode != null) {
|
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
|
||||||
queryResult.addEntry(predicateNode.toString(),
|
|
||||||
objectNode.toString());
|
if (predicateNode != null && objectNode != null) {
|
||||||
}
|
queryResult.addEntry(predicateNode.toString(),
|
||||||
|
objectNode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResult;
|
}
|
||||||
}
|
|
||||||
|
return queryResult;
|
||||||
private ResultSet executeQuery(String queryText,
|
}
|
||||||
Dataset dataset) {
|
|
||||||
|
private ResultSet executeQuery(String queryText,
|
||||||
QueryExecution queryExecution = null;
|
Dataset dataset) {
|
||||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
|
||||||
|
QueryExecution queryExecution = null;
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||||
return queryExecution.execSelect();
|
|
||||||
}
|
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||||
|
return queryExecution.execSelect();
|
||||||
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
}
|
||||||
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
|
||||||
String filterClause;
|
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
|
||||||
|
// Resource uri1 = ResourceFactory.createResource(queryURI);
|
||||||
if (StringUtils.isNotBlank(filterRule)) {
|
String filterClause;
|
||||||
filterClause = "FILTER ( " + filterRule + " ) . ";
|
|
||||||
} else {
|
if (StringUtils.isNotBlank(filterRule)) {
|
||||||
filterClause = "";
|
filterClause = "FILTER ( " + filterRule + " ) . ";
|
||||||
}
|
} else {
|
||||||
|
filterClause = "";
|
||||||
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
}
|
||||||
+ "SELECT "
|
|
||||||
+ " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") "
|
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
|
||||||
+ " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") "
|
+ "SELECT "
|
||||||
+ "WHERE { "
|
+ " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") "
|
||||||
+ "<" + queryURI + "> ?predicate ?object. "
|
+ " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") "
|
||||||
+ filterClause
|
+ "WHERE { "
|
||||||
+ "}";
|
+ "<" + queryURI + "> ?predicate ?object. "
|
||||||
|
+ filterClause
|
||||||
return sparqlQuery;
|
+ "}";
|
||||||
}
|
|
||||||
|
log.debug("sparqlQuery = " + sparqlQuery.toString());
|
||||||
public GenericQueryMap getQueryResult()
|
|
||||||
throws MalformedQueryParametersException {
|
return sparqlQuery;
|
||||||
if (StringUtils.isNotBlank(this.individualURI)) {
|
}
|
||||||
/*
|
|
||||||
* To test for the validity of the URI submitted.
|
public GenericQueryMap getQueryResult()
|
||||||
* */
|
throws MalformedQueryParametersException {
|
||||||
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
if (StringUtils.isNotBlank(this.individualURI)) {
|
||||||
IRI iri = iRIFactory.create(this.individualURI);
|
/*
|
||||||
if (iri.hasViolation(false)) {
|
* To test for the validity of the URI submitted.
|
||||||
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
* */
|
||||||
log.error("Generic Query " + errorMsg);
|
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
|
||||||
throw new MalformedQueryParametersException(
|
IRI iri = iRIFactory.create(this.individualURI);
|
||||||
"URI provided for an individual is malformed.");
|
if (iri.hasViolation(false)) {
|
||||||
}
|
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
|
||||||
|
log.error("Generic Query " + errorMsg);
|
||||||
} else {
|
throw new MalformedQueryParametersException(
|
||||||
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
"URI provided for an individual is malformed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
|
} else {
|
||||||
this.individualURI,
|
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
|
||||||
this.filterRule),
|
}
|
||||||
this.dataset);
|
|
||||||
|
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
|
||||||
return createJavaValueObjects(resultSet);
|
this.individualURI,
|
||||||
}
|
this.filterRule),
|
||||||
}
|
this.dataset);
|
||||||
|
|
||||||
|
return createJavaValueObjects(resultSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,98 +1,104 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import com.hp.hpl.jena.query.Query;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import com.hp.hpl.jena.query.Dataset;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
|
|
||||||
/**
|
|
||||||
* This query runner is used to run a generic sparql query based on the "select",
|
|
||||||
* "where" & "filter" rules provided to it.
|
/**
|
||||||
*
|
* This query runner is used to run a generic sparql query based on the "select",
|
||||||
* @author cdtank
|
* "where" & "filter" rules provided to it.
|
||||||
*/
|
*
|
||||||
public class GenericQueryRunner implements QueryRunner<ResultSet> {
|
* @author cdtank
|
||||||
|
*/
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
public class GenericQueryRunner implements QueryRunner<ResultSet> {
|
||||||
|
|
||||||
private String whereClause;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
private Dataset dataset;
|
|
||||||
|
private String whereClause;
|
||||||
private Map<String, String> fieldLabelToOutputFieldLabel;
|
private Dataset dataset;
|
||||||
|
|
||||||
private String groupOrderClause;
|
private Map<String, String> fieldLabelToOutputFieldLabel;
|
||||||
|
|
||||||
private String aggregationRules;
|
private Log log = LogFactory.getLog(GenericQueryRunner.class.getName());
|
||||||
|
|
||||||
public GenericQueryRunner(Map<String, String> fieldLabelToOutputFieldLabel,
|
private String groupOrderClause;
|
||||||
String aggregationRules,
|
|
||||||
String whereClause,
|
private String aggregationRules;
|
||||||
String groupOrderClause,
|
|
||||||
Dataset dataset) {
|
public GenericQueryRunner(Map<String, String> fieldLabelToOutputFieldLabel,
|
||||||
|
String aggregationRules,
|
||||||
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
String whereClause,
|
||||||
this.aggregationRules = aggregationRules;
|
String groupOrderClause,
|
||||||
this.whereClause = whereClause;
|
Dataset dataset) {
|
||||||
this.groupOrderClause = groupOrderClause;
|
|
||||||
this.dataset = dataset;
|
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
||||||
}
|
this.aggregationRules = aggregationRules;
|
||||||
|
this.whereClause = whereClause;
|
||||||
private ResultSet executeQuery(String queryText,
|
this.groupOrderClause = groupOrderClause;
|
||||||
Dataset dataset) {
|
this.dataset = dataset;
|
||||||
|
}
|
||||||
QueryExecution queryExecution = null;
|
|
||||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
private ResultSet executeQuery(String queryText,
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
Dataset dataset) {
|
||||||
return queryExecution.execSelect();
|
|
||||||
}
|
QueryExecution queryExecution = null;
|
||||||
|
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||||
private String generateGenericSparqlQuery() {
|
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||||
|
return queryExecution.execSelect();
|
||||||
StringBuilder sparqlQuery = new StringBuilder();
|
}
|
||||||
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
|
|
||||||
|
private String generateGenericSparqlQuery() {
|
||||||
sparqlQuery.append("SELECT\n");
|
|
||||||
|
StringBuilder sparqlQuery = new StringBuilder();
|
||||||
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
|
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
|
||||||
: this.fieldLabelToOutputFieldLabel.entrySet()) {
|
|
||||||
|
sparqlQuery.append("SELECT\n");
|
||||||
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
|
|
||||||
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
|
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
|
||||||
|
: this.fieldLabelToOutputFieldLabel.entrySet()) {
|
||||||
}
|
|
||||||
|
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
|
||||||
sparqlQuery.append("\n" + this.aggregationRules + "\n");
|
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
|
||||||
|
|
||||||
sparqlQuery.append("WHERE {\n");
|
}
|
||||||
|
|
||||||
sparqlQuery.append(this.whereClause);
|
sparqlQuery.append("\n" + this.aggregationRules + "\n");
|
||||||
|
|
||||||
sparqlQuery.append("}\n");
|
sparqlQuery.append("WHERE {\n");
|
||||||
|
|
||||||
sparqlQuery.append(this.groupOrderClause);
|
sparqlQuery.append(this.whereClause);
|
||||||
|
|
||||||
return sparqlQuery.toString();
|
sparqlQuery.append("}\n");
|
||||||
}
|
|
||||||
|
sparqlQuery.append(this.groupOrderClause);
|
||||||
public ResultSet getQueryResult()
|
|
||||||
throws MalformedQueryParametersException {
|
log.debug("sparqlQuery = " + sparqlQuery.toString());
|
||||||
|
|
||||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
|
return sparqlQuery.toString();
|
||||||
this.dataset);
|
}
|
||||||
|
|
||||||
return resultSet;
|
public ResultSet getQueryResult()
|
||||||
}
|
throws MalformedQueryParametersException {
|
||||||
}
|
|
||||||
|
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
|
||||||
|
this.dataset);
|
||||||
|
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,97 +1,103 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.hp.hpl.jena.query.Query;
|
import org.apache.commons.logging.Log;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|
||||||
import com.hp.hpl.jena.query.QueryFactory;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.QueryExecution;
|
||||||
import com.hp.hpl.jena.query.Syntax;
|
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
||||||
import com.hp.hpl.jena.rdf.model.Model;
|
import com.hp.hpl.jena.query.QueryFactory;
|
||||||
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
import com.hp.hpl.jena.query.Syntax;
|
||||||
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
import com.hp.hpl.jena.rdf.model.Model;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
|
||||||
/**
|
|
||||||
* This query runner is used to run a generic sparql query based on the "select",
|
|
||||||
* "where" & "filter" rules provided to it.
|
|
||||||
*
|
/**
|
||||||
* @author cdtank
|
* This query runner is used to run a generic sparql query based on the "select",
|
||||||
*/
|
* "where" & "filter" rules provided to it.
|
||||||
public class GenericQueryRunnerOnModel implements QueryRunner<ResultSet> {
|
*
|
||||||
|
* @author cdtank
|
||||||
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
*/
|
||||||
|
public class GenericQueryRunnerOnModel implements QueryRunner<ResultSet> {
|
||||||
private String whereClause;
|
|
||||||
private Model model;
|
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
|
||||||
|
|
||||||
private Map<String, String> fieldLabelToOutputFieldLabel;
|
private String whereClause;
|
||||||
|
private Model model;
|
||||||
private String groupOrderClause;
|
|
||||||
|
private Map<String, String> fieldLabelToOutputFieldLabel;
|
||||||
private String aggregationRules;
|
|
||||||
|
private Log log = LogFactory.getLog(GenericQueryRunnerOnModel.class.getName());
|
||||||
public GenericQueryRunnerOnModel(Map<String, String> fieldLabelToOutputFieldLabel,
|
|
||||||
String aggregationRules,
|
private String groupOrderClause;
|
||||||
String whereClause,
|
|
||||||
String groupOrderClause,
|
private String aggregationRules;
|
||||||
Model model) {
|
|
||||||
|
public GenericQueryRunnerOnModel(Map<String, String> fieldLabelToOutputFieldLabel,
|
||||||
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
String aggregationRules,
|
||||||
this.aggregationRules = aggregationRules;
|
String whereClause,
|
||||||
this.whereClause = whereClause;
|
String groupOrderClause,
|
||||||
this.groupOrderClause = groupOrderClause;
|
Model model) {
|
||||||
this.model = model;
|
|
||||||
}
|
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
|
||||||
|
this.aggregationRules = aggregationRules;
|
||||||
private ResultSet executeQuery(String queryText,
|
this.whereClause = whereClause;
|
||||||
Model dataset) {
|
this.groupOrderClause = groupOrderClause;
|
||||||
|
this.model = model;
|
||||||
QueryExecution queryExecution = null;
|
}
|
||||||
Query query = QueryFactory.create(queryText, SYNTAX);
|
|
||||||
queryExecution = QueryExecutionFactory.create(query, dataset);
|
private ResultSet executeQuery(String queryText,
|
||||||
return queryExecution.execSelect();
|
Model dataset) {
|
||||||
}
|
|
||||||
|
QueryExecution queryExecution = null;
|
||||||
private String generateGenericSparqlQuery() {
|
Query query = QueryFactory.create(queryText, SYNTAX);
|
||||||
|
queryExecution = QueryExecutionFactory.create(query, dataset);
|
||||||
StringBuilder sparqlQuery = new StringBuilder();
|
return queryExecution.execSelect();
|
||||||
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
|
}
|
||||||
|
|
||||||
sparqlQuery.append("SELECT\n");
|
private String generateGenericSparqlQuery() {
|
||||||
|
|
||||||
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
|
StringBuilder sparqlQuery = new StringBuilder();
|
||||||
: this.fieldLabelToOutputFieldLabel.entrySet()) {
|
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
|
||||||
|
|
||||||
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
|
sparqlQuery.append("SELECT\n");
|
||||||
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
|
|
||||||
|
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
|
||||||
}
|
: this.fieldLabelToOutputFieldLabel.entrySet()) {
|
||||||
|
|
||||||
sparqlQuery.append("\n" + this.aggregationRules + "\n");
|
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
|
||||||
|
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
|
||||||
sparqlQuery.append("WHERE {\n");
|
|
||||||
|
}
|
||||||
sparqlQuery.append(this.whereClause);
|
|
||||||
|
sparqlQuery.append("\n" + this.aggregationRules + "\n");
|
||||||
sparqlQuery.append("}\n");
|
|
||||||
|
sparqlQuery.append("WHERE {\n");
|
||||||
sparqlQuery.append(this.groupOrderClause);
|
|
||||||
|
sparqlQuery.append(this.whereClause);
|
||||||
return sparqlQuery.toString();
|
|
||||||
}
|
sparqlQuery.append("}\n");
|
||||||
|
|
||||||
public ResultSet getQueryResult()
|
sparqlQuery.append(this.groupOrderClause);
|
||||||
throws MalformedQueryParametersException {
|
|
||||||
|
log.debug("sparqlQuery = " + sparqlQuery.toString());
|
||||||
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
|
return sparqlQuery.toString();
|
||||||
this.model);
|
}
|
||||||
|
|
||||||
return resultSet;
|
public ResultSet getQueryResult()
|
||||||
}
|
throws MalformedQueryParametersException {
|
||||||
}
|
|
||||||
|
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
|
||||||
|
this.model);
|
||||||
|
|
||||||
|
return resultSet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue