Browse Source

Amend SPARQL query to exclude objects with any living parent.

pull/697/head
Brandon Weigel 7 years ago
parent
commit
bb19d99617
  1. 21
      includes/orphaned_objects.inc

21
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() { function islandora_orphaned_objects_get_orphaned_objects() {
$connection = islandora_get_tuque_connection(); $connection = islandora_get_tuque_connection();
// First query: get standard objects. // SPARQL: get orphaned objects, exclude any with a living parent.
$object_query = <<<EOQ $object_query = <<<EOQ
SELECT ?object ?otherobject ?title ?p PREFIX islandora: <http://islandora.ca/ontology/relsext#>
SELECT ?object ?p ?otherobject ?title
WHERE { WHERE {
?object <fedora-model:hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ; ?object <fedora-model:hasModel> <info:fedora/fedora-system:FedoraObject-3.0> ;
?p ?otherobject . ?p ?otherobject .
?object <fedora-model:label> ?title; ?object <fedora-model:label> ?title;
FILTER( regex( str(?p), "/fedora-system:def/relations-external#"))
OPTIONAL { OPTIONAL {
?otherobject <fedora-model:hasModel> ?model . ?otherobject <fedora-model:hasModel> ?model .
} .
FILTER (!bound(?model))
# Filter by "parent" relationships - isMemberOf, isMemberOfCollection, isPageOf.
FILTER (?p = <fedora-rels-ext:isMemberOfCollection> || ?p = <fedora-rels-ext:isMemberOf> || ?p = <islandora:isPageOf>)
# Exclude objects with live parents - isMemberOf, isMemberOfCollection, isPageOf.
OPTIONAL {
{?object <fedora-rels-ext:isMemberOfCollection> ?liveparent }
UNION {?object <fedora-rels-ext:isMemberOf> ?liveparent }
UNION { ?object <islandora:isPageOf> ?liveparent } .
?liveparent <fedora-model:hasModel> <info:fedora/fedora-system:FedoraObject-3.0> .
} }
FILTER(!bound(?model)) FILTER (!bound(?liveparent))
} }
EOQ; EOQ;
$optionals = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_optionals', 'view'); $optionals = (array) module_invoke('islandora_xacml_api', 'islandora_basic_collection_get_query_optionals', 'view');
$filter_modules = array( $filter_modules = array(
'islandora_xacml_api', 'islandora_xacml_api',

Loading…
Cancel
Save