Skip to content

Commit

Permalink
Merge pull request #584 from tripal/577-tv3-pub_syncing
Browse files Browse the repository at this point in the history
Syncing of Pubs in Tv3 Legacy Mode
  • Loading branch information
bradfordcondon committed Aug 31, 2018
2 parents 85fa360 + e77f6f0 commit dbdfe0f
Show file tree
Hide file tree
Showing 16 changed files with 539 additions and 532 deletions.
84 changes: 1 addition & 83 deletions legacy/tripal_contact/tripal_contact.install
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ function tripal_contact_requirements($phase) {
*/
function tripal_contact_install() {

// Add the contactprop table to Chado.
tripal_contact_add_custom_tables();

// Add loading of the the tripal contact ontology to the job queue.
$obo_path = '{tripal_contact}/files/tcontact.obo';
$obo_id = tripal_insert_obo('Tripal Contacts', $obo_path);
tripal_submit_obo_job(array('obo_id' => $obo_id));

// Add cvterms for relationship types.
tripal_contact_add_cvs();
tripal_contact_add_cvterms();
Expand All @@ -75,13 +67,7 @@ function tripal_contact_install() {
* @ingroup tripal_legacy_contact
*/
function tripal_contact_uninstall() {
/*
// remove our custom block visibility settings per node type
db_delete('block_node_type')
->condition('module', 'chado_contact')
->condition('delta', 'contbase')
->execute();
*/

}

/**
Expand Down Expand Up @@ -166,71 +152,3 @@ function tripal_contact_schema() {
return $schema;
}

/**
* Add any custom tables needed by this module.
* - Contactprop: keep track of properties of contact
*
* @ingroup tripal_legacy_contact
*/
// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
/* function tripal_contact_add_custom_tables(){
$schema = array (
'table' => 'contactprop',
'fields' => array (
'contactprop_id' => array (
'type' => 'serial',
'not null' => true,
),
'contact_id' => array (
'type' => 'int',
'not null' => true,
),
'type_id' => array (
'type' => 'int',
'not null' => true,
),
'value' => array (
'type' => 'text',
'not null' => false,
),
'rank' => array (
'type' => 'int',
'not null' => true,
'default' => 0,
),
),
'primary key' => array (
0 => 'contactprop_id',
),
'unique keys' => array (
'contactprop_c1' => array (
0 => 'contact_id',
1 => 'type_id',
2 => 'rank',
),
),
'indexes' => array (
'contactprop_idx1' => array (
0 => 'contact_id',
),
'contactprop_idx2' => array (
0 => 'type_id',
),
),
'foreign keys' => array (
'cvterm' => array (
'table' => 'cvterm',
'columns' => array (
'type_id' => 'cvterm_id',
),
),
'contact' => array (
'table' => 'contact',
'columns' => array (
'contact_id' => 'contact_id',
),
),
),
);
chado_create_custom_table('contactprop', $schema, TRUE);
} */
4 changes: 2 additions & 2 deletions legacy/tripal_pub/api/tripal_pub.DEPRECATED.inc
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ function tripal_pub_import_publications_by_import_id($import_id, $job_id = NULL)
"DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
array(
'%old_function'=>'tripal_pub_import_publications_by_import_id',
'%new_function' => 'tripal_execute_pub_importer'
'%new_function' => 'chado_execute_pub_importer'
)
);

return tripal_execute_pub_importer($import_id, $job_id);
return chado_execute_pub_importer($import_id, TRUE, FALSE, $job_id);
}

/**
Expand Down
97 changes: 0 additions & 97 deletions legacy/tripal_pub/tripal_pub.install
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ function tripal_pub_requirements($phase) {
function tripal_pub_install() {
global $base_path;

// add loading of the the tripal pub ontology to the job queue
$obo_path = '{tripal_pub}/files/tpub.obo';
$obo_id = tripal_insert_obo('Tripal Publication', $obo_path);
tripal_submit_obo_job(array('obo_id' => $obo_id));

tripal_pub_add_cvs();
tripal_pub_add_cvterms();

// add the custom tables
tripal_pub_add_custom_tables();

// set the default vocabularies
tripal_set_default_cv('pub', 'type_id', 'tripal_pub');
tripal_set_default_cv('pubprop', 'type_id', 'tripal_pub');
Expand Down Expand Up @@ -126,95 +115,9 @@ function tripal_pub_schema() {
'primary key' => array('nid'),
);

$schema['tripal_pub_import'] = array(
'fields' => array(
'pub_import_id' => array(
'type' => 'serial',
'not null' => TRUE
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE
),
'criteria' => array(
'type' => 'text',
'size' => 'normal',
'not null' => TRUE,
'description' => 'Contains a serialized PHP array containing the search criteria'
),
'disabled' => array(
'type' => 'int',
'unsigned' => TRUE,
'not NULL' => TRUE,
'default' => 0
),
'do_contact' => array(
'type' => 'int',
'unsigned' => TRUE,
'not NULL' => TRUE,
'default' => 0
),
),
'primary key' => array('pub_import_id'),
'indexes' => array(
'name' => array('name')
),
);

return $schema;
}

/**
* Add custom table related to publications
* - pubauthor_contact
*
* @ingroup tripal_legacy_pub
*/
// This function was moved to tripal_chado/includes/setup/tripal_chado.setup.inc
/* function tripal_pub_add_custom_tables() {
$schema = array (
'table' => 'pubauthor_contact',
'fields' => array (
'pubauthor_contact_id' => array (
'type' => 'serial',
'not null' => true,
),
'contact_id' => array (
'type' => 'int',
'not null' => true,
),
'pubauthor_id' => array (
'type' => 'int',
'not null' => true,
),
),
'primary key' => array (
0 => 'pubauthor_contact_id',
),
'unique keys' => array (
'pubauthor_contact_c1' => array (
0 => 'contact_id',
1 => 'pubauthor_id',
),
),
'foreign keys' => array (
'contact' => array (
'table' => 'contact',
'columns' => array (
'contact_id' => 'contact_id',
),
),
'pubauthor' => array (
'table' => 'pubauthor',
'columns' => array (
'pubauthor_id' => 'pubauthor_id',
),
),
),
);
chado_create_custom_table('pubauthor_contact', $schema, TRUE);
} */

/**
* This is the required update for tripal_pub when upgrading from Drupal core API 6.x.
Expand Down
2 changes: 1 addition & 1 deletion legacy/tripal_pub/tripal_pub.module
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function tripal_pub_form_alter(&$form, &$form_state, $form_id) {
function tripal_pub_job_describe_args($callback, $args) {

$new_args = array();
if ($callback == 'tripal_execute_pub_importer') {
if ($callback == 'chado_execute_pub_importer') {
// get all of the loaders
$qargs = array(':import_id' => $args[0]);
$sql = "SELECT * FROM {tripal_pub_import} WHERE pub_import_id = :import_id ";
Expand Down
2 changes: 1 addition & 1 deletion tripal/api/tripal.jobs.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -567,4 +567,4 @@ function tripal_execute_job($job_id, $redirect = TRUE) {
if ($redirect) {
drupal_goto("admin/tripal/tripal_jobs/view/$job_id");
}
}
}
44 changes: 32 additions & 12 deletions tripal/api/tripal.notice.api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ define('TRIPAL_DEBUG',7);
/**
* Provide better error notice for Tripal.
*
* Please be sure to set the $options array as desired. For example, by default
* this function sends all messages to the Drupal watchdog. If a long running
* job uses this function and prints status messages you may not want to have
* those go to the watchdog as it can dramatically affect performance.
*
* If the environment variable 'TRIPAL_DEBUG' is set to 1 then this function
* will add backtrace information to the message.
* will add backtrace information to the message.
*
* @param $type
* The catagory to which this message belongs. Can be any string, but the
Expand Down Expand Up @@ -60,6 +65,12 @@ define('TRIPAL_DEBUG',7);
* display is the command-line
* - drupal_set_message: set to TRUE to call drupal_set_message with the
* same error.
* - drupal_set_message: set to TRUE then send the message to the
* drupal_set_message function.
* - watchdog: set to FALSE to disable logging to Drupal's watchdog.
* - job: The jobs management object for the job if this function is run
* as a job. Adding the job object here ensures that any status or error
* messages are also logged with the job.
*
* @ingroup tripal_notify_api
*/
Expand Down Expand Up @@ -110,13 +121,15 @@ function tripal_report_error($type, $severity, $message, $variables = array(), $
}
}

// Send to watchdog.
try {
watchdog($type, $message, $variables, $severity);
}
catch (Exception $e) {
print "CRITICAL (TRIPAL): Unable to add error message with watchdog: " . $e->getMessage(). "\n.";
$options['print'] = TRUE;
// Send to watchdog if the user wants.
if (array_key_exists('watchdog', $options) and $options['watchdog'] !== FALSE) {
try {
watchdog($type, $message, $variables, $severity);
}
catch (Exception $e) {
print "CRITICAL (TRIPAL): Unable to add error message with watchdog: " . $e->getMessage(). "\n.";
$options['print'] = TRUE;
}
}

// Format the message for printing (either to the screen, log or both).
Expand Down Expand Up @@ -149,7 +162,10 @@ function tripal_report_error($type, $severity, $message, $variables = array(), $
if (($severity != TRIPAL_INFO)) {
tripal_log('[' . strtoupper($type) . '] ' . $print_message . "\n", $severity_string);
}


if (array_key_exists('job', $options) and is_a($options['job'], 'TripalJob')) {
$options['job']->logMessage($message, $variables, $severity);
}
}

/**
Expand Down Expand Up @@ -231,16 +247,20 @@ function tripal_set_message($message, $importance = TRIPAL_INFO, $options = arra
}

/**
* File-based logging for Tripal.
*
* File-based error logging for Tripal.
*
* Consider using the tripal_report_error function rather than
* calling this function directly, as that function calls this one for non
* INFO messages and has greater functionality.
*
* @param $message
* The message to be logged. Need not contain date/time information.
* @param $log_type
* The type of log. Should be one of 'error' or 'job' although other types
* are supported.
* @param $options
* An array of options where the following keys are supported:
* - first_progress_bar: this sohuld be used for the first log call for a
* - first_progress_bar: this should be used for the first log call for a
* progress bar.
* - is_progress_bar: this option should be used for all but the first print
* of a progress bar to allow it all to be printed on the same line
Expand Down
9 changes: 9 additions & 0 deletions tripal/includes/TripalJob.inc
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@ class TripalJob {
* Logging works regardless if the job uses a transaction. If the
* transaction must be rolled back to to an error the error messages will
* persist.
*
* If a function can be executed by the Tripal job system (and hence the
* job object is passed in) then you can directly use this function to
* log messages. However, if the function can be run via drush on the
* command-line, consider using the tripal_report_error() function which can
* accept a job object as an $option and will print to both the terminal
* and to the job object. If you use the tripal_report_error() be sure
* to set the 'watchdog' option only if you need log messages also going
* to the watchdog.
*
* @param $message
* The message to store in the log. Keep $message translatable by not
Expand Down
21 changes: 15 additions & 6 deletions tripal/includes/tripal.jobs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,21 @@ function tripal_jobs_view($job_id) {
}

// build the links
$links = l('Return to jobs list', "admin/tripal/tripal_jobs/") . ' | ';
$links .= l('Re-run this job', "admin/tripal/tripal_jobs/rerun/" . $job->job_id) . ' | ';
$items = [];
$items[] = l('Return to jobs list', "admin/tripal/tripal_jobs/");
$items[] = l('Re-run this job', "admin/tripal/tripal_jobs/rerun/" . $job->job_id);
if ($job->start_time == 0 and $job->end_time == 0) {
$links .= l('Cancel this job', "admin/tripal/tripal_jobs/cancel/" . $job->job_id) . ' | ';
$links .= l('Execute this job', "admin/tripal/tripal_jobs/execute/".$job->job_id);
$items[] = l('Cancel this job', "admin/tripal/tripal_jobs/cancel/" . $job->job_id);
$items[] = l('Execute this job', "admin/tripal/tripal_jobs/execute/".$job->job_id);
}
$links = theme_item_list([
'items' => $items,
'title' => '',
'type' => 'ul',
'attributes' => [
'class' => ['action-links'],
],
]);

// make our start and end times more legible
$job->submit_date = tripal_get_job_submit_date($job);
Expand Down Expand Up @@ -320,7 +329,7 @@ function tripal_jobs_view($job_id) {

$content['links'] = array(
'#type' => 'markup',
'#markup' => '<p>' . substr($links, 0, -2) . '</p>',
'#markup' => $links,
);
$content['job_title'] = array(
'#type' => 'item',
Expand Down Expand Up @@ -362,7 +371,7 @@ function tripal_jobs_view($job_id) {
);
$content['log_fset']['job_logs'] = array(
'#type' => 'markup',
'#markup' => '<pre>' . $job->error_msg . '</pre>',
'#markup' => '<pre class="tripal-job-logs">' . $job->error_msg . '</pre>',
);
return $content;
}
Expand Down

0 comments on commit dbdfe0f

Please sign in to comment.