Tripal
Functions
tripal_bulk_loader.loader.inc File Reference

Functions

 tripal_bulk_loader_add_loader_job_form ($form, &$form_state, $node)
 
 tripal_bulk_loader_add_loader_job_form_submit ($form, $form_state)
 
 tripal_bulk_loader_load_data ($nid, $job_id)
 
 process_data_array_for_line ($priority, &$data, &$default_data, $addt)
 
 tripal_bulk_loader_add_spreadsheetdata_to_values ($values, $line, $field2column)
 
 tripal_bulk_loader_add_foreignkey_to_values ($table_array, $values, $data, $record2priority, $nid, $priority, $default_data)
 
 tripal_bulk_loader_regex_tranform_values ($values, $table_data, $line)
 
 tripal_bulk_loader_flatten_array ($values)
 
 tripal_bulk_loader_progress_bar ($current=0, $total=100, $size=50)
 
 tripal_bulk_loader_progress_file_track_job ($job_id, $record_added, $line_complete=FALSE, $close=FALSE)
 
 tripal_bulk_loader_throw_error ($msg, $args, $severity)
 
 tripal_bulk_loader_finish_loading ($nid, $loaded_without_errors)
 

Detailed Description

Handles the actual loading of data.

Function Documentation

◆ process_data_array_for_line()

process_data_array_for_line (   $priority,
$data,
$default_data,
  $addt 
)

Process the data array for a given line

Parameters
$addtRequires: field2column', 'record2priority', 'line', 'line_num', 'group_index', 'node', 'nid'

◆ tripal_bulk_loader_add_foreignkey_to_values()

tripal_bulk_loader_add_foreignkey_to_values (   $table_array,
  $values,
  $data,
  $record2priority,
  $nid,
  $priority,
  $default_data 
)

Handles foreign keys in the values array.

Specifically, if the value for a field is an array then it is assumed that the array contains the name of the record whose values array should be substituted here. Thus the foreign record is looked up and the values array is substituted in.

◆ tripal_bulk_loader_add_loader_job_form()

tripal_bulk_loader_add_loader_job_form (   $form,
$form_state,
  $node 
)

Add Loader Job Form

This form is meant to be included on the node page to allow users to submit/re-submit loading jobs

◆ tripal_bulk_loader_add_loader_job_form_submit()

tripal_bulk_loader_add_loader_job_form_submit (   $form,
  $form_state 
)

Add Loader Job Form (Submit)

◆ tripal_bulk_loader_add_spreadsheetdata_to_values()

tripal_bulk_loader_add_spreadsheetdata_to_values (   $values,
  $line,
  $field2column 
)

This function adds the file data to the values array

Parameters
$valuesThe default values array -contains all constants
$lineAn array of values for the current line
$field2columnAn array mapping values fields to line columns
Returns
Supplemented values array

◆ tripal_bulk_loader_finish_loading()

tripal_bulk_loader_finish_loading (   $nid,
  $loaded_without_errors 
)

Finishes the loading job by setting variables and exiting.

◆ tripal_bulk_loader_flatten_array()

tripal_bulk_loader_flatten_array (   $values)

Flattens an array up to two levels Used for printing of arrays without taking up much space

◆ tripal_bulk_loader_load_data()

tripal_bulk_loader_load_data (   $nid,
  $job_id 
)

Tripal Bulk Loader

This is the function that's run by tripal_launch_jobs to bulk load chado data.

Parameters
$nidThe Node ID of the bulk loading job node to be loaded. All other needed data is expected to be in the node (ie: template ID and file)

Note: Instead of returning a value this function updates the tripal_bulk_loader.status. Errors are thrown through watchdog and can be viewed at admin/reports/dblog.

◆ tripal_bulk_loader_progress_bar()

tripal_bulk_loader_progress_bar (   $current = 0,
  $total = 100,
  $size = 50 
)

Used to display loader progress to the user

◆ tripal_bulk_loader_progress_file_track_job()

tripal_bulk_loader_progress_file_track_job (   $job_id,
  $record_added,
  $line_complete = FALSE,
  $close = FALSE 
)

Keep track of progress in file rather then database

This provides an alternative method to keep track of progress that doesn't require the database. It was needed because you can't switch databases within a transaction... Waiting until the end of a constant set is much too long to wait for any indication that things are working.

Each line represents a line processed in the loading file. Each period (.) represents a successfully inserted record.

Parameters
$job_idThe ID of the current tripal job
$record_addedA boolean indicated whether a record was added successfully
$line_completeA boolean indicating whether the current line is finished
$closeA boolean indicating that the file should be closed

◆ tripal_bulk_loader_regex_tranform_values()

tripal_bulk_loader_regex_tranform_values (   $values,
  $table_data,
  $line 
)

Uses a supplied regex to transform spreadsheet values

Parameters
$valuesThe select/insert values array for the given table
$table_dataThe data array for the given table

◆ tripal_bulk_loader_throw_error()

tripal_bulk_loader_throw_error (   $msg,
  $args,
  $severity 
)

Used to throw a hopefully human-readable error.