Browse Source

ISLANDORA-214 Handle datastream versioning in Solution Pack form.

pull/105/head
Alexander O'Neill 14 years ago
parent
commit
abf001d96a
  1. 3
      fedora_repository.module
  2. 51
      fedora_repository.solutionpacks.inc

3
fedora_repository.module

@ -1413,7 +1413,7 @@ function fedora_repository_required_fedora_objects() {
'label' => 'Islandora Collection Content Model', 'label' => 'Islandora Collection Content Model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml", 'datastream_file' => "$module_path/content_models/COLLECTIONCM.xml",
'dsversion' => NULL, 'dsversion' => 2,
'cmodel' => 'fedora-system:ContentModel-3.0', 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
array ( array (
@ -1421,7 +1421,6 @@ function fedora_repository_required_fedora_objects() {
'label' => 'Islandora strict PDF content model', 'label' => 'Islandora strict PDF content model',
'dsid' => 'ISLANDORACM', 'dsid' => 'ISLANDORACM',
'datastream_file' => "$module_path/content_models/STRICT_PDFCM.xml", 'datastream_file' => "$module_path/content_models/STRICT_PDFCM.xml",
'dsversion' => NULL,
'cmodel' => 'fedora-system:ContentModel-3.0', 'cmodel' => 'fedora-system:ContentModel-3.0',
), ),
array( array(

51
fedora_repository.solutionpacks.inc

@ -76,7 +76,8 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
$table_rows = array(); $table_rows = array();
foreach($objects as $object) { foreach ($objects as $object) {
$datastreams = NULL;
if (isset($object['pid'])) { if (isset($object['pid'])) {
$pid = $object['pid']; $pid = $object['pid'];
@ -86,20 +87,35 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
if (!$item->exists()) { if (!$item->exists()) {
$object_status = 'Missing'; $object_status = 'Missing';
$needs_install = TRUE; $needs_install = TRUE;
} } else {
elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { if (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) {
// Check if the datastream is versioned and needs updating. $datastreams = array(
$installed_version = fedora_repository_get_islandora_datastream_version($item, $object['dsid']); array(
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']); 'dsid' => $object['dsid'],
if ($available_version > $installed_version) { 'datastream_file' => $object['datastream_file'],
$needs_update = TRUE; 'dsversion' => $object['dsversion'],
$object_status = 'Out of date'; ),
);
} elseif (!empty($object['datastreams'])) {
$datastreams = $object['datastreams'];
} }
} if (!empty($datastreams) && is_array($datastreams)) {
array_push($table_row, $object_status); foreach ($datastreams as $ds) {
if (isset($ds['dsversion'])) {
$table_rows[] = $table_row; // Check if the datastream is versioned and needs updating.
$installed_version = fedora_repository_get_islandora_datastream_version($item, $ds['dsid']);
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $ds['datastream_file']);
if ($available_version > $installed_version) {
$needs_update = TRUE;
$object_status = 'Out of date';
}
}
}
}
array_push($table_row, $object_status);
$table_rows[] = $table_row;
}
} }
} }
$form['objects']['table'] = array( $form['objects']['table'] = array(
@ -113,19 +129,18 @@ function fedora_repository_solution_pack_form(&$form_state, $solution_pack_modul
'#prefix' => '<strong>' . t('Object status:') . '&nbsp;</strong>', '#prefix' => '<strong>' . t('Object status:') . '&nbsp;</strong>',
'#suffix' => '&nbsp;', '#suffix' => '&nbsp;',
); );
if (!$needs_install) { if (!$needs_install && !$needs_update) {
$form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.'); $form['install_status']['#value'] = theme_image('misc/watchdog-ok.png') . t('All required objects are installed and up-to-date.');
} } else {
else {
$form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.'); $form['install_status']['#value'] = theme_image('misc/watchdog-warning.png') . t('Some objects must be re-ingested. See Objects list for details.');
} }
$form['submit'] = array( $form['submit'] = array(
'#value' => t('Install'), '#value' => t('Install'),
'#disabled' => !$needs_install, '#disabled' => !$needs_install && !$needs_update,
'#type' => 'submit', '#type' => 'submit',
'#name' => $solution_pack_module, '#name' => $solution_pack_module,
); );
$form['#submit'] = array( $form['#submit'] = array(
'fedora_repository_solution_pack_form_submit', 'fedora_repository_solution_pack_form_submit',
); );

Loading…
Cancel
Save