NIHVIVO-2186 Modify custom list view queries to filter out statements with no linked individual when user is not editing the page. Involves pruning the grouped property list of properties and groups which are thereby empty.

This commit is contained in:
ryounes 2011-03-21 22:24:37 +00:00
parent 77a7ce801a
commit f80de8c1ba
9 changed files with 60 additions and 51 deletions

View file

@ -9,28 +9,26 @@
PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX core: <http://vivoweb.org/ontology/core#>
PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#>
SELECT DISTINCT <collation-fragment> ?subclass </collation-fragment> SELECT DISTINCT <collated> ?subclass </collated>
?authorship ?authorship
?infoResource ?infoResourceName ?infoResource ?infoResourceName
?dateTime WHERE { ?dateTime WHERE {
?subject ?property ?authorship . ?subject ?property ?authorship
<linked-individual-optional> OPTIONAL { ?authorship core:linkedInformationResource ?infoResource .
OPTIONAL {
</linked-individual-optional>
?authorship core:linkedInformationResource ?infoResource .
?infoResource rdfs:label ?infoResourceName ?infoResource rdfs:label ?infoResourceName
<collation-fragment> <collated>
OPTIONAL { ?subclass rdfs:subClassOf core:InformationResource . OPTIONAL { ?subclass rdfs:subClassOf core:InformationResource .
?infoResource a ?subclass ?infoResource a ?subclass
} }
</collation-fragment> </collated>
OPTIONAL { ?infoResource core:dateTimeValue ?dateTimeValue . OPTIONAL { ?infoResource core:dateTimeValue ?dateTimeValue .
?dateTimeValue core:dateTime ?dateTime ?dateTimeValue core:dateTime ?dateTime
} }
<linked-individual-optional>
} }
</linked-individual-optional> <linked-individual-required>
} ORDER BY <collation-fragment> ?subclass </collation-fragment> ?infoResourceName FILTER ( bound(?infoResource) )
</linked-individual-required>
} ORDER BY <collated> ?subclass </collated> ?infoResourceName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -10,7 +10,7 @@
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT DISTINCT <collation-fragment> ?subclass </collation-fragment> SELECT DISTINCT <collated> ?subclass </collated>
?edTraining ?edTraining
?org ?orgName ?org ?orgName
?degreeName ?degreeAbbr ?degreeName ?degreeAbbr
@ -20,11 +20,11 @@
?subject ?property ?edTraining ?subject ?property ?edTraining
OPTIONAL { ?edTraining core:trainingAtOrganization ?org . OPTIONAL { ?edTraining core:trainingAtOrganization ?org .
?org rdfs:label ?orgName ?org rdfs:label ?orgName
<collation-fragment> <collated>
OPTIONAL { ?subclass rdfs:subClassOf foaf:Organization . OPTIONAL { ?subclass rdfs:subClassOf foaf:Organization .
?org a ?subclass ?org a ?subclass
} }
</collation-fragment> </collated>
} }
OPTIONAL { ?edTraining core:degreeEarned ?degree OPTIONAL { ?edTraining core:degreeEarned ?degree
OPTIONAL { ?degree rdfs:label ?degreeName } OPTIONAL { ?degree rdfs:label ?degreeName }

View file

@ -9,7 +9,7 @@
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt; PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
SELECT DISTINCT <collation-fragment>?subclass</collation-fragment> SELECT DISTINCT <collated>?subclass</collated>
?role ?role
?roleLabel ?roleLabel
?activity ?activityName ?activity ?activityName
@ -18,11 +18,11 @@
OPTIONAL { ?role core:roleIn ?activity . OPTIONAL { ?role core:roleIn ?activity .
?activity rdfs:label ?activityName ?activity rdfs:label ?activityName
} }
<collation-fragment> <collated>
OPTIONAL { ?role a ?subclass . OPTIONAL { ?role a ?subclass .
?subclass rdfs:subClassOf core:Role ?subclass rdfs:subClassOf core:Role
} }
</collation-fragment> </collated>
OPTIONAL { ?role rdfs:label ?roleLabel } OPTIONAL { ?role rdfs:label ?roleLabel }
OPTIONAL { ?role core:dateTimeInterval ?dateTimeInterval OPTIONAL { ?role core:dateTimeInterval ?dateTimeInterval
OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue . OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue .
@ -32,7 +32,10 @@
?dateTimeEndValue core:dateTime ?dateTimeEnd ?dateTimeEndValue core:dateTime ?dateTimeEnd
} }
} }
} ORDER BY <collation-fragment>?subclass</collation-fragment> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityName <linked-individual-required>
FILTER ( bound(?activity) )
</linked-individual-required>
} ORDER BY <collated>?subclass</collated> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -10,20 +10,23 @@
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt; PREFIX foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
SELECT DISTINCT <collation-fragment> ?subclass </collation-fragment> SELECT DISTINCT <collated> ?subclass </collated>
?authorship ?authorship
?person ?personName WHERE { ?person ?personName WHERE {
?subject ?property ?authorship ?subject ?property ?authorship
OPTIONAL { ?authorship core:authorRank ?rank } OPTIONAL { ?authorship core:authorRank ?rank }
OPTIONAL { ?authorship core:linkedAuthor ?person . OPTIONAL { ?authorship core:linkedAuthor ?person .
?person rdfs:label ?personName ?person rdfs:label ?personName
<collation-fragment> <collated>
OPTIONAL { ?person a ?subclass . OPTIONAL { ?person a ?subclass .
?subclass rdfs:subClassOf foaf:Person ?subclass rdfs:subClassOf foaf:Person
} }
</collation-fragment> </collated>
} }
} ORDER BY <collation-fragment> ?subclass </collation-fragment> ?rank ?personName <linked-individual-required>
FILTER ( bound(?person) )
</linked-individual-required>
} ORDER BY <collated> ?subclass </collated> ?rank ?personName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -9,7 +9,7 @@
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt; PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
SELECT DISTINCT <collation-fragment> ?subclass </collation-fragment> SELECT DISTINCT <collated> ?subclass </collated>
?position ?position
?positionTitle ?positionTitle
?person ?personName ?person ?personName
@ -18,11 +18,11 @@
OPTIONAL { ?position core:positionForPerson ?person . OPTIONAL { ?position core:positionForPerson ?person .
?person rdfs:label ?personName ?person rdfs:label ?personName
} }
<collation-fragment> <collated>
OPTIONAL { ?position a ?subclass . OPTIONAL { ?position a ?subclass .
?subclass rdfs:subClassOf core:Position ?subclass rdfs:subClassOf core:Position
} }
</collation-fragment> </collated>
OPTIONAL { ?position rdfs:label ?positionTitle } OPTIONAL { ?position rdfs:label ?positionTitle }
OPTIONAL { ?position core:dateTimeInterval ?dateTimeInterval OPTIONAL { ?position core:dateTimeInterval ?dateTimeInterval
OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue . OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue .
@ -31,10 +31,13 @@
OPTIONAL { ?dateTimeInterval core:end ?dateTimeEndValue . OPTIONAL { ?dateTimeInterval core:end ?dateTimeEndValue .
?dateTimeEndValue core:dateTime ?dateTimeEnd ?dateTimeEndValue core:dateTime ?dateTimeEnd
} }
# Current positions only: end date is either null or not in the past # Get current positions only: end date is either null or not in the past
} FILTER ( !bound(?dateTimeEnd) || } FILTER ( !bound(?dateTimeEnd) ||
afn:substring(str(?dateTimeEnd), 0, 4) &gt;= afn:substring(str(afn:now()), 0, 4) ) afn:substring(str(?dateTimeEnd), 0, 4) &gt;= afn:substring(str(afn:now()), 0, 4) )
} ORDER BY <collation-fragment> ?subclass </collation-fragment> ?personName <linked-individual-required>
FILTER ( bound(?person) )
</linked-individual-required>
} ORDER BY <collated> ?subclass </collated> ?personName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -9,7 +9,7 @@
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt; PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
SELECT DISTINCT <collation-fragment>?subclass</collation-fragment> SELECT DISTINCT <collated>?subclass</collated>
?position ?position
?positionTitle ?positionTitle
?hrJobTitle ?hrJobTitle
@ -29,12 +29,15 @@
?dateTimeEndValue core:dateTime ?dateTimeEnd ?dateTimeEndValue core:dateTime ?dateTimeEnd
} }
} }
<collation-fragment> <collated>
OPTIONAL { ?position a ?subclass . OPTIONAL { ?position a ?subclass .
?subclass rdfs:subClassOf core:Position ?subclass rdfs:subClassOf core:Position
} }
</collation-fragment> </collated>
} ORDER BY <collation-fragment>?subclass</collation-fragment> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?orgName <linked-individual-required>
FILTER ( bound(?org) )
</linked-individual-required>
} ORDER BY <collated>?subclass</collated> DESC(?dateTimeEnd) DESC(?dateTimeStart) ?orgName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -9,7 +9,7 @@
PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt; PREFIX core: &lt;http://vivoweb.org/ontology/core#&gt;
PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt; PREFIX afn: &lt;http://jena.hpl.hp.com/ARQ/function#&gt;
SELECT DISTINCT <collation-fragment>?subclass</collation-fragment> SELECT DISTINCT <collated>?subclass</collated>
?role ?role
?roleLabel ?roleTypeLabel ?roleLabel ?roleTypeLabel
?indivInRole (afn:localname(?indivInRole) AS ?indivName) ?indivInRole (afn:localname(?indivInRole) AS ?indivName)
@ -39,8 +39,10 @@
?dateTimeEndValue core:dateTime ?dateTimeEnd ?dateTimeEndValue core:dateTime ?dateTimeEnd
} }
} }
<linked-individual-required>
} ORDER BY <collation-fragment>?subclass</collation-fragment>?indivName ?indivLabel ?roleLabel ?roleTypeLabel FILTER ( bound(?indivInRole) )
</linked-individual-required>
} ORDER BY <collated>?subclass</collated> ?indivLabel ?roleLabel ?roleTypeLabel ?indivName
</query-select> </query-select>
<query-construct> <query-construct>

View file

@ -5,11 +5,11 @@
<#import "lib-sequence.ftl" as s> <#import "lib-sequence.ftl" as s>
<#import "lib-datetime.ftl" as dt> <#import "lib-datetime.ftl" as dt>
<@showEducationalTraining statement /> <@showEducationalTraining statement individual />
<#-- Use a macro to keep variable assignments local; otherwise the values carry over to the <#-- Use a macro to keep variable assignments local; otherwise the values carry over to the
next statement --> next statement -->
<#macro showEducationalTraining statement> <#macro showEducationalTraining statement individual>
<#local degree> <#local degree>
<#if statement.degreeName??> <#if statement.degreeName??>
@ -25,12 +25,12 @@
<#local linkedIndividual> <#local linkedIndividual>
<#if statement.org??> <#if statement.org??>
<a href="${profileUrl(statement.org)}">${statement.orgName}</a> <a href="${profileUrl(statement.org)}">${statement.orgName}</a>
<#else> <#elseif individual.editable>
<#-- This shouldn't happen, but we must provide for it --> <#-- Show the link to the context node only if the user is editing the page. -->
<a href="${profileUrl(statement.edTraining)}">missing organization</a> <a href="${profileUrl(statement.edTraining)}">missing organization</a>
</#if> </#if>
</#local> </#local>
<@s.join [ degree, linkedIndividual, statement.deptOrSchool!, statement.info! ] /> <@dt.yearIntervalSpan "${statement.dateTimeStart!}" "${statement.dateTimeEnd!}" false/> <@s.join [ degree, linkedIndividual!, statement.deptOrSchool!, statement.info! ] /> <@dt.yearIntervalSpan "${statement.dateTimeStart!}" "${statement.dateTimeEnd!}" false/>
</#macro> </#macro>

View file

@ -2,9 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;