NIHVIVO-1727 Corrections to core:relatedRole list view to get related individual that has no label

This commit is contained in:
rjy7 2011-01-31 20:04:46 +00:00
parent 0493637b3a
commit 18ade9a1dd
2 changed files with 50 additions and 50 deletions

View file

@ -9,42 +9,43 @@
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 ?role (afn:localname(?role) AS ?roleName) SELECT DISTINCT ?role (afn:localname(?role) AS ?roleName)
?roleLabel ?roleTypeLabel ?indivInRole (afn:localname(?indivInRole) AS ?indivName)
?indivInRole ?indivName ?indivLabel
?roleLabel ?roleTypeLabel
?dateTimeInterval ?dateTimeStart ?dateTimeEnd WHERE { ?dateTimeInterval ?dateTimeStart ?dateTimeEnd WHERE {
GRAPH ?g1 { ?subject ?property ?role }
GRAPH ?g1 { ?subject ?property ?role }
# ?role is either a core:Role or one of its subclasses # We need ?subclass in query-base to get the roleTypeLabel for roles that
{ # have no label (e.g., InvestigatorRole and its subclasses)
{ GRAPH ?g2 { ?role a ?subclass } } OPTIONAL { GRAPH ?g2 { ?role a ?subclass }
{ GRAPH ?g3 { ?subclass rdfs:subClassOf core:Role } } GRAPH ?g3 { ?subclass rdfs:subClassOf core:Role }
UNION OPTIONAL { GRAPH ?g4 { ?subclass rdfs:label ?roleTypeLabel } }
{ GRAPH ?g4 { ?role a core:Role } } }
}
# Works because we don't do inferencing on subproperties, so the only ?roleProp
# returned will be the asserted one.
OPTIONAL { GRAPH ?g5 { ?roleProp rdfs:subPropertyOf core:roleOf } OPTIONAL { GRAPH ?g5 { ?roleProp rdfs:subPropertyOf core:roleOf }
GRAPH ?g6 { ?role ?roleProp ?indivInRole } GRAPH ?g6 { ?role ?roleProp ?indivInRole }
GRAPH ?g7 { ?indivInRole rdfs:label ?indivName } OPTIONAL { GRAPH ?g7 { ?indivInRole rdfs:label ?indivLabel } }
} }
OPTIONAL { GRAPH ?g8 { ?role rdfs:label ?roleLabel } }
OPTIONAL { GRAPH ?g9 { ?subclass rdfs:label ?roleTypeLabel } } OPTIONAL { GRAPH ?g8 { ?role rdfs:label ?roleLabel } }
OPTIONAL { GRAPH ?g10 { ?role core:dateTimeInterval ?dateTimeInterval }
OPTIONAL { GRAPH ?g11 { ?dateTimeInterval core:start ?dateTimeStartValue } OPTIONAL { GRAPH ?g9 { ?role core:dateTimeInterval ?dateTimeInterval }
GRAPH ?g12 { ?dateTimeStartValue core:dateTime ?dateTimeStart } OPTIONAL { GRAPH ?g10 { ?dateTimeInterval core:start ?dateTimeStartValue }
GRAPH ?g11 { ?dateTimeStartValue core:dateTime ?dateTimeStart }
} }
OPTIONAL { GRAPH ?g13 { ?dateTimeInterval core:end ?dateTimeEndValue } OPTIONAL { GRAPH ?g12 { ?dateTimeInterval core:end ?dateTimeEndValue }
GRAPH ?g14 { ?dateTimeEndValue core:dateTime ?dateTimeEnd } GRAPH ?g13 { ?dateTimeEndValue core:dateTime ?dateTimeEnd }
} }
} }
# Make sure we get the role that goes with the role property
FILTER ( FILTER (
( ?roleProp != core:investigatorRoleOf || ?subclass = core:InvestigatorRole ) && ( ?roleProp != core:investigatorRoleOf || ?subclass = core:InvestigatorRole ) &&
( ?roleProp != core:principalInvestigatorRoleOf || ?subclass = core:PrincipalInvestigatorRole ) && ( ?roleProp != core:principalInvestigatorRoleOf || ?subclass = core:PrincipalInvestigatorRole ) &&
( ?roleProp != core:co-PrincipalInvestigatorRoleOf || ?subclass = core:CoPrincipalInvestigatorRole ) ( ?roleProp != core:co-PrincipalInvestigatorRoleOf || ?subclass = core:CoPrincipalInvestigatorRole )
) )
} ORDER BY ?indivName ?roleLabel ?roleTypeLabel } ORDER BY ?indivName ?indivLabel ?roleLabel ?roleTypeLabel
</query-base> </query-base>
<query-collated> <query-collated>
@ -54,41 +55,40 @@
SELECT DISTINCT ?subclass SELECT DISTINCT ?subclass
?role (afn:localname(?role) AS ?roleName) ?role (afn:localname(?role) AS ?roleName)
?roleLabel ?roleTypeLabel ?indivInRole (afn:localname(?indivInRole) AS ?indivName)
?indivInRole ?indivName ?indivLabel
?roleLabel ?roleTypeLabel
?dateTimeInterval ?dateTimeStart ?dateTimeEnd WHERE { ?dateTimeInterval ?dateTimeStart ?dateTimeEnd WHERE {
GRAPH ?g1 { ?subject ?property ?role } GRAPH ?g1 { ?subject ?property ?role }
# ?role is either a core:Role or one of its subclasses OPTIONAL { GRAPH ?g2 { ?role a ?subclass }
{ GRAPH ?g3 { ?subclass rdfs:subClassOf core:Role }
{ GRAPH ?g2 { ?role a ?subclass } } OPTIONAL { GRAPH ?g4 { ?subclass rdfs:label ?roleTypeLabel } }
{ GRAPH ?g3 { ?subclass rdfs:subClassOf core:Role } }
UNION
{ GRAPH ?g4 { ?role a core:Role } }
} }
# Works because we don't do inferencing on subproperties, so the only ?roleProp
# returned will be the asserted one.
OPTIONAL { GRAPH ?g5 { ?roleProp rdfs:subPropertyOf core:roleOf } OPTIONAL { GRAPH ?g5 { ?roleProp rdfs:subPropertyOf core:roleOf }
GRAPH ?g6 { ?role ?roleProp ?indivInRole } GRAPH ?g6 { ?role ?roleProp ?indivInRole }
GRAPH ?g7 { ?indivInRole rdfs:label ?indivName } OPTIONAL { GRAPH ?g7 { ?indivInRole rdfs:label ?indivLabel } }
}
OPTIONAL { GRAPH ?g8 { ?role rdfs:label ?roleLabel } }
OPTIONAL { GRAPH ?g9 { ?subclass rdfs:label ?roleTypeLabel } }
OPTIONAL { GRAPH ?g10 { ?role core:dateTimeInterval ?dateTimeInterval }
OPTIONAL { GRAPH ?g11 { ?dateTimeInterval core:start ?dateTimeStartValue }
GRAPH ?g12 { ?dateTimeStartValue core:dateTime ?dateTimeStart }
}
OPTIONAL { GRAPH ?g13 { ?dateTimeInterval core:end ?dateTimeEndValue }
GRAPH ?g14 { ?dateTimeEndValue core:dateTime ?dateTimeEnd }
}
} }
OPTIONAL { GRAPH ?g8 { ?role rdfs:label ?roleLabel } }
OPTIONAL { GRAPH ?9 { ?role core:dateTimeInterval ?dateTimeInterval }
OPTIONAL { GRAPH ?g10 { ?dateTimeInterval core:start ?dateTimeStartValue }
GRAPH ?g11 { ?dateTimeStartValue core:dateTime ?dateTimeStart }
}
OPTIONAL { GRAPH ?g12 { ?dateTimeInterval core:end ?dateTimeEndValue }
GRAPH ?g13 { ?dateTimeEndValue core:dateTime ?dateTimeEnd }
}
}
# Make sure we get the role that goes with the role property
FILTER ( FILTER (
( ?roleProp != core:investigatorRoleOf || ?subclass = core:InvestigatorRole ) &amp;&amp; ( ?roleProp != core:investigatorRoleOf || ?subclass = core:InvestigatorRole ) &amp;&amp;
( ?roleProp != core:principalInvestigatorRoleOf || ?subclass = core:PrincipalInvestigatorRole ) &amp;&amp; ( ?roleProp != core:principalInvestigatorRoleOf || ?subclass = core:PrincipalInvestigatorRole ) &amp;&amp;
( ?roleProp != core:co-PrincipalInvestigatorRoleOf || ?subclass = core:CoPrincipalInvestigatorRole ) ( ?roleProp != core:co-PrincipalInvestigatorRoleOf || ?subclass = core:CoPrincipalInvestigatorRole )
) )
} ORDER BY ?subclass ?indivName ?roleLabel ?roleTypeLabel } ORDER BY ?subclass ?indivName ?indivLabel ?roleLabel ?roleTypeLabel
</query-collated> </query-collated>
<!-- <!--

View file

@ -13,7 +13,7 @@
<#local linkedIndividual> <#local linkedIndividual>
<#if statement.indivInRole??> <#if statement.indivInRole??>
<a href="${profileUrl(statement.indivInRole)}">${statement.indivName}</a> <a href="${profileUrl(statement.indivInRole)}">${statement.indivLabel!statement.indivName}</a>
<#else> <#else>
<#-- This shouldn't happen, but we must provide for it --> <#-- This shouldn't happen, but we must provide for it -->
<a href="${profileUrl(statement.role)}">${statement.roleName}</a> (no linked individual in this role) <a href="${profileUrl(statement.role)}">${statement.roleName}</a> (no linked individual in this role)