Browse Source

Fixed merge conflict

Stephen Ficklin 9 years ago
parent
commit
aea7d85367

+ 5 - 175
legacy/tripal_core/tripal_core.drush.inc

@@ -22,25 +22,6 @@
 function tripal_core_drush_help($command) {
   switch ($command) {
 
-    // TRIPAL JOBS
-    case 'trp-run-jobs':
-      return dt('Launches pending jobs waiting in the queue.');
-      break;
-    case 'trp-rerun-job':
-      return dt('Rerun a job in the queue.');
-      break;
-    case 'trp-get-currjob':
-      return dt('Returns details about the currently running tripal job including percent complete.');
-      break;
-    // Placeholders for unimplmeneted jobs
-    case 'trp-show-job':
-      break;
-    case 'trp-revert-jobs':
-      break;
-    case 'trp-cancel-job':
-      break;
-    case 'trp-list-jobs':
-      break;
     // Deprecated functions
     case 'drush:tripal-launch-jobs':
       return dt('DEPRECATED. Please use: trp-run-jobs.');
@@ -91,52 +72,7 @@ function tripal_core_drush_command() {
       'table' => dt('The name of the materialized view table to update.'),
     ),
   );
-  $items['trp-get-currjob'] = array(
-    'description' => dt('Returns details about the currently running job including percent complete.'),
-    'arguments'   => array(),
-    'examples' => array(
-      'Standard example' => 'drush trp-get-currjob',
-    ),
-  );
-  $items['trp-run-jobs'] = array(
-    'description' => dt('Launches jobs waiting in the queue. Only one job can execute at a time unless the --parllel=1 option is provided.'),
-    'examples' => array(
-      'Single Job' => 'drush trp-run-jobs --username=administrator',
-      'Parallel Job' => 'drush trp-run-jobs --username=administrator --parallel=1'
-    ),
-    'arguments' => array(),
-    'options' => array(
-      'user' => array(
-        'description' => dt('DEPRECATED. Conflicts with Drush 7.x --user argument. Please use the --username argument.'),
-      ),
-      'username' => array(
-        'description' => dt('The Drupal user name for which the job should be run.  The permissions for this user will be used.'),
-      ),
-      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
-      'job_id' => dt('Provide a job_id to run a specific job. Only jobs that have not been run already can be used'),
-    ),
-  );
-  $items['trp-rerun-job'] = array(
-    'description' => dt('Re-run a specific job from the queue.'),
-    'examples' => array(
-      'Single Job' => 'drush trp-rerun-job --username=administrator --job_id=2',
-      'Parallel Job' => 'drush trp-rerun-job --username=administrator  --job_id=2 --parallel=1'
-    ),
-    'arguments' => array(),
-    'options' => array(
-      'user' => array(
-        'description' => dt('DEPRECATED. Conflicts with Drush 7.x --user argument. Please use the --username argument.'),
-      ),
-      'username' => array(
-        'description' => dt('The Drupal user name for which the job should be run.  The permissions for this user will be used.'),
-      ),
-      'job_id' => array(
-        'description' => dt('The job ID to run.'),
-        'required' => TRUE,
-      ),
-      'parallel' => dt('Normally jobs are executed one at a time. But if you are certain no conflicts will occur with other currently running jobs you may set this argument to a value of 1 to make the job run in parallel with other running jobs.'),
-    ),
-  );
+ 
   $items['trp-get-cversion'] = array(
     'description' => dt('Returns the current installed version of Chado.'),
     'arguments' => array(),
@@ -268,22 +204,7 @@ function tripal_core_drush_command() {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_set_user($username) {
-  if ($username) {
-    $sql = "SELECT uid FROM {users} WHERE name = :name";
-    $results = db_query($sql, array(':name' => $username));
-    $u = $results->fetchObject();
-    if (!$u) {
-      drush_print('ERROR: Please provide a valid username (--username argument) for running this job.');
-      exit;
-    }
-    global $user;
-    $user = user_load($u->uid);
-    return $u->uid;
-  }
-  else {
-    drush_print('ERROR: Please provide a username (--username argument) for running this job.');
-    exit;
-  }
+  drush_tripal_set_user($username);
 }
 
 /**
@@ -294,40 +215,7 @@ function drush_tripal_core_set_user($username) {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_trp_run_jobs() {
-  $parallel = drush_get_option('parallel');
-  $job_id   = drush_get_option('job_id');
-
-  // Unfortunately later versions of Drush use the '--user' argument which
-  // makes it incompatible with how Tripal was using it.  For backwards
-  // compatabiliy we will accept --user with a non numeric value only. The
-  // numeric value should be for Drush. Tripal will instead use the
-  // --username argument for the fture.
-  $user = drush_get_option('user');
-  $uname = drush_get_option('username');
-  if ($user and is_numeric($user)) {
-  }
-  elseif ($user) {
-    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
-    $username = $user;
-  }
-  if ($uname) {
-    $username = $uname;
-  }
-
-  drush_tripal_core_set_user($username);
-
-  if ($parallel) {
-    drush_print("Tripal Job Launcher (in parallel)");
-    drush_print("Running as user '$username'");
-    drush_print("-------------------");
-    tripal_launch_job($parallel, $job_id);
-  }
-  else {
-    drush_print("Tripal Job Launcher");
-    drush_print("Running as user '$username'");
-    drush_print("-------------------");
-    tripal_launch_job(0, $job_id);
-  }
+  drush_tripal_trp_run_jobs();
 }
 /**
  * DEPRECATED. Executes jobs in the Tripal Jobs Queue.
@@ -367,43 +255,7 @@ function drush_tripal_core_tripal_jobs_launch($username) {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_trp_rerun_job() {
-  // Unfortunately later versions of Drush use the '--user' argument which
-  // makes it incompatible with how Tripal was using it.  For backwards
-  // compatabiliy we will accept --user with a non numeric value only. The
-  // numeric value should be for Drush. Tripal will instead use the
-  // --username argument for the fture.
-  $user = drush_get_option('user');
-  $uname = drush_get_option('username');
-  print "USER: '$user', UNAME: '$uname'\n";
-  if ($user and is_numeric($user)) {
-  }
-  elseif ($user) {
-    print "\nNOTE: Use of the --user argument is deprecated as it conflicts with the --user argument of Drush 7.x. Please now use --username instead.\n\n";
-    $username = $user;
-  }
-  if ($uname) {
-    $username = $uname;
-  }
-
-  $parallel = drush_get_option('parallel');
-  $job_id   = drush_get_option('job_id');
-
-  drush_tripal_core_set_user($username);
-  $new_job_id = tripal_rerun_job($job_id, FALSE);
-
-  if ($parallel) {
-    drush_print("Tripal Job Launcher (in parallel)");
-    drush_print("Running as user '$username'");
-    drush_print("-------------------");
-    tripal_launch_job($parallel, $new_job_id);
-  }
-  else {
-    drush_print("Tripal Job Launcher");
-    drush_print("Running as user '$username'");
-    drush_print("-------------------");
-    tripal_launch_job(0, $new_job_id);
-  }
-
+  drush_tripal_trp_rerun_job();
 }
 
 /**
@@ -432,29 +284,7 @@ function drush_tripal_core_tripal_jobs_rerun($username, $job_id) {
  * @ingroup tripal_drush
  */
 function drush_tripal_core_trp_get_currjob() {
-  $sql =  "
-    SELECT *
-    FROM {tripal_jobs} TJ
-    WHERE TJ.end_time IS NULL and NOT TJ.start_time IS NULL
-  ";
-  $jobs = db_query($sql);
-
-  foreach ($jobs as $job) {
-    $job_pid = $job->pid;
-    $output = "Name: " . $job->job_name . "\n" .
-        "Submitted: " . date(DATE_RFC822, $job->submit_date) . "\n" .
-        "Started: " . date(DATE_RFC822, $job->start_time) . "\n" .
-        "Module: " . $job->modulename . "\n" .
-        "Callback: " . $job->callback . "\n" .
-        "Process ID: " . $job->pid . "\n" .
-        "Progress: " . $job->progress . "%\n";
-    drush_print($output);
-  }
-  if (!$job_pid) {
-    drush_print('There are currently no running jobs.');
-  }
-  //log to the command line with an OK status
-  drush_log('Running tripal-current-job', 'ok');
+  drush_tripal_trp_get_currjob();
 }
 
 /**

+ 0 - 31
legacy/tripal_core/tripal_core.module

@@ -220,34 +220,3 @@ function tripal_core_node_view($node, $view_mode, $langcode) {
     }
   }
 }
-
-/**
- * Implements hook_exclude_type_by_default()
- *
- * This hooks allows fields of a specified type that match a specified criteria
- * to be excluded by default from any table when chado_generate_var() is called.
- * Keep in mind that if fields are excluded by default they can always be
- * expanded at a later date using chado_expand_var().
- *
- * Criteria are php strings that evaluate to either TRUE or FALSE. These
- * strings are evaluated using drupal_eval() which suppresses syntax errors
- * and throws watchdog entries of type php. There are also watchdog entries of
- * type tripal_core stating the exact criteria evaluated. Criteria can
- * contain the following tokens:
- *   - <field_name>
- *       Replaced by the name of the field to be excluded
- *   - <field_value>
- *       Replaced by the value of the field in the current record
- * Also keep in mind that if your criteria doesn't contain the
- * &gt;field_value&lt;  token then it will be evaluated before the query is
- * executed and if the field is excluded it won't be included in the query.
- *
- * @return
- *   An array of type => criteria where the type is excluded if the criteria
- *   evaluates to TRUE
- *
- * @ingroup tripal_core
- */
-function tripal_core_exclude_type_by_default() {
-  return array('text' => 'strlen("<field_value> ") > 250');
-}

+ 1 - 1
legacy/tripal_db/tripal_db.module

@@ -4,7 +4,7 @@
  * General functions for the db module
  */
 
-require_once 'api/tripal_db.api.inc';
+//require_once 'api/tripal_db.api.inc';
 require_once 'api/tripal_db.DEPRECATED.inc';
 
 require_once 'includes/tripal_db.admin.inc';

+ 4 - 2
tripal_chado/includes/fields/dbxref.inc

@@ -52,7 +52,8 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
   $base_table = $field['settings']['base_table'];
   $schema = chado_get_schema($chado_table);
   $pkey = $schema['primary key'][0];
-  $fkey = array_values($schema['foreign keys'][$base_table]['columns'])[0];
+  $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
+  $fkey = $fkeys[0];
 
   // Get the field defaults.
   $record_id = '';
@@ -304,7 +305,8 @@ function tripal_chado_dbxref_field_load($field, $entity, $base_table, $record) {
   $chado_table = $field['settings']['chado_table'];
   $schema = chado_get_schema($chado_table);
   $pkey = $schema['primary key'][0];
-  $fkey = array_values($schema['foreign keys'][$base_table]['columns'])[0];
+  $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
+  $fkey = $fkeys[0];
 
   // Set some defaults for the empty record.
   $entity->{$field_name}['und'][0] = array(