From a3f174f813247ec75627cbdffd6f3021b901ecdc Mon Sep 17 00:00:00 2001 From: tworrall Date: Mon, 15 Aug 2011 19:29:13 +0000 Subject: [PATCH] custom list view for mailingAddress. Will still display the label if there are no other address details --- .../loadedAtStartup/vivoListViewConfig.rdf | 3 + .../config/listViewConfig-mailingAddress.xml | 63 +++++++++++++++++++ .../propStatement-mailingAddress.ftl | 38 +++++++++++ 3 files changed, 104 insertions(+) create mode 100644 productMods/config/listViewConfig-mailingAddress.xml create mode 100644 productMods/templates/freemarker/body/partials/individual/propStatement-mailingAddress.ftl diff --git a/productMods/WEB-INF/ontologies/app/loadedAtStartup/vivoListViewConfig.rdf b/productMods/WEB-INF/ontologies/app/loadedAtStartup/vivoListViewConfig.rdf index 2f1002dc..287ead6c 100644 --- a/productMods/WEB-INF/ontologies/app/loadedAtStartup/vivoListViewConfig.rdf +++ b/productMods/WEB-INF/ontologies/app/loadedAtStartup/vivoListViewConfig.rdf @@ -35,6 +35,9 @@ listViewConfig-organizationForPosition.xml + + listViewConfig-mailingAddress.xml + + + + + + + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX core: <http://vivoweb.org/ontology/core#> + PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> + + SELECT DISTINCT ?subclass + ?address + ?label + ?street + ?city + ?state + ?postalCode + ?country WHERE { + ?subject ?property ?address + OPTIONAL { ?address rdfs:label ?label } + OPTIONAL { ?address core:addressStreet ?street } + OPTIONAL { ?address core:addressCity ?city } + OPTIONAL { ?address core:addressState ?state } + OPTIONAL { ?address core:addressPostalCode ?postalCode } + OPTIONAL { ?address core:addressCountry ?country } + + + OPTIONAL { ?address a ?subclass . + ?subclass rdfs:subClassOf core:Address + } + + } ORDER BY ?subclass ?label + + + + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX core: <http://vivoweb.org/ontology/core#> + CONSTRUCT { + ?subclass rdfs:subClassOf core:Address + } WHERE { + ?subclass rdfs:subClassOf core:Address + } + + + + PREFIX core: <http://vivoweb.org/ontology/core#> + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + CONSTRUCT { + ?subject ?property ?address . + ?address ?addressProperty ?addressValue + } WHERE { + { + ?subject ?property ?address + } UNION { + ?subject ?property ?address . + ?address ?addressProperty ?addressValue + } + } + + + + diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-mailingAddress.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-mailingAddress.ftl new file mode 100644 index 00000000..8fa6831c --- /dev/null +++ b/productMods/templates/freemarker/body/partials/individual/propStatement-mailingAddress.ftl @@ -0,0 +1,38 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Custom object property statement view for http://vivoweb.org/ontology/core#mailingAddress. + + This template must be self-contained and not rely on other variables set for the individual page, because it + is also used to generate the property statement during a deletion. + --> +<#import "lib-sequence.ftl" as s> +<@showAddress statement /> + +<#-- Use a macro to keep variable assignments local; otherwise the values carry over to the + next statement --> + <#macro showAddress statement> + + <#-- Pre-1.4 addresses may only have an rdfs:label, so display that when --> + <#-- there's no street number. --> + <#if statement.street??> +
+
${statement.street}
+ <#-- If the subclass is core:US Postal Address, or if the country is --> + <#-- the US, display the city, state, and postal code on a single line. --> + <#local cityStateZip><@s.join [ statement.city!, statement.state!, statement.postalCode!], " " /> + <#if ( statement.subclass?? && statement.subclass?contains("USPostalAddress") ) || ( statement.country?? && statement.country?contains("United States") ) > + <#if cityStateZip?has_content> +
${cityStateZip}
+ + <#else> +
${statement.city!}
+ <#if statement.state??>
${statement.state}
+ <#if statement.postalCode??>
${statement.postalCode}
+ + <#if statement.country??>
${statement.country}
+
+ <#else> + ${statement.label!} + + + \ No newline at end of file