function tripal_core_chado_load_form

2.x tripal_core.chado_install.inc tripal_core_chado_load_form($form, $form_state)
1.x chado_install.inc tripal_core_chado_load_form()

Load Chado Schema Form

Related topics

1 string reference to 'tripal_core_chado_load_form'
tripal_core_menu in tripal_core/tripal_core.module
Implements hook_menu(). Defines all menu items needed by Tripal Core

File

tripal_core/includes/tripal_core.chado_install.inc, line 12
Functions to install chado schema through Drupal

Code

function tripal_core_chado_load_form($form, $form_state) {

  // we want to force the version of Chado to be set properly
  $real_version = chado_get_version(TRUE);

  // get the effective version.  Pass true as second argument
  // to warn the user if the current version is not compatible
  $version = chado_get_version(FALSE, TRUE);
  if (array_key_exists('values', $form_state)) {
    if ($form_state['values']['action_to_do'] == "Upgrade Chado v1.2 to v1.3") {
      $tables_list = implode(', ', array('analysis_cvterm', 'analysis_dbxref', 'analysis_pub',
        'analysis_relationship', 'contactprop', 'dbprop', 'feature_contact',
        'featuremap_contact', 'featuremap_dbxref', 'featuremap_organism', 'featuremapprop',
        'featureposprop', 'library_contact', 'library_expression', 'library_expressionprop',
        'library_featureprop', 'library_relationship', 'library_relationship_pub', 'nd_experiment_analysis',
        'organism_cvterm', 'organism_cvtermprop', 'organism_pub', 'organism_relationship',
        'organismprop_pub', 'phenotypeprop', 'phylotreeprop', 'project_analysis',
        'project_dbxref', 'project_feature', 'project_stock', 'pubauthor_contact',
        'stock_feature', 'stock_featuremap', 'stock_library', 'stockcollection_db'));
      $items = array(
        'PostgreSQL version 9.1 is required to perform this upgrade. If your Tripal
         site uses an older version please upgrade before proceeding.',
        'A major change between Chado v1.2 and v1.3 is that primary and foreign
         keys were upgraded from integers to big integers. If your site has custom
         materialized views that will hold data derived from fields changed to
         big integers then you may need to alter the views to change the fields
         from integers to big integers and repopulate those views. If you have not
         added any materialized views you can ignore this issue.',
        'Custom PL/pgSQL functions that expect primary and
         foreign key fields to be integers will not work after the upgrade.
         Those functions will need to be altered to accept big integers. If you
         do not have any custom PL/pgSQL functions you can ignore this issue.',
        'PostgreSQL Views that use fields that are converted to big
         integers will cause this upgrade to fail.  You must first remove
         those views, perform the upgrade and then recreate them with the
         appropriate fields change to big integers. If you do not have custom
         PostgreSQL Views you can ignore this issue.',
        'Several new tables were added to Chado v1.3.  However, some groups have
         added these tables to their Chado v1.2 installation.  The Tripal upgrader
         will alter the primary and foreign keys of those tables to be "bigints"
         if they already exist but will otherwise leave them the same.  You should
         verify that any tables with Chado v1.3 names correctly match the v1.3 schema.
         Otherwise you may have problems using Tripal. If you have not added any
         Chado v1.3 tables to your Chado v1.2 database you can ignore this issue.
         These are the newly added tables:  ' .
          $tables_list . '.'
      );
      $list = theme_item_list(array(
        'items' => $items,
        'title' => '',
        'type' => 'ul',
        'attributes' => array(),
      ));
      drupal_set_message('Please note: the upgrade of Chado from v1.2 to v1.3 may
          require several fixes to your database. Please review the following
          list to ensure a safe upgrade. The Tripal upgrader is
          not able to fix these problems automatically: ' . $list, 'warning');
    }
    if ($form_state['values']['action_to_do'] == "Install Chado v1.3" or 
      $form_state['values']['action_to_do'] == "Install Chado v1.2" or 
      $form_state['values']['action_to_do'] == "Install Chado v1.11") {
      drupal_set_message('Please note: if Chado is already installed it will
          be removed and recreated and all data will be lost. If this is
          desired or if this is the first time Chado has been installed
          you can ignore this issue.', 'warning');
    }
  }

  $form['current_version'] = array(
    '#type' => 'item',
    '#title' => t("Current installed version of Chado:"),
    '#description' => $real_version,
  );

  $form['action_to_do'] = array(
    '#type' => 'radios',
    '#title' => 'Installation/Upgrade Action',
    '#options' => array(
      'Install Chado v1.3' => t('New Install of Chado v1.3 (erases all existing Chado data if Chado already exists)'),
      'Upgrade Chado v1.2 to v1.3' => t('Upgrade existing Chado v1.2 to v1.3 (no data is lost)'),
      'Install Chado v1.2' => t('New Install of Chado v1.2 (erases all existing Chado data if Chado already exists)'),
      'Upgrade Chado v1.11 to v1.2' => t('Upgrade existing Chado v1.11 to v1.2 (no data is lost)'),
      'Install Chado v1.11' => t('New Install of Chado v1.11 (erases all existing Chado data if Chado already exists)'),
    ),
    '#description' => t('Select an action to perform. If you want to install Chado all other Tripal modules must not be installed.'),
    '#required' => TRUE,
    '#ajax' => array(
      'callback' => "tripal_core_chado_load_form_ajax_callback",
      'wrapper' => 'tripal_core_chado_load_form',
      'effect' => 'fade',
      'method' => 'replace',
    ),
  );

  $form['warning'] = array(
    '#markup' => "<div><font color=\"red\">WARNING:</font>" . t('A new install of
      Chado will remove and recreate the Chado database if it already exists.') . '</div>',
  );

  $form['button'] = array(
    '#type' => 'submit',
    '#value' => t('Install/Upgrade Chado'),
  );

  $form['#prefix'] = '<div id="tripal_core_chado_load_form">';
  $form['#suffix'] = '</div>';
  return $form;
}