Browse Source

converted to sparql - itql was getting messy

pull/386/head
Alan Stanley 12 years ago
parent
commit
45199e802b
  1. 47
      includes/manage_deleted_objects.inc

47
includes/manage_deleted_objects.inc

@ -216,26 +216,29 @@ function islandora_delete_form_contentmodels(array $form, array &$form_state) {
function islandora_get_deleted_objects($content_models) { function islandora_get_deleted_objects($content_models) {
$tuque = islandora_get_tuque_connection(); $tuque = islandora_get_tuque_connection();
$repository = $tuque->repository; $repository = $tuque->repository;
$qualifier = ''; $first_contentmodel = array_shift($content_models);
$last_content_model = key(array_slice($content_models, -1, 1, TRUE)); $prefix = "PREFIX fm: <" . FEDORA_MODEL_URI . "> ";
foreach ($content_models as $content_model) { $select = "SELECT ?subject ?label ?object FROM <#ri> WHERE { ";
$qualifier .= "\$subject <" . FEDORA_MODEL_URI . "hasModel> <info:fedora/$content_model>"; $where_clause = "{?subject fm:hasModel <info:fedora/$first_contentmodel>;
if ($content_model != $last_content_model) { fm:state fm:Deleted;
$qualifier .= ' or '; fm:hasModel ?object;
} }";
} $suffix = '}';
$unions = '';
$query = "select \$subject \$title \$object from <#ri>"; foreach ($content_models as $contentmodel) {
$query .= "where ($qualifier)"; $unions .= "UNION {?subject fm:hasModel <info:fedora/$contentmodel>;
$query .= "and \$subject <" . FEDORA_MODEL_URI . "state> <" . FEDORA_MODEL_URI . "Deleted>"; fm:state fm:Deleted;
$query .= "and \$subject<" . FEDORA_MODEL_URI . "hasModel> \$object "; fm:hasModel ?object;
$query .= "and \$subject <dc:title> \$title"; } ";
$objects = $repository->ri->itqlQuery($query, 'unlimited'); }
$optional = "OPTIONAL{?subject fm:label ?label}";
$query = "$prefix $select $where_clause $unions $optional $suffix";
$objects = $repository->ri->sparqlQuery($query, -1);
$deleted_objects = array(); $deleted_objects = array();
foreach ($objects as $object) { foreach ($objects as $object) {
if ($object['object']['value'] != "fedora-system:FedoraObject-3.0") { if ($object['object']['value'] != "fedora-system:FedoraObject-3.0") {
$pid = $object['subject']['value']; $pid = $object['subject']['value'];
$title = $object['title']['value']; $title = $object['label']['value'];
$content_model = islandora_object_load($object['object']['value']); $content_model = islandora_object_load($object['object']['value']);
$deleted_objects[$pid] = array( $deleted_objects[$pid] = array(
'title' => $title, 'pid' => $pid, 'title' => $title, 'pid' => $pid,
@ -256,11 +259,15 @@ function islandora_get_contentmodels_with_deleted_members() {
$tuque = new IslandoraTuque(); $tuque = new IslandoraTuque();
$repository = $tuque->repository; $repository = $tuque->repository;
$query = "select \$object from <#ri>"; $query = "PREFIX fm: <info:fedora/fedora-system:def/model#>
$query .= "where \$subject <" . FEDORA_MODEL_URI . "state> <" . FEDORA_MODEL_URI . "Deleted>"; SELECT DISTINCT ?object FROM <#ri>
$query .= "and \$subject<" . FEDORA_MODEL_URI . "hasModel> \$object"; WHERE {
{?subject fm:state fm:Deleted;
fm:hasModel ?object;
}
}";
$objects = $repository->ri->itqlQuery($query, 'unlimited'); $objects = $repository->ri->sparqlQuery($query, -1);
$content_models = array(); $content_models = array();
foreach ($objects as $object) { foreach ($objects as $object) {
if ($object['object']['value'] != "fedora-system:FedoraObject-3.0") { if ($object['object']['value'] != "fedora-system:FedoraObject-3.0") {

Loading…
Cancel
Save