Quellcode durchsuchen

Merge branch '7.x-2.x' of git.drupal.org:sandbox/spficklin/1337878 into 7.x-2.x

Stephen Ficklin vor 11 Jahren
Ursprung
Commit
11d4f56a1b

+ 42 - 64
tripal_bulk_loader/includes/tripal_bulk_loader.admin.inc

@@ -5,76 +5,54 @@
  * Bulk Loader Administration (Miscellaneous)
  */
 
-
-
-/**
- * Provides a description page and quick links for template management
- *
- * @ingroup tripal_bulk_loader
- */
-function tripal_bulk_loader_admin_manage_templates() {
+function tripal_bulk_loader_admin_jobs_listing() {
   $output = '';
-  $output .= '<p>' . t('Templates, as the term is used for this module, refer to plans
-  describing how the columns in the data file supplied to a bulk loading job map to tables
-  and fields in chado. Templates are created independently of bulk loading jobs so that
-  they can be re-used. Thus you only need one template to load any number of files of the
-  same format.') . '</p>';
+
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  drupal_set_breadcrumb($breadcrumb);
+
+  // Add the view
+  $jobs_view = views_embed_view('tripal_bulk_loading_jobs','default');
+  $template_view = views_embed_view('tripal_bulk_loader_templates','default');
+  if (isset($jobs_view) && isset($template_view)) {
+    $output .= $jobs_view;
+  }
+  else {
+    $output .= '<p>The Tripal Bulk Loader uses primarily views to provide an '
+      . 'administrative interface. Currently one or more views needed for this '
+      . 'administrative interface are disabled. <strong>Click each of the following links to '
+      . 'enable the pertinent views</strong>:</p>';
+    $output .= '<ul>';
+    if (!isset($jobs_view)) {
+      $output .= '<li>'.l('Tripal Bulk Loading Jobs', 'admin/tripal/loaders/bulk/views/jobs/enable').'</li>';
+    }
+    if (!isset($template_view)) {
+      $output .= '<li>'.l('Tripal Bulk Loader Templates', 'admin/tripal/loaders/bulk/views/templates/enable').'</li>';
+    }
+    $output .= '</ul>';
+  }
 
   return $output;
 }
 
-/**
- * Provides a listing of bulk loader jobs and links for administration
- *
- * @ingroup tripal_bulk_loader
- */
-function tripal_bulk_loader_admin_jobs() {
-  $output = '';
-  $num_jobs_per_page = 50;
-
-  $output .= '<p>' . t('Jobs are not automatically submitted to the tripal jobs management
-  system when they are first created. Any jobs listed below with a status of "Initialized"
-  will not have a Job ID until you go to the bulk loader page and submit the job.') . '</p>';
-
-  $header = array(
-    array('data' => 'Job ID', 'field' => 'job_id', 'sort' => 'DESC'),
-    array('data' => 'Name', 'field' => 'loader_name'),
-    array('data' =>  'Template', 'field' => 'template_name'),
-    array('data' =>  'Status', 'field' => 'job_status'),
-    array('data' => 'Progress', 'field' => 'progress'),
-    '');
-  $rows = array();
-  $query = db_select('tripal_bulk_loader', 'n')->extend('TableSort');
-  $query->join('tripal_bulk_loader_template', 't', 'cast(n.template_id as integer) = t.template_id');
-  $query->join('tripal_jobs', 'j', 'n.job_id = j.job_id');
-  $query->fields('n')
-    ->fields('t', array('name'))
-    ->fields('j', array('progress'))
-    ->orderByHeader($header);
-  $result = $query->execute();
-  /**
-  $resource = pager_query("SELECT n.*, t.name as template_name, j.progress
-    FROM {tripal_bulk_loader} n
-    LEFT JOIN {tripal_bulk_loader_template} t ON cast(n.template_id as integer) = t.template_id
-    LEFT JOIN {tripal_jobs} j ON n.job_id = j.job_id"
-    . tablesort_sql($header),
-    $num_jobs_per_page);
-    */
-  foreach ($result as $n) {
-    $rows[] = array(
-      l($n->job_id, 'admin/tripal/tripal_jobs/view/' . $n->job_id),
-      l($n->loader_name, 'node/' . $n->nid),
-      l($n->template_name, 'admin/tripal/loaders/bulk/template/'.$n->template_id.'/edit'),
-      $n->job_status,
-      ($n->progress) ? $n->progress . '%' : '',
-      l('View', 'node/' . $n->nid) . ' | ' .  l('Edit', 'node/' . $n->nid . '/edit')
-    );
-  }
-  $output .= theme_table(array('header' => $header, 'rows' => $rows));
+function tripal_bulk_loader_admin_enable_view($view_name) {
 
-  $output .= theme('pager');
-
-  return $output;
+  $status = variable_get('views_defaults', array());
+  if (isset($status[$view_name])) {
+    $status[$view_name] = FALSE;
+    variable_set('views_defaults', $status);
+    drupal_set_message("Successfully Enabled $view_name");
+  }
+  else {
+    drupal_set_message("Unable to find a view by the name of '$view_name'",'error');
+  }
+  drupal_goto('admin/tripal/loaders/bulk');
 }
 
 /**

+ 119 - 11
tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc

@@ -19,6 +19,16 @@
  */
 function tripal_bulk_loader_modify_template_base_form($form, $form_state = NULL, $mode) {
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  drupal_set_breadcrumb($breadcrumb);
+
    // get template id from path and rebuild form
   if (isset($form_state['build_info']['args'][1])) {
     $mode = 'edit';
@@ -533,6 +543,16 @@ function tripal_bulk_loader_modify_template_base_form_submit($form, &$form_state
 function tripal_bulk_loader_delete_template_base_form($form, $form_state) {
   $form = array();
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  drupal_set_breadcrumb($breadcrumb);
+
   $template_id = $form_state['build_info']['args'][0];
   $form_state['storage']['template_id'] = $template_id;
 
@@ -624,6 +644,16 @@ function tripal_bulk_loader_delete_template_base_form_submit($form, &$form_state
 function tripal_bulk_loader_import_template_form($form, $form_state) {
   $form = array();
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  drupal_set_breadcrumb($breadcrumb);
+
   $form['new_template_name'] = array(
     '#type' => 'textfield',
     '#title' => 'Template Name',
@@ -694,6 +724,16 @@ function tripal_bulk_loader_import_template_form_submit($form, &$form_state) {
  */
 function tripal_bulk_loader_export_template_form($form, $form_state) {
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  drupal_set_breadcrumb($breadcrumb);
+
   $template_id = $form_state['build_info']['args'][0];
   $form_state['storage']['template_id'] = $template_id;
   if ($template_id > 0) {
@@ -763,6 +803,17 @@ function tripal_bulk_loader_edit_template_record_form($form, $form_state) {
     return $form;
   }
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  $breadcrumb[] = l('Edit Template', 'admin/tripal/loaders/bulk/template/' . $template_id . '/edit');
+  drupal_set_breadcrumb($breadcrumb);
+
   // Pre-process values/defaults ---------------------------
 
   // If this is the first load of the form (no form state) we need to initialize some variables
@@ -1115,6 +1166,17 @@ function tripal_bulk_loader_delete_template_record_form($form, $form_state) {
     return $form;
   }
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  $breadcrumb[] = l('Edit Template', 'admin/tripal/loaders/bulk/template/' . $template_id . '/edit');
+  drupal_set_breadcrumb($breadcrumb);
+
   $_GET['record_name'] = (isset($_GET['record_name'])) ?  $_GET['record_name'] : '';
   $_GET['chado_table'] = (isset($_GET['chado_table'])) ?  $_GET['chado_table'] : '';
   $_GET['record_mode'] = (isset($_GET['record_mode'])) ?  $_GET['record_mode'] : '';
@@ -1221,7 +1283,18 @@ function tripal_bulk_loader_duplicate_template_record_form($form, &$form_state)
     return $form;
   }
 
-    $_GET['record_name'] = (isset($_GET['record_name'])) ?  $_GET['record_name'] : '';
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  $breadcrumb[] = l('Edit Template', 'admin/tripal/loaders/bulk/template/' . $template_id . '/edit');
+  drupal_set_breadcrumb($breadcrumb);
+
+  $_GET['record_name'] = (isset($_GET['record_name'])) ?  $_GET['record_name'] : '';
   $_GET['chado_table'] = (isset($_GET['chado_table'])) ?  $_GET['chado_table'] : '';
   $_GET['record_mode'] = (isset($_GET['record_mode'])) ?  $_GET['record_mode'] : '';
 
@@ -1604,6 +1677,10 @@ function tripal_bulk_loader_template_field_form_default_values($mode, &$form_sta
   $v['foreign_field'] = (isset($form_state['values']['foreign_field'])) ? $form_state['values']['foreign_field'] : current($ref_chado_fields);
   $v['required'] = (isset($form_state['values']['required'])) ? $form_state['values']['required'] : FALSE;
 
+  if (isset($original_field['regex']) && empty($form_state['storage']['regex']['pattern'])) {
+    $form_state['storage']['regex']['pattern'] = $original_field['regex']['pattern'];
+    $form_state['storage']['regex']['replace'] = $original_field['regex']['replace'];
+  }
   $v['regex_are_set'] = (isset($form_state['storage']['regex']['pattern'])) ? TRUE : FALSE;
   $v['regex-pattern'] = (isset($form_state['storage']['regex']['pattern'])) ? $form_state['storage']['regex']['pattern'] : array();
   $v['regex-replace'] = (isset($form_state['storage']['regex']['replace'])) ? $form_state['storage']['regex']['replace'] : array();
@@ -1643,6 +1720,17 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
 
   $values = tripal_bulk_loader_template_field_form_default_values($mode, $form_state);
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  $breadcrumb[] = l('Edit Template', 'admin/tripal/loaders/bulk/template/' . $values['template_id'] . '/edit');
+  drupal_set_breadcrumb($breadcrumb);
+
   $form['template_name'] = array(
     '#type' => 'item',
     '#title' => 'Template',
@@ -1660,7 +1748,13 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#suffix' => '</div>',
   );
 
-  $form['fields']['field_type'] = array(
+  $form['fields']['basic'] = array(
+    '#type' => 'markup',
+    '#prefix' => '<div class="basic">',
+    '#suffix' => '</div>'
+  );
+
+  $form['fields']['basic']['field_type'] = array(
     '#type' => 'radios',
     '#title' => t('Type of Field'),
     '#options' => array(
@@ -1677,7 +1771,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     ),
   );
 
-  $form['fields']['field_group']  = array(
+  $form['fields']['basic']['field_group']  = array(
     '#type' => 'select',
     '#title' => 'Record',
     '#description' => 'This is used to group a set of fields together allowing '
@@ -1692,7 +1786,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#required' => TRUE,
   );
 
-  $form['fields']['record_name'] = array(
+  $form['fields']['basic']['record_name'] = array(
     '#type' => ($values['no_record_id']) ? 'textfield' : 'hidden',
     '#title' => 'Unique Record Name',
     '#prefix' => '<div id="tripal_bulk_loader_template-add_record">',
@@ -1701,7 +1795,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#default_value' => $values['record_name'],
   );
 
-  $form['fields']['field_title'] = array(
+  $form['fields']['basic']['field_title'] = array(
     '#type' => 'textfield',
     '#title' => t('Human-readable Title for Field'),
     '#default_value' => $values['field_title'],
@@ -1844,7 +1938,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#type' => 'fieldset',
     '#title' => 'Additional Options',
     '#collapsible' => TRUE,
-    '#collapsed' => TRUE
+    '#collapsed' => FALSE
   );
 
   $form['fields']['additional']['required'] = array(
@@ -1857,7 +1951,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#type' => 'fieldset',
     '#title' => 'Transform Data File Value Rules',
     '#collapsible' => TRUE,
-    '#collapsed' => $values['regex_are_set'],
+    '#collapsed' => FALSE//$values['regex_are_set'],
   );
 
   $form['fields']['additional']['regex_transform']['regex_description'] = array(
@@ -1873,16 +1967,17 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
 
   $form['fields']['additional']['regex_transform']['regex-data'] = array(
     '#tree' => TRUE,
+    '#theme' => 'tripal_bulk_loader_field_regex_fieldset'
   );
   foreach ($values['regex-pattern'] as $index => $pattern) {
     $data_element = array(
       'pattern' => array(
         '#type' => 'item',
-        '#markup' => $pattern,
+        '#markup' => check_plain($pattern),
       ),
       'replace' => array(
         '#type' => 'item',
-        '#markup' => $values['regex-replace'][$index],
+        '#markup' => check_plain($values['regex-replace'][$index]),
       ),
       'old_index' => array(
         '#type' => 'hidden',
@@ -1892,6 +1987,7 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
         '#type' => 'select',
         '#options' => range(0, sizeof($values['regex-pattern'])-1),
         '#default_value' => $index,
+        '#attributes' => array('class' => array('rank-weight')), // needed for table dragging
       ),
       'id' => array(
         '#type' => 'hidden',
@@ -1980,12 +2076,12 @@ function tripal_bulk_loader_template_field_form($form, $form_state = NULL) {
     '#value' => 'Test Transformation Rules'
   );
 
-  $form['fields']['submit-save'] = array(
+  $form['submit-save'] = array(
       '#type' => 'submit',
       '#value' => 'Save Changes'
   );
 
-  $form['fields']['submit-cancel'] = array(
+  $form['submit-cancel'] = array(
       '#type' => 'submit',
       '#value' => 'Cancel'
   );
@@ -2123,6 +2219,7 @@ function tripal_bulk_loader_template_field_form_submit($form, &$form_state) {
     // Add transformation rule to original field
     $form_state['storage']['regex']['pattern'][] = '/' . $form_state['values']['pattern'] . '/';
     $form_state['storage']['regex']['replace'][] = $form_state['values']['replace'];
+    $form_state['rebuild'] = TRUE;
     drupal_set_message(t('Successfully Added Transformation Rule'));
 
   }
@@ -2189,6 +2286,17 @@ function tripal_bulk_loader_delete_template_field_form($form, $form_state) {
     return $form;
   }
 
+  // set the breadcrumb
+  $breadcrumb = array();
+  $breadcrumb[] = l('Home', '<front>');
+  $breadcrumb[] = l('Administration', 'admin');
+  $breadcrumb[] = l('Tripal', 'admin/tripal');
+  $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
+  $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
+  $breadcrumb[] = l('Templates', 'admin/tripal/loaders/bulk/templates');
+  $breadcrumb[] = l('Edit Template', 'admin/tripal/loaders/bulk/template/' . $template_id . '/edit');
+  drupal_set_breadcrumb($breadcrumb);
+
   $_GET['record_name'] = (isset($_GET['record_name'])) ?  $_GET['record_name'] : '';
   $_GET['field_name'] = (isset($_GET['field_name'])) ?  $_GET['field_name'] : '';
   $_GET['chado_table'] = (isset($_GET['chado_table'])) ?  $_GET['chado_table'] : '';

+ 99 - 56
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -140,8 +140,10 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   drupal_set_time_limit(0);
 
   // set the status of the job (in the node not the tripal jobs)
-  db_query("UPDATE {tripal_bulk_loader} SET job_status=:status WHERE nid=:nid", array(':status' => 'Loading...', ':nid' => $nid))->execute();
-
+  db_update('tripal_bulk_loader')
+    ->fields(array('job_status' => 'Loading...'))
+    ->condition('nid', $nid)
+    ->execute();
 
   $node = node_load($nid);
   print "Template: " . $node->template->name . " (" . $node->template_id . ")\n";
@@ -149,8 +151,8 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   $total_lines = trim(`wc --lines < $node->file`);
   print "File: " . $node->file . " (" . $total_lines . " lines)\n";
 
-  print "\nClearing all prepared statements from previous runs of this loader...\n";
-  tripal_core_chado_clear_prepared('_'.$node->nid.'_');
+  //print "\nClearing all prepared statements from previous runs of this loader...\n";
+  //tripal_core_chado_clear_prepared('_'.$node->nid.'_');
 
   // Prep Work ==================================================================================
   print "\nPreparing to load...\n";
@@ -254,6 +256,14 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
   $original_default_data = $default_data;
   $group_index = 0;
   $total_num_groups = sizeof($node->constants);
+  // If there are no constant sets and no exposed fields
+  // then create an empty constant set so loader runs
+  if ($total_num_groups == 0 && empty($node->exposed_fields)) {
+    $node->constants = array(
+      0 => array()
+    );
+    $total_num_groups = 1;
+  }
   foreach ($node->constants as $group_id => $set) {
     // revert default data array for next set of constants
     $default_data = $original_default_data;
@@ -278,13 +288,13 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
             }
             else {
               print "ERROR: Template has changed after constants were assigned!\n";
-              watchdog('T_bulk_loader', 'Template has changed after constants were assigned', array(), WATCHDOG_NOTICE);
+              tripal_bulk_loader_throw_error('Template has changed after constants were assigned', array(), TRIPAL_NOTICE);
               exit(1);
             }
           }
           else {
             print "ERROR: Template has changed after constants were assigned!\n";
-            watchdog('T_bulk_loader', 'Template has changed after constants were assigned', array(), WATCHDOG_NOTICE);
+            tripal_bulk_loader_throw_error('Template has changed after constants were assigned', array(), TRIPAL_NOTICE);
             exit(1);
           }
         }
@@ -298,8 +308,8 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       $file = new SplFileObject($node->file, 'r');
     }
     catch (Exception $e) {
-      watchdog('T_bulk_loader', 'Could not open file %file',
-        array($node->file), WATCHDOG_ERROR);
+      tripal_bulk_loader_throw_error('Could not open file %file',
+        array('%file' => $node->file), TRIPAL_ERROR);
       return;
     }
 
@@ -324,15 +334,14 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
         break;
       case "all":
         print "\t\tStart Transaction...\n";
-        tripal_db_start_transaction();
+        $TRANSACTION = db_transaction();
         $transactions = TRUE;
-        $savepoint = "";
         break;
       case "row":
         print "\t\tStart Transaction...\n";
-        tripal_db_start_transaction();
+        $TRANSACTION = db_transaction();
         $transactions = TRUE;
-        $savepoint = "last_row_complete";
+        $new_transaction_per_row = TRUE;
         break;
     }
 
@@ -414,12 +423,12 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
 
         tripal_bulk_loader_progress_file_track_job($job_id, $no_errors);
         $failed = FALSE;
-        if ( !$no_errors ) {
+        if ($no_errors == FALSE) {
           // Encountered an error
           if ($transactions) {
-            tripal_db_rollback_transaction($savepoint);
+            $TRANSACTION->rollback();
           }
-          $failed = TRUE;
+          tripal_bulk_loader_finish_loading($node->nid, FALSE);
           break;
         }
       } // end of foreach table in default data array
@@ -427,46 +436,34 @@ function tripal_bulk_loader_load_data($nid, $job_id) {
       tripal_bulk_loader_progress_file_track_job($job_id, FALSE, TRUE);
 
       if ($failed) {
+        $TRANSACTION->rollback();
+        tripal_bulk_loader_finish_loading($node->nid, FALSE);
         break;
       }
       else {
         // Row inserted successfully
-        // Set savepoint if supplied
-        if ($savepoint) {
-          if ($num_lines == 1) {
-            tripal_db_set_savepoint_transaction($savepoint);
-          }
-          else {
-            // Tell it to remove the previous savepoint of the same name
-            tripal_db_set_savepoint_transaction($savepoint, TRUE);
-          }
+        if ($transactions && $new_transaction_per_row) {
+          // commit current transaction and start a new one
+          unset($TRANSACTION);
+          $TRANSACTION = db_transaction();
         }
       }
     } //end of foreach line of file
 
     // END Transaction
     if ($transactions) {
-      // end the transaction
-      tripal_db_commit_transaction();
+      unset($TRANSACTION);
     }
 
     if ($failed) {
       $loaded_without_errors = FALSE;
       break;
     }
-
     tripal_bulk_loader_progress_bar($total_lines, $total_lines);
     tripal_bulk_loader_progress_file_track_job($job_id, FALSE, FALSE, TRUE);
   } //end of foreach constant set
 
-  // set the status of the job (in the node not the tripal jobs)
-  if ($loaded_without_errors) {
-    $status = 'Loading Completed Successfully';
-  }
-  else {
-    $status = 'Errors Encountered';
-  }
-  db_query("UPDATE {tripal_bulk_loader} SET job_status=:status WHERE nid=:nid", array(':status' => $status, ':nid' => $nid))->execute();
+  tripal_bulk_loader_finish_loading($node->nid, $loaded_without_errors);
 
 }
 
@@ -500,14 +497,15 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
 
   $values = tripal_bulk_loader_regex_tranform_values($values, $table_data, $addt->line);
   if (!$values) {
-    //watchdog('T_bulk_loader', 'Line ' . $addt->line_num . ' Regex:<pre>' . print_r($values, TRUE) . print_r($table_data, TRUE) . '</pre>' . '</pre>', array(), WATCHDOG_NOTICE);
+    //tripal_bulk_loader_throw_error('Line ' . $addt->line_num . ' Regex:<pre>' . print_r($values, TRUE) . print_r($table_data, TRUE) . '</pre>' . '</pre>', array(), TRIPAL_NOTICE);
   }
 
   // get the table description
   $table_desc = tripal_core_get_chado_table_schema($table);
   if (!$table_desc) {
-    watchdog('T_bulk_loader', "Failure: Tripal does not know about the table named '%table'. If this is a custom table,
-      please define it first", array('%table' => $table), WATCHDOG_ERROR);
+    $msg = "Tripal does not know about the table named '%table'. If this is a custom table,
+      please define it first";
+    tripal_bulk_loader_throw_error($msg,  array('%table' => $table), TRIPAL_ERROR);
     $data[$priority]['error'] = TRUE;
     return;
   }
@@ -532,9 +530,9 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
           $values = array();
         }
         else {
-          $msg = "\nLine " . $addt->line_num . ' "' . $table_data['record_id'] .
+          $msg = "Line " . $addt->line_num . ' "' . $table_data['record_id'] .
             '" (' . $table_data['mode'] . ') Missing template required value: ' . $table . '.' . $field;
-          watchdog('T_bulk_loader', $msg, array(), WATCHDOG_WARNING);
+          tripal_bulk_loader_throw_error($msg, array(), TRIPAL_WARNING);
           $data[$priority]['error'] = TRUE;
           $no_errors = FALSE;
         }
@@ -556,10 +554,11 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
           !array_key_exists($field, $values) and                             // there is not a value for it
           !array_key_exists('default', $def) and                             // there is no default for it
           strcmp($def['type'], 'serial') != 0) {                             // it is not a 'serial' type column
-        $msg = "\nLine " . $addt->line_num . ' ' . $table_data['record_id'] .
+        $msg = "Line " . $addt->line_num . ' ' . $table_data['record_id'] .
                ' (' . $table_data['mode'] . ') Missing Database Required Value: ' . $table . '.' . $field;
-        watchdog('T_bulk_loader', $msg, array(), WATCHDOG_ERROR);
+        tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
         $data[$priority]['error'] = TRUE;
+        $no_errors = FALSE;
       }
     }
   }
@@ -569,19 +568,19 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
 
   // if there was an error already -> don't insert
   if (array_key_exists('error', $data[$priority]) and $data[$priority]['error']) {
-    watchdog('T_bulk_loader','Skipping processing of %table due to previous errors',array('%table'=>$table),WATCHDOG_NOTICE);
+    tripal_bulk_loader_throw_error('Skipping processing of %table due to previous errors',array('%table'=>$table),TRIPAL_NOTICE);
     return $no_errors;
   }
 
   // skip optional fields
   if ($skip_optional) {
-    watchdog('T_bulk_loader','Skipping an optional record (%record)',array('%record'=>$table_data['record_id']),WATCHDOG_NOTICE);
+    tripal_bulk_loader_throw_error('Skipping an optional record (%record)',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
   // check if it is already inserted
   if (array_key_exists('inserted', $table_data) and $table_data['inserted']) {
-    watchdog('T_bulk_loader','Skipping %record since it is already inserted',array('%record'=>$table_data['record_id']),WATCHDOG_NOTICE);
+    tripal_bulk_loader_throw_error('Skipping %record since it is already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
@@ -589,7 +588,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
   // the default_data array
   if (array_key_exists('selected', $table_data) and $table_data['selected']) {
     $data[$priority]['values_array'] = $default_data[$priority]['values_array'];
-    watchdog('T_bulk_loader','%record was already selected thus we are just returning the values previously selected.',array('%record'=>$table_data['record_id']),WATCHDOG_NOTICE);
+    tripal_bulk_loader_throw_error('%record was already selected thus we are just returning the values previously selected.',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
     return $no_errors;
   }
 
@@ -608,7 +607,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
   if (preg_match('/insert_unique/', $table_data['mode']) or
      $table_data['select_if_duplicate'] == 1 or
      $table_data['update_if_duplicate'] == 1) {
-    $options = array('is_duplicate' => TRUE);
+    $options = array('is_duplicate' => TRUE, 'print_errors' => TRUE);
     $duplicate = tripal_core_chado_select($table, array_keys($table_desc['fields']), $values, $options);
 
     // if this is a duplicate then substitute the values in the table_data array so
@@ -640,7 +639,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
       }
       // return if this is a select_if_duplicate
       if ($table_data['select_if_duplicate'] == 1) {
-        watchdog('T_bulk_loader','Simply returning values for %record since it was already inserted',array('%record'=>$table_data['record_id']),WATCHDOG_NOTICE);
+        tripal_bulk_loader_throw_error('Simply returning values for %record since it was already inserted',array('%record'=>$table_data['record_id']),TRIPAL_NOTICE);
         return $no_errors;
       }
     }
@@ -696,14 +695,16 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
 			}
 			if (!empty($match)) {
 				// Now we need to check if it already exists via a select
-				$results = tripal_core_chado_select($table, array_keys($table_desc['fields']), $match);
+				$results = tripal_core_chado_select($table, array_keys($table_desc['fields']), $match, array('print_errors' => TRUE));
 				// If not then insert
 				if (empty($results)) {
 					$options['statement_name'] = 'ins_'.$options['statement_name'];
+					$options['print_errors'] = TRUE;
 					$record = tripal_core_chado_insert($table, $values, $options);
 				}
 				else {
 				  $options['return_record'] = TRUE;
+				  $options['print_errors'] = TRUE;
   		    $record = tripal_core_chado_update($table, $match, $values, $options);
   		  }
   	  }
@@ -712,12 +713,13 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
         $table_data['mode'] . ') Unable to update record since none of the unique key or primary key fields were available ' .
         ' where values:' . print_r($values, TRUE);
 
-      	watchdog('T_bulk_loader', $msg, array(), WATCHDOG_ERROR);
+      	tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
       	$data[$priority]['error'] = TRUE;
       	$no_errors = FALSE;
   	  }
     }
     else {
+      $options['print_errors'] = TRUE;
       $record = tripal_core_chado_insert($table, $values, $options);
     }
 
@@ -727,7 +729,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
         $table_data['mode'] . ') Unable to insert record into ' . $table .
         ' where values:' . print_r($values, TRUE);
 
-      watchdog('T_bulk_loader', $msg, array(), WATCHDOG_ERROR);
+      tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
       $data[$priority]['error'] = TRUE;
       $no_errors = FALSE;
     }
@@ -786,14 +788,14 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
     // get the matches for this select
     $matches = array();
     if (is_array($values) and count($values) > 0) {
-      $matches = tripal_core_chado_select($table, array_keys($table_desc['fields']), $values);
+      $matches = tripal_core_chado_select($table, array_keys($table_desc['fields']), $values, array('print_errors' => TRUE));
     }
     // if the record doesn't exist and it's not optional then generate an error
     if (count($matches) == 0) {
       // No record on select
       if ($table_data['select_optional'] != 1) {
         $msg = "\nLine " . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') No Matching record in ' . $table . ' where values:' . print_r($values, TRUE);
-        watchdog('T_bulk_loader', $msg, array(), WATCHDOG_ERROR);
+        tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
         $data[$priority]['error'] = TRUE;
         $no_errors = FALSE;
       }
@@ -807,7 +809,7 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
     if (count($matches) > 1) {
       if ($table_data['select_optional'] != 1) {
         $msg = "\nLine " . $addt->line_num . ' ' . $table_data['record_id'] . ' (' . $table_data['mode'] . ') Too many matching records in ' . $table . ' where values:' . print_r($values, TRUE);
-        watchdog('T_bulk_loader', $msg, array(), WATCHDOG_WARNING);
+        tripal_bulk_loader_throw_error($msg, array(), TRIPAL_WARNING);
         $data[$priority]['error'] = TRUE;
         $no_errors = FALSE;
       }
@@ -915,7 +917,11 @@ function tripal_bulk_loader_add_foreignkey_to_values($table_array, $values, $dat
           array_key_exists($foreign_table, $tbl_description['foreign keys']) and
           array_key_exists($field, $tbl_description['foreign keys'][$foreign_table]['columns']) and
           $foreign_field == $tbl_description['foreign keys'][$foreign_table]['columns'][$field]) {
-         $values[$field] = $foreign_values;
+
+        if (sizeof($foreign_values) == 1 && isset($foreign_values->currval)) {
+          $foreign_values = $foreign_values->currval;
+        }
+        $values[$field] = $foreign_values;
       }
       // if the field in the Referral records is not in an FK relationship
       // with this field then we we have to get the requested value, we must
@@ -930,6 +936,7 @@ function tripal_bulk_loader_add_foreignkey_to_values($table_array, $values, $dat
             $fvalues = array($fk_description['primary key'][0] => $foreign_values);
             $columns = array($foreign_field);
             $options = array('statement_name' => 'pk_' . $foreign_table);
+            $options['print_errors'] = TRUE;
             $record  = tripal_core_chado_select($foreign_table, $columns, $fvalues, $options);
             if ($record) {
               $values[$field] = $record[0]->$foreign_field;
@@ -950,6 +957,7 @@ function tripal_bulk_loader_add_foreignkey_to_values($table_array, $values, $dat
           $fvalues  = $foreign_values;
           $columns = array($foreign_field);
           $options = array('statement_name' => 'blk_' . $nid . $priority . $foreign_table);
+          $options['print_errors'] = TRUE;
           $record  = tripal_core_chado_select($foreign_table, $columns, $fvalues, $options);
           if ($record) {
             $values[$field] = $record[0]->$foreign_field;
@@ -985,7 +993,7 @@ function tripal_bulk_loader_regex_tranform_values($values, $table_data, $line) {
     return $values;
   }
 
-  //watchdog('T_bulk_loader','Regex Transformation:<pre>'.print_r($table_data['regex_transform'], TRUE).'</pre>', array(), WATCHDOG_NOTICE);
+  //watchdog('T_bulk_loader','Regex Transformation:<pre>'.print_r($table_data['regex_transform'], TRUE).'</pre>', array(), TRIPAL_NOTICE);
 
   foreach ($table_data['regex_transform'] as $field => $regex_array) {
     if (!array_key_exists('replace', $regex_array) or
@@ -1155,3 +1163,38 @@ function tripal_bulk_loader_progress_file_track_job($job_id, $record_added, $lin
     variable_set('tripal_bulk_loader_progress_file_handle', NULL);
   }
 }
+
+function tripal_bulk_loader_throw_error($msg, $args, $severity) {
+  $options = array('print' => TRUE);
+  if ($severity == TRIPAL_NOTICE OR $severity == TRIPAL_INFO OR $severity == TRIPAL_DEBUG) {
+    unset($options['print']);
+  }
+
+  tripal_core_report_error(
+    'tripal_bulk',
+    $severity,
+    $msg,
+    $args,
+    $options
+  );
+}
+
+function tripal_bulk_loader_finish_loading($nid, $loaded_without_errors) {
+
+  // set the status of the job (in the node not the tripal jobs)
+  if ($loaded_without_errors) {
+    $status = 'Loading Completed Successfully';
+  }
+  else {
+    $status = 'Errors Encountered';
+  }
+  db_update('tripal_bulk_loader')
+    ->fields(array('job_status' => $status))
+    ->condition('nid', $nid)
+    ->execute();
+
+  if(!$loaded_without_errors) {
+    drush_set_error('BULK_LOAD_FAILED', 'Execution aborted due to errors.');
+    exit();
+  }
+}

+ 33 - 0
tripal_bulk_loader/theme/tripal_bulk_loader.theme.inc

@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * Theme the regex data in the tripal_bulk_loader_template_field_form form
+ */
+function tripal_bulk_loader_field_regex_fieldset($variables) {
+  $element = $variables['element'];
+  drupal_add_tabledrag('regex_list_form_id', 'order', 'sibling', 'rank-weight'); // needed for table dragging
+
+  $header = array(
+    'Match Pattern',
+    'Replacement Pattern',
+    'Order',
+    ''
+  );
+
+  $rows = array();
+  foreach (element_children($element) as $key) {
+    $row = array();
+    $row['data'][] = $element[$key]['pattern']['#markup'];
+    $row['data'][] = $element[$key]['replace']['#markup'];
+    $row['data'][] = drupal_render($element[$key]['new_index']) . drupal_render($element[$key]['id']);
+    $row['data'][] = drupal_render($element[$key]['submit-delete']);
+    $row['class'] = array('draggable'); // needed for table dragging
+    $rows[] = $row;
+  }
+
+  return theme('table', array(
+    'header' => $header,
+    'rows' => $rows,
+    'attributes' => array('id' => 'regex_list_form_id'), // needed for table dragging
+  ));
+}

+ 0 - 83
tripal_bulk_loader/theme/tripal_bulk_loader_add_template_field_form.tpl.php

@@ -1,83 +0,0 @@
-
-<?php print $form['add_fields']['#prefix']; ?>
-<fieldset><legend> <?php print $form['add_fields']['#title']; ?> </legend>
-<?php
-  print drupal_render($form['template_name']);
-
-  // Foreach element in the form fieldset 'add_fields'
-  foreach ($form['add_fields'] as $key => $form_array) {
-    if (preg_match('/^#/',$key)) { continue; }
-    
-    // We only care about the additional fieldset
-    if (preg_match('/additional/', $key)) {
-      //print fieldset
-      if ($form_array['#collapsible']) { $class[] = 'collapsible'; }
-      if ($form_array['#collapsed']) { $class[] = 'collapsed'; }
-      if (sizeof($class)) { $class = ' class="'.implode(' ',$class).'"'; }
-      print '<fieldset'.$class.'><legend>'.$form_array['#title'].'</legend>';
-      
-      // Foreach element in the 'additional' fieldset
-      foreach ($form_array as $key => $sub_form_array) {
-        if (preg_match('/^#/',$key)) { continue; }
-        
-        // We only care about the 'regex_transform' fieldset
-        if (preg_match('/regex_transform/', $key)) {
-          
-          // print fieldset
-          if ($sub_form_array['#collapsible']) { $class[] = 'collapsible'; }
-          if ($sub_form_array['#collapsed']) { $class[] = 'collapsed'; }
-          if (sizeof($class)) { $class = ' class="'.implode(' ',$class).'"'; }
-          print '<fieldset'.$class.'><legend>'.$sub_form_array['#title'].'</legend>';
-          
-          // print description
-          print drupal_render($sub_form_array['regex_description']);
-          
-          // Render Draggable Table
-          drupal_add_tabledrag('draggable-table', 'order', 'sibling', 'transform-reorder');
-          $header = array('Match Pattern', 'Replacement Pattern', 'Order', '');
-          $rows = array();
-          foreach ($sub_form_array['regex-data'] as $key => $element) {
-            if (preg_match('/^#/',$key)) { continue; }
-            $element['new_index']['#attributes']['class'] = 'transform-reorder';
-            
-            $row = array();
-            $row[] = drupal_render($element['pattern']);
-            $row[] = drupal_render($element['replace']);
-            $row[] = drupal_render($element['new_index']) . drupal_render($element['id']);
-            $row[] = drupal_render($element['submit-delete']);
-            $rows[] = array('data' => $row, 'class' => 'draggable');
-          }
-          
-          print theme('table', $header, $rows, array('id' => 'draggable-table'));          
-          
-          // render remaining elements
-          foreach ($sub_form_array as $key => $s2_form_array) {
-            if (preg_match('/^#/',$key)) { continue; }
-            if (!preg_match('/regex-data/', $key)) {
-              print drupal_render($s2_form_array);
-            }
-          }
-          
-          print '</fieldset>';
-          
-        } else {
-          // render other elements  in additional fieldset
-          print drupal_render($sub_form_array);
-        }
-      }
-      print '</fieldset>';
-    } else {
-      // render other elements in add_fields fieldset
-      print drupal_render($form_array);
-    }
-  }
-  unset($form['add_fields']);
-?>
-
-</fieldset>
-</div>
-
-<?php
-  //Render remaining -Needed to submit
-  print drupal_render($form);
-?>

+ 0 - 83
tripal_bulk_loader/theme/tripal_bulk_loader_edit_template_field_form.tpl.php

@@ -1,83 +0,0 @@
-
-<?php print $form['edit_fields']['#prefix']; ?>
-<fieldset><legend> <?php print $form['edit_fields']['#title']; ?> </legend>
-<?php
-  print drupal_render($form['template_name']);
-
-  // Foreach element in the form fieldset 'edit_fields'
-  foreach ($form['edit_fields'] as $key => $form_array) {
-    if (preg_match('/^#/',$key)) { continue; }
-    
-    // We only care about the additional fieldset
-    if (preg_match('/additional/', $key)) {
-      //print fieldset
-      if ($form_array['#collapsible']) { $class[] = 'collapsible'; }
-      if ($form_array['#collapsed']) { $class[] = 'collapsed'; }
-      if (sizeof($class)) { $class = ' class="'.implode(' ',$class).'"'; }
-      print '<fieldset'.$class.'><legend>'.$form_array['#title'].'</legend>';
-      
-      // Foreach element in the 'additional' fieldset
-      foreach ($form_array as $key => $sub_form_array) {
-        if (preg_match('/^#/',$key)) { continue; }
-        
-        // We only care about the 'regex_transform' fieldset
-        if (preg_match('/regex_transform/', $key)) {
-          
-          // print fieldset
-          if ($sub_form_array['#collapsible']) { $class[] = 'collapsible'; }
-          if ($sub_form_array['#collapsed']) { $class[] = 'collapsed'; }
-          if (sizeof($class)) { $class = ' class="'.implode(' ',$class).'"'; }
-          print '<fieldset'.$class.'><legend>'.$sub_form_array['#title'].'</legend>';
-          
-          // print description
-          print drupal_render($sub_form_array['regex_description']);
-          
-          // Render Draggable Table
-          drupal_add_tabledrag('draggable-table', 'order', 'sibling', 'transform-reorder');
-          $header = array('Match Pattern', 'Replacement Pattern', 'Order', '');
-          $rows = array();
-          foreach ($sub_form_array['regex-data'] as $key => $element) {
-            if (preg_match('/^#/',$key)) { continue; }
-            $element['new_index']['#attributes']['class'] = 'transform-reorder';
-            
-            $row = array();
-            $row[] = drupal_render($element['pattern']);
-            $row[] = drupal_render($element['replace']);
-            $row[] = drupal_render($element['new_index']) . drupal_render($element['id']);
-            $row[] = drupal_render($element['submit-delete']);
-            $rows[] = array('data' => $row, 'class' => 'draggable');
-          }
-          
-          print theme('table', $header, $rows, array('id' => 'draggable-table'));          
-          
-          // render remaining elements
-          foreach ($sub_form_array as $key => $s2_form_array) {
-            if (preg_match('/^#/',$key)) { continue; }
-            if (!preg_match('/regex-data/', $key)) {
-              print drupal_render($s2_form_array);
-            }
-          }
-          
-          print '</fieldset>';
-          
-        } else {
-          // render other elements  in additional fieldset
-          print drupal_render($sub_form_array);
-        }
-      }
-      print '</fieldset>';
-    } else {
-      // render other elements in edit_fields fieldset
-      print drupal_render($form_array);
-    }
-  }
-  unset($form['edit_fields']);
-?>
-
-</fieldset>
-</div>
-
-<?php
-  //Render remaining -Needed to submit
-  print drupal_render($form);
-?>

+ 59 - 36
tripal_bulk_loader/tripal_bulk_loader.module

@@ -58,6 +58,7 @@ function tripal_bulk_loader_menu() {
   $items['admin/tripal/loaders/bulk'] = array(
     'title' => 'Bulk Loader',
     'description' => 'Templates for loading tab-delimited data',
+    'page callback' => 'tripal_bulk_loader_admin_jobs_listing',
     'access arguments' => array('administer tripal_bulk_loader'),
     'type' => MENU_NORMAL_ITEM,
   );
@@ -68,7 +69,7 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_configuration_form'),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => 8,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_LOCAL_TASK,
   );
   $items['admin/tripal/loaders/bulk/help'] = array(
     'title' => 'Help',
@@ -76,15 +77,25 @@ function tripal_bulk_loader_menu() {
     'page callback' => 'tripal_bulk_loader_admin_manage_templates',
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => 10,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_LOCAL_TASK,
   );
-  $items['admin/tripal/loaders/bulk/jobs'] = array(
-    'title' => 'Bulk Loader Jobs',
-    'description' => 'Listing of Bulk Loading Jobs',
-    'page callback' => 'tripal_bulk_loader_admin_jobs',
+
+  // Enable View Callbacks
+  $items['admin/tripal/loaders/bulk/views/jobs/enable'] = array(
+    'title' => 'Enable Jobs Administrative View',
+    'description' => 'Enable Jobs Administrative View',
+    'page callback' => 'tripal_bulk_loader_admin_enable_view',
+    'page arguments' => array('tripal_bulk_loading_jobs'),
     'access arguments' => array('administer tripal_bulk_loader'),
-    'weight' => -10,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
+  );
+  $items['admin/tripal/loaders/bulk/views/templates/enable'] = array(
+    'title' => 'Enable Templates Administrative View',
+    'description' => 'Enable Templates Administrative View',
+    'page callback' => 'tripal_bulk_loader_admin_enable_view',
+    'page arguments' => array('tripal_bulk_loader_templates'),
+    'access arguments' => array('administer tripal_bulk_loader'),
+    'type' => MENU_CALLBACK,
   );
 
   // Create/Edit Template --------
@@ -95,7 +106,7 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'create'),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => -8,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
   );
   $items['admin/tripal/loaders/bulk/template/%tblid/edit'] = array(
     'title' => 'Edit Template',
@@ -105,6 +116,7 @@ function tripal_bulk_loader_menu() {
     'access arguments' => array('administer tripal_bulk_loader'),
     'type' => MENU_CALLBACK,
   );
+  /**
   $items['admin/tripal/loaders/bulk/template/edit'] = array(
     'title' => 'Edit Template',
     'description' => 'Edit loader template for loading tab-delimited data',
@@ -112,8 +124,9 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_modify_template_base_form', 'edit',FALSE),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => -6,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
   );
+  */
 
   // Add/Edit Record -----
   $items['admin/tripal/loaders/bulk/template/%tblid/add_record'] = array(
@@ -183,7 +196,7 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_delete_template_base_form',5),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => -4,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
   );
   // Import/Export ---------
   $items['admin/tripal/loaders/bulk/templates/import'] = array(
@@ -193,7 +206,7 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_import_template_form'),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => 2,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
   );
   $items['admin/tripal/loaders/bulk/template/%tblid/export'] = array(
     'title' => 'Export Template',
@@ -202,7 +215,7 @@ function tripal_bulk_loader_menu() {
     'page arguments' => array('tripal_bulk_loader_export_template_form', 5),
     'access arguments' => array('administer tripal_bulk_loader'),
     'weight' => 4,
-    'type' => MENU_NORMAL_ITEM,
+    'type' => MENU_CALLBACK,
   );
 
   return $items;
@@ -248,23 +261,15 @@ function tripal_bulk_loader_theme() {
       'path' => drupal_get_path('module', 'tripal_bulk_loader') . '/theme',
     ),
     'tripal_bulk_loader_modify_template_base_form' => array(
-      //'variables' => array('form' => NULL),
       'template' => 'tripal_bulk_loader_modify_template_base_form',
       'path' => drupal_get_path('module', 'tripal_bulk_loader') . '/theme',
       'render element' => 'form'
     ),
-    /**
-    'tripal_bulk_loader_edit_template_field_form' => array(
-      'variables' => array('form' => NULL),
-      'template' => 'tripal_bulk_loader_edit_template_field_form',
-      'path' => drupal_get_path('module', 'tripal_bulk_loader') . '/theme',
-    ),
-    'tripal_bulk_loader_add_template_field_form' => array(
-      'variables' => array('form' => NULL),
-      'template' => 'tripal_bulk_loader_add_template_field_form',
-      'path' => drupal_get_path('module', 'tripal_bulk_loader') . '/theme',
+    'tripal_bulk_loader_field_regex_fieldset' => array(
+      'file' => 'theme/tripal_bulk_loader.theme.inc',
+      'function' => 'tripal_bulk_loader_field_regex_fieldset',
+      'render element' => 'element'
     ),
-    */
     'tripal_bulk_loader_admin' => array(
       'template' => 'tripal_bulk_loader_admin',
       'path' => drupal_get_path('module', 'tripal_bulk_loader') . '/theme',
@@ -297,26 +302,29 @@ function tripal_bulk_loader_theme() {
 function tripal_bulk_loader_node_access($node, $op, $account) {
   if ($op == 'create') {
     if (!user_access('create tripal_bulk_loader', $account)) {
-      return FALSE;
+      return NODE_ACCESS_DENY;
     }
-    return TRUE;
+    return NODE_ACCESS_ALLOW;
   }
   if ($op == 'update') {
     if (!user_access('edit tripal_bulk_loader', $account)) {
-      return FALSE;
+      return NODE_ACCESS_DENY;
     }
+    return NODE_ACCESS_ALLOW;
   }
   if ($op == 'delete') {
     if (!user_access('delete tripal_bulk_loader', $account)) {
-      return FALSE;
+      return NODE_ACCESS_DENY;
     }
+    return NODE_ACCESS_ALLOW;
   }
   if ($op == 'view') {
     if (!user_access('access tripal_bulk_loader', $account)) {
-      return FALSE;
+      return NODE_ACCESS_DENY;
     }
+    return NODE_ACCESS_ALLOW;
   }
-  return NULL;
+  return NODE_ACCESS_IGNORE;
 }
 
 /**
@@ -326,11 +334,26 @@ function tripal_bulk_loader_node_access($node, $op, $account) {
  */
 function tripal_bulk_loader_permission() {
   return array(
-      'access tripal_bulk_loader',
-      'create tripal_bulk_loader',
-      'delete tripal_bulk_loader',
-      'edit tripal_bulk_loader',
-      'administer tripal_bulk_loader',
+      'access tripal_bulk_loader' => array(
+        'title' => t('View Tripal Bulk Loading Jobs'),
+        'description' => t('Permission to view Tripal Bulk Loader Nodes')
+      ),
+      'create tripal_bulk_loader' => array(
+        'title' => t('Create Tripal Bulk Loading Jobs'),
+        'description' => t('Permission to create Tripal Bulk Loader Nodes')
+      ),
+      'edit tripal_bulk_loader' => array(
+        'title' => t('Edit Tripal Bulk Loading Jobs'),
+        'description' => t('Permission to edit Tripal Bulk Loader Nodes')
+      ),
+      'delete tripal_bulk_loader' => array(
+        'title' => t('Delete Tripal Bulk Loading Jobs'),
+        'description' => t('Permission to delete Tripal Bulk Loader Nodes')
+      ),
+      'administer tripal_bulk_loader' => array(
+        'title' => t('Administrate Tripal Bulk Loader'),
+        'description' => t('Permission to administrate the Tripal Bulk Loader including template management.')
+      ),
   );
 }
 

+ 98 - 66
tripal_bulk_loader/tripal_bulk_loader.views_default.inc

@@ -6,20 +6,20 @@ function tripal_bulk_loader_views_default_views() {
   $views = array();
 
   // Default Tripal Admin View: Jobs
-  $view = tripal_bulk_loader_admin_job_listing();
+  $view = tripal_bulk_loader_defaultview_admin_job_listing();
   $views[$view->name] = $view;
 
   // Default Tripal Admin View: Templates
-  $view = tripal_bulk_loader_admin_template_listing();
+  $view = tripal_bulk_loader_defaultview_admin_template_listing();
   $views[$view->name] = $view;
 
   return $views;
 }
 
 /**
- *
+ * Default Admin Vire for job management
  */
-function tripal_bulk_loader_admin_job_listing() {
+function tripal_bulk_loader_defaultview_admin_job_listing() {
 
   $view = new view();
   $view->name = 'tripal_bulk_loading_jobs';
@@ -35,7 +35,8 @@ function tripal_bulk_loader_admin_job_listing() {
   $handler = $view->new_display('default', 'Master', 'default');
   $handler->display->display_options['title'] = 'Tripal Bulk Loading Jobs';
   $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'none';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'administer tripal_bulk_loader';
   $handler->display->display_options['cache']['type'] = 'none';
   $handler->display->display_options['query']['type'] = 'views_query';
   $handler->display->display_options['exposed_form']['type'] = 'basic';
@@ -108,8 +109,8 @@ function tripal_bulk_loader_admin_job_listing() {
   $handler->display->display_options['header']['area']['label'] = 'Add Job';
   $handler->display->display_options['header']['area']['empty'] = TRUE;
   $handler->display->display_options['header']['area']['content'] = '<ul class="action-links">
-  <li><a href="../../../../node/add/tripal-bulk-loader">Add Bulk Loading Job</a></li>
-  </ul>';
+    <li><a href="../../../../node/add/tripal-bulk-loader">Add Bulk Loading Job</a></li>
+    </ul>';
   $handler->display->display_options['header']['area']['format'] = 'full_html';
   /* No results behavior: Global: Text area */
   $handler->display->display_options['empty']['area']['id'] = 'area';
@@ -124,31 +125,6 @@ function tripal_bulk_loader_admin_job_listing() {
   $handler->display->display_options['relationships']['nid']['table'] = 'tripal_bulk_loader';
   $handler->display->display_options['relationships']['nid']['field'] = 'nid';
   $handler->display->display_options['relationships']['nid']['label'] = 'TBL Job => Node';
-  /* Field: Content: Edit link */
-  $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
-  $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
-  $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
-  $handler->display->display_options['fields']['edit_node']['relationship'] = 'nid';
-  $handler->display->display_options['fields']['edit_node']['label'] = '';
-  $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE;
-  $handler->display->display_options['fields']['edit_node']['text'] = 'edit';
-  /* Field: Content: Delete link */
-  $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
-  $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
-  $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
-  $handler->display->display_options['fields']['delete_node']['relationship'] = 'nid';
-  $handler->display->display_options['fields']['delete_node']['label'] = '';
-  $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
-  $handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE;
-  $handler->display->display_options['fields']['delete_node']['text'] = 'delete';
-  /* Field: Global: Custom text */
-  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['table'] = 'views';
-  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
-  $handler->display->display_options['fields']['nothing']['label'] = '';
-  $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node]    [delete_node]';
-  $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
   /* Field: Content: Nid */
   $handler->display->display_options['fields']['nid']['id'] = 'nid';
   $handler->display->display_options['fields']['nid']['table'] = 'node';
@@ -195,6 +171,31 @@ function tripal_bulk_loader_admin_job_listing() {
   $handler->display->display_options['fields']['job_status']['table'] = 'tripal_bulk_loader';
   $handler->display->display_options['fields']['job_status']['field'] = 'job_status';
   $handler->display->display_options['fields']['job_status']['label'] = 'Status';
+  /* Field: Content: Edit link */
+  $handler->display->display_options['fields']['edit_node']['id'] = 'edit_node';
+  $handler->display->display_options['fields']['edit_node']['table'] = 'views_entity_node';
+  $handler->display->display_options['fields']['edit_node']['field'] = 'edit_node';
+  $handler->display->display_options['fields']['edit_node']['relationship'] = 'nid';
+  $handler->display->display_options['fields']['edit_node']['label'] = '';
+  $handler->display->display_options['fields']['edit_node']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['edit_node']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['edit_node']['text'] = 'edit';
+  /* Field: Content: Delete link */
+  $handler->display->display_options['fields']['delete_node']['id'] = 'delete_node';
+  $handler->display->display_options['fields']['delete_node']['table'] = 'views_entity_node';
+  $handler->display->display_options['fields']['delete_node']['field'] = 'delete_node';
+  $handler->display->display_options['fields']['delete_node']['relationship'] = 'nid';
+  $handler->display->display_options['fields']['delete_node']['label'] = '';
+  $handler->display->display_options['fields']['delete_node']['exclude'] = TRUE;
+  $handler->display->display_options['fields']['delete_node']['element_label_colon'] = FALSE;
+  $handler->display->display_options['fields']['delete_node']['text'] = 'delete';
+  /* Field: Global: Custom text */
+  $handler->display->display_options['fields']['nothing']['id'] = 'nothing';
+  $handler->display->display_options['fields']['nothing']['table'] = 'views';
+  $handler->display->display_options['fields']['nothing']['field'] = 'nothing';
+  $handler->display->display_options['fields']['nothing']['label'] = '';
+  $handler->display->display_options['fields']['nothing']['alter']['text'] = '[edit_node]    [delete_node]';
+  $handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
   /* Filter criterion: Tripal Bulk Loader Templates: Name */
   $handler->display->display_options['filters']['name']['id'] = 'name';
   $handler->display->display_options['filters']['name']['table'] = 'tripal_bulk_loader_template';
@@ -240,24 +241,23 @@ function tripal_bulk_loader_admin_job_listing() {
     3 => 0,
   );
 
-  /* Display: Tripal Admin Listing */
-  $handler = $view->new_display('page', 'Tripal Admin Listing', 'tripaladminlist');
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page_1');
   $handler->display->display_options['path'] = 'admin/tripal/loaders/bulk/jobs';
-  $handler->display->display_options['menu']['type'] = 'normal';
+  $handler->display->display_options['menu']['type'] = 'default tab';
   $handler->display->display_options['menu']['title'] = 'Jobs';
-  $handler->display->display_options['menu']['description'] = 'A listing of Tripal Bulk Loading Jobs including the ability to edit or delete existing jobs.';
   $handler->display->display_options['menu']['weight'] = '0';
-  $handler->display->display_options['menu']['name'] = 'management';
   $handler->display->display_options['menu']['context'] = 0;
   $handler->display->display_options['menu']['context_only_inline'] = 0;
+  $handler->display->display_options['tab_options']['weight'] = '0';
 
   return $view;
 }
 
 /**
- *
+ * Default Admin View for template management
  */
-function tripal_bulk_loader_admin_template_listing() {
+function tripal_bulk_loader_defaultview_admin_template_listing() {
 
   $view = new view();
   $view->name = 'tripal_bulk_loader_templates';
@@ -273,10 +273,12 @@ function tripal_bulk_loader_admin_template_listing() {
   $handler = $view->new_display('default', 'Master', 'default');
   $handler->display->display_options['title'] = 'Tripal Bulk Loader Templates';
   $handler->display->display_options['use_more_always'] = FALSE;
-  $handler->display->display_options['access']['type'] = 'none';
+  $handler->display->display_options['access']['type'] = 'perm';
+  $handler->display->display_options['access']['perm'] = 'administer tripal_bulk_loader';
   $handler->display->display_options['cache']['type'] = 'none';
   $handler->display->display_options['query']['type'] = 'views_query';
   $handler->display->display_options['exposed_form']['type'] = 'basic';
+  $handler->display->display_options['exposed_form']['options']['submit_button'] = 'Filter';
   $handler->display->display_options['pager']['type'] = 'full';
   $handler->display->display_options['pager']['options']['items_per_page'] = '25';
   $handler->display->display_options['style_plugin'] = 'table';
@@ -286,10 +288,26 @@ function tripal_bulk_loader_admin_template_listing() {
   $handler->display->display_options['header']['area']['field'] = 'area';
   $handler->display->display_options['header']['area']['label'] = 'Add Template';
   $handler->display->display_options['header']['area']['content'] = '<ul class="action-links">
-  <li><a href="template/create">Add Template</a></li>
-  <li><a href="templates/import">Import Template</a></li>
-  </ul>';
+      <li><a href="template/create">Add Template</a></li>
+      <li><a href="templates/import">Import Template</a></li>
+      </ul>';
   $handler->display->display_options['header']['area']['format'] = 'full_html';
+  /* Field: Tripal Bulk Loader Templates: Name */
+  $handler->display->display_options['fields']['name']['id'] = 'name';
+  $handler->display->display_options['fields']['name']['table'] = 'tripal_bulk_loader_template';
+  $handler->display->display_options['fields']['name']['field'] = 'name';
+  /* Field: Tripal Bulk Loader Templates: Created */
+  $handler->display->display_options['fields']['created']['id'] = 'created';
+  $handler->display->display_options['fields']['created']['table'] = 'tripal_bulk_loader_template';
+  $handler->display->display_options['fields']['created']['field'] = 'created';
+  $handler->display->display_options['fields']['created']['label'] = 'Created On';
+  $handler->display->display_options['fields']['created']['date_format'] = 'long';
+  /* Field: Tripal Bulk Loader Templates: Updated */
+  $handler->display->display_options['fields']['changed']['id'] = 'changed';
+  $handler->display->display_options['fields']['changed']['table'] = 'tripal_bulk_loader_template';
+  $handler->display->display_options['fields']['changed']['field'] = 'changed';
+  $handler->display->display_options['fields']['changed']['label'] = 'Updated On';
+  $handler->display->display_options['fields']['changed']['date_format'] = 'long';
   /* Field: Tripal Bulk Loader Templates: Template ID */
   $handler->display->display_options['fields']['template_id']['id'] = 'template_id';
   $handler->display->display_options['fields']['template_id']['table'] = 'tripal_bulk_loader_template';
@@ -315,7 +333,7 @@ function tripal_bulk_loader_admin_template_listing() {
   $handler->display->display_options['fields']['nothing_1']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_1']['alter']['text'] = 'delete';
   $handler->display->display_options['fields']['nothing_1']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/loaders/bulk/template/[template_id]/delete';
+  $handler->display->display_options['fields']['nothing_1']['alter']['path'] = 'admin/tripal/loaders/bulk/template/[template_id]/delete?template_name=[name]';
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_2']['id'] = 'nothing_2';
   $handler->display->display_options['fields']['nothing_2']['table'] = 'views';
@@ -333,39 +351,53 @@ function tripal_bulk_loader_admin_template_listing() {
   $handler->display->display_options['fields']['nothing_3']['exclude'] = TRUE;
   $handler->display->display_options['fields']['nothing_3']['alter']['text'] = 'View Jobs';
   $handler->display->display_options['fields']['nothing_3']['alter']['make_link'] = TRUE;
-  $handler->display->display_options['fields']['nothing_3']['alter']['path'] = 'admin/tripal/loaders/bulk/jobs';
+  $handler->display->display_options['fields']['nothing_3']['alter']['path'] = 'admin/tripal/loaders/bulk/jobs?name=[name]';
   /* Field: Global: Custom text */
   $handler->display->display_options['fields']['nothing_4']['id'] = 'nothing_4';
   $handler->display->display_options['fields']['nothing_4']['table'] = 'views';
   $handler->display->display_options['fields']['nothing_4']['field'] = 'nothing';
   $handler->display->display_options['fields']['nothing_4']['label'] = '';
   $handler->display->display_options['fields']['nothing_4']['alter']['text'] = '[nothing]   [nothing_1]   [nothing_2]<br />
-  [nothing_3]';
+      [nothing_3]';
   $handler->display->display_options['fields']['nothing_4']['element_label_colon'] = FALSE;
   $handler->display->display_options['fields']['nothing_4']['element_wrapper_class'] = 'active';
-  /* Field: Tripal Bulk Loader Templates: Name */
-  $handler->display->display_options['fields']['name']['id'] = 'name';
-  $handler->display->display_options['fields']['name']['table'] = 'tripal_bulk_loader_template';
-  $handler->display->display_options['fields']['name']['field'] = 'name';
-  /* Field: Tripal Bulk Loader Templates: Created */
-  $handler->display->display_options['fields']['created']['id'] = 'created';
-  $handler->display->display_options['fields']['created']['table'] = 'tripal_bulk_loader_template';
-  $handler->display->display_options['fields']['created']['field'] = 'created';
-  $handler->display->display_options['fields']['created']['label'] = 'Created On';
-  $handler->display->display_options['fields']['created']['date_format'] = 'long';
-  /* Field: Tripal Bulk Loader Templates: Updated */
-  $handler->display->display_options['fields']['changed']['id'] = 'changed';
-  $handler->display->display_options['fields']['changed']['table'] = 'tripal_bulk_loader_template';
-  $handler->display->display_options['fields']['changed']['field'] = 'changed';
-  $handler->display->display_options['fields']['changed']['label'] = 'Updated On';
-  $handler->display->display_options['fields']['changed']['date_format'] = 'long';
+  /* Filter criterion: Tripal Bulk Loader Templates: Name */
+  $handler->display->display_options['filters']['name']['id'] = 'name';
+  $handler->display->display_options['filters']['name']['table'] = 'tripal_bulk_loader_template';
+  $handler->display->display_options['filters']['name']['field'] = 'name';
+  $handler->display->display_options['filters']['name']['operator'] = 'contains';
+  $handler->display->display_options['filters']['name']['group'] = 1;
+  $handler->display->display_options['filters']['name']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['name']['expose']['operator_id'] = 'name_op';
+  $handler->display->display_options['filters']['name']['expose']['label'] = 'Template Name Contains';
+  $handler->display->display_options['filters']['name']['expose']['operator'] = 'name_op';
+  $handler->display->display_options['filters']['name']['expose']['identifier'] = 'name';
+  $handler->display->display_options['filters']['name']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
+  /* Filter criterion: Tripal Bulk Loader Templates: Created */
+  $handler->display->display_options['filters']['created']['id'] = 'created';
+  $handler->display->display_options['filters']['created']['table'] = 'tripal_bulk_loader_template';
+  $handler->display->display_options['filters']['created']['field'] = 'created';
+  $handler->display->display_options['filters']['created']['group'] = 1;
+  $handler->display->display_options['filters']['created']['exposed'] = TRUE;
+  $handler->display->display_options['filters']['created']['expose']['operator_id'] = 'created_op';
+  $handler->display->display_options['filters']['created']['expose']['label'] = 'Date Created';
+  $handler->display->display_options['filters']['created']['expose']['operator'] = 'created_op';
+  $handler->display->display_options['filters']['created']['expose']['identifier'] = 'created';
+  $handler->display->display_options['filters']['created']['expose']['remember_roles'] = array(
+    2 => '2',
+    1 => 0,
+    3 => 0,
+  );
 
-  /* Display: Tripal Admin Listing */
-  $handler = $view->new_display('page', 'Tripal Admin Listing', 'tripaladminlist');
+  /* Display: Page */
+  $handler = $view->new_display('page', 'Page', 'page_1');
   $handler->display->display_options['path'] = 'admin/tripal/loaders/bulk/templates';
-  $handler->display->display_options['menu']['type'] = 'normal';
+  $handler->display->display_options['menu']['type'] = 'tab';
   $handler->display->display_options['menu']['title'] = 'Templates';
-  $handler->display->display_options['menu']['description'] = 'A listing of Loading Templates to be used for Tripal Bulk Loader Jobs including the ability to manage existing templates.';
   $handler->display->display_options['menu']['weight'] = '0';
   $handler->display->display_options['menu']['name'] = 'management';
   $handler->display->display_options['menu']['context'] = 0;

+ 291 - 51
tripal_core/api/tripal_core_chado.api.inc

@@ -3,6 +3,83 @@
 require_once "tripal_core.schema_v1.2.api.inc";
 require_once "tripal_core.schema_v1.11.api.inc";
 
+// Globals used by Tripals Error catching functions
+// Should match those defined by watchdog
+define('TRIPAL_CRITICAL',2);
+define('TRIPAL_ERROR',3);
+define('TRIPAL_WARNING',4);
+define('TRIPAL_NOTICE',5);
+define('TRIPAL_INFO',6);
+define('TRIPAL_DEBUG',7);
+
+/**
+ * Provide better error notice for Tripal
+ * @param $type
+ *   The catagory to which this message belongs. Can be any string, but the general
+ *   practice is to use the name of the module.
+ * @param $message
+ *   The message to store in the log. Keep $message translatable by not concatenating
+ *   dynamic values into it! Variables in the message should be added by using placeholder
+ *   strings alongside the variables argument to declare the value of the placeholders.
+ *   See t() for documentation on how $message and $variables interact.
+ * @param $variables
+ *   Array of variables to replace in the message on display or NULL if message is
+ *   already translated or not possible to translate.
+ * @param $severity
+ *   The severity of the message; one of the following values:
+ *     - TRIPAL_CRITICAL: Critical conditions.
+ *     - TRIPAL_ERROR: Error conditions.
+ *     - TRIPAL_WARNING: Warning conditions.
+ *     - TRIPAL_NOTICE: (default) Normal but significant conditions.
+ *     - TRIPAL_INFO: Informational messages.
+ *     - TRIPAL_DEBUG: Debug-level messages.
+ * @param $options
+ *   An array of options. Some available options include:
+ *     - print: prints the error message to the screen. Useful when display is the command-line
+ */
+function tripal_core_report_error($type, $severity, $message, $variables = array(), $options = array()) {
+
+  // Get human-readable severity string
+  $severity_string = '';
+  switch ($severity) {
+    case TRIPAL_CRITICAL:
+      $severity_string = 'CRITICAL';
+      break;
+    case TRIPAL_ERROR:
+      $severity_string = 'ERROR';
+      break;
+    case TRIPAL_WARNING:
+      $severity_string = 'WARNING';
+      break;
+    case TRIPAL_NOTICE:
+      $severity_string = 'NOTICE';
+      break;
+    case TRIPAL_INFO:
+      $severity_string = 'INFO';
+      break;
+    case TRIPAL_DEBUG:
+      $severity_string = 'DEBUG';
+      break;
+  }
+
+  // Send to watchdog
+  try {
+    watchdog($type, $message, $variables, $severity);
+  }
+  catch (Exception $e) {
+    print "CRITICAL (TRIPAL_CORE): Unable to register error message with watchdog";
+    $options['print'] = TRUE;
+  }
+
+  // If print option supplied then print directly to the screen
+  if (isset($options['print'])) {
+    if (sizeof($variables) > 0) {
+      $message = str_replace(array_keys($variables), $variables, $message);
+    }
+    print $severity_string . ' (' . strtoupper($type) . '):' . $message . "\n";
+  }
+}
+
 /**
  * @file
  * The Tripal Core API
@@ -96,12 +173,26 @@ require_once "tripal_core.schema_v1.11.api.inc";
  */
 function tripal_core_chado_insert($table, $values, $options = array()) {
 
+  $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
+
   if (!is_array($values)) {
-    watchdog('tripal_core', 'Cannot pass non array as values for inserting.', array(), WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass non array as values for inserting.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
   if (count($values)==0) {
-    watchdog('tripal_core', 'Cannot pass an empty array as values for inserting.', array(), WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass an empty array as values for inserting.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
@@ -130,7 +221,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
   // get the table description
   $table_desc = tripal_core_get_chado_table_schema($table);
   if (empty($table_desc)) {
-    watchdog('tripal_core', 'tripal_core_chado_insert: There is no table description for !table_name', array('!table_name' => $table), WATCHDOG_WARNING);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_WARNING,
+      'tripal_core_chado_insert; There is no table description for !table_name',
+      array('!table_name' => $table),
+      array('print' => $print_errors)
+    );
   }
 
   // iterate through the values array and create a new 'insert_values' array
@@ -140,9 +237,14 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     // make sure the field is in the table description. If not then return an error
     // message
     if (!array_key_exists($field, $table_desc['fields'])) {
-      watchdog('tripal_core', "tripal_core_chado_insert: The field '%field' does not exist " .
-        "for the table '%table'.  Cannot perform insert. Values: %array",
-        array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)), WATCHDOG_ERROR);
+      tripal_core_report_error(
+        'tripal_core',
+        TRIPAL_ERROR,
+        "tripal_core_chado_insert; The field '%field' does not exist " .
+          "for the table '%table'.  Cannot perform insert. Values: %array",
+        array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
+        array('print' => $print_errors)
+      );
       return FALSE;
     }
 
@@ -151,10 +253,22 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
       $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value, $foreign_options);
 
       if (sizeof($results) > 1) {
-        watchdog('tripal_core', 'tripal_core_chado_insert: Too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_ERROR,
+          'tripal_core_chado_insert: Too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
+          array('print' => $print_errors)
+        );
       }
       elseif (sizeof($results) < 1) {
-        //watchdog('tripal_core', 'tripal_core_chado_insert: no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_DEBUG,
+          'tripal_core_chado_insert: no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
+          array('print' => $print_errors)
+        );
       }
       else {
         $insert_values[$field] = $results[0];
@@ -190,8 +304,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
         }
         // now check the constraint
         if (tripal_core_chado_select($table, $ukselect_cols, $ukselect_vals)) {
-          watchdog('tripal_core', "tripal_core_chado_insert: Cannot insert duplicate record into $table table: " .
-            print_r($values, 1), array(), 'WATCHDOG_ERROR');
+          tripal_core_report_error(
+            'tripal_core',
+            TRIPAL_ERROR,
+            "tripal_core_chado_insert; Cannot insert duplicate record into $table table: !values",
+            array('!values' => print_r($values, TRUE)),
+            array('print' => $print_errors)
+          );
           return FALSE;
         }
       }
@@ -203,7 +322,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
       if (array_key_exists($pkey, $insert_values)) {
         $coptions = array('statement_name' => 'pqsel_' . $table . '_' . $pkey);
         if (tripal_core_chado_select($table, array($pkey), array($pkey => $insert_values[$pkey]), $coptions)) {
-          watchdog('tripal_core', "tripal_core_chado_insert: Cannot insert duplicate primary key into $table table: " . print_r($values, 1), array(), 'WATCHDOG_ERROR');
+          tripal_core_report_error(
+            'tripal_core',
+            TRIPAL_ERROR,
+            'tripal_core_chado_insert; Cannot insert duplicate primary key into !table table: !values',
+            array('!table' => $table, '!values' => print_r($values, TRUE)),
+            array('print' => $print_errors)
+          );
           return FALSE;
         }
       }
@@ -212,9 +337,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     // make sure required fields have a value
     if (!is_array($table_desc['fields'])) {
       $table_desc['fields'] = array();
-      watchdog('tripal_core', "tripal_core_chado_insert: %table missing fields: \n %schema",
-        array('%table' => $table, '%schema' => print_r($table_desc, 1)), WATCHDOG_WARNING);
-
+      tripal_core_report_error(
+        'tripal_core',
+        TRIPAL_WARNING,
+        "tripal_core_chado_insert; %table missing fields: \n %schema",
+        array('%table' => $table, '%schema' => print_r($table_desc, 1)),
+        array('print' => $print_errors)
+      );
     }
     foreach ($table_desc['fields'] as $field => $def) {
       // a field is considered missing if it cannot be NULL and there is no default
@@ -223,8 +352,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
           !array_key_exists($field, $insert_values) and
           !array_key_exists('default', $def) and
           strcmp($def['type'], serial) != 0) {
-        watchdog('tripal_core', "tripal_core_chado_insert: Field $table.$field cannot be NULL: " .
-          print_r($values, 1), array(), 'WATCHDOG_ERROR');
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_ERROR,
+          "tripal_core_chado_insert; Field %table.%field cannot be NULL: %values",
+          array('%table' => $table, '%field' => $field, '%values' => print_r($values, 1)),
+          array('print' => $print_errors)
+        );
         return FALSE;
       }
     }
@@ -259,8 +393,13 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
         $results = chado_query($sql);
         $value = $results->fetchObject();
         if (!$value) {
-          watchdog('tripal_core', "tripal_core_chado_insert: not able to retrieve primary key after insert: %sql",
-            array('%sql' => $sql), WATCHDOG_ERROR);
+          tripal_core_report_error(
+            'tripal_core',
+            TRIPAL_ERROR,
+            "tripal_core_chado_insert; not able to retrieve primary key after insert: %sql",
+            array('%sql' => $sql),
+            array('print' => $print_errors)
+          );
           return FALSE;
         }
         $values[$field] = $value;
@@ -272,14 +411,20 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     return TRUE;
   }
   else {
-    watchdog('tripal_core', "tripal_core_chado_insert: Cannot insert record into '%table': " . print_r($values, 1),
-      array('%table' => $table), 'WATCHDOG_ERROR');
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'tripal_core_chado_insert; Cannot insert record into "%table": %values',
+      array('%table' => $table, '%values' => print_r($values, 1)),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
   return FALSE;
 
 }
+
 /**
  * Provides a generic routine for updating into any Chado table
  *
@@ -344,25 +489,47 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
  */
 function tripal_core_chado_update($table, $match, $values, $options = NULL) {
 
+  $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
+
   if (!is_array($values)) {
-    watchdog('tripal_core', 'Cannot pass non array as values for updating.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass non array as values for updating.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
   if (count($values)==0) {
-    watchdog('tripal_core', 'Cannot pass an empty array as values for updating.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass an empty array as values for updating.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
   if (!is_array($match)) {
-    watchdog('tripal_core', 'Cannot pass non array as values for matching.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass non array as values for matching.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
   if (count($match)==0) {
-    watchdog('tripal_core', 'Cannot pass an empty array as values for matching.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass an empty array as values for matching.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
@@ -410,10 +577,22 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
     if (is_array($value)) {
       $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value);
       if (sizeof($results) > 1) {
-        watchdog('tripal_core', 'tripal_core_chado_update: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_ERROR,
+          'tripal_core_chado_update: When trying to find record to update, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
+          array('print' => $print_errors)
+        );
       }
       elseif (sizeof($results) < 1) {
-        //watchdog('tripal_core', 'tripal_core_chado_update: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_DEBUG,
+          'tripal_core_chado_update: When trying to find record to update, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
+          array('print' => $print_errors)
+        );
       }
       else {
         $update_matches[$field] = $results[0];
@@ -431,10 +610,22 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
       // select the value from the foreign key relationship for this value
       $results = tripal_core_chado_get_foreign_key($table_desc, $field, $value, $foreign_options);
       if (sizeof($results) > 1) {
-        watchdog('tripal_core', 'tripal_core_chado_update: When trying to find update values, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_ERROR,
+          'tripal_core_chado_update: When trying to find update values, too many records match the criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value, TRUE)),
+          array('print' => $print_errors)
+        );
       }
       elseif (sizeof($results) < 1) {
-        //watchdog('tripal_core', 'tripal_core_chado_update: When trying to find update values, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)', array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)), WATCHDOG_ERROR);
+        tripal_core_report_error(
+          'tripal_core',
+          TRIPAL_DEBUG,
+          'tripal_core_chado_update: When trying to find update values, no record matches criteria supplied for !foreign_key foreign key constraint (!criteria)',
+          array('!foreign_key' => $field, '!criteria' => print_r($value,TRUE)),
+          array('print' => $print_errors)
+        );
       }
       else {
         $update_values[$field] = $results[0];
@@ -491,7 +682,13 @@ function tripal_core_chado_update($table, $match, $values, $options = NULL) {
     return TRUE;
   }
   else {
-    watchdog('tripal_core', "Cannot update record in $table table.  \nMatch:" . print_r($match, 1) . "\nValues: " . print_r($values, 1), array(), 'WATCHDOG_ERROR');
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      "tripal_core_chado_update: Cannot update record in %table table.  \nMatch: %match \nValues: %values",
+      array('%table' => table, '%match' => print_r($match,TRUE), '%values' => print_r($values, 1)),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
@@ -747,19 +944,36 @@ function tripal_core_chado_delete($table, $match, $options = NULL) {
  */
 function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
 
+  $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
+
   if (!is_array($values)) {
-    watchdog('tripal_core', 'Cannot pass non array as values for selecting.', array(),
-      WATCHDOG_ERROR);
-      return FALSE;
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass non array as values for selecting.',
+      array(),
+      array('print' => $print_errors)
+    );
+    return FALSE;
   }
   if (!is_array($columns)) {
-    watchdog('tripal_core', 'Cannot pass non array as columns for selecting.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass non array as columns for selecting.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
   if (count($columns)==0) {
-    watchdog('tripal_core', 'Cannot pass an empty array as columns for selecting.', array(),
-      WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'Cannot pass an empty array as columns for selecting.',
+      array(),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
@@ -793,11 +1007,23 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
 
   // check that our columns and values arguments are proper arrays
   if (!is_array($columns)) {
-    watchdog('tripal_core', 'the $columns argument for tripal_core_chado_select must be an array.');
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'tripal_core_chado_select; the $columns argument must be an array. Columns:%columns',
+      array('%columns' => print_r($columns, TRUE)),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
   if (!is_array($values)) {
-    watchdog('tripal_core', 'the $values argument for tripal_core_chado_select must be an array.');
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'tripal_core_chado_select; the $values argument must be an array. Values:%values',
+      array('%values' => print_r($values, TRUE)),
+      array('print' => $print_errors)
+    );
     return FALSE;
   }
 
@@ -868,9 +1094,13 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
         // and there is no default value then we cannot check if the record
         // is a duplicate so return FALSE
         else {
-          watchdog('tripal_core', "tripal_core_chado_select: There is no value for %field"
-            . " thus we cannot check if this record is unique",
-            array('%field' => $field), WATCHDOG_ERROR);
+          tripal_core_report_error(
+            'tripal_core',
+            TRIPAL_ERROR,
+            'tripal_core_chado_select: There is no value for %field thus we cannot check if this record is unique',
+            array('%field' => $field),
+            array('print' => $print_errors)
+          );
           return FALSE;
         }
       }
@@ -897,9 +1127,13 @@ function tripal_core_chado_select($table, $columns, $values, $options = NULL) {
     // make sure the field is in the table description. If not then return an error
     // message
     if (!array_key_exists($field, $table_desc['fields'])) {
-      watchdog('tripal_core', "tripal_core_chado_select: The field '%field' does not exist " .
-        "for the table '%table'.  Cannot perform query. Values: %array",
-        array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)), WATCHDOG_ERROR);
+      tripal_core_report_error(
+        'tripal_core',
+        TRIPAL_ERROR,
+        'tripal_core_chado_select: The field "%field" does not exist for the table "%table".  Cannot perform query. Values: %array',
+        array('%field' => $field, '%table' => $table, '%array' => print_r($values, 1)),
+        array('print' => $print_errors)
+      );
       return array();
     }
 
@@ -1907,8 +2141,14 @@ function chado_query($sql, $args = array()) {
 
   $is_local = tripal_core_is_chado_local();
 
+  // Args should be an array
   if (!is_array($args)) {
-    watchdog('tripal_core', 'Need to pass an array to chado_query, "%value" passed instead. Query: %query', array('%value' => $args, '%query' => $sql), WATCHDOG_ERROR);
+    tripal_core_report_error(
+      'tripal_core',
+      TRIPAL_ERROR,
+      'chado_query; Need to pass an array to chado_query, "%value" passed instead. Query: %query',
+      array('%value' => $args, '%query' => $sql)
+    );
     $args = array($args);
   }
 
@@ -2466,7 +2706,7 @@ function tripal_core_schema_exists($schema) {
   $name = $results->fetchObject();
   if (strcmp($name->nspname, $schema) != 0) {
     return FALSE;
-  }  
+  }
   return TRUE;
 }
 
@@ -2796,7 +3036,7 @@ function tripal_core_is_chado_installed() {
     return TRUE;
   }
 
-  // check to make sure the chado schema exists          
+  // check to make sure the chado schema exists
   return tripal_core_chado_schema_exists();
 }
 

+ 44 - 0
tripal_views/theme/tripal_views_admin_views.css

@@ -0,0 +1,44 @@
+/**
+ * @file
+ * CSS rules to theme tripal admin listings
+ */
+
+.views-exposed-form {
+  border: 1px solid #ccc;
+  padding: 15px;
+  margin-bottom: 15px;
+  position: relative;
+}
+
+.views-exposed-form .views-exposed-widget {
+  float: none;
+  display: block;
+  width: 450px;
+}
+
+.views-exposed-widget .views-widget {
+  display: inline-block;
+}
+
+.views-exposed-widget .views-widget .form-item {
+  padding-top: 0px;
+  padding-bottom: 0px;
+  margin-top: 0px;
+  margin-bottom: 0px;
+}
+
+.views-exposed-widget label {
+  display: inline-block;
+  width: 15em;
+  font-weight: normal;
+}
+
+.views-exposed-widget label :after {
+  content: ":";
+}
+
+.views-exposed-form .views-submit-button {
+  position:absolute;
+  left:475px;
+  top: 0px;
+}

+ 4 - 1
tripal_views/tripal_views.module

@@ -154,7 +154,10 @@ function tripal_views_help ($path, $arg) {
  */
 function tripal_views_permission() {
   return array(
-    'manage tripal_views_integration',
+    'manage tripal_views_integration' => array(
+      'title' => t('Administrate Tripal Views Integration'),
+      'description' => t('Permission to manage Tripal Views Integration.')
+    ),
   );
 }
 

+ 6 - 0
tripal_views/tripal_views.views.inc

@@ -117,6 +117,12 @@ function tripal_views_views_pre_render(&$view) {
   // view has populated the $view->exposed_input variable
   unset($view->exposed_input);
 
+  // Add css if tripal admin tagged view
+  if ($view->tag == 'tripal admin') {
+    $tripal_admin_view_css = drupal_get_path('module', 'tripal_views') . '/theme/tripal_views_admin_views.css';
+    drupal_add_css($tripal_admin_view_css);
+  }
+
 }
 
 /**