From f80de8c1baeb1c678ac91a036fdbba5b59620c86 Mon Sep 17 00:00:00 2001 From: ryounes Date: Mon, 21 Mar 2011 22:24:37 +0000 Subject: [PATCH] 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. --- .../listViewConfig-authorInAuthorship.xml | 34 +++++++++---------- .../listViewConfig-educationalTraining.xml | 8 ++--- productMods/config/listViewConfig-hasRole.xml | 13 ++++--- ...Config-informationResourceInAuthorship.xml | 11 +++--- ...listViewConfig-organizationForPosition.xml | 13 ++++--- .../listViewConfig-personInPosition.xml | 11 +++--- .../config/listViewConfig-relatedRole.xml | 8 +++-- .../propStatement-educationalTraining.ftl | 10 +++--- .../individual/IndividualTemplateModel.java | 3 -- 9 files changed, 60 insertions(+), 51 deletions(-) diff --git a/productMods/config/listViewConfig-authorInAuthorship.xml b/productMods/config/listViewConfig-authorInAuthorship.xml index a51f1f03..042cef1a 100644 --- a/productMods/config/listViewConfig-authorInAuthorship.xml +++ b/productMods/config/listViewConfig-authorInAuthorship.xml @@ -9,28 +9,26 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?authorship ?infoResource ?infoResourceName ?dateTime WHERE { - ?subject ?property ?authorship . - - OPTIONAL { - - ?authorship core:linkedInformationResource ?infoResource . - ?infoResource rdfs:label ?infoResourceName - - OPTIONAL { ?subclass rdfs:subClassOf core:InformationResource . - ?infoResource a ?subclass - } - - OPTIONAL { ?infoResource core:dateTimeValue ?dateTimeValue . - ?dateTimeValue core:dateTime ?dateTime - } - + ?subject ?property ?authorship + OPTIONAL { ?authorship core:linkedInformationResource ?infoResource . + ?infoResource rdfs:label ?infoResourceName + + OPTIONAL { ?subclass rdfs:subClassOf core:InformationResource . + ?infoResource a ?subclass + } + + OPTIONAL { ?infoResource core:dateTimeValue ?dateTimeValue . + ?dateTimeValue core:dateTime ?dateTime + } } - - } ORDER BY ?subclass ?infoResourceName + + FILTER ( bound(?infoResource) ) + + } ORDER BY ?subclass ?infoResourceName diff --git a/productMods/config/listViewConfig-educationalTraining.xml b/productMods/config/listViewConfig-educationalTraining.xml index f43f80f0..133db8aa 100644 --- a/productMods/config/listViewConfig-educationalTraining.xml +++ b/productMods/config/listViewConfig-educationalTraining.xml @@ -10,7 +10,7 @@ PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?edTraining ?org ?orgName ?degreeName ?degreeAbbr @@ -20,11 +20,11 @@ ?subject ?property ?edTraining OPTIONAL { ?edTraining core:trainingAtOrganization ?org . ?org rdfs:label ?orgName - + OPTIONAL { ?subclass rdfs:subClassOf foaf:Organization . ?org a ?subclass } - + } OPTIONAL { ?edTraining core:degreeEarned ?degree OPTIONAL { ?degree rdfs:label ?degreeName } @@ -40,7 +40,7 @@ OPTIONAL { ?dateTimeInterval core:end ?dateTimeEndValue . ?dateTimeEndValue core:dateTime ?dateTimeEnd } - } + } } ORDER BY ?subclass DESC(?dateTimeEnd) DESC(?dateTimeStart) diff --git a/productMods/config/listViewConfig-hasRole.xml b/productMods/config/listViewConfig-hasRole.xml index 0ac5d78c..64657a5b 100644 --- a/productMods/config/listViewConfig-hasRole.xml +++ b/productMods/config/listViewConfig-hasRole.xml @@ -9,7 +9,7 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?role ?roleLabel ?activity ?activityName @@ -18,11 +18,11 @@ OPTIONAL { ?role core:roleIn ?activity . ?activity rdfs:label ?activityName } - + OPTIONAL { ?role a ?subclass . ?subclass rdfs:subClassOf core:Role } - + OPTIONAL { ?role rdfs:label ?roleLabel } OPTIONAL { ?role core:dateTimeInterval ?dateTimeInterval OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue . @@ -31,8 +31,11 @@ OPTIONAL { ?dateTimeInterval core:end ?dateTimeEndValue . ?dateTimeEndValue core:dateTime ?dateTimeEnd } - } - } ORDER BY ?subclass DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityName + } + + FILTER ( bound(?activity) ) + + } ORDER BY ?subclass DESC(?dateTimeEnd) DESC(?dateTimeStart) ?activityName diff --git a/productMods/config/listViewConfig-informationResourceInAuthorship.xml b/productMods/config/listViewConfig-informationResourceInAuthorship.xml index 93069d9f..4404c409 100644 --- a/productMods/config/listViewConfig-informationResourceInAuthorship.xml +++ b/productMods/config/listViewConfig-informationResourceInAuthorship.xml @@ -10,20 +10,23 @@ PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?authorship ?person ?personName WHERE { ?subject ?property ?authorship OPTIONAL { ?authorship core:authorRank ?rank } OPTIONAL { ?authorship core:linkedAuthor ?person . ?person rdfs:label ?personName - + OPTIONAL { ?person a ?subclass . ?subclass rdfs:subClassOf foaf:Person } - + } - } ORDER BY ?subclass ?rank ?personName + + FILTER ( bound(?person) ) + + } ORDER BY ?subclass ?rank ?personName diff --git a/productMods/config/listViewConfig-organizationForPosition.xml b/productMods/config/listViewConfig-organizationForPosition.xml index 2e39f5ef..769835c8 100644 --- a/productMods/config/listViewConfig-organizationForPosition.xml +++ b/productMods/config/listViewConfig-organizationForPosition.xml @@ -9,7 +9,7 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?position ?positionTitle ?person ?personName @@ -18,11 +18,11 @@ OPTIONAL { ?position core:positionForPerson ?person . ?person rdfs:label ?personName } - + OPTIONAL { ?position a ?subclass . ?subclass rdfs:subClassOf core:Position } - + OPTIONAL { ?position rdfs:label ?positionTitle } OPTIONAL { ?position core:dateTimeInterval ?dateTimeInterval OPTIONAL { ?dateTimeInterval core:start ?dateTimeStartValue . @@ -31,10 +31,13 @@ OPTIONAL { ?dateTimeInterval core:end ?dateTimeEndValue . ?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) || afn:substring(str(?dateTimeEnd), 0, 4) >= afn:substring(str(afn:now()), 0, 4) ) - } ORDER BY ?subclass ?personName + + FILTER ( bound(?person) ) + + } ORDER BY ?subclass ?personName diff --git a/productMods/config/listViewConfig-personInPosition.xml b/productMods/config/listViewConfig-personInPosition.xml index 3a46b378..862ef3bb 100644 --- a/productMods/config/listViewConfig-personInPosition.xml +++ b/productMods/config/listViewConfig-personInPosition.xml @@ -9,7 +9,7 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?position ?positionTitle ?hrJobTitle @@ -29,12 +29,15 @@ ?dateTimeEndValue core:dateTime ?dateTimeEnd } } - + OPTIONAL { ?position a ?subclass . ?subclass rdfs:subClassOf core:Position } - - } ORDER BY ?subclass DESC(?dateTimeEnd) DESC(?dateTimeStart) ?orgName + + + FILTER ( bound(?org) ) + + } ORDER BY ?subclass DESC(?dateTimeEnd) DESC(?dateTimeStart) ?orgName diff --git a/productMods/config/listViewConfig-relatedRole.xml b/productMods/config/listViewConfig-relatedRole.xml index d9b119d9..afe691c4 100644 --- a/productMods/config/listViewConfig-relatedRole.xml +++ b/productMods/config/listViewConfig-relatedRole.xml @@ -9,7 +9,7 @@ PREFIX core: <http://vivoweb.org/ontology/core#> PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> - SELECT DISTINCT ?subclass + SELECT DISTINCT ?subclass ?role ?roleLabel ?roleTypeLabel ?indivInRole (afn:localname(?indivInRole) AS ?indivName) @@ -39,8 +39,10 @@ ?dateTimeEndValue core:dateTime ?dateTimeEnd } } - - } ORDER BY ?subclass?indivName ?indivLabel ?roleLabel ?roleTypeLabel + + FILTER ( bound(?indivInRole) ) + + } ORDER BY ?subclass ?indivLabel ?roleLabel ?roleTypeLabel ?indivName diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl index 1e0e4670..fa519553 100644 --- a/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl +++ b/productMods/templates/freemarker/body/partials/individual/propStatement-educationalTraining.ftl @@ -5,11 +5,11 @@ <#import "lib-sequence.ftl" as s> <#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 next statement --> -<#macro showEducationalTraining statement> +<#macro showEducationalTraining statement individual> <#local degree> <#if statement.degreeName??> @@ -25,12 +25,12 @@ <#local linkedIndividual> <#if statement.org??> ${statement.orgName} - <#else> - <#-- This shouldn't happen, but we must provide for it --> + <#elseif individual.editable> + <#-- Show the link to the context node only if the user is editing the page. --> missing organization - <@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/> \ No newline at end of file diff --git a/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java b/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java index d3f32844..cebb19c9 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java +++ b/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java @@ -2,9 +2,6 @@ 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.LogFactory;