From fec776de32f7c0aea82500fc30f5a41adf6c89ee Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Wed, 7 Mar 2012 14:02:34 -0400 Subject: [PATCH] Added a force reinstall and fixed a move to trash bug --- api/fedora_item.inc | 6 ++++-- fedora_repository.module | 7 +++++++ fedora_repository.solutionpacks.inc | 18 ++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/api/fedora_item.inc b/api/fedora_item.inc index 7524ebbb..e7043b14 100644 --- a/api/fedora_item.inc +++ b/api/fedora_item.inc @@ -669,12 +669,14 @@ class Fedora_Item { { $this->set_datastream_state($dsid, 'D'); } - + // Create a message to mark the object deleted $params = array( 'pid' => $this->pid, 'state' => 'D', - 'logMessage' => $logMessage + 'logMessage' => $logMessage, + 'label' => $this->objectProfile->objLabel, + 'ownerId' => null, ); // Send message to mark the object deleted diff --git a/fedora_repository.module b/fedora_repository.module index 1646ce4f..eeee9851 100644 --- a/fedora_repository.module +++ b/fedora_repository.module @@ -2150,13 +2150,16 @@ function fedora_repository_display_schema($file) { * @return type */ function fedora_repository_batch_reingest_object($object, &$context) { + module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); + if (!empty($object) && is_array($object)) { $pid = $object['pid']; if (!valid_pid($pid)) { return NULL; } + // Does the object exist? If so, purge it. $item = new Fedora_Item($pid); if ($item->exists()) { @@ -2172,6 +2175,7 @@ function fedora_repository_batch_reingest_object($object, &$context) { $context['message'][] = "$new_item->pid installed."; } } + if (!empty($object['dsid']) && !empty($object['datastream_file'])) { $datastreams = array( array( @@ -2185,10 +2189,13 @@ function fedora_repository_batch_reingest_object($object, &$context) { } if (!empty($datastreams) && is_array($datastreams)) { + $label = !empty($object['label']) ? $object['label'] : ''; + if (empty($object['foxml_file']) && !isset($new_item)) { $new_item = Fedora_Item::ingest_new_item($object['pid'], 'A', $label); } + if (!empty($object['cmodel'])) { $new_item->add_relationship('hasModel', $object['cmodel'], FEDORA_MODEL_URI); } diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 1ee956f1..12a4e08c 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -46,19 +46,21 @@ function fedora_repository_solution_packs_page() { * @param array $solution_pack */ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { + // Check each object to see if it is in the repository. module_load_include('inc', 'fedora_repository', 'api/fedora_item'); global $base_path; $needs_update = FALSE; $needs_install = FALSE; $form = array(); + $form['solution_pack_module'] = array( '#type' => 'hidden', '#value' => $solution_pack_module, ); if (!$form_state['submitted']) { - $form['soluction_pack_name'] = array( + $form['solution_pack_name'] = array( '#type' => 'markup', '#value' => t($solution_pack_name), '#prefix' => '

', @@ -75,7 +77,6 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul $table_header = array('PID', 'Status'); $table_rows = array(); - foreach ($objects as $object) { $datastreams = NULL; if (isset($object['pid'])) { @@ -149,6 +150,12 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul '#type' => 'submit', '#name' => $solution_pack_module, ); + $form['forcesubmit'] = array( + '#value' => t('Force Reinstall'), + //'#disabled' => !$needs_install && !$needs_update, + '#type' => 'submit', + '#name' => $solution_pack_module, + ); $form['#submit'] = array( 'fedora_repository_solution_pack_form_submit', @@ -159,7 +166,11 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul function fedora_repository_solution_pack_form_submit($form, &$form_state) { $what = $form_state; $module_name = $form_state['values']['solution_pack_module']; + + // This should be replaced with module_invoke $solution_pack_info = call_user_func($module_name . '_required_fedora_objects'); + //$solution_pack_info = module_invoke($module_name, 'required_fedora_objects'); + $batch = array( 'title' => t('Installing / updating solution pack objects'), 'file' => drupal_get_path('module', 'fedora_repository') . '/fedora_repository.module', @@ -171,6 +182,9 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) { // Add this object to the batch job queue. $batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); } + foreach($batch['operations'] as $key => $value) { + //var_dump($value); + } batch_set($batch); }