From 741a1727242c9d9941ce64e80bc75711b187fafb Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 11:13:44 -0400 Subject: [PATCH 01/11] Added solution pack install boilerplate --- fedora_repository.solutionpacks.inc | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 756f8bf0..c45f475a 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -200,3 +200,54 @@ function solution_pack_add_form_association($content_model, $form_name) { } } +/** + * Solution pack install helper + * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" + * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) + * @param type $content_model The Content Model (islandora:docs_sp_cm) + */ +function solution_pack_installer($mods_form_name, $mods_form_file, $content_model) +{ + module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); + + if (!XMLFormDatabase::Exists($mods_form_name)) { + //$module_path = drupal_get_path('module', ISLANDORA_SP_MODULE_NAME); + $definition = new DOMDocument(); + $definition->load($mods_form_file); + XMLFormDatabase::Create($mods_form_name, $definition); + } + + // Associates the form with the content model + $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); + + if (!$result) { + $object = new stdClass(); + $object->content_model = $content_model; + $object->form_name = $mods_form_name; + $object->dsid = 'MODS'; + $object->title_field = "['titleInfo']['title']"; + $object->transform = 'mods_to_dc.xsl'; + $result = drupal_write_record('islandora_content_model_forms', $object); + } +} + +/** + * Solution Pack Uninstall Helper + * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" + * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) + * @param type $content_model The Content Model (islandora:docs_sp_cm) + */ +function solution_pack_uninstaller($mods_form_name, $mods_form_name, $content_model) +{ + module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); + + if (XMLFormDatabase::Exists($mods_form_name)) { + XMLFormDatabase::Delete($mods_form_name); + } + + $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); + + if (!$result) { + db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name); + } +} From 800407ec54029acb876031f6549b8e45d1e1c08c Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 11:47:59 -0400 Subject: [PATCH 02/11] Renamed the files to something more appropriate --- fedora_repository.solutionpacks.inc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index c45f475a..64dc78bb 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -201,12 +201,12 @@ function solution_pack_add_form_association($content_model, $form_name) { } /** - * Solution pack install helper + * Solution pack register form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) * @param type $content_model The Content Model (islandora:docs_sp_cm) */ -function solution_pack_installer($mods_form_name, $mods_form_file, $content_model) +function solution_pack_register_form($mods_form_name, $mods_form_file, $content_model) { module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); @@ -232,12 +232,12 @@ function solution_pack_installer($mods_form_name, $mods_form_file, $content_mode } /** - * Solution Pack Uninstall Helper + * Solution pack unregister form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) * @param type $content_model The Content Model (islandora:docs_sp_cm) */ -function solution_pack_uninstaller($mods_form_name, $mods_form_name, $content_model) +function solution_pack_unregister_form($mods_form_name, $mods_form_name, $content_model) { module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); From 9948737d7c585ff4297477a688023b92b32e342e Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 12:20:28 -0400 Subject: [PATCH 03/11] Added a force reinstall option --- fedora_repository.solutionpacks.inc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 64dc78bb..b7edc8ab 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -205,16 +205,28 @@ function solution_pack_add_form_association($content_model, $form_name) { * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) * @param type $content_model The Content Model (islandora:docs_sp_cm) + * @param boolean $force Force a reinstall */ -function solution_pack_register_form($mods_form_name, $mods_form_file, $content_model) +function solution_pack_register_form($mods_form_name, $mods_form_file, $content_model, $force=false) { + // Load the form builder database module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); + + // Load the form + $definition = new DOMDocument(); + $definition->load($mods_form_file); - if (!XMLFormDatabase::Exists($mods_form_name)) { - //$module_path = drupal_get_path('module', ISLANDORA_SP_MODULE_NAME); - $definition = new DOMDocument(); - $definition->load($mods_form_file); + // If it doesn't exist + if (!XMLFormDatabase::Exists($mods_form_name) ) { + + // Create the form XMLFormDatabase::Create($mods_form_name, $definition); + + // Force Update of an existing form + } elseif ( $force == true ) { + + // Update the form + XMLFormDatabase::Update($mods_form_name, $definition); } // Associates the form with the content model @@ -234,10 +246,9 @@ function solution_pack_register_form($mods_form_name, $mods_form_file, $content_ /** * Solution pack unregister form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" - * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) * @param type $content_model The Content Model (islandora:docs_sp_cm) */ -function solution_pack_unregister_form($mods_form_name, $mods_form_name, $content_model) +function solution_pack_unregister_form($mods_form_name, $content_model) { module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); From 783e2da0c86117ab8456b4daff31efabd2047c01 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 12:30:33 -0400 Subject: [PATCH 04/11] Cleaned up, added a force and fixed a bug in the delete --- fedora_repository.solutionpacks.inc | 37 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index b7edc8ab..bdd36132 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -211,34 +211,43 @@ function solution_pack_register_form($mods_form_name, $mods_form_file, $content_ { // Load the form builder database module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); - - // Load the form - $definition = new DOMDocument(); - $definition->load($mods_form_file); - + // If it doesn't exist if (!XMLFormDatabase::Exists($mods_form_name) ) { + + // Load the form + $definition = new DOMDocument(); + $definition->load($mods_form_file); // Create the form XMLFormDatabase::Create($mods_form_name, $definition); // Force Update of an existing form } elseif ( $force == true ) { + + // Load the form + $definition = new DOMDocument(); + $definition->load($mods_form_file); // Update the form XMLFormDatabase::Update($mods_form_name, $definition); } - // Associates the form with the content model - $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); + // Check to see if the form has already been registered + $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); + // Check for results if (!$result) { + + // Create a model for the database $object = new stdClass(); $object->content_model = $content_model; $object->form_name = $mods_form_name; $object->dsid = 'MODS'; $object->title_field = "['titleInfo']['title']"; $object->transform = 'mods_to_dc.xsl'; + + // Write the association $result = drupal_write_record('islandora_content_model_forms', $object); } } @@ -250,15 +259,23 @@ function solution_pack_register_form($mods_form_name, $mods_form_file, $content_ */ function solution_pack_unregister_form($mods_form_name, $content_model) { + // Load the form builders xmlformdatabase module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); + // Check to see if the form exists if (XMLFormDatabase::Exists($mods_form_name)) { + + // Delete the form XMLFormDatabase::Delete($mods_form_name); } - + + // Check to see if the form has already been registered $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); - - if (!$result) { + + // Is there anything to delete + if ($result) { + + // Delete the association db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name); } } From 0a13bf248fb509b7a0c2fa23719f0ed9fd819834 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 13:13:50 -0400 Subject: [PATCH 05/11] We now use the database to store instead of xmlformdatabase and a force has been added --- fedora_repository.solutionpacks.inc | 132 ++++++++++++++++------------ 1 file changed, 76 insertions(+), 56 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index bdd36132..34a4b33d 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -181,7 +181,7 @@ function solution_pack_add_form($form_name, $form_xml) { $object->name = $form_name; $object->form = $form_xml; $result = drupal_write_record('xml_forms', $object); - drupal_set_message(t("Added @name", array("@name" => $name))); + drupal_set_message(t("Added @name", array("@name" => $form_name))); } } @@ -196,7 +196,7 @@ function solution_pack_add_form_association($content_model, $form_name) { $object->title_field = "['titleInfo']['title']"; $object->transform = 'mods_to_dc.xsl'; $result = drupal_write_record('islandora_content_model_forms', $object); - drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$name))); + drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$form_name))); } } @@ -204,78 +204,98 @@ function solution_pack_add_form_association($content_model, $form_name) { * Solution pack register form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) - * @param type $content_model The Content Model (islandora:docs_sp_cm) - * @param boolean $force Force a reinstall + * @return int 0 = Ok and 1 = Unable to load file */ -function solution_pack_register_form($mods_form_name, $mods_form_file, $content_model, $force=false) +function solution_pack_register_form($mods_form_name, $mods_form_file, $force=false) { - // Load the form builder database - module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); - - // If it doesn't exist - if (!XMLFormDatabase::Exists($mods_form_name) ) { + // Lookup the form + $results = db_result(db_query('Select name from {xml_forms} where name = "%s"', $mods_form_name)); + + // Check to see if there is anything to do + if ( $results && $force==false) { - // Load the form - $definition = new DOMDocument(); - $definition->load($mods_form_file); - - // Create the form - XMLFormDatabase::Create($mods_form_name, $definition); - - // Force Update of an existing form - } elseif ( $force == true ) { - - // Load the form - $definition = new DOMDocument(); - $definition->load($mods_form_file); + // Nothing to do so early out + return 0; + } + + // Get the contents of the file + $mods_form_data = file_get_contents($mods_form_file); + + // Didn't load the file + if ( ! $mods_form_data ) { - // Update the form - XMLFormDatabase::Update($mods_form_name, $definition); + // Return an error + return 1; } - - // Check to see if the form has already been registered - $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); - // Check for results - if (!$result) { + // Create the data model + $object = new stdClass(); + $object->name = $mods_form_name; + $object->form = $mods_form_data; + + // Are we adding the form + if ( ! $results ) { - // Create a model for the database - $object = new stdClass(); - $object->content_model = $content_model; - $object->form_name = $mods_form_name; - $object->dsid = 'MODS'; - $object->title_field = "['titleInfo']['title']"; - $object->transform = 'mods_to_dc.xsl'; + // Add the model to the database + $result = drupal_write_record('xml_forms', $object); - // Write the association - $result = drupal_write_record('islandora_content_model_forms', $object); + } else { + + // Update the model in the database + $result = drupal_write_record('xml_forms', $object, array("name" => $mods_form_name)); } + + // Log the action + drupal_set_message(t("Added @name", array("@name" => $mods_form_name))); } /** - * Solution pack unregister form + * Solution pack register form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $content_model The Content Model (islandora:docs_sp_cm) */ -function solution_pack_unregister_form($mods_form_name, $content_model) -{ - // Load the form builders xmlformdatabase - module_load_include('inc', 'xml_form_builder', 'XMLFormDatabase'); - - // Check to see if the form exists - if (XMLFormDatabase::Exists($mods_form_name)) { +function solution_pack_register_form_association($mods_form_name, $content_model, $force=false) { + + // Query the database for previous associations + $results = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', + $content_model, $mods_form_name)); + + // Check to see if there is anything to do + if ( $results && $force==false) { - // Delete the form - XMLFormDatabase::Delete($mods_form_name); + // Nothing to do so early out + return; } - // Check to see if the form has already been registered - $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name)); + // Create a model for the database + $object = new stdClass(); + $object->content_model = $content_model; + $object->form_name = $mods_form_name; + $object->dsid = 'MODS'; + $object->title_field = "['titleInfo']['title']"; + $object->transform = 'mods_to_dc.xsl'; - // Is there anything to delete - if ($result) { + // Are we adding the form association + if ( ! $results ) { - // Delete the association - db_query('DELETE FROM {islandora_content_model_forms} WHERE content_model = "%s" and form_name = "%s"', $content_model, $mods_form_name); - } + // Add the association + $result = drupal_write_record('islandora_content_model_forms', $object); + } else { + + // Update the association + $result = drupal_write_record('islandora_content_model_forms', $object, array("content_model" => $content_model)); + } + + // Log the action + drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$mods_form_name))); +} + +/** + * Solution pack unregister form + * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" + * @param type $content_model The Content Model (islandora:docs_sp_cm) + */ +function solution_pack_unregister_form($mods_form_name, $content_model) +{ + } From f153548f0740eb7c3176d7feef345e03bca97997 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 13:27:41 -0400 Subject: [PATCH 06/11] Added delete calls --- fedora_repository.solutionpacks.inc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 34a4b33d..59e2f6da 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -290,12 +290,21 @@ function solution_pack_register_form_association($mods_form_name, $content_model drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$mods_form_name))); } +/** + * Solution pack unregister form + * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" + */ +function solution_pack_unregister_form($mods_form_name) +{ + +} + /** * Solution pack unregister form * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" * @param type $content_model The Content Model (islandora:docs_sp_cm) */ -function solution_pack_unregister_form($mods_form_name, $content_model) +function solution_pack_unregister_form_association($mods_form_name, $content_model) { } From 63ac3d44d30327e6af1660766a5385d5d2c6eb8d Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Mon, 5 Mar 2012 16:36:19 -0400 Subject: [PATCH 07/11] Added a new sp architecture based around alans ideas --- fedora_repository.newsp.inc | 11 +++++++++++ fedora_repository.solutionpacks.inc | 2 ++ formClass.inc | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 fedora_repository.newsp.inc diff --git a/fedora_repository.newsp.inc b/fedora_repository.newsp.inc new file mode 100644 index 00000000..98e6d3e0 --- /dev/null +++ b/fedora_repository.newsp.inc @@ -0,0 +1,11 @@ + diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 59e2f6da..f8f4bdd5 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -308,3 +308,5 @@ function solution_pack_unregister_form_association($mods_form_name, $content_mod { } + + diff --git a/formClass.inc b/formClass.inc index 86a5128f..4ac1c246 100644 --- a/formClass.inc +++ b/formClass.inc @@ -48,7 +48,16 @@ class formClass { 'file' => 'fedora_repository.solutionpacks.inc', 'type' => MENU_LOCAL_TASK, ); - + + $items['admin/settings/fedora_repository/newsp'] = array( + 'title' => t('New Solution Packs'), + 'description' => t('Install content models and collections required by installed solution packs.'), + 'page callback' => 'fedora_repository_newsp_page', + 'access arguments' => array('add fedora datastreams'), + 'file' => 'fedora_repository.newsp.inc', + 'type' => MENU_LOCAL_TASK, + ); + $items['islandoracm.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), 'page callback' => 'fedora_repository_display_schema', From bac9026c93fdaa5de361c7bb2b50b01eb0037a40 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Tue, 6 Mar 2012 10:30:11 -0400 Subject: [PATCH 08/11] cleanup my solution pack code --- fedora_repository.newsp.inc | 11 ----------- formClass.inc | 10 ---------- 2 files changed, 21 deletions(-) delete mode 100644 fedora_repository.newsp.inc diff --git a/fedora_repository.newsp.inc b/fedora_repository.newsp.inc deleted file mode 100644 index 98e6d3e0..00000000 --- a/fedora_repository.newsp.inc +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/formClass.inc b/formClass.inc index 4ac1c246..09bfce8b 100644 --- a/formClass.inc +++ b/formClass.inc @@ -48,16 +48,6 @@ class formClass { 'file' => 'fedora_repository.solutionpacks.inc', 'type' => MENU_LOCAL_TASK, ); - - $items['admin/settings/fedora_repository/newsp'] = array( - 'title' => t('New Solution Packs'), - 'description' => t('Install content models and collections required by installed solution packs.'), - 'page callback' => 'fedora_repository_newsp_page', - 'access arguments' => array('add fedora datastreams'), - 'file' => 'fedora_repository.newsp.inc', - 'type' => MENU_LOCAL_TASK, - ); - $items['islandoracm.xsd'] = array( 'title' => t('Islandora Content Model XML Schema Definition'), 'page callback' => 'fedora_repository_display_schema', From 286354196927f0b88d6f4734dec24bacf5470226 Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Tue, 6 Mar 2012 16:11:44 -0400 Subject: [PATCH 09/11] removed register functions --- fedora_repository.solutionpacks.inc | 110 ---------------------------- 1 file changed, 110 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index f8f4bdd5..1ee956f1 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -200,113 +200,3 @@ function solution_pack_add_form_association($content_model, $form_name) { } } -/** - * Solution pack register form - * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" - * @param type $mods_form_file The MODS form file name relative to the module (solutionpack/xml/mods_article.xml) - * @return int 0 = Ok and 1 = Unable to load file - */ -function solution_pack_register_form($mods_form_name, $mods_form_file, $force=false) -{ - // Lookup the form - $results = db_result(db_query('Select name from {xml_forms} where name = "%s"', $mods_form_name)); - - // Check to see if there is anything to do - if ( $results && $force==false) { - - // Nothing to do so early out - return 0; - } - - // Get the contents of the file - $mods_form_data = file_get_contents($mods_form_file); - - // Didn't load the file - if ( ! $mods_form_data ) { - - // Return an error - return 1; - } - - // Create the data model - $object = new stdClass(); - $object->name = $mods_form_name; - $object->form = $mods_form_data; - - // Are we adding the form - if ( ! $results ) { - - // Add the model to the database - $result = drupal_write_record('xml_forms', $object); - - } else { - - // Update the model in the database - $result = drupal_write_record('xml_forms', $object, array("name" => $mods_form_name)); - } - - // Log the action - drupal_set_message(t("Added @name", array("@name" => $mods_form_name))); -} - -/** - * Solution pack register form - * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" - * @param type $content_model The Content Model (islandora:docs_sp_cm) - */ -function solution_pack_register_form_association($mods_form_name, $content_model, $force=false) { - - // Query the database for previous associations - $results = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', - $content_model, $mods_form_name)); - - // Check to see if there is anything to do - if ( $results && $force==false) { - - // Nothing to do so early out - return; - } - - // Create a model for the database - $object = new stdClass(); - $object->content_model = $content_model; - $object->form_name = $mods_form_name; - $object->dsid = 'MODS'; - $object->title_field = "['titleInfo']['title']"; - $object->transform = 'mods_to_dc.xsl'; - - // Are we adding the form association - if ( ! $results ) { - - // Add the association - $result = drupal_write_record('islandora_content_model_forms', $object); - } else { - - // Update the association - $result = drupal_write_record('islandora_content_model_forms', $object, array("content_model" => $content_model)); - } - - // Log the action - drupal_set_message(t("Added association between @cm@name", array("@cm" => $content_model, "@name"=>$mods_form_name))); -} - -/** - * Solution pack unregister form - * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" - */ -function solution_pack_unregister_form($mods_form_name) -{ - -} - -/** - * Solution pack unregister form - * @param type $mods_form_name The MODS form name "Islandora Docs MODS Form" - * @param type $content_model The Content Model (islandora:docs_sp_cm) - */ -function solution_pack_unregister_form_association($mods_form_name, $content_model) -{ - -} - - From fec776de32f7c0aea82500fc30f5a41adf6c89ee Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Wed, 7 Mar 2012 14:02:34 -0400 Subject: [PATCH 10/11] 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); } From c5bcc3d082476386bbfa108ee8b3f55876a3bb8a Mon Sep 17 00:00:00 2001 From: Ben Woodhead Date: Wed, 7 Mar 2012 14:06:44 -0400 Subject: [PATCH 11/11] Removed some debug info --- fedora_repository.solutionpacks.inc | 3 --- 1 file changed, 3 deletions(-) diff --git a/fedora_repository.solutionpacks.inc b/fedora_repository.solutionpacks.inc index 12a4e08c..1fa64a9c 100644 --- a/fedora_repository.solutionpacks.inc +++ b/fedora_repository.solutionpacks.inc @@ -182,9 +182,6 @@ 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); }