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',