function tripal_bulk_loader_form

2.x tripal_bulk_loader.chado_node.inc tripal_bulk_loader_form($node, $form_state)
3.x tripal_bulk_loader.chado_node.inc tripal_bulk_loader_form($node, $form_state)
1.x tripal_bulk_loader.module tripal_bulk_loader_form($node, $form_state)

Implements node_form Used to gather the extra details stored with a Bulk Loading Job Node

Related topics

File

tripal_bulk_loader/tripal_bulk_loader.module, line 293
The functions for the Tripal bulk loader.

Code

function tripal_bulk_loader_form($node, $form_state) {
  $form = array();

  if (isset($form_state['values'])) {
    $node = $form_state['values'] + (array) $node;
    $node = (object) $node;
  }

  $sql = "SELECT * FROM {tripal_bulk_loader_template}";
  $results = db_query($sql);
  $templates = array();
  while ($template = db_fetch_object($results)) {
    $templates[$template->template_id] = $template->name;
  }

  if (!$templates) {
    $form['label'] = array(
      '#type' => 'item',
      '#description' => t("Loader template needs to be created before any bulk loader can be added. Go to 'Tripal Management > Bulk Loader Template' to create the template."),
      '#weight' => -10,
    );

    return $form;
  }

  $form['loader'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic Details'),
  );

  $form['loader']['loader_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Loading Job Name'),
    '#weight' => -10,
    '#required' => TRUE,
    '#default_value' => $node->loader_name
  );

  $form['loader']['template_id'] = array(
    '#type' => 'select',
    '#title' => t('Template'),
    '#description' => t('Please specify a template for this loader'),
    '#options' => $templates,
    '#weight' => -9,
    '#required' => TRUE,
    '#default_value' => $node->template_id,
  );

  $form['loader']['file'] = array(
    '#type' => 'textfield',
    '#title' => t('Data File'),
    '#description' => t('Please specify the data file to be loaded. This must be a tab-delimited text file with UNIX line endings.'),
    '#weight' => -8,
    '#default_value' => $node->file,
    '#maxlength' => 1024,
  );

  $form['loader']['has_header'] = array(
    '#type' => 'radios',
    '#title' => t('File has a Header'),
    '#options' => array(1 => 'Yes', 2 => 'No'),
    '#weight' => -7,
    '#default_value' => $node->file_has_header,
  );

  $form['loader']['keep_track_inserted'] = array(
    '#type' => 'radios',
    '#title' => t('Keep track of inserted record IDs'),
    '#description' => t('This enables the ability to revert an entire loading job even if '
      . 'it completed successfully. Furthermore, it displays the number of records '
      . 'successfully inserted into each table.'),
    '#options' => array(1 => 'Yes', 0 => 'No'),
    '#weight' => -7,
    '#default_value' => (isset($node->keep_track_inserted)) ? $node->keep_track_inserted : variable_get('tripal_bulk_loader_keep_track_inserted', FALSE),
  );

  return $form;
}