From bb19d996171944ba6fb6c7616aeab25cf648d8a3 Mon Sep 17 00:00:00 2001 From: Brandon Weigel Date: Mon, 26 Feb 2018 15:31:17 +0000 Subject: [PATCH] Amend SPARQL query to exclude objects with any living parent. --- includes/orphaned_objects.inc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/includes/orphaned_objects.inc b/includes/orphaned_objects.inc index 8e598911..c4140170 100644 --- a/includes/orphaned_objects.inc +++ b/includes/orphaned_objects.inc @@ -138,20 +138,33 @@ function islandora_orphaned_objects_manage_confirm_submit($form, &$form_state) { */ function islandora_orphaned_objects_get_orphaned_objects() { $connection = islandora_get_tuque_connection(); - // First query: get standard objects. + // SPARQL: get orphaned objects, exclude any with a living parent. $object_query = << +SELECT ?object ?p ?otherobject ?title WHERE { ?object ; ?p ?otherobject . ?object ?title; - FILTER( regex( str(?p), "/fedora-system:def/relations-external#")) - OPTIONAL { - ?otherobject ?model . - } - FILTER(!bound(?model)) + OPTIONAL { + ?otherobject ?model . + } . + FILTER (!bound(?model)) + + # Filter by "parent" relationships - isMemberOf, isMemberOfCollection, isPageOf. + FILTER (?p = || ?p = || ?p = ) + +# Exclude objects with live parents - isMemberOf, isMemberOfCollection, isPageOf. + OPTIONAL { + {?object ?liveparent } + UNION {?object ?liveparent } + UNION { ?object ?liveparent } . + ?liveparent . + } + FILTER (!bound(?liveparent)) } EOQ; + $optionals = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_optionals', 'view'); $filter_modules = array( 'islandora_xacml_api',