Skip to content
adamrmor edited this page Sep 25, 2016 · 1 revision

Sample Queries for accessing the Auckland Museum Medal Collection.

This complex query uses the group_concat feature to group results into an array. It provides a standard delimited text string response.

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>PREFIX dc:<http://purl.org/dc/elements/1.1/>PREFIX foaf:<http://xmlns.com/foaf/0.1/>PREFIX geo-ont:<http://www.geonames.org/ontology#>PREFIX ecrm:<http://erlangen-crm.org/current/>PREFIX am:<http://collections.aucklandmuseum.com/ontology/core/>PREFIX dwc:<http://rs.tdwg.org/dwc/terms/>PREFIX tsp: <http://rs.tdwg.org/ontology/voc/Specimen#>PREFIX tn: <http://rs.tdwg.org/ontology/voc/TaxonName#>PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
select distinct ?medal  ?OtherTitle ?Titletype ?descname ?description ?displayLocation ?materials ?medalRepresentation ?medaltype ?places ?serviceperiods ?recipient

#Using the group feature to merge data into one Json response per medal
(group_concat(?branch;separator="|") as ?branches) 
(group_concat(?place;separator="|") as ?places) 
(group_concat(?serviceperiod;separator="|") as ?serviceperiods) 
(group_concat(?material;separator="|") as ?materials) 

#Start search by selecting only Man Made Objects
{
?medal rdf:type ecrm:E22_Man-Made_Object .

# Find the title/name of medal
?medal dc:title ?medaltype.

#Check if medal refers to an event + Check Medals Material
optional {
?medal am:refersToEvent/dc:title ?serviceperiod.
?medal ecrm:P45_consists_of/ecrm:P3_has_note ?material .}

# Find Medals image
?medal am:primaryRepresentation ?medalRepresentation. 

#Find Medals Description
?medal dc:description ?description .

#Find Medal Type
?medal am:otherTitle ?descname . 
?descname ecrm:P2_has_type ?Titletype.
filter regex(?Titletype,'descriptive','i')

#Find medal recipients name
?medal am:otherTitle ?recipient1.
?recipient1 ecrm:P2_has_type ?recipienttype.  
filter regex(?recipienttype,'associated','i'). 
?recipient1 rdf:value ?recipient

# Check if medal is on display in Pou Maumahara
optional {
?medal am:onDisplayFlag ?displayLocation . }

?descname rdf:value ?OtherTitle.

#Filter out all non Military Medals
filter (!regex (?OtherTitle,'wine','i')) 
filter regex (?medaltype,'medal','i') 
filter (!regex (?medaltype,'box','i')) 
filter (!regex (?medaltype,'police','i')) 
filter (!regex (?medaltype,'clasp','i')) 
Filter (!regex (?medaltype,'ribbon','i')) 
filter (!regex (?medaltype,'lodge','i')) 
filter (!regex (?medaltype,'medallion','i')) 
filter (!regex (?medaltype,'jewel','i')) 
filter (!regex (?medaltype,'prize','i')) 
filter (!regex (?medaltype,'shooting','i')) 
filter (!regex (?medaltype,'case','i')) 
filter (!regex (?medaltype,'badge','i')) 
filter (!regex (?medaltype,'bar','i')) 
filter (!regex (?medaltype,'award','i')) 
filter (!regex (?medaltype,'commemorative','i')) 
filter (!regex (?medaltype,'presentation','i')) 
  
#Check if record has associated Cenotaph Record
OPTIONAL {
?medal am:refersToPerson ?AssociatedPerson_cenotaph.
?AssociatedPerson_cenotaph rdf:type am:MilitaryPerson.
?AssociatedPerson_cenotaph foaf:name ?recepient_cenotaph.}

#Check if record has associated Unit
OPTIONAL {
?medal am:refersToPerson ?AssociatedUnit.
?AssociatedUnit rdf:type am:Corporation.
?AssociatedUnit foaf:name ?branch .}

OPTIONAL { 
?medal am:refersToPerson ?cenotaph_person . 
?cenotaph_person am:force ?force .}

OPTIONAL 
{ ?medal ecrm:P108i_was_produced_by/ecrm:P7_took_place_at/dc:title ?place.} }

group by ?medal ?OtherTitle ?Titletype ?descname ?description ?displayLocation ?medalRepresentation ?medaltype ?recipient