function tripal_organism_delete_organisms

2.x tripal_organism.delete.inc tripal_organism_delete_organisms($organisms, $job = NULL)
3.x tripal_organism.delete.inc tripal_organism_delete_organisms($organisms, $job = NULL)

Function to actually delete the features indicated

Parameters

$organism_id: The list of organism_id of the features to delete

$job: The tripal_job id

Related topics

1 string reference to 'tripal_organism_delete_organisms'
tripal_organism_delete_form_submit in tripal_organism/includes/tripal_organism.delete.inc
Submit for the delete features form

File

tripal_organism/includes/tripal_organism.delete.inc, line 81
Administration Interface for deleting multiple organisms

Code

function tripal_organism_delete_organisms($organisms, $job = NULL) {

  global $user;

  // Deleting of organisms will cause a cascade delete on the
  // fassociated tables which may include the fatureloc table. The create_point
  // function which is not prefix with the schema, and an error occurs.
  // Therefore, we set the active database to chado to get around that
  // problem.
  //  $previous_db = chado_set_active('chado');

  // begin the transaction
  $transaction = db_transaction();
  print "\nNOTE: Deleting organisms is performed using a database transaction. \n" .
    "If the load fails or is terminated prematurely then the entire set of \n" .
    "deletions is rolled back and will not be found in the database\n\n";

  try {
    $values = array(
      'organism_id' => $organisms
    );
    $num_deletes = chado_select_record('organism', array('count(*) as cnt'), $values);
    print "Deleting " . $num_deletes[0]->cnt . " organisms\n";
    chado_delete_record('organism', $values);

    print "Removing orphaned organism pages\n";
    chado_cleanup_orphaned_nodes('organism');
  }
  catch (Exception $e) {
    print "\n"; // make sure we start errors on new line
    $transaction->rollback();
    print "FAILED: Rolling back database changes...\n";
    watchdog_exception('tripal_organism', $e);
    return 0;
  }
  //  chado_set_active($previous_db);
  print "\nDone\n";
}