Merge branch 'develop' of github.com:vivo-project/VIVO into develop

This commit is contained in:
Brian Caruso 2013-09-30 16:31:11 -04:00
commit b82429924e
61 changed files with 3021 additions and 4968 deletions

View file

@ -421,8 +421,8 @@ check_grants_to_exclude = Compruebe las subvenciones y proyectos que desea exclu
manage_affiliated_people = Gestione personas afiliadas
check_people_to_exclude = Compruebe las personas que desea excluir de la página de perfil.
manage_grants = Gestione subvenciones para
check_pubs_to_exclude = Compruebe las subvenciones que desea excluir de la página de perfil.
manage_publications = Gestione publicaciónes para
check_pubs_to_exclude = Compruebe las publicaciónes que desea excluir de la página de perfil.
manage_web_pages = Gestionar páginas Web
has_no_webpages = Este individuo no tiene actualmente las páginas web específicas. Añadir una nueva página web haciendo clic en el botón de abajo.
@ -821,4 +821,7 @@ enter_email_address = Por favor, introduzca un valor en el campo Dirección de C
full_name = Nombre y apellidos
full_name_for = nombre y apellidos para
first_name = Primer nombre
last_name = Apellido
last_name = Apellido
title_not_found = Título que no se encuentra.
speeches_capitalized = Discursos
theses_capitalized = Tesis

File diff suppressed because one or more lines are too long

View file

@ -13,5 +13,6 @@ CONSTRUCT {
?person vivo:editorOf ?document
} UNION {
?document vivo:editor ?person
FILTER NOT EXISTS { ?person vivo:editorOf ?document }
}
}

View file

@ -11,5 +11,7 @@ CONSTRUCT {
} WHERE {
{ ?person vivo:currentlyHeadOf ?org }
UNION
{ ?org vivo:currentlyHeadedBy ?person }
{ ?org vivo:currentlyHeadedBy ?person
FILTER NOT EXISTS { ?person vivo:currentlyHeadOf ?org }
}
}

View file

@ -11,5 +11,7 @@ CONSTRUCT {
} WHERE {
{ ?person vivo:currentMemberOf ?org }
UNION
{ ?org vivo:hasCurrentMember ?person }
{ ?org vivo:hasCurrentMember ?person
FILTER NOT EXISTS { ?person vivo:currentMemberOf ?org }
}
}

View file

@ -0,0 +1,17 @@
PREFIX vivo: <http://vivoweb.org/ontology/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#Thing>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT {
?person1 vivo:relatedBy _:relationship .
?person2 vivo:relatedBy _:relationship .
_:relationship vivo:relates ?person1 .
_:relationship vivo:relates ?person2 .
} WHERE {
{ ?person1 vivo:hasCollaborator ?person2
FILTER NOT EXISTS {
?person1 vivo:relatedBy ?relationship .
?relationship vivo:relates ?person2
}
}
}

View file

@ -0,0 +1,11 @@
PREFIX vivo: <http://vivoweb.org/ontology/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#Thing>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT {
?role vivo:relatedBy ?grant .
?grant vivo:relates ?role
} WHERE {
?role vivo:roleContributesTo ?grant .
?grant a vivo:Grant .
}

View file

@ -13,5 +13,7 @@ CONSTRUCT {
} WHERE {
{ ?agent vivo:administers ?grant }
UNION
{ ?grant vivo:administeredBy ?agent }
{ ?grant vivo:administeredBy ?agent
FILTER NOT EXISTS { ?agent vivo:administers ?grant }
}
}

View file

@ -0,0 +1,11 @@
PREFIX vivo: <http://vivoweb.org/ontology/core#>
PREFIX owl: <http://www.w3.org/2002/07/owl#Thing>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
CONSTRUCT {
?role vivo:roleContributesTo ?grant .
?grant vivo:contributingRole ?role .
} WHERE {
?role vivo:roleContributesTo ?grant .
?grant a vivo:Grant .
}

View file

@ -25,11 +25,14 @@
?dateTimeEnd
WHERE {
?subject ?property ?advisory
?subject ?property ?advisory .
?advisory core:relates ?advisor .
?advisor &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?advisorRole .
LET ( ?localName := afn:localname(?advisory) )
OPTIONAL { ?advisory rdfs:label ?advisoryLabel }
OPTIONAL { ?advisory core:relates ?advisee .
?advisee a foaf:Person .
?advisee &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?adviseeRole
OPTIONAL { ?advisee rdfs:label ?adviseeLabel }
}
OPTIONAL { ?advisory core:relates ?degree .
@ -74,7 +77,10 @@
?subject ?property ?advisory .
?advisory a core:AdvisingRelationship .
?advisory ?advisoryProperty ?advisoryValue .
?advisory rdfs:label ?advisoryLabel
?advisory rdfs:label ?advisoryLabel .
?advisory core:relates ?advisor .
?advisor &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?advisorRole .
?advisorRole a core:AdvisorRole
} WHERE {
{
?subject ?property ?advisory .
@ -88,10 +94,23 @@
?advisory a core:AdvisingRelationship .
?advisory ?advisoryProperty ?advisoryValue .
?advisory rdfs:label ?advisoryLabel
} UNION {
?subject ?property ?advisory .
?advisory a core:AdvisingRelationship .
?advisory ?advisoryProperty ?advisoryValue .
?advisory core:relates ?advisor .
?advisor &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?advisorRole .
?advisorRole a core:AdvisorRole
}
}
</query-construct>
OPTIONAL { ?advisory core:relates ?advisee .
?advisee a foaf:Person .
?advisee &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?adviseeRole
<query-construct>
PREFIX bibo: &lt;http://purl.org/ontology/bibo/&gt;
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
@ -104,6 +123,8 @@
?advisory core:relates ?advisee .
?advisee a foaf:Person .
?advisee rdfs:label ?adviseeLabel .
?advisee &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?adviseeRole .
?adviseeRole a core:AdviseeRole .
?advisory core:relates ?degree .
?degree a core:AcademicDegree .
?degree rdfs:label ?degreeLabel .
@ -117,11 +138,15 @@
?advisory a core:AdvisingRelationship .
?advisory core:relates ?advisee .
?advisee a foaf:Person .
?advisee &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?adviseeRole .
?adviseeRole a core:AdviseeRole
} UNION {
?subject ?property ?advisory .
?advisory a core:AdvisingRelationship .
?advisory core:relates ?advisee .
?advisee a foaf:Person .
?advisee &lt;http://purl.obolibrary.org/obo/RO_0000053&gt; ?adviseeRole .
?adviseeRole a core:AdviseeRole .
?advisee rdfs:label ?adviseeLabel
} UNION {
?subject ?property ?advisory .

View file

@ -30,7 +30,7 @@
?subject ?property ?authorship .
?authorship core:relates ?infoResource .
?infoResource a bibo:Document .
?infoResource rdfs:label ?infoResourceName
?infoResource rdfs:label ?infoResourceName .
OPTIONAL { ?infoResource bibo:volume ?volume }
OPTIONAL { ?infoResource bibo:pageStart ?startPage }
@ -49,9 +49,7 @@
OPTIONAL { ?infoResource core:partOf ?partOfObj .
?partOfObj rdfs:label ?partOf
}
OPTIONAL { ?infoResource vitro:mostSpecificType ?subclass .
?subclass rdfs:subClassOf core:InformationResource
}
OPTIONAL { ?infoResource vitro:mostSpecificType ?subclass }
OPTIONAL { ?infoResource core:hasPublicationVenue ?publishedIn .
?publishedIn rdfs:label ?journal
}
@ -67,12 +65,14 @@
</query-select>
<query-construct>
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
PREFIX bibo: &lt;http://purl.org/ontology/bibo/&gt;
PREFIX vitro: &lt;http://vitro.mannlib.cornell.edu/ns/vitro/0.7#&gt;
CONSTRUCT {
?subclass rdfs:subClassOf core:InformationResource
?infoResource a bibo:Document .
?infoResource vitro:mostSpecificType ?subclass
} WHERE {
?subclass rdfs:subClassOf core:InformationResource
?infoResource a bibo:Document .
?infoResource vitro:mostSpecificType ?subclass
}
</query-construct>

View file

@ -122,19 +122,19 @@ $(document).ready(function(){
// if there are no selected pubs, hide the manage link; same for grants
// and affiliated people on the org profile page
if ( $('ul#authorInAuthorshipList').children('li').length < 1 && $('h3#authorInAuthorship').attr('class') != "hiddenPubs" ) {
if ( $('ul#relatedBy-Authorship-List').children('li').length < 1 && $('h3#relatedBy-Authorship').attr('class') != "hiddenPubs" ) {
$('a#managePubLink').hide();
}
if ( $('ul#hasResearcherRoleList').children('li').length < 1 &&
$('ul#hasPrincipalInvestigatorRoleList').children('li').length < 1 &&
$('ul#hasCo-PrincipalInvestigatorRoleList').children('li').length < 1 &&
$('ul#hasInvestigatorRoleList').children('li').length < 1 &&
$('h3#hasResearcherRole').attr('class') != "hiddenGrants" ) {
if ( $('ul#RO_0000053-ResearcherRole-List').children('li').length < 1 &&
$('ul#RO_0000053-PrincipalInvestigatorRole-List').children('li').length < 1 &&
$('ul#RO_0000053-CoPrincipalInvestigatorRole-List').children('li').length < 1 &&
$('ul#RO_0000053-InvestigatorRole-List').children('li').length < 1 &&
$('h3#RO_0000053-ResearcherRole').attr('class') != "hiddenGrants" ) {
$('a#manageGrantLink').hide();
}
if ( $('ul#organizationForPositionList').children('li').length < 1 && $('h3#organizationForPosition').attr('class') != "hiddenPeople" ) {
if ( $('ul#relatedBy-Position-List').children('li').length < 1 && $('h3#relatedBy-Position').attr('class') != "hiddenPeople" ) {
$('a#managePeopleLink').hide();
}

View file

@ -15,7 +15,7 @@
${affiliatedResearchAreas!}
</section> <!-- #individual-info -->
</section> <!-- #individual-intro -->
<!--postindiviudal overiew tfl-->
<!--postindividual overiew ftl-->
</#assign>
<#include "individual-vitro.ftl">

View file

@ -3,17 +3,17 @@
<#assign isPersonType = editConfiguration.pageData.isPersonType />
<form id="addLabelForm" name="addLabelForm" class="customForm" action="${submitUrl}">
<h2>${i18n().add_label}</h2>
<#if isPersonType = "true">
<#if isPersonType?has_content && isPersonType = "true">
<p>
<label for="firstName">${i18n().first_name} ${requiredHint}</label>
<input size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" />
</p>
<#--TODO: With ISF changes, add middle name input-->
<!--p-->
<!--label for="middleName">${i18n().middle_name} ${requiredHint}</label>
<p>
<label for="middleName">${i18n().middle_name} </label>
<input size="30" type="text" id="middleName" name="middleName" value="${middleNameValue}" />
</p-->
</p>
<p>
<label for="lastName">${i18n().last_name} ${requiredHint}</label>

View file

@ -5,8 +5,7 @@
<#--Get existing value for specific data literals and uris, in case the form is returned because of an error-->
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName")/>
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName")/>
<#--With ISF changes, we also have a niddle name value, also add error field below-->
<#--assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName") /-->
<#assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName") />
<#assign labelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "label")/>
<#assign newLabelLanguageValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "newLabelLanguage")/>

View file

@ -3,12 +3,14 @@
<#-- Template for sparkline visualization on individual profile page -->
<#-- 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 -->
<#assign isInvestigator = ( p.hasStatements(propertyGroups, "${core}hasInvestigatorRole") ||
p.hasStatements(propertyGroups, "${core}hasPrincipalInvestigatorRole") ||
p.hasStatements(propertyGroups, "${core}hasCo-PrincipalInvestigatorRole") ) >
<#assign obo_RO53 = "http://purl.obolibrary.org/obo/RO_0000053">
<#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)>
@ -70,4 +72,4 @@
<div class="collaboratorship-link"><a href="${coInvestigatorVisUrl}" title="${i18n().co_investigator_network}">${i18n().co_investigator_network_capitalized}</a></div>
</div>
</#if>
</#if>
</#if>

View file

@ -18,8 +18,8 @@
<span class="hideThis">&nbsp;</span>
<script type="text/javascript" >
$('span.hideThis').parent().parent().addClass("hideThis");
if ( $('h3#authorInAuthorship').attr('class').length == 0 ) {
$('h3#authorInAuthorship').addClass('hiddenPubs');
if ( $('h3#relatedBy-Authorship').attr('class').length == 0 ) {
$('h3#relatedBy-Authorship').addClass('hiddenPubs');
}
$('span.hideThis').parent().remove();
</script>
@ -111,6 +111,6 @@
</#if>
</#local>
${resourceTitle} ${citationDetails} <@dt.yearSpan "${statement.dateTime!}" />
${resourceTitle} ${citationDetails} <@dt.yearSpan "${statement.dateTime!}" />
</#if>
</#macro>

View file

@ -16,8 +16,8 @@
<span class="hideThis">&nbsp;</span>
<script type="text/javascript" >
$('span.hideThis').parent().parent().addClass("hideThis");
if ( $('h3#hasResearcherRole').attr('class').length == 0 ) {
$('h3#hasResearcherRole').addClass('hiddenGrants');
if ( $('h3#RO_0000053-ResearcherRole').attr('class').length == 0 ) {
$('h3#RO_0000053-ResearcherRole').addClass('hiddenGrants');
}
$('span.hideThis').parent().remove();
</script>

View file

@ -25,7 +25,7 @@ ${i18n().check_grants_to_exclude}
<ul >
<#list grantList as grant>
<li>
<input type="checkbox" class="grantCheckbox" <#if grant.hideThis??>checked</#if> />${grant.label!}
<input type="checkbox" class="grantCheckbox" <#if grant.hideThis??>checked</#if> />${grant.label!grant.activity!}
</li>
<script type="text/javascript">
grantData.push({

View file

@ -6,9 +6,9 @@
<#if subjectName?contains(",") >
<#assign lastName = subjectName?substring(0,subjectName?index_of(",")) />
<#assign firstName = subjectName?substring(subjectName?index_of(",") + 1) />
<h2>${i18n().manage_publications} ${firstName} ${lastName}</h2>
<h2>${i18n().manage_publications_for} ${firstName} ${lastName}</h2>
<#else>
<h2>${i18n().manage_publications} ${subjectName}</h2>
<h2>${i18n().manage_publications_for} ${subjectName}</h2>
</#if>
<p style="margin-left:25px;margin-bottom:12px">
${i18n().check_pubs_to_exclude}
@ -25,9 +25,9 @@ ${i18n().check_pubs_to_exclude}
<#if sub = "Software">
${sub}
<#elseif sub = "Thesis">
Theses
${i18n().theses_capitalized}
<#elseif sub = "Speech">
Speeches
${i18n().speeches_capitalized}
<#else>
${sub}s
</#if>
@ -38,7 +38,7 @@ ${i18n().check_pubs_to_exclude}
<#list pubs as pub>
<li>
<input type="checkbox" class="pubCheckbox" <#if pub.hideThis??>checked</#if> />
<#if pub.title?has_content>${pub.title!}<#else>Title not found.</#if>
<#if pub.title?has_content>${pub.title!}<#else>${i18n().title_not_found}</#if>
</li>
<script type="text/javascript">
publicationData.push({

View file

@ -11,6 +11,8 @@
<#--Get existing value for specific data literals and uris-->
<#assign firstNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "firstName")/>
<#assign lastNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "lastName")/>
<#assign middleNameValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "middleName")/>
<#assign labelValue = lvf.getFormFieldValue(editSubmission, editConfiguration, "label")/>
<#--If edit submission exists, then retrieve validation errors if they exist-->
@ -51,6 +53,11 @@
<label for="firstName">${i18n().first_name} ${requiredHint}</label>
<input size="30" type="text" id="firstName" name="firstName" value="${firstNameValue}" />
</p>
<p>
<label for="lastName">${i18n().middle_name} </label>
<input size="30" type="text" id="middleName" name="middleName" value="${middleNameValue}" />
</p>
<p>
<label for="lastName">${i18n().last_name} ${requiredHint}</label>

View file

@ -16,7 +16,7 @@
<h1 id="noPubsOrGrants-header">${organizationLabel}</h1>
<h3 id="alternative-vis-info">${textForCurrentEntityComparisonType?capitalize} ${i18n().temporal_graph_capitalized}
<span id="noPubsOrGrants-span">|&nbsp;<a href="${temporalGraphURL}" title="${i18n().view}">${i18n().view} ${textForOtherEntityComparisonType} ${i18n().temporal_graph}</a></span>
<span id="noPubsOrGrants-span">|&nbsp;<a href="${temporalGraphURL}" title="${i18n().view}">${i18n().view}&nbsp${textForOtherEntityComparisonType}&nbsp;${i18n().temporal_graph}</a></span>
</h3>
<div id="error-body">
<p>${i18n().entity_comp_error_text1}

View file

@ -5,7 +5,7 @@
<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">
<h3>${i18n().why_needed}</h3>
<p>${i18n().vis_tools_note_one}</p>

View file

@ -453,7 +453,7 @@ local:eventWithinConfig a :ObjectPropertyDisplayConfig ;
local:includesEventContext a :ConfigContext ;
: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> ;
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#Event> .
@ -467,11 +467,11 @@ local:includesEventConfig a :ObjectPropertyDisplayConfig ;
local:inEventSeriesContext a :ConfigContext ;
: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> ;
:qualifiedBy <http://purl.org/NET/c4dm/event.owl#EventSeries> .
local:includesEventConfig a :ObjectPropertyDisplayConfig ;
local:inEventSeriesConfig a :ObjectPropertyDisplayConfig ;
:listViewConfigFile "listViewConfig-default.xml"^^xsd:string ;
:displayName "in event series" ;
vitro:displayRankAnnot 3;
@ -479,3 +479,16 @@ local:includesEventConfig a :ObjectPropertyDisplayConfig ;
vitro:prohibitedFromUpdateBelowRoleLevelAnnot role:public ;
: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> .

View file

@ -539,7 +539,6 @@
<owl:Class rdf:about="http://purl.org/spar/c4o/BibliographicInformationSource">
<rdfs:label xml:lang="en-us">Bibliographic Information Source</rdfs:label>
<rdfs:subClassOf rdf:resource="http://isf/deprecated_class"/>
<vitro:descriptionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A source of information about bibliographic citations, such as Google Scholar, Web of Science or Scopus.</vitro:descriptionAnnot>
</owl:Class>
@ -792,7 +791,6 @@
<owl:Class rdf:about="http://vivoweb.org/ontology/core#EducationalProcess">
<rdfs:label xml:lang="en-us">Educational Process</rdfs:label>
<rdfs:subClassOf rdf:resource="http://isf/deprecated_class"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://vivoweb.org/ontology/core#supplementalInformation"/>
@ -805,8 +803,8 @@
<owl:allValuesFrom rdf:resource="http://vivoweb.org/ontology/core#DateTimeInterval"/>
</owl:Restriction>
</rdfs:subClassOf>
<vitro:exampleAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Currently any abstract name is given to individuals of this class. This could change in the future.</vitro:exampleAnnot>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Represents educational training that has been received.</vitro:shortDef>
<obo:IAO_0000112 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Currently any abstract name is given to individuals of this class. This could change in the future.</obo:IAO_0000112>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Represents educational training that has been received.</obo:IAO_0000115>
<vitro:descriptionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">This connects person to their academic degree through this educational training, but can also be used when the training does not result in a degree.</vitro:descriptionAnnot>
</owl:Class>
@ -915,7 +913,7 @@
<owl:allValuesFrom rdf:resource="http://vivoweb.org/ontology/core#DateTimeValue"/>
</owl:Restriction>
</rdfs:subClassOf>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The most general classification of an information resource</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The most general classification of an information resource</obo:IAO_0000115>
</owl:Class>
@ -1044,8 +1042,8 @@
<owl:allValuesFrom rdf:resource="http://vivoweb.org/ontology/core#DateTimeInterval"/>
</owl:Restriction>
</rdfs:subClassOf>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A person&apos;s, group&apos;s or organization&apos;s role in an endeavor</vitro:shortDef>
<vitro:exampleAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Only use if no specific subclasses of core:Role describe the role.</vitro:exampleAnnot>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A person&apos;s, group&apos;s or organization&apos;s role in an endeavor</obo:IAO_0000115>
<obo:IAO_0000112 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Only use if no specific subclasses of core:Role describe the role.</obo:IAO_0000112>
<vitro:descriptionAnnot rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Only use this broad role class if no subclasses of role describe the item being classified.</vitro:descriptionAnnot>
</owl:Class>
@ -1056,7 +1054,6 @@
<owl:Class rdf:about="http://vivoweb.org/ontology/core#Software">
<rdfs:label xml:lang="en-us">Software</rdfs:label>
<rdfs:subClassOf rdf:resource="http://isf/deprecated_class"/>
<rdfs:subClassOf rdf:resource="http://vivoweb.org/ontology/core#InformationResource"/>
<rdfs:subClassOf>
<owl:Restriction>
@ -1064,7 +1061,7 @@
<owl:allValuesFrom rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/>
</owl:Restriction>
</rdfs:subClassOf>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Computer program and its related documentation; directs the operation of a computer</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Computer program and its related documentation; directs the operation of a computer</obo:IAO_0000115>
</owl:Class>

View file

@ -1532,6 +1532,7 @@ there is a measurement process p that has specified output m, a measurement datu
<owl:ObjectProperty rdf:about="http://vivoweb.org/ontology/core#geographicFocusOf">
<rdfs:label xml:lang="en">geographic focus of</rdfs:label>
<rdfs:domain rdf:resource="http://vivoweb.org/ontology/core#GeographicRegion"/>
<owl:inverseOf rdf:resource="http://vivoweb.org/ontology/core#geographicFocus"/>
</owl:ObjectProperty>

File diff suppressed because it is too large Load diff

View file

@ -73,16 +73,6 @@
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/IAO_0000003"/>
</owl:Class>
<!-- http://vivoweb.org/ontology/core#URLLink -->
<owl:Class rdf:about="http://vivoweb.org/ontology/core#URLLink">
<rdfs:label xml:lang="en">urllink</rdfs:label>
<obo:IAO_0000112 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The full URL.</obo:IAO_0000112>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Uniform Resource Locator (URL) specifies where an identified resource is available and the mechanism for retrieving it.</obo:IAO_0000115>
<obo:IAO_0000112 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://info.slis.indiana.edu/~katy/</obo:IAO_0000112>
</owl:Class>

View file

@ -52,46 +52,46 @@ core:FacultyMember
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:descriptionAnnot
"Definition from here: http://research.carleton.ca/htr/defs.php."^^xsd:string ;
vitro:shortDef "A person with at least one academic appointment to a specific faculty of a university or institution of higher learning."^^xsd:string .
obo:IAO_0000115 "A person with at least one academic appointment to a specific faculty of a university or institution of higher learning."^^xsd:string .
core:Postdoc
a owl:Class ;
rdfs:label "Postdoc"@en-us ;
rdfs:subClassOf <http://isf/deprecated_class> , core:NonFacultyAcademic ;
vitro:shortDef "A Person holding an academic employment appointment focused on research rather than teaching; temporary (or for some defined term)"^^xsd:string .
obo:IAO_0000115 "A Person holding an academic employment appointment focused on research rather than teaching; temporary (or for some defined term)"^^xsd:string .
core:NonFacultyAcademic
a owl:Class ;
rdfs:label "Non-Faculty Academic"@en-us ;
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A person not considered a faculty member but holding an academic appointment."^^xsd:string .
obo:IAO_0000115 "A person not considered a faculty member but holding an academic appointment."^^xsd:string .
core:EmeritusLibrarian
a owl:Class ;
rdfs:label "Librarian Emeritus"@en-us ;
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A retired librarian who has retained their rank, title and privileges."^^xsd:string .
obo:IAO_0000115 "A retired librarian who has retained their rank, title and privileges."^^xsd:string .
core:EmeritusFaculty
a owl:Class ;
rdfs:label "Faculty Member Emeritus"@en-us ;
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A retired faculty member who has retained their rank, title and privileges."^^xsd:string .
obo:IAO_0000115 "A retired faculty member who has retained their rank, title and privileges."^^xsd:string .
core:Librarian
a owl:Class ;
rdfs:label "Librarian"@en-us ;
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A person working in a position of librarian or information professional, or academic or technical expert in support of providing information services or materials."^^xsd:string .
obo:IAO_0000115 "A person working in a position of librarian or information professional, or academic or technical expert in support of providing information services or materials."^^xsd:string .
core:EmeritusProfessor
a owl:Class ;
rdfs:label "Professor Emeritus"@en-us ;
rdfs:subClassOf core:EmeritusFaculty , foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A retired professor who has retained their rank, title and privileges."^^xsd:string .
obo:IAO_0000115 "A retired professor who has retained their rank, title and privileges."^^xsd:string .
core:NonAcademic
a owl:Class ;
rdfs:label "Non-Academic"@en-us ;
rdfs:subClassOf foaf:Person , <http://isf/deprecated_class> ;
vitro:shortDef "A person holding a position that is not considered to be an academic appointment."^^xsd:string .
obo:IAO_0000115 "A person holding a position that is not considered to be an academic appointment."^^xsd:string .

View file

@ -27,7 +27,6 @@
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000114"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000119"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000117"/>
<owl:AnnotationProperty rdf:about="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#shortDef"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000111"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000112"/>
@ -864,7 +863,7 @@
<owl:Class rdf:about="http://purl.org/spar/fabio/ClinicalGuideline">
<rdfs:label xml:lang="en">clinical guideline</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.org/ontology/bibo/Document"/>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A recommendation on the appropriate treatment and care of people with a specific disease or condition, based on the best available evidence, designed to help healthcare professionals in their work.</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A recommendation on the appropriate treatment and care of people with a specific disease or condition, based on the best available evidence, designed to help healthcare professionals in their work.</obo:IAO_0000115>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A recommendation on the appropriate treatment and care of people with a specific disease or condition, based on the best available evidence, designed to help healthcare professionals in their work.</obo:IAO_0000115>
</owl:Class>
@ -875,7 +874,7 @@
<owl:Class rdf:about="http://purl.org/spar/fabio/Comment">
<rdfs:label xml:lang="en">comment</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.org/ontology/bibo/Document"/>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A verbal or written remark concerning some entity. In written form, a comment is often appended to that entity and termed an annotation. Within computer programs or ontologies, comments are added to enhance human understanding, and are usually prefaced by</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A verbal or written remark concerning some entity. In written form, a comment is often appended to that entity and termed an annotation. Within computer programs or ontologies, comments are added to enhance human understanding, and are usually prefaced by</obo:IAO_0000115>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A verbal or written remark concerning some entity. In written form, a comment is often appended to that entity and termed an annotation. Within computer programs or ontologies, comments are added to enhance human understanding, and are usually prefaced by a special syntactic symbol that ensures they are ignored during execution of the program.
has super-classes</obo:IAO_0000115>
@ -888,7 +887,7 @@ has super-classes</obo:IAO_0000115>
<owl:Class rdf:about="http://purl.org/spar/fabio/Erratum">
<rdfs:label xml:lang="en">erratum</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.org/ontology/bibo/Document"/>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A formal correction to an error introduced by the publisher into a previously published document.</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A formal correction to an error introduced by the publisher into a previously published document.</obo:IAO_0000115>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">A formal correction to an error introduced by the publisher into a previously published document.</obo:IAO_0000115>
</owl:Class>
@ -1142,12 +1141,6 @@ Contents
<!-- http://vivoweb.org/ontology/core#URLLink -->
<owl:Class rdf:about="http://vivoweb.org/ontology/core#URLLink"/>
<!-- http://vivoweb.org/ontology/core#Video -->
<owl:Class rdf:about="http://vivoweb.org/ontology/core#Video">

View file

@ -25,7 +25,6 @@
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000119"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000117"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000118"/>
<owl:AnnotationProperty rdf:about="http://vitro.mannlib.cornell.edu/ns/vitro/0.7#shortDef"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000111"/>
<owl:AnnotationProperty rdf:about="http://purl.obolibrary.org/obo/IAO_0000112"/>
@ -93,7 +92,7 @@
<owl:Class rdf:about="http://vivoweb.org/ontology/scientific-research#Phase0ClinicalTrial">
<rdfs:label xml:lang="en">phase 0 clinical trial</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/ERO_0000016"/>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 0 Clinical Trial</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 0 Clinical Trial</obo:IAO_0000115>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 0 is a recent designation for exploratory, first-in-human trials conducted in accordance with the United States Food and Drug Administration&apos;s (FDA) 2006 Guidance on Exploratory Investigational New Drug (IND) Studies. Phase 0 trials are also known as human microdosing studies and are designed to speed up the development of promising drugs or imaging agents by establishing very early on whether the drug or agent behaves in human subjects as was expected from preclinical studies.</obo:IAO_0000115>
</owl:Class>
@ -105,7 +104,7 @@
<rdfs:label xml:lang="en">phase 1 clinical trial</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/ERO_0000016"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In Phase I trials, researchers test an experimental drug or treatment in a small group of people (20-80) for the first time to evaluate its safety, determine a safe dosage range, and identify side effects</obo:IAO_0000115>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 1 Clinical Trial</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 1 Clinical Trial</obo:IAO_0000115>
</owl:Class>
@ -116,7 +115,7 @@
<rdfs:label xml:lang="en">phase 2 clinical trial</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/ERO_0000016"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In Phase 2 trials, an experimental study drug or treatment is given to a larger group of people (100-300) to see if it is effective and to further evaluate its safety.</obo:IAO_0000115>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 2 Clinical Trial</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 2 Clinical Trial</obo:IAO_0000115>
</owl:Class>
@ -128,7 +127,7 @@
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/ERO_0000016"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In Phase 3 trials, an experimental study drug or treatment is given to large groups of people (1,000-3,000) to confirm its effectiveness, monitor side effects, compare it to commonly used treatments, and collect information that will allow the experimental drug or treatment to be used safely.
</obo:IAO_0000115>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 3 Clinical Trial</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 3 Clinical Trial</obo:IAO_0000115>
</owl:Class>
@ -139,7 +138,7 @@
<rdfs:label xml:lang="en">phase 4 clinical trial</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/ERO_0000016"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">In Phase 4 trials, post marketing studies delineate additional information including the drug&apos;s or treatment&apos;s risks, benefits, and optimal use.</obo:IAO_0000115>
<vitro:shortDef rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 4 Clinical Trial</vitro:shortDef>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Phase 4 Clinical Trial</obo:IAO_0000115>
</owl:Class>
</rdf:RDF>

View file

@ -67,13 +67,13 @@ public class ManageGrantsForIndividualController extends FreemarkerHttpServlet {
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
+ "SELECT DISTINCT ?subclass ?role (str(?label2) as ?label) ?activity ?hideThis WHERE { \n"
+ " ?subject ?roleProp ?role . \n"
+ " ?roleProp rdfs:subPropertyOf core:hasResearcherRole . \n"
+ " ?role a core:ResearcherRole . \n"
+ " ?role vitro:mostSpecificType ?subclass \n"
+ " OPTIONAL { ?role core:roleRealizedIn ?activity . \n"
+ " ?activity rdfs:label ?label2 \n"
+ " OPTIONAL { ?role core:relatedBy ?activity . \n"
+ " OPTIONAL {?activity rdfs:label ?label2} \n"
+ " } \n"
+ " OPTIONAL { ?role core:roleContributesTo ?activity . \n"
+ " ?activity rdfs:label ?label2 \n"
+ " OPTIONAL { ?role <http://purl.obolibrary.org/obo/BFO_0000054> ?activity . \n"
+ " OPTIONAL {?activity rdfs:label ?label2} \n"
+ " } \n"
+ " OPTIONAL { ?role core:hideFromDisplay ?hideThis } \n"
+ "} ORDER BY ?subclass ?label2";

View file

@ -65,12 +65,14 @@ public class ManagePeopleForOrganizationController extends FreemarkerHttpServlet
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \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"
+ " ?subject core:organizationForPosition ?position . \n"
+ " OPTIONAL { ?position core:positionForPerson ?person . "
+ " ?subject core:relatedBy ?position . \n"
+ " ?position a core:Position . \n"
+ " OPTIONAL { ?position core:relates ?person . "
+ " ?person a foaf:Person . \n"
+ " ?person rdfs:label ?label } \n"
+ " OPTIONAL { ?position vitro:mostSpecificType ?subclass . \n"
+ " ?subclass rdfs:subClassOf core:Position } \n"
+ " OPTIONAL { ?position vitro:mostSpecificType ?subclass } \n"
+ " OPTIONAL { ?position core:hideFromDisplay ?hideThis } \n "
+ "} ORDER BY ?subclass ?name";

View file

@ -66,11 +66,12 @@ public class ManagePublicationsForIndividualController extends FreemarkerHttpSer
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
+ "PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n"
+ "SELECT DISTINCT ?subclass ?authorship (str(?label) as ?title) ?pub ?hideThis WHERE { \n"
+ " ?subject core:authorInAuthorship ?authorship . \n"
+ " OPTIONAL { ?authorship core:linkedInformationResource ?pub . "
+ " ?subject core:relatedBy ?authorship . \n"
+ " ?authorship a core:Authorship . \n"
+ " OPTIONAL { ?authorship core:relates ?pub . "
+ " ?pub a <http://purl.org/ontology/bibo/Document> . \n"
+ " ?pub rdfs:label ?label \n"
+ " OPTIONAL { ?pub vitro:mostSpecificType ?subclass . \n"
+ " ?subclass rdfs:subClassOf core:InformationResource } \n"
+ " OPTIONAL { ?pub vitro:mostSpecificType ?subclass } \n"
+ " } \n"
+ " OPTIONAL { ?authorship core:hideFromDisplay ?hideThis } \n"
+ "} ORDER BY ?subclass ?title";

View file

@ -54,6 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForIndividualPreprocessor;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForPersonPreprocessor;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionDataGetter;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectorUtilities;
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
@ -69,12 +70,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private static String template = "manageLabelsForPerson.ftl";
private HashMap<String, List<LabelInformation>> labelsSortedByLanguage = null;
private List<Literal> existingLabelLiterals = null;
//list of language names sorted alphabetically
private List<String> existingSortedLanguageNameList = null;
//This would be for the full list and can be used for the existing labels list as well
private HashMap<String, String> fullLanguageNameToCodeMap = null;
private static String predicateUri = RDFS.label.getURI();
@Override
public EditConfigurationVTwo getEditConfiguration(VitroRequest vreq, HttpSession session) {
@ -115,7 +111,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
addFormSpecificData(config, vreq);
//This preprocessor handles getting the correct label language and putting the attribute on the label
config.addEditSubmissionPreprocessor(
new ManageLabelsForIndividualPreprocessor(config));
new ManageLabelsForPersonPreprocessor(config));
//This will handle generating the label from the first name, middle, and last names and also make sure to associate
//a language with that label
config.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
@ -150,22 +146,20 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private List<String> generateN3Optional(VitroRequest vreq) {
List<String> n3Optional = new ArrayList<String>();
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
String n3 = "?subject <" + predicateUri + "> ?label ";
//n3 used if the subject is a person
//String personN3 = this.N3_PREFIX + "?subject foaf:firstName ?firstName ; foaf:lastName ?lastName .";
//This n3 will be different with the ISF changes
String personN3 = this.N3_PREFIX +
String personFullNameN3 = this.N3_PREFIX +
"?subject <http://purl.obolibrary.org/obo/ARG_2000028> ?individualVcard . \n" +
"?individualVcard a <http://www.w3.org/2006/vcard/ns#Individual> . \n" +
"?individualVcard <http://purl.obolibrary.org/obo/ARG_2000029> ?subject . \n" +
"?individualVcard <http://www.w3.org/2006/vcard/ns#hasName> ?fullName . \n" +
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> . \n" +
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName . \n" +
"?fullName a <http://www.w3.org/2006/vcard/ns#Name> .";
String personFirstNameN3 =
"?fullName <http://www.w3.org/2006/vcard/ns#givenName> ?firstName . ";
String personLastNameN3 =
"?fullName <http://www.w3.org/2006/vcard/ns#familyName> ?lastName .";
n3Optional.add(n3);
n3Optional.add(personN3);
String personMiddleNameN3 = "?fullName <http://www.w3.org/2006/vcard/ns#middleName> ?middleName .";
n3Optional.add(personFullNameN3 + "\n " + personFirstNameN3 + "\n " + personLastNameN3);
n3Optional.add(personMiddleNameN3);
return n3Optional;
}
@ -174,9 +168,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private void setFields(EditConfigurationVTwo editConfiguration, VitroRequest vreq, String predicateUri) {
Map<String, FieldVTwo> fields = new HashMap<String, FieldVTwo>();
editConfiguration.setFields(fields);
editConfiguration.addField(new FieldVTwo().
setName("label").
setValidators(getLabelValidators(vreq, editConfiguration)));
editConfiguration.addField(new FieldVTwo(
).setName("newLabelLanguage"));
//no validators since all of this is optional
@ -186,7 +178,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
setValidators(getFirstNameValidators(vreq, editConfiguration)));
editConfiguration.addField(new FieldVTwo().
setName("middleName").
setValidators(getLastNameValidators(vreq, editConfiguration)));
setValidators(getMiddleNameValidators(vreq, editConfiguration)));
editConfiguration.addField(new FieldVTwo().
setName("lastName").
@ -199,39 +191,36 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//first and last name have validators if is person is true
private List<String> getFirstNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List<String> validators = new ArrayList<String>();
if(isPersonType(vreq, config)) {
validators.add("nonempty");
}
return validators;
}
private List<String> getMiddleNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List<String> validators = new ArrayList<String>();
return validators;
}
private List<String> getLastNameValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List<String> validators = new ArrayList<String>();
if(isPersonType(vreq, config)) {
validators.add("nonempty");
}
return validators;
}
//validate label if person is not true
private List<String> getLabelValidators(VitroRequest vreq, EditConfigurationVTwo config) {
List<String> validators = new ArrayList<String>();
if(!isPersonType(vreq, config)) {
validators.add("nonempty");
}
return validators;
}
private void setUrisAndLiteralsOnForm(EditConfigurationVTwo config,
VitroRequest vreq) {
List<String> literalsOnForm = new ArrayList<String>();
literalsOnForm.add("label");
literalsOnForm.add("newLabelLanguage");
//optional for person
literalsOnForm.add("firstName");
literalsOnForm.add("lastName");
literalsOnForm.add("middleName");
config.setLiteralsOnForm(literalsOnForm);
}
@ -253,17 +242,6 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
private void initExistingLabels(EditConfigurationVTwo config,
VitroRequest vreq) {
this.existingLabelLiterals = this.getExistingLabels(config.getSubjectUri(), vreq);
// this.labelsSortedByLanguage = this.getLabelsSortedByLanguage(config,vreq);
//language names sorted for the existing languages
// this.existingSortedLanguageNameList = getExistingSortedLanguageNamesList();
//Generate a label to language code hash map
//TODO:
//HashMap<String, String> labelToLanguageCode = new HashMap<String, String>();
//this.labels = getExistingLabels(config.getSubjectUri(), vreq);
//this.labelsSortedByLanguage = getLabelsSortedByLanguage(config.getSubjectUri(), vreq);
}
@ -318,15 +296,7 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
config.addFormSpecificData("subjectName", null);
}
//Put in whether or not person type
if(isPersonType(vreq, config)) {
//Doing this b/c unsure how freemarker will handle boolean value from JAVA
config.addFormSpecificData("isPersonType", "true");
} else {
config.addFormSpecificData("isPersonType", "false");
}
config.addFormSpecificData("isPersonType", "true");
//Include whether or not editable to enable edit/remove links and add to show up
config.addFormSpecificData("editable", isEditable(vreq, config));
}
@ -376,7 +346,6 @@ public class ManageLabelsForPersonGenerator extends BaseEditConfigurationGenerat
//Copied from NewIndividualFormGenerator
//TODO: Refactor so common code can be used by both generators
public String getFOAFPersonClassURI() {
return "http://xmlns.com/foaf/0.1/Person";
}

View file

@ -41,6 +41,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
));
//Optional because user may have selected either person or individual of another kind
//Person uses first name and last name whereas individual of other class would use label
//middle name is also optional
config.setN3Optional(list(
N3_PREFIX + "@prefix vcard:<http://www.w3.org/2006/vcard/ns#> .\n"
+ " ?newInd <http://purl.obolibrary.org/obo/ARG_2000028> ?newVcardInd . \n"
@ -50,6 +51,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
+ " ?newVcardName a <http://www.w3.org/2006/vcard/ns#Name> . \n"
+ " ?newVcardName vcard:givenName ?firstName . \n"
+ " ?newVcardName vcard:familyName ?lastName .",
"?newVcardName <http://www.w3.org/2006/vcard/ns#middleName> ?middleName .",
N3_PREFIX + " ?newInd <" + RDFS.label.getURI() + "> ?label ."
));
@ -58,7 +60,7 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
config.addNewResource("newVcardName", vreq.getWebappDaoFactory().getDefaultNamespace());
config.setUrisOnform(list ());
config.setLiteralsOnForm( list( "label", "firstName", "lastName" ));
config.setLiteralsOnForm( list( "label", "firstName", "lastName", "middleName" ));
setUrisAndLiteralsInScope(config);
//No SPARQL queries for existing since this is only used to create new, never for edit
@ -67,6 +69,11 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
setRangeDatatypeUri(XSD.xstring.getURI()).
setValidators(getFirstNameValidators(vreq)));
config.addField(new FieldVTwo().
setName("middleName").
setRangeDatatypeUri(XSD.xstring.getURI()).
setValidators(getMiddleNameValidators(vreq)));
config.addField(new FieldVTwo().
setName("lastName").
setRangeDatatypeUri(XSD.xstring.getURI()).
@ -96,7 +103,12 @@ public class NewIndividualFormGenerator extends BaseEditConfigurationGenerator i
return config;
}
//first and last name have validators if is person is true
private List<String> getMiddleNameValidators(VitroRequest vreq) {
List<String> validators = new ArrayList<String>();
return validators;
}
//first and last name have validators if is person is true
private List<String> getFirstNameValidators(VitroRequest vreq) {
List<String> validators = new ArrayList<String>();
if(isPersonType(vreq)) {

View file

@ -209,25 +209,25 @@ public class PersonHasAwardOrHonorGenerator extends VivoBaseGenerator implements
"?awardReceipt <"+ descriptionPred +"> ?description .";
final static String n3ForExistingOrgNewAwardAssertion =
"?award <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?award . \n" +
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
"?award <"+ label + "> ?awardLabel .";
final static String n3ForExistingOrgExistingAwardAssertion =
"?existingAward <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?existingAward . ";
"?awardReceipt <" + awardConferredByPred +"> ?existingOrg . \n" +
"?existingOrg <" + awardConferredPred + "> ?awardReceipt . ";
final static String n3ForNewOrgNewAwardAssertion =
"?newOrg a <" + orgClass + "> . \n" +
"?award <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?award . \n" +
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
"?award <"+ label + "> ?awardLabel . \n" +
"?newOrg <"+ label + "> ?orgLabel .";
final static String n3ForNewOrgExistingAwardAssertion =
"?newOrg a <" + orgClass + "> . \n" +
"?existingAward <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?existingAward . \n" +
"?awardReceipt <" + awardConferredByPred +"> ?newOrg . \n" +
"?newOrg <" + awardConferredPred + "> ?awardReceipt . \n" +
"?newOrg <"+ label + "> ?orgLabel .";
final static String n3ForYearAwarded =

View file

@ -240,6 +240,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
"?newOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
"?newOrg a ?orgType . \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"+
"?degreeType <http://vivoweb.org/ontology/core#relatedBy> ?newAwardedDegree . \n"+
"?newAwardedDegree a core:AwardedDegree .";
@ -254,6 +256,8 @@ public class PersonHasEducationalTraining extends VivoBaseGenerator implements
"?existingOrg <http://vivoweb.org/ontology/core#assigns> ?newAwardedDegree . \n" +
"?newAwardedDegree <http://vivoweb.org/ontology/core#assignedBy> ?existingOrg . \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"+
"?newAwardedDegree a core:AwardedDegree .";

View file

@ -0,0 +1,105 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.ResIterator;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/*
* This preprocessor is used to set the language attribute on the label based on the user selection
* on the manage labels page when adding a new label.
*/
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BaseEditSubmissionPreprocessorVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission;
public class ManageLabelsForPersonPreprocessor extends ManageLabelsForIndividualPreprocessor {
public ManageLabelsForPersonPreprocessor(EditConfigurationVTwo editConfig) {
super(editConfig);
}
@Override
public void preprocess(MultiValueEditSubmission inputSubmission, VitroRequest vreq) {
//Use the ManageLabelsForIndividualPreprocessor in addition to this code specific for person
super.preprocess(inputSubmission, vreq);
//First name and last name would also have a language selected so make sure those literals are also
//correctly typed
//Middle name is optional
if(inputSubmission.hasLiteralValue("firstName") && inputSubmission.hasLiteralValue("lastName") && inputSubmission.hasLiteralValue("newLabelLanguage")) {
Map<String, List<Literal>> literalsFromForm = inputSubmission.getLiteralsFromForm();
List<Literal> newLabelLanguages = literalsFromForm.get("newLabelLanguage");
List<Literal> firstNames = literalsFromForm.get("firstName");
List<Literal> lastNames = literalsFromForm.get("lastName");
List<Literal> middleNames = new ArrayList<Literal>();
if(inputSubmission.hasLiteralValue("middleName")) {
middleNames = literalsFromForm.get("middleName");
}
//Expecting only one language
if(firstNames.size() > 0 && lastNames.size() > 0 && newLabelLanguages.size() > 0) {
Literal newLabelLanguage = newLabelLanguages.get(0);
Literal firstNameLiteral = firstNames.get(0);
Literal lastNameLiteral = lastNames.get(0);
//Get the string
String lang = this.getLanguage(newLabelLanguage.getString());
String firstNameValue = firstNameLiteral.getString();
String lastNameValue = lastNameLiteral.getString();
//Now add the language category to the literal
Literal firstNameWithLanguage = inputSubmission.createLiteral(firstNameValue,
null,
lang);
Literal lastNameWithLanguage = inputSubmission.createLiteral(lastNameValue,
null,
lang);
firstNames = new ArrayList<Literal>();
lastNames = new ArrayList<Literal>();
firstNames.add(firstNameWithLanguage);
lastNames.add(lastNameWithLanguage);
//replace the label with one with language, again assuming only one label being returned
literalsFromForm.put("firstName", firstNames);
literalsFromForm.put("lastName", lastNames);
//Middle name handling
if(middleNames.size() > 0) {
Literal middleNameLiteral = middleNames.get(0);
String middleNameValue = middleNameLiteral.getString();
Literal middleNameWithLanguage = inputSubmission.createLiteral(middleNameValue,
null,
lang);
middleNames = new ArrayList<Literal>();
middleNames.add(middleNameWithLanguage);
literalsFromForm.put("middleName", middleNames);
}
//Set literals
inputSubmission.setLiteralsFromForm(literalsFromForm);
}
}
}
}

View file

@ -1,442 +1,445 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import 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.CollaboratorComparator;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
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.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator;
/**
* 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
* on that particular publication.
*
* @author cdtank
*/
public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private Dataset dataset;
private Log log;
private UniqueIDGenerator nodeIDGenerator;
private UniqueIDGenerator edgeIDGenerator;
public CoAuthorshipQueryRunner(String egoURI,
Dataset dataset, Log log) {
this.egoURI = egoURI;
this.dataset = dataset;
this.log = log;
this.nodeIDGenerator = new UniqueIDGenerator();
this.edgeIDGenerator = new UniqueIDGenerator();
}
private CollaborationData createQueryResult(ResultSet resultSet) {
Set<Collaborator> nodes = new HashSet<Collaborator>();
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors =
new HashMap<String, Set<Collaborator>>();
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
Collaborator egoNode = null;
Set<Collaboration> edges = new HashSet<Collaboration>();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
/*
* We only want to create only ONE ego node.
* */
RDFNode egoAuthorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
if (nodeURLToVO.containsKey(egoAuthorURLNode.toString())) {
egoNode = nodeURLToVO.get(egoAuthorURLNode.toString());
} else {
egoNode = new Collaborator(egoAuthorURLNode.toString(), nodeIDGenerator);
nodes.add(egoNode);
nodeURLToVO.put(egoAuthorURLNode.toString(), egoNode);
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
if (authorLabelNode != null) {
egoNode.setCollaboratorName(authorLabelNode.toString());
}
}
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
Activity biboDocument;
if (biboDocumentURLToVO.containsKey(documentNode.toString())) {
biboDocument = biboDocumentURLToVO.get(documentNode.toString());
} else {
biboDocument = createDocumentVO(solution, documentNode.toString());
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
}
egoNode.addActivity(biboDocument);
/*
* 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
* author and that happens to be the ego.
* */
if (solution.get(QueryFieldLabels.AUTHOR_URL).toString().equalsIgnoreCase(
solution.get(QueryFieldLabels.CO_AUTHOR_URL).toString())) {
continue;
}
Collaborator coAuthorNode;
RDFNode coAuthorURLNode = solution.get(QueryFieldLabels.CO_AUTHOR_URL);
if (nodeURLToVO.containsKey(coAuthorURLNode.toString())) {
coAuthorNode = nodeURLToVO.get(coAuthorURLNode.toString());
} else {
coAuthorNode = new Collaborator(coAuthorURLNode.toString(), nodeIDGenerator);
nodes.add(coAuthorNode);
nodeURLToVO.put(coAuthorURLNode.toString(), coAuthorNode);
RDFNode coAuthorLabelNode = solution.get(QueryFieldLabels.CO_AUTHOR_LABEL);
if (coAuthorLabelNode != null) {
coAuthorNode.setCollaboratorName(coAuthorLabelNode.toString());
}
}
coAuthorNode.addActivity(biboDocument);
Set<Collaborator> coAuthorsForCurrentBiboDocument;
if (biboDocumentURLToCoAuthors.containsKey(biboDocument.getActivityURI())) {
coAuthorsForCurrentBiboDocument = biboDocumentURLToCoAuthors
.get(biboDocument.getActivityURI());
} else {
coAuthorsForCurrentBiboDocument = new HashSet<Collaborator>();
biboDocumentURLToCoAuthors.put(biboDocument.getActivityURI(),
coAuthorsForCurrentBiboDocument);
}
coAuthorsForCurrentBiboDocument.add(coAuthorNode);
Collaboration egoCoAuthorEdge =
getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO);
/*
* If "egoCoAuthorEdge" is null it means that no Collaboration exists in between the
* egoNode & current coAuthorNode. Else create a new Collaboration, add it to the edges
* set & add the collaborator document to it.
* */
if (egoCoAuthorEdge != null) {
egoCoAuthorEdge.addActivity(biboDocument);
} else {
egoCoAuthorEdge =
new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
edges.add(egoCoAuthorEdge);
edgeUniqueIdentifierToVO.put(
getEdgeUniqueIdentifier(egoNode.getCollaboratorID(),
coAuthorNode.getCollaboratorID()),
egoCoAuthorEdge);
}
}
/*
* 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
* insight. However, we have left the documents be.
*
* This method side-effects "nodes" & "edges".
* */
removeLowQualityNodesAndEdges(nodes,
biboDocumentURLToVO,
biboDocumentURLToCoAuthors,
edges);
/*
* 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
* ego - B
* The below sub-routine will take care of,
* A - B
*
* We are side-effecting "edges" here. The only reason to do this is because we are adding
* edges en masse for all the co-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
* & co-author edges created during the course of this method) when we are creating a new
* Collaboration.
* */
createCoAuthorEdges(biboDocumentURLToVO,
biboDocumentURLToCoAuthors,
edges,
edgeUniqueIdentifierToVO);
return new CoAuthorshipData(egoNode, nodes, edges);
}
private void removeLowQualityNodesAndEdges(
Set<Collaborator> nodes,
Map<String, Activity> biboDocumentURLToVO,
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors,
Set<Collaboration> edges) {
Set<Collaborator> nodesToBeRemoved = new HashSet<Collaborator>();
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
: biboDocumentURLToCoAuthors.entrySet()) {
if (currentBiboDocumentEntry.getValue().size() > MAX_AUTHORS_PER_PAPER_ALLOWED) {
Activity currentBiboDocument = biboDocumentURLToVO
.get(currentBiboDocumentEntry.getKey());
Set<Collaboration> edgesToBeRemoved = new HashSet<Collaboration>();
for (Collaboration currentEdge : edges) {
Set<Activity> currentCollaboratorDocuments =
currentEdge.getCollaborationActivities();
if (currentCollaboratorDocuments.contains(currentBiboDocument)) {
currentCollaboratorDocuments.remove(currentBiboDocument);
if (currentCollaboratorDocuments.isEmpty()) {
edgesToBeRemoved.add(currentEdge);
}
}
}
edges.removeAll(edgesToBeRemoved);
for (Collaborator currentCoAuthor : currentBiboDocumentEntry.getValue()) {
currentCoAuthor.getCollaboratorActivities().remove(currentBiboDocument);
if (currentCoAuthor.getCollaboratorActivities().isEmpty()) {
nodesToBeRemoved.add(currentCoAuthor);
}
}
}
}
nodes.removeAll(nodesToBeRemoved);
}
private void createCoAuthorEdges(
Map<String, Activity> biboDocumentURLToVO,
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors, Set<Collaboration> edges,
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
: biboDocumentURLToCoAuthors.entrySet()) {
/*
* 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.
*
* 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
* & causes unnecessary computations causing the server to time-out.
* */
if (currentBiboDocumentEntry.getValue().size() > 1
&& currentBiboDocumentEntry.getValue().size()
<= MAX_AUTHORS_PER_PAPER_ALLOWED) {
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
/*
* In order to leverage the nested "for loop" for making edges between all the
* co-authors we need to create a list out of the set first.
* */
List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator());
int numOfCoAuthors = coAuthorNodes.size();
for (int ii = 0; ii < numOfCoAuthors - 1; ii++) {
for (int jj = ii + 1; jj < numOfCoAuthors; jj++) {
Collaborator coAuthor1 = coAuthorNodes.get(ii);
Collaborator coAuthor2 = coAuthorNodes.get(jj);
Collaboration coAuthor1_2Edge = getExistingEdge(coAuthor1,
coAuthor2,
edgeUniqueIdentifierToVO);
Activity currentBiboDocument = biboDocumentURLToVO
.get(currentBiboDocumentEntry
.getKey());
if (coAuthor1_2Edge != null) {
coAuthor1_2Edge.addActivity(currentBiboDocument);
} else {
coAuthor1_2Edge = new Collaboration(coAuthor1,
coAuthor2,
currentBiboDocument,
edgeIDGenerator);
newlyAddedEdges.add(coAuthor1_2Edge);
edgeUniqueIdentifierToVO.put(
getEdgeUniqueIdentifier(coAuthor1.getCollaboratorID(),
coAuthor2.getCollaboratorID()),
coAuthor1_2Edge);
}
}
}
edges.addAll(newlyAddedEdges);
}
}
}
private Collaboration getExistingEdge(
Collaborator collaboratingNode1,
Collaborator collaboratingNode2,
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
collaboratingNode1.getCollaboratorID(),
collaboratingNode2.getCollaboratorID());
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
}
private String getEdgeUniqueIdentifier(int nodeID1, int nodeID2) {
String separator = "*";
if (nodeID1 < nodeID2) {
return nodeID1 + separator + nodeID2;
} else {
return nodeID2 + separator + nodeID1;
}
}
private Activity createDocumentVO(QuerySolution solution, String documentURL) {
Activity biboDocument = new Activity(documentURL);
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString());
}
return biboDocument;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT \n"
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?"
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . \n"
+ "?document core:informationResourceInAuthorship ?coAuthorshipNode . \n"
+ "?coAuthorshipNode core:linkedAuthor ?coAuthorPerson . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n";
log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
return sparqlQuery;
}
public CollaborationData getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.egoURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Ego Co-Authorship Vis Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI),
this.dataset);
return createQueryResult(resultSet);
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.coauthorship;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import 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.CollaboratorComparator;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
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.visutils.QueryRunner;
import edu.cornell.mannlib.vitro.webapp.visualization.visutils.UniqueIDGenerator;
/**
* 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
* on that particular publication.
*
* @author cdtank
*/
public class CoAuthorshipQueryRunner implements QueryRunner<CollaborationData> {
private static final int MAX_AUTHORS_PER_PAPER_ALLOWED = 100;
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String egoURI;
private Dataset dataset;
private Log log;
private UniqueIDGenerator nodeIDGenerator;
private UniqueIDGenerator edgeIDGenerator;
public CoAuthorshipQueryRunner(String egoURI,
Dataset dataset, Log log) {
this.egoURI = egoURI;
this.dataset = dataset;
this.log = log;
this.nodeIDGenerator = new UniqueIDGenerator();
this.edgeIDGenerator = new UniqueIDGenerator();
}
private CollaborationData createQueryResult(ResultSet resultSet) {
Set<Collaborator> nodes = new HashSet<Collaborator>();
Map<String, Activity> biboDocumentURLToVO = new HashMap<String, Activity>();
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors =
new HashMap<String, Set<Collaborator>>();
Map<String, Collaborator> nodeURLToVO = new HashMap<String, Collaborator>();
Map<String, Collaboration> edgeUniqueIdentifierToVO = new HashMap<String, Collaboration>();
Collaborator egoNode = null;
Set<Collaboration> edges = new HashSet<Collaboration>();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
/*
* We only want to create only ONE ego node.
* */
RDFNode egoAuthorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
if (nodeURLToVO.containsKey(egoAuthorURLNode.toString())) {
egoNode = nodeURLToVO.get(egoAuthorURLNode.toString());
} else {
egoNode = new Collaborator(egoAuthorURLNode.toString(), nodeIDGenerator);
nodes.add(egoNode);
nodeURLToVO.put(egoAuthorURLNode.toString(), egoNode);
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
if (authorLabelNode != null) {
egoNode.setCollaboratorName(authorLabelNode.toString());
}
}
RDFNode documentNode = solution.get(QueryFieldLabels.DOCUMENT_URL);
Activity biboDocument;
if (biboDocumentURLToVO.containsKey(documentNode.toString())) {
biboDocument = biboDocumentURLToVO.get(documentNode.toString());
} else {
biboDocument = createDocumentVO(solution, documentNode.toString());
biboDocumentURLToVO.put(documentNode.toString(), biboDocument);
}
egoNode.addActivity(biboDocument);
/*
* 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
* author and that happens to be the ego.
* */
if (solution.get(QueryFieldLabels.AUTHOR_URL).toString().equalsIgnoreCase(
solution.get(QueryFieldLabels.CO_AUTHOR_URL).toString())) {
continue;
}
Collaborator coAuthorNode;
RDFNode coAuthorURLNode = solution.get(QueryFieldLabels.CO_AUTHOR_URL);
if (nodeURLToVO.containsKey(coAuthorURLNode.toString())) {
coAuthorNode = nodeURLToVO.get(coAuthorURLNode.toString());
} else {
coAuthorNode = new Collaborator(coAuthorURLNode.toString(), nodeIDGenerator);
nodes.add(coAuthorNode);
nodeURLToVO.put(coAuthorURLNode.toString(), coAuthorNode);
RDFNode coAuthorLabelNode = solution.get(QueryFieldLabels.CO_AUTHOR_LABEL);
if (coAuthorLabelNode != null) {
coAuthorNode.setCollaboratorName(coAuthorLabelNode.toString());
}
}
coAuthorNode.addActivity(biboDocument);
Set<Collaborator> coAuthorsForCurrentBiboDocument;
if (biboDocumentURLToCoAuthors.containsKey(biboDocument.getActivityURI())) {
coAuthorsForCurrentBiboDocument = biboDocumentURLToCoAuthors
.get(biboDocument.getActivityURI());
} else {
coAuthorsForCurrentBiboDocument = new HashSet<Collaborator>();
biboDocumentURLToCoAuthors.put(biboDocument.getActivityURI(),
coAuthorsForCurrentBiboDocument);
}
coAuthorsForCurrentBiboDocument.add(coAuthorNode);
Collaboration egoCoAuthorEdge =
getExistingEdge(egoNode, coAuthorNode, edgeUniqueIdentifierToVO);
/*
* If "egoCoAuthorEdge" is null it means that no Collaboration exists in between the
* egoNode & current coAuthorNode. Else create a new Collaboration, add it to the edges
* set & add the collaborator document to it.
* */
if (egoCoAuthorEdge != null) {
egoCoAuthorEdge.addActivity(biboDocument);
} else {
egoCoAuthorEdge =
new Collaboration(egoNode, coAuthorNode, biboDocument, edgeIDGenerator);
edges.add(egoCoAuthorEdge);
edgeUniqueIdentifierToVO.put(
getEdgeUniqueIdentifier(egoNode.getCollaboratorID(),
coAuthorNode.getCollaboratorID()),
egoCoAuthorEdge);
}
}
/*
* 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
* insight. However, we have left the documents be.
*
* This method side-effects "nodes" & "edges".
* */
removeLowQualityNodesAndEdges(nodes,
biboDocumentURLToVO,
biboDocumentURLToCoAuthors,
edges);
/*
* 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
* ego - B
* The below sub-routine will take care of,
* A - B
*
* We are side-effecting "edges" here. The only reason to do this is because we are adding
* edges en masse for all the co-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
* & co-author edges created during the course of this method) when we are creating a new
* Collaboration.
* */
createCoAuthorEdges(biboDocumentURLToVO,
biboDocumentURLToCoAuthors,
edges,
edgeUniqueIdentifierToVO);
return new CoAuthorshipData(egoNode, nodes, edges);
}
private void removeLowQualityNodesAndEdges(
Set<Collaborator> nodes,
Map<String, Activity> biboDocumentURLToVO,
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors,
Set<Collaboration> edges) {
Set<Collaborator> nodesToBeRemoved = new HashSet<Collaborator>();
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
: biboDocumentURLToCoAuthors.entrySet()) {
if (currentBiboDocumentEntry.getValue().size() > MAX_AUTHORS_PER_PAPER_ALLOWED) {
Activity currentBiboDocument = biboDocumentURLToVO
.get(currentBiboDocumentEntry.getKey());
Set<Collaboration> edgesToBeRemoved = new HashSet<Collaboration>();
for (Collaboration currentEdge : edges) {
Set<Activity> currentCollaboratorDocuments =
currentEdge.getCollaborationActivities();
if (currentCollaboratorDocuments.contains(currentBiboDocument)) {
currentCollaboratorDocuments.remove(currentBiboDocument);
if (currentCollaboratorDocuments.isEmpty()) {
edgesToBeRemoved.add(currentEdge);
}
}
}
edges.removeAll(edgesToBeRemoved);
for (Collaborator currentCoAuthor : currentBiboDocumentEntry.getValue()) {
currentCoAuthor.getCollaboratorActivities().remove(currentBiboDocument);
if (currentCoAuthor.getCollaboratorActivities().isEmpty()) {
nodesToBeRemoved.add(currentCoAuthor);
}
}
}
}
nodes.removeAll(nodesToBeRemoved);
}
private void createCoAuthorEdges(
Map<String, Activity> biboDocumentURLToVO,
Map<String, Set<Collaborator>> biboDocumentURLToCoAuthors, Set<Collaboration> edges,
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
for (Map.Entry<String, Set<Collaborator>> currentBiboDocumentEntry
: biboDocumentURLToCoAuthors.entrySet()) {
/*
* 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.
*
* 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
* & causes unnecessary computations causing the server to time-out.
* */
if (currentBiboDocumentEntry.getValue().size() > 1
&& currentBiboDocumentEntry.getValue().size()
<= MAX_AUTHORS_PER_PAPER_ALLOWED) {
Set<Collaboration> newlyAddedEdges = new HashSet<Collaboration>();
/*
* In order to leverage the nested "for loop" for making edges between all the
* co-authors we need to create a list out of the set first.
* */
List<Collaborator> coAuthorNodes =
new ArrayList<Collaborator>(currentBiboDocumentEntry.getValue());
Collections.sort(coAuthorNodes, new CollaboratorComparator());
int numOfCoAuthors = coAuthorNodes.size();
for (int ii = 0; ii < numOfCoAuthors - 1; ii++) {
for (int jj = ii + 1; jj < numOfCoAuthors; jj++) {
Collaborator coAuthor1 = coAuthorNodes.get(ii);
Collaborator coAuthor2 = coAuthorNodes.get(jj);
Collaboration coAuthor1_2Edge = getExistingEdge(coAuthor1,
coAuthor2,
edgeUniqueIdentifierToVO);
Activity currentBiboDocument = biboDocumentURLToVO
.get(currentBiboDocumentEntry
.getKey());
if (coAuthor1_2Edge != null) {
coAuthor1_2Edge.addActivity(currentBiboDocument);
} else {
coAuthor1_2Edge = new Collaboration(coAuthor1,
coAuthor2,
currentBiboDocument,
edgeIDGenerator);
newlyAddedEdges.add(coAuthor1_2Edge);
edgeUniqueIdentifierToVO.put(
getEdgeUniqueIdentifier(coAuthor1.getCollaboratorID(),
coAuthor2.getCollaboratorID()),
coAuthor1_2Edge);
}
}
}
edges.addAll(newlyAddedEdges);
}
}
}
private Collaboration getExistingEdge(
Collaborator collaboratingNode1,
Collaborator collaboratingNode2,
Map<String, Collaboration> edgeUniqueIdentifierToVO) {
String edgeUniqueIdentifier = getEdgeUniqueIdentifier(
collaboratingNode1.getCollaboratorID(),
collaboratingNode2.getCollaboratorID());
return edgeUniqueIdentifierToVO.get(edgeUniqueIdentifier);
}
private String getEdgeUniqueIdentifier(int nodeID1, int nodeID2) {
String separator = "*";
if (nodeID1 < nodeID2) {
return nodeID1 + separator + nodeID2;
} else {
return nodeID2 + separator + nodeID1;
}
}
private Activity createDocumentVO(QuerySolution solution, String documentURL) {
Activity biboDocument = new Activity(documentURL);
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString());
}
return biboDocument;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateEgoCoAuthorshipSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT \n"
+ " (str(<" + queryURI + ">) as ?" + QueryFieldLabels.AUTHOR_URL + ") \n"
+ " (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?coAuthorPerson) as ?" + QueryFieldLabels.CO_AUTHOR_URL + ") \n"
+ " (str(?coAuthorPersonLabel) as ?" + QueryFieldLabels.CO_AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?"
+ QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ") \n"
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;"
+ " rdfs:label ?authorLabel ;"
+ " core:relatedBy ?authorshipNode . \n"
+ "?authorshipNode rdf:type core:Authorship ;"
+ " core:relates ?document . \n"
+ "?document rdf:type bibo:Document . \n"
+ "?document core:relatedBy ?coAuthorshipNode . \n"
+ "?coAuthorshipNode rdf:type core:Authorship . \n"
+ "?coAuthorshipNode core:relates ?coAuthorPerson . \n"
+ "?coAuthorPerson rdf:type foaf:Person . \n"
+ "?coAuthorPerson rdfs:label ?coAuthorPersonLabel . \n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n"
+ "} \n"
+ "ORDER BY ?document ?coAuthorPerson\n";
log.debug("COAUTHORSHIP QUERY - " + sparqlQuery);
return sparqlQuery;
}
public CollaborationData getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.egoURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.egoURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Ego Co-Authorship Vis Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(generateEgoCoAuthorshipSparqlQuery(this.egoURI),
this.dataset);
return createQueryResult(resultSet);
}
}

View file

@ -38,9 +38,9 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
.getLog(CoPIGrantCountConstructQueryRunner.class.getName());
private static final String SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING =
"?Role core:roleContributesTo ?Grant . "
// + "?Grant rdfs:label ?GrantLabel . "
+ "?Grant core:contributingRole ?RelatedRole . ";
"?Role core:relatedBy ?Grant . "
+ "?Grant rdf:type core:Grant ."
+ "?Grant core:relates ?RelatedRole . ";
public CoPIGrantCountConstructQueryRunner(String egoURI, Dataset dataset,
Log log) {
@ -59,23 +59,31 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
}
private String generateConstructQueryForInvestigatorRoleOfProperty(
String queryURI, String preboundProperty) {
String queryURI, String preboundProperty, String preboundRoleType) {
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
+ preboundProperty + " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ 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 . " + "}"
+ "WHERE { " + "<" + queryURI + ">" + preboundProperty
+ " ?Role . " + SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
+ "?RelatedRole core:investigatorRoleOf ?coInvestigator ."
+ "?coInvestigator rdfs:label ?coInvestigatorLabel . " + "}";
+ "WHERE { " + "<" + queryURI + ">" + preboundProperty + " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ SPARQL_QUERY_COMMON_CONSTRUCT_AND_WHERE_STRING
+ "?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;
}
private String generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
String queryURI, String preboundProperty) {
String queryURI, String preboundProperty, String preboundRoleType) {
String sparqlQuery = "CONSTRUCT { "
+ "<"
@ -83,8 +91,11 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ 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 . "
+ "}"
+ "WHERE { "
@ -93,15 +104,18 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ 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 . " + "}";
return sparqlQuery;
}
private String generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
String queryURI, String preboundProperty) {
String queryURI, String preboundProperty, String preboundRoleType) {
String sparqlQuery = "CONSTRUCT { "
+ "<"
@ -109,8 +123,11 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ 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 . "
+ "}"
+ "WHERE { "
@ -119,18 +136,22 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ 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 . " + "}";
return sparqlQuery;
}
private String generateConstructQueryForDateTimeValueofRole(
String queryURI, String preboundProperty) {
String queryURI, String preboundProperty, String preboundRoleType) {
String sparqlQuery = "CONSTRUCT { " + "<" + queryURI + ">"
+ preboundProperty + " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
@ -139,6 +160,7 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ "}"
+ "WHERE { " + "{" + "<" + queryURI + ">" + preboundProperty
+ " ?Role . "
+ "?Role rdf:type " + preboundRoleType + " . "
+ "?Role core:dateTimeInterval ?dateTimeIntervalValue . "
+ "?dateTimeIntervalValue core:start ?startDate . "
+ "?startDate core:dateTime ?startDateTimeValue . "
@ -153,14 +175,16 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
}
private String generateConstructQueryForDateTimeValueofGrant(
String queryURI, String preboundProperty) {
String queryURI, String preboundProperty, String preboundRoleType) {
String sparqlQuery = "CONSTRUCT { " + "<"
+ queryURI
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleContributesTo ?Grant ."
+ "?Role rdf:type " + preboundRoleType + " . "
+ "?Role core:relatedBy ?Grant ."
+ "?Grant rdf:type core:Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
@ -174,7 +198,9 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
+ ">"
+ preboundProperty
+ " ?Role . "
+ "?Role core:roleContributesTo ?Grant ."
+ "?Role rdf:type " + preboundRoleType + " . "
+ "?Role core:relatedBy ?Grant ."
+ "?Grant rdf:type core:Grant ."
+ "?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
+ "?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ "?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
@ -268,45 +294,45 @@ public class CoPIGrantCountConstructQueryRunner implements ModelConstructor {
.add(generateConstructQueryForInvestigatorLabel(this.egoURI));
constructQueries
.add(generateConstructQueryForInvestigatorRoleOfProperty(
this.egoURI, "core:hasInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
constructQueries
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
constructQueries
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:InvestigatorRole"));
constructQueries
.add(generateConstructQueryForInvestigatorRoleOfProperty(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasPrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:PrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForInvestigatorRoleOfProperty(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForCoPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
constructQueries
.add(generateConstructQueryForPrincipalInvestigatorRoleOfProperty(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofRole(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
constructQueries.add(generateConstructQueryForDateTimeValueofGrant(
this.egoURI, "core:hasCo-PrincipalInvestigatorRole"));
this.egoURI, "<http://purl.obolibrary.org/obo/RO_0000053>", "core:CoPrincipalInvestigatorRole"));
}
}

View file

@ -113,13 +113,21 @@ public class CoPIGrantCountQueryRunner implements QueryRunner<CollaborationData>
+ "<" + 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 . "
@ -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 . "
@ -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 . "
@ -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 . "
@ -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 . "
@ -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 . "
@ -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 . "
@ -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 . "
@ -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 . "

View file

@ -53,8 +53,9 @@ public class OrganizationAssociatedPeopleModelWithTypesConstructor implements Mo
+ " <" + organizationURI + "> rdf:type foaf:Organization . "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " OPTIONAL { "
+ " <" + organizationURI + "> core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person . "
+ " <" + organizationURI + "> core:relatedBy ?Position . "
+ " ?Position rdf:type core:Position . "
+ " ?Position core:relates ?Person . "
+ " ?Person rdfs:label ?personLabel. "
+ " ?Person rdf:type ?personType . "
+ " ?personType rdfs:label ?personTypeLabel . "

View file

@ -50,7 +50,8 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
+ " CONSTRUCT { "
+ " ?organization rdf:type foaf:Organization . "
+ " ?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 rdf:type ?subOrganizationType . "
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "
@ -60,7 +61,8 @@ public class OrganizationModelWithTypesConstructor implements ModelConstructor {
+ " ?organization rdfs:label ?organizationLabel . "
+ " "
+ " OPTIONAL { "
+ " ?organization core:hasSubOrganization ?subOrganization . "
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrganization . "
+ " ?subOrganization rdf:type foaf:Organization . "
+ " ?subOrganization rdfs:label ?subOrganizationLabel . "
+ " ?subOrganization rdf:type ?subOrganizationType . "
+ " ?subOrganizationType rdfs:label ?subOrganizationTypeLabel . "

View file

@ -1,189 +1,204 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class OrganizationToGrantsForSubOrganizationsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
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";
private String organizationURI;
private Log log = LogFactory.getLog(OrganizationToGrantsForSubOrganizationsModelConstructor.class.getName());
private long before, after;
public OrganizationToGrantsForSubOrganizationsModelConstructor(String organizationURI, Dataset dataset) {
this.organizationURI = organizationURI;
this.dataset = dataset;
}
private Set<String> constructOrganizationGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " <" + organizationURI + "> vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
+ " ?subOrganization core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person . "
+ " ?Person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
+ " ?subOrganization core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person . "
+ " ?Person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
+ " ?subOrganization core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person . "
+ " ?Person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructOrganizationToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "hasInvestigatorRole");
Set<String> piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "hasPrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "hasCo-PrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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());
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class OrganizationToGrantsForSubOrganizationsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
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";
private String organizationURI;
private Log log = LogFactory.getLog(OrganizationToGrantsForSubOrganizationsModelConstructor.class.getName());
private long before, after;
public OrganizationToGrantsForSubOrganizationsModelConstructor(String organizationURI, Dataset dataset) {
this.organizationURI = organizationURI;
this.dataset = dataset;
}
private Set<String> constructOrganizationGrantsQueryTemplate(String constructProperty, String roleType) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " <" + organizationURI + "> vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
+ " ?subOrganization rdf:type foaf:Organization . "
+ " ?subOrganization core:relatedBy ?Position . "
+ " ?Position rdf:type core:Position . "
+ " ?Position core:relates ?Person . "
+ " ?Person rdf:type foaf:Person . "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
+ " ?subOrganization rdf:type foaf:Organization . "
+ " ?subOrganization core:relatedBy ?Position . "
+ " ?Position rdf:type core:Position . "
+ " ?Position core:relates ?Person . "
+ " ?Person rdf:type foaf:Person . "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> vivosocnet:lastCachedAt ?now . "
+ " "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
+ " ?subOrganization rdf:type foaf:Organization . "
+ " ?subOrganization core:relatedBy ?Position . "
+ " ?Position rdf:type core:Position . "
+ " ?Position core:relates ?Person . "
+ " ?Person rdf:type foaf:Person . "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructOrganizationToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructOrganizationGrantsQueryTemplate("hasInvestigatorWithGrant", "InvestigatorRole");
Set<String> piRoleQuery = constructOrganizationGrantsQueryTemplate("hasPIWithGrant", "PrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructOrganizationGrantsQueryTemplate("hascoPIWithGrant", "CoPrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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());
}
}

View file

@ -53,11 +53,16 @@ public class OrganizationToPublicationsForSubOrganizationsModelConstructor imple
+ " } "
+ " WHERE { "
+ " <" + organizationURI + "> rdfs:label ?organizationLabel . "
+ " <" + organizationURI + "> core:hasSubOrganization* ?subOrganization . "
+ " ?subOrganization core:organizationForPosition ?Position . "
+ " ?Position core:positionForPerson ?Person . "
+ " ?Person core:authorInAuthorship ?Resource . "
+ " ?Resource core:linkedInformationResource ?Document . "
+ " <" + organizationURI + "> <http://purl.obolibrary.org/obo/BFO_0000051>* ?subOrganization . "
+ " ?subOrganization rdf:type foaf:Organization . "
+ " ?subOrganization core:relatedBy ?Position . "
+ " ?Position rdf:type core:Position . "
+ " ?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 . "
+ " "
+ " OPTIONAL { "

View file

@ -1,171 +1,177 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class PeopleToGrantsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
public static final String MODEL_TYPE = "PEOPLE_TO_GRANTS";
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for all people via all roles";
private Log log = LogFactory.getLog(PeopleToGrantsModelConstructor.class.getName());
private long before, after;
public PeopleToGrantsModelConstructor(Dataset dataset) {
this.dataset = dataset;
}
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " ?person vivosocnet:lastCachedAt ?now . "
+ " ?person vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " ?person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " ?person vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " ?person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " ?person vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " ?person core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructPeopleToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "hasInvestigatorRole");
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "hasPrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "hasCo-PrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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(constructPeopleToGrantsQuery());
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class PeopleToGrantsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
public static final String MODEL_TYPE = "PEOPLE_TO_GRANTS";
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for all people via all roles";
private Log log = LogFactory.getLog(PeopleToGrantsModelConstructor.class.getName());
private long before, after;
public PeopleToGrantsModelConstructor(Dataset dataset) {
this.dataset = dataset;
}
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " ?Person vivosocnet:lastCachedAt ?now . "
+ " ?Person vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " ?Person vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " ?Person vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " ?Person <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructPeopleToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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(constructPeopleToGrantsQuery());
}
}

View file

@ -48,8 +48,11 @@ public class PeopleToPublicationsModelConstructor implements ModelConstructor {
+ " ?journal rdfs:label ?journalLabel . "
+ " } "
+ " WHERE { "
+ " ?person core:authorInAuthorship ?Resource . "
+ " ?Resource core:linkedInformationResource ?Document . "
+ " ?person core:relatedBy ?Resource . "
+ " ?person rdf:type foaf:Person . "
+ " ?Resource rdf:type core:Authorship . "
+ " ?Resource core:relates ?Document . "
+ " ?Document rdf:type bibo:Document . "
+ " ?Document rdfs:label ?DocumentLabel . "
+ " "
+ " OPTIONAL { "

View file

@ -1,174 +1,180 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class PersonToGrantsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
public static final String MODEL_TYPE = "PERSON_TO_GRANTS";
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
private String personURI;
private Log log = LogFactory.getLog(PersonToGrantsModelConstructor.class.getName());
private long before, after;
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
this.personURI = personURI;
this.dataset = dataset;
}
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleTypeProperty) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> core:" + roleTypeProperty + " ?Role . "
+ " ?Role core:roleContributesTo ?Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructPersonToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "hasInvestigatorRole");
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "hasPrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "hasCo-PrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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(constructPersonToGrantsQuery());
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.modelconstructor;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
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.visutils.ModelConstructor;
public class PersonToGrantsModelConstructor implements ModelConstructor {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private Dataset dataset;
public static final String MODEL_TYPE = "PERSON_TO_GRANTS";
public static final String MODEL_TYPE_HUMAN_READABLE = "Grants for specific person via all roles";
private String personURI;
private Log log = LogFactory.getLog(PersonToGrantsModelConstructor.class.getName());
private long before, after;
public PersonToGrantsModelConstructor(String personURI, Dataset dataset) {
this.personURI = personURI;
this.dataset = dataset;
}
private Set<String> constructPersonGrantsQueryTemplate(String constructProperty, String roleType) {
Set<String> differentPerspectiveQueries = new HashSet<String>();
String justGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " <" + personURI + "> vivosocnet:" + constructProperty + " ?Grant . "
+ " "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " ?Grant rdfs:label ?grantLabel . "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnGrantsQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnGrant ?startDateTimeValueForGrant . "
// + " ?Grant vivosocnet:endDateTimeOnGrant ?endDateTimeValueForGrant . "
+ " "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Grant core:dateTimeInterval ?dateTimeIntervalValueForGrant . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValueForGrant core:start ?startDateForGrant . "
+ " ?startDateForGrant core:dateTime ?startDateTimeValueForGrant . "
// + " } "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValueForGrant core:end ?endDateForGrant . "
// + " ?endDateForGrant core:dateTime ?endDateTimeValueForGrant "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
String justDateTimeOnRolesQuery = ""
+ " CONSTRUCT { "
+ " <" + personURI + "> vivosocnet:lastCachedAt ?now . "
+ " ?Grant vivosocnet:startDateTimeOnRole ?startDateTimeValue . "
// + " ?Grant vivosocnet:endDateTimeOnRole ?endDateTimeValue . "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> <http://purl.obolibrary.org/obo/RO_0000053> ?Role . "
+ " ?Role rdf:type core:" + roleType + " . "
+ " ?Role core:relatedBy ?Grant . "
+ " ?Grant rdf:type core:Grant . "
+ " "
+ " ?Role core:dateTimeInterval ?dateTimeIntervalValue . "
// + " OPTIONAL { "
+ " ?dateTimeIntervalValue core:start ?startDate . "
+ " ?startDate core:dateTime ?startDateTimeValue . "
// + " } "
// + " "
// + " OPTIONAL { "
// + " ?dateTimeIntervalValue core:end ?endDate . "
// + " ?endDate core:dateTime ?endDateTimeValue . "
// + " } "
+ " "
+ " LET(?now := afn:now()) "
+ " } ";
differentPerspectiveQueries.add(justGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnGrantsQuery);
differentPerspectiveQueries.add(justDateTimeOnRolesQuery);
return differentPerspectiveQueries;
}
private Set<String> constructPersonToGrantsQuery() {
Set<String> differentInvestigatorTypeQueries = new HashSet<String>();
Set<String> investigatorRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsAnInvestigator", "InvestigatorRole");
Set<String> piRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsPI", "PrincipalInvestigatorRole");
Set<String> coPIRoleQuery = constructPersonGrantsQueryTemplate("hasGrantAsCoPI", "CoPrincipalInvestigatorRole");
differentInvestigatorTypeQueries.addAll(investigatorRoleQuery);
differentInvestigatorTypeQueries.addAll(piRoleQuery);
differentInvestigatorTypeQueries.addAll(coPIRoleQuery);
return differentInvestigatorTypeQueries;
}
private Model executeQuery(Set<String> constructQueries) {
Model constructedModel = ModelFactory.createDefaultModel();
before = System.currentTimeMillis();
log.debug("CONSTRUCT query string : " + constructQueries);
for (String currentQuery : constructQueries) {
Query query = null;
try {
query = QueryFactory.create(QueryConstants.getSparqlPrefixQuery() + currentQuery, SYNTAX);
} catch (Throwable th) {
log.error("Could not create CONSTRUCT SPARQL query for query "
+ "string. " + th.getMessage());
log.error(currentQuery);
}
QueryExecution qe = QueryExecutionFactory.create(query, dataset);
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(constructPersonToGrantsQuery());
}
}

View file

@ -51,8 +51,10 @@ public class PersonToPublicationsModelConstructor implements ModelConstructor {
+ " ?journal rdfs:label ?journalLabel . "
+ " } "
+ " WHERE { "
+ " <" + personURI + "> core:authorInAuthorship ?Resource . "
+ " ?Resource core:linkedInformationResource ?Document . "
+ " <" + personURI + "> core:relatedBy ?Resource . "
+ " ?Resource rdf:type core:Authorship . "
+ " ?Resource core:relates ?Document . "
+ " ?Document rdf:type bibo:Document . "
+ " ?Document rdfs:label ?DocumentLabel . "
+ " "
+ " OPTIONAL { "

View file

@ -50,7 +50,8 @@ public class SubOrganizationWithinModelConstructor implements ModelConstructor {
+ " CONSTRUCT { "
+ " ?organization rdf:type foaf:Organization . "
+ " ?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 . "
+ " } "
+ " WHERE { "
@ -58,7 +59,8 @@ public class SubOrganizationWithinModelConstructor implements ModelConstructor {
+ " ?organization rdfs:label ?organizationLabel . "
+ " "
+ " OPTIONAL { "
+ " ?organization core:subOrganizationWithin ?parentOrganization . "
+ " ?organization <http://purl.obolibrary.org/obo/BFO_0000050> ?parentOrganization . "
+ " ?parentOrganization rdf:type foaf:Organization . "
+ " ?parentOrganization rdfs:label ?parentOrganizationLabel . "
+ " } "
+ " } ";

View file

@ -1,162 +1,163 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.personpubcount;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
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
* defined by bibo:Document property for a particular individual.
*
* @author cdtank
*/
public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activity>> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI;
private Dataset dataset;
private Individual author;
public Individual getAuthor() {
return author;
}
private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")\n";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n";
public PersonPublicationCountQueryRunner(String personURI,
Dataset dataset, Log log) {
this.personURI = personURI;
this.dataset = dataset;
this.log = log;
}
private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
Set<Activity> authorDocuments = new HashSet<Activity>();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
Activity biboDocument = new Activity(
solution.get(QueryFieldLabels.DOCUMENT_URL)
.toString());
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString());
}
/*
* 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
* make sure that it has not already been instantiated.
* */
RDFNode authorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
if (authorURLNode != null && author == null) {
author = new Individual(authorURLNode.toString());
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
if (authorLabelNode != null) {
author.setIndividualLabel(authorLabelNode.toString());
}
}
authorDocuments.add(biboDocument);
}
return authorDocuments;
}
private ResultSet executeQuery(String queryURI,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String getSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
+ "(str(<" + queryURI + ">) as ?authPersonLit)\n "
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;\n"
+ " rdfs:label ?authorLabel \n;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ " ?authorshipNode rdf:type core:Authorship ;"
+ " core:linkedInformationResource ?document . \n"
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}\n";
log.debug(sparqlQuery);
return sparqlQuery;
}
public Set<Activity> getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.personURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.personURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Pub Count vis Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URL parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(this.personURI,
this.dataset);
return createJavaValueObjects(resultSet);
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.personpubcount;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Activity;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.Individual;
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
* defined by bibo:Document property for a particular individual.
*
* @author cdtank
*/
public class PersonPublicationCountQueryRunner implements QueryRunner<Set<Activity>> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String personURI;
private Dataset dataset;
private Individual author;
public Individual getAuthor() {
return author;
}
private Log log;
private static final String SPARQL_QUERY_COMMON_SELECT_CLAUSE = ""
+ "SELECT (str(?authorLabel) as ?" + QueryFieldLabels.AUTHOR_LABEL + ") \n"
+ " (str(?document) as ?" + QueryFieldLabels.DOCUMENT_URL + ") \n"
+ " (str(?publicationDate) as ?" + QueryFieldLabels.DOCUMENT_PUBLICATION_DATE + ")\n";
private static final String SPARQL_QUERY_COMMON_WHERE_CLAUSE = ""
+ "?document rdfs:label ?documentLabel .\n"
+ "OPTIONAL { ?document core:dateTimeValue ?dateTimeValue . \n"
+ " ?dateTimeValue core:dateTime ?publicationDate } .\n";
public PersonPublicationCountQueryRunner(String personURI,
Dataset dataset, Log log) {
this.personURI = personURI;
this.dataset = dataset;
this.log = log;
}
private Set<Activity> createJavaValueObjects(ResultSet resultSet) {
Set<Activity> authorDocuments = new HashSet<Activity>();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
Activity biboDocument = new Activity(
solution.get(QueryFieldLabels.DOCUMENT_URL)
.toString());
RDFNode publicationDateNode = solution.get(QueryFieldLabels.DOCUMENT_PUBLICATION_DATE);
if (publicationDateNode != null) {
biboDocument.setActivityDate(publicationDateNode.toString());
}
/*
* 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
* make sure that it has not already been instantiated.
* */
RDFNode authorURLNode = solution.get(QueryFieldLabels.AUTHOR_URL);
if (authorURLNode != null && author == null) {
author = new Individual(authorURLNode.toString());
RDFNode authorLabelNode = solution.get(QueryFieldLabels.AUTHOR_LABEL);
if (authorLabelNode != null) {
author.setIndividualLabel(authorLabelNode.toString());
}
}
authorDocuments.add(biboDocument);
}
return authorDocuments;
}
private ResultSet executeQuery(String queryURI,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(getSparqlQuery(queryURI), SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String getSparqlQuery(String queryURI) {
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ SPARQL_QUERY_COMMON_SELECT_CLAUSE
+ "(str(<" + queryURI + ">) as ?authPersonLit)\n "
+ "WHERE { \n"
+ "<" + queryURI + "> rdf:type foaf:Person ;\n"
+ " rdfs:label ?authorLabel \n;"
+ " core:relatedBy ?authorshipNode . \n"
+ " ?authorshipNode rdf:type core:Authorship ;"
+ " core:relates ?document . \n"
+ " ?document rdf:type bibo:Document . \n"
+ SPARQL_QUERY_COMMON_WHERE_CLAUSE
+ "}\n";
log.debug(sparqlQuery);
return sparqlQuery;
}
public Set<Activity> getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.personURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.personURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Pub Count vis Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URL parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(this.personURI,
this.dataset);
return createJavaValueObjects(resultSet);
}
}

View file

@ -80,8 +80,10 @@ public class OrganizationUtilityFunctions {
String whereClause = "?organization rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel . \n"
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
+ "OPTIONAL { ?organization <http://purl.obolibrary.org/obo/BFO_0000051> ?subOrg . \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";
String groupOrderClause = "GROUP BY ?organization ?organizationLabel \n"

View file

@ -123,9 +123,10 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
String whereClause =
"<" + individualURI + "> rdf:type foaf:Person ;"
+ " core:authorInAuthorship ?authorshipNode . \n"
+ " core:relatedBy ?authorshipNode . \n"
+ "?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";
@ -152,16 +153,22 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
ObjectProperty predicate = ModelUtils.getPropertyForRoleInClass(grantType, vitroRequest.getWebappDaoFactory());
String roleToGrantPredicate = "<" + predicate.getURI() + ">";
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 . }"
+ "UNION \n"
+ "{ <" + 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 . }"
+ "UNION \n"
+ "{ <" + individualURI + "> rdf:type foaf:Person ;"
+ " core:hasInvestigatorRole ?Role . \n"
+ "?Role " + roleToGrantPredicate + " ?Grant . }";
+ " <http://purl.obolibrary.org/obo/RO_0000053> ?Role . \n"
+ "?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 =
new GenericQueryRunner(fieldLabelToOutputFieldLabel,
@ -302,9 +309,11 @@ public class UtilitiesRequestHandler implements VisualizationRequestHandler {
String whereClause = "?organization rdf:type foaf:Organization ;"
+ " rdfs:label ?organizationLabel . \n"
+ "OPTIONAL { ?organization core:hasSubOrganization ?subOrg } . \n"
+ "OPTIONAL { ?organization core:subOrganizationWithin ?parent } . \n"
+ "FILTER ( !bound(?parent) ). \n";
+ "OPTIONAL { ?organization core:http://purl.obolibrary.org/obo/BFO_0000051 ?subOrg . \n"
+ " ?subOrg rdf:type foaf:Organization } . \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"
+ "ORDER BY DESC(?numOfChildren)\n"

View file

@ -1,134 +1,138 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
/**
* This query runner is used to execute a sparql query that will fetch all the
* properties available for the provided individual URI.
*
* @author cdtank
*/
public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String filterRule, individualURI;
private Dataset dataset;
private Log log;
public AllPropertiesQueryRunner(String individualURI,
String filterRule,
Dataset dataset,
Log log) {
this.individualURI = individualURI;
this.filterRule = filterRule;
this.dataset = dataset;
this.log = log;
}
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
GenericQueryMap queryResult = new GenericQueryMap();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
if (predicateNode != null && objectNode != null) {
queryResult.addEntry(predicateNode.toString(),
objectNode.toString());
}
}
return queryResult;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
// Resource uri1 = ResourceFactory.createResource(queryURI);
String filterClause;
if (StringUtils.isNotBlank(filterRule)) {
filterClause = "FILTER ( " + filterRule + " ) . ";
} else {
filterClause = "";
}
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT "
+ " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") "
+ " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") "
+ "WHERE { "
+ "<" + queryURI + "> ?predicate ?object. "
+ filterClause
+ "}";
return sparqlQuery;
}
public GenericQueryMap getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.individualURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.individualURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Generic Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
this.individualURI,
this.filterRule),
this.dataset);
return createJavaValueObjects(resultSet);
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.iri.Violation;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
import com.hp.hpl.jena.rdf.model.RDFNode;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryConstants;
import edu.cornell.mannlib.vitro.webapp.visualization.constants.QueryFieldLabels;
import edu.cornell.mannlib.vitro.webapp.visualization.exceptions.MalformedQueryParametersException;
import edu.cornell.mannlib.vitro.webapp.visualization.valueobjects.GenericQueryMap;
/**
* This query runner is used to execute a sparql query that will fetch all the
* properties available for the provided individual URI.
*
* @author cdtank
*/
public class AllPropertiesQueryRunner implements QueryRunner<GenericQueryMap> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String filterRule, individualURI;
private Dataset dataset;
private Log log = LogFactory.getLog(AllPropertiesQueryRunner.class.getName());
public AllPropertiesQueryRunner(String individualURI,
String filterRule,
Dataset dataset,
Log log) {
this.individualURI = individualURI;
this.filterRule = filterRule;
this.dataset = dataset;
this.log = log;
}
private GenericQueryMap createJavaValueObjects(ResultSet resultSet) {
GenericQueryMap queryResult = new GenericQueryMap();
while (resultSet.hasNext()) {
QuerySolution solution = resultSet.nextSolution();
RDFNode predicateNode = solution.get(QueryFieldLabels.PREDICATE);
RDFNode objectNode = solution.get(QueryFieldLabels.OBJECT);
if (predicateNode != null && objectNode != null) {
queryResult.addEntry(predicateNode.toString(),
objectNode.toString());
}
}
return queryResult;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery(String queryURI, String filterRule) {
// Resource uri1 = ResourceFactory.createResource(queryURI);
String filterClause;
if (StringUtils.isNotBlank(filterRule)) {
filterClause = "FILTER ( " + filterRule + " ) . ";
} else {
filterClause = "";
}
String sparqlQuery = QueryConstants.getSparqlPrefixQuery()
+ "SELECT "
+ " (str(?predicate) as ?" + QueryFieldLabels.PREDICATE + ") "
+ " (str(?object) as ?" + QueryFieldLabels.OBJECT + ") "
+ "WHERE { "
+ "<" + queryURI + "> ?predicate ?object. "
+ filterClause
+ "}";
log.debug("sparqlQuery = " + sparqlQuery.toString());
return sparqlQuery;
}
public GenericQueryMap getQueryResult()
throws MalformedQueryParametersException {
if (StringUtils.isNotBlank(this.individualURI)) {
/*
* To test for the validity of the URI submitted.
* */
IRIFactory iRIFactory = IRIFactory.jenaImplementation();
IRI iri = iRIFactory.create(this.individualURI);
if (iri.hasViolation(false)) {
String errorMsg = ((Violation) iri.violations(false).next()).getShortMessage();
log.error("Generic Query " + errorMsg);
throw new MalformedQueryParametersException(
"URI provided for an individual is malformed.");
}
} else {
throw new MalformedQueryParametersException("URI parameter is either null or empty.");
}
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(
this.individualURI,
this.filterRule),
this.dataset);
return createJavaValueObjects(resultSet);
}
}

View file

@ -1,98 +1,104 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import java.util.Map;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
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
*/
public class GenericQueryRunner implements QueryRunner<ResultSet> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String whereClause;
private Dataset dataset;
private Map<String, String> fieldLabelToOutputFieldLabel;
private String groupOrderClause;
private String aggregationRules;
public GenericQueryRunner(Map<String, String> fieldLabelToOutputFieldLabel,
String aggregationRules,
String whereClause,
String groupOrderClause,
Dataset dataset) {
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
this.aggregationRules = aggregationRules;
this.whereClause = whereClause;
this.groupOrderClause = groupOrderClause;
this.dataset = dataset;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery() {
StringBuilder sparqlQuery = new StringBuilder();
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
sparqlQuery.append("SELECT\n");
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
: this.fieldLabelToOutputFieldLabel.entrySet()) {
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
}
sparqlQuery.append("\n" + this.aggregationRules + "\n");
sparqlQuery.append("WHERE {\n");
sparqlQuery.append(this.whereClause);
sparqlQuery.append("}\n");
sparqlQuery.append(this.groupOrderClause);
return sparqlQuery.toString();
}
public ResultSet getQueryResult()
throws MalformedQueryParametersException {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.dataset);
return resultSet;
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
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
*/
public class GenericQueryRunner implements QueryRunner<ResultSet> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String whereClause;
private Dataset dataset;
private Map<String, String> fieldLabelToOutputFieldLabel;
private Log log = LogFactory.getLog(GenericQueryRunner.class.getName());
private String groupOrderClause;
private String aggregationRules;
public GenericQueryRunner(Map<String, String> fieldLabelToOutputFieldLabel,
String aggregationRules,
String whereClause,
String groupOrderClause,
Dataset dataset) {
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
this.aggregationRules = aggregationRules;
this.whereClause = whereClause;
this.groupOrderClause = groupOrderClause;
this.dataset = dataset;
}
private ResultSet executeQuery(String queryText,
Dataset dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery() {
StringBuilder sparqlQuery = new StringBuilder();
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
sparqlQuery.append("SELECT\n");
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
: this.fieldLabelToOutputFieldLabel.entrySet()) {
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
}
sparqlQuery.append("\n" + this.aggregationRules + "\n");
sparqlQuery.append("WHERE {\n");
sparqlQuery.append(this.whereClause);
sparqlQuery.append("}\n");
sparqlQuery.append(this.groupOrderClause);
log.debug("sparqlQuery = " + sparqlQuery.toString());
return sparqlQuery.toString();
}
public ResultSet getQueryResult()
throws MalformedQueryParametersException {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.dataset);
return resultSet;
}
}

View file

@ -1,97 +1,103 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import java.util.Map;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
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
*/
public class GenericQueryRunnerOnModel implements QueryRunner<ResultSet> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String whereClause;
private Model model;
private Map<String, String> fieldLabelToOutputFieldLabel;
private String groupOrderClause;
private String aggregationRules;
public GenericQueryRunnerOnModel(Map<String, String> fieldLabelToOutputFieldLabel,
String aggregationRules,
String whereClause,
String groupOrderClause,
Model model) {
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
this.aggregationRules = aggregationRules;
this.whereClause = whereClause;
this.groupOrderClause = groupOrderClause;
this.model = model;
}
private ResultSet executeQuery(String queryText,
Model dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery() {
StringBuilder sparqlQuery = new StringBuilder();
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
sparqlQuery.append("SELECT\n");
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
: this.fieldLabelToOutputFieldLabel.entrySet()) {
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
}
sparqlQuery.append("\n" + this.aggregationRules + "\n");
sparqlQuery.append("WHERE {\n");
sparqlQuery.append(this.whereClause);
sparqlQuery.append("}\n");
sparqlQuery.append(this.groupOrderClause);
return sparqlQuery.toString();
}
public ResultSet getQueryResult()
throws MalformedQueryParametersException {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.model);
return resultSet;
}
}
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.visualization.visutils;
import java.util.Map;
import org.apache.commons.logging.Log;
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.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.Syntax;
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
*/
public class GenericQueryRunnerOnModel implements QueryRunner<ResultSet> {
protected static final Syntax SYNTAX = Syntax.syntaxARQ;
private String whereClause;
private Model model;
private Map<String, String> fieldLabelToOutputFieldLabel;
private Log log = LogFactory.getLog(GenericQueryRunnerOnModel.class.getName());
private String groupOrderClause;
private String aggregationRules;
public GenericQueryRunnerOnModel(Map<String, String> fieldLabelToOutputFieldLabel,
String aggregationRules,
String whereClause,
String groupOrderClause,
Model model) {
this.fieldLabelToOutputFieldLabel = fieldLabelToOutputFieldLabel;
this.aggregationRules = aggregationRules;
this.whereClause = whereClause;
this.groupOrderClause = groupOrderClause;
this.model = model;
}
private ResultSet executeQuery(String queryText,
Model dataset) {
QueryExecution queryExecution = null;
Query query = QueryFactory.create(queryText, SYNTAX);
queryExecution = QueryExecutionFactory.create(query, dataset);
return queryExecution.execSelect();
}
private String generateGenericSparqlQuery() {
StringBuilder sparqlQuery = new StringBuilder();
sparqlQuery.append(QueryConstants.getSparqlPrefixQuery());
sparqlQuery.append("SELECT\n");
for (Map.Entry<String, String> currentfieldLabelToOutputFieldLabel
: this.fieldLabelToOutputFieldLabel.entrySet()) {
sparqlQuery.append("\t(str(?" + currentfieldLabelToOutputFieldLabel.getKey() + ") as ?"
+ currentfieldLabelToOutputFieldLabel.getValue() + ")\n");
}
sparqlQuery.append("\n" + this.aggregationRules + "\n");
sparqlQuery.append("WHERE {\n");
sparqlQuery.append(this.whereClause);
sparqlQuery.append("}\n");
sparqlQuery.append(this.groupOrderClause);
log.debug("sparqlQuery = " + sparqlQuery.toString());
return sparqlQuery.toString();
}
public ResultSet getQueryResult()
throws MalformedQueryParametersException {
ResultSet resultSet = executeQuery(generateGenericSparqlQuery(),
this.model);
return resultSet;
}
}

View file

@ -435,8 +435,8 @@ check_grants_to_exclude = Check those grants and projects you want to exclude fr
manage_affiliated_people = Manage People Affiliated with
check_people_to_exclude = Check those people you want to exclude from the profile page.
manage_grants = Manage grants for
check_pubs_to_exclude = Check those grants you want to exclude from the profile page.
manage_publications_for = Manage Publications for
check_pubs_to_exclude = Check those publications you want to exclude from the profile page.
manage_web_pages = Manage Web Pages
has_no_webpages = This individual currently has no web pages specified. Add a new web page by clicking on the button below.
@ -840,3 +840,6 @@ full_name = Full name
full_name_for = full name for
first_name = First name
last_name = Last name
title_not_found = Title not found.
speeches_capitalized = Speeches
theses_capitalized = Theses

View file

@ -148,4 +148,3 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/individual/in
'<script type="text/javascript" src="${urls.base}/js/individual/individualUriRdf.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/imageUpload/imageUploadUtils.js"></script>')}