function tripal_cv_obo_form_submit

2.x tripal_cv.obo_loader.inc tripal_cv_obo_form_submit($form, &$form_state)
1.x obo_loader.inc tripal_cv_obo_form_submit($form, &$form_state)

The submit function for the load ontology form. It registers a tripal job to import the user specified ontology file

Parameters

$form: The form array

$form_state: The form state array

Related topics

File

tripal_cv/includes/tripal_cv.obo_loader.inc, line 285
Functions to aid in loading ontologies into the chado cv module

Code

function tripal_cv_obo_form_submit($form, &$form_state) {

  $obo_id = $form_state['values']['obo_id'];
  $obo_name = trim($form_state['values']['obo_name']);
  $obo_url = trim($form_state['values']['obo_url']);
  $obo_file = trim($form_state['values']['obo_file']);
  $uobo_name = array_key_exists('uobo_name', $form_state['values']) ? trim($form_state['values']['uobo_name']) : '';
  $uobo_url = array_key_exists('uobo_url', $form_state['values']) ? trim($form_state['values']['uobo_url']) : '';
  $uobo_file = array_key_exists('uobo_file', $form_state['values']) ? trim($form_state['values']['uobo_file']) : '';

  // If the user requested to alter the details then do that.
  if ($form_state['clicked_button']['#name'] == 'update_obo_details' or 
    $form_state['clicked_button']['#name'] == 'update_load_obo') {
    $success = db_update('tripal_cv_obo')
      ->fields(array(
        'name' => $uobo_name,
        'path' => $uobo_url ? $uobo_url : $uobo_file,
      ))
      ->condition('obo_id', $obo_id)
      ->execute();
    if ($success) {
      drupal_set_message(t("The vocabulary %vocab has been updated.", array('%vocab' => $uobo_name)));
    }
    else {
      drupal_set_message(t("The vocabulary %vocab could not be updated.", array('%vocab' => $uobo_name)), 'error');
    }

  }
  // If the user requested to update and load then we've already handled the
  // update now we just need to load.
  if ($form_state['clicked_button']['#name'] == 'update_load_obo') {
    tripal_submit_obo_job(array('obo_id' => $obo_id));
  }
  if ($form_state['clicked_button']['#name'] == 'add_new_obo') {
    $success = db_insert('tripal_cv_obo')
      ->fields(array(
        'name' => $obo_name,
        'path' => $obo_url ? $obo_url : $obo_file,
      ))
      ->execute();
    if ($success) {
      drupal_set_message(t("The vocabulary %vocab has been added.", array('%vocab' => $obo_name)));
    }
    else {
      drupal_set_message(t("The vocabulary %vocab could not be added.", array('%vocab' => $obo_name)), 'error');
    }
  }
}