function tripal_bulk_loader_load

2.x tripal_bulk_loader.chado_node.inc tripal_bulk_loader_load($nodes)
3.x tripal_bulk_loader.chado_node.inc tripal_bulk_loader_load($nodes)
1.x tripal_bulk_loader.module tripal_bulk_loader_load($node)

Implements node_load

Related topics

File

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

Code

function tripal_bulk_loader_load($node) {
  $sql = "SELECT * FROM {tripal_bulk_loader} WHERE nid = %d";
  $node = db_fetch_object(db_query($sql, $node->nid));

  $node->title = 'Bulk Loading Job: ' . $node->loader_name;

  // Add job details
  $progress = tripal_bulk_loader_progess_file_get_progress($node->job_id);
  $sql = "SELECT * FROM {tripal_jobs} WHERE job_id=%d";
  $node->job = db_fetch_object(db_query($sql, $node->job_id));

  // Add the loader template
  $sql = "SELECT * FROM {tripal_bulk_loader_template} WHERE template_id=%d";
  $results = db_fetch_object(db_query($sql, $node->template_id));
  $template = unserialize($results->template_array);
  $node->template = $results;
  $node->template->template_array = $template;

  // Add inserted records
  $sql = 'SELECT * FROM {tripal_bulk_loader_inserted} WHERE nid=%d';
  $resource = db_query($sql, $node->nid);
  while ($r = db_fetch_object($resource)) {
    $r->num_inserted = sizeof(preg_split('/,/', $r->ids_inserted));
    $node->inserted_records->{$r->table_inserted_into} = $r;
  }

  // Add exposed field list
  $node->exposed_fields = array();
  if ($template) {
    foreach ($template as $record_id => $record) {
      foreach ($record['fields'] as $field_id => $field) {
        if ($field['exposed']) {
          $node->exposed_fields[] = array(
            'record_id' => $record_id,
            'field_id' => $field_id,
            'title' => $field['title'],
          );
        }
      }
    }

    if (empty($node->exposed_fields)) {
      $node->exposed_fields[] = array();
    }
  }


  // Add constants
  $sql = 'SELECT * FROM {tripal_bulk_loader_constants} WHERE nid=%d ORDER BY group_id, record_id, field_id';
  $resource = db_query($sql, $node->nid);
  while ($r = db_fetch_object($resource)) {
    $node->constants[$r->group_id][$r->record_id][$r->field_id] = array(
      'constant_id' => $r->constant_id,
      'group_id' => $r->group_id,
      'chado_table' => $r->chado_table,
      'chado_field' => $r->chado_field,
      'record_id' => $r->record_id,
      'field_id' => $r->field_id,
      'value' => $r->value
    );
  }
  if (!$node->constants) {
    $node->constants[] = array();
  }

  return $node;
}