Explorar o código

Added ability to update publications on import

spficklin %!s(int64=12) %!d(string=hai) anos
pai
achega
3b99716309
Modificáronse 2 ficheiros con 14 adicións e 5 borrados
  1. 4 4
      tripal_pub/api/tripal_pub.api.inc
  2. 10 1
      tripal_pub/tripal_pub.drush.inc

+ 4 - 4
tripal_pub/api/tripal_pub.api.inc

@@ -199,7 +199,7 @@ function tripal_pub_update_publications($do_contact = FALSE, $dbxref = NULL, $db
 /*
  * @ingroup tripal_pub_api
  */
-function tripal_pub_import_publications($report_email = FALSE) {
+function tripal_pub_import_publications($report_email = FALSE, $do_update = FALSE) {
   $num_to_retrieve = 100;
   $pager_id = 0;
   $page = 0;
@@ -236,7 +236,7 @@ function tripal_pub_import_publications($report_email = FALSE) {
     do {       
       // retrieve the pubs for this page. We'll retreive 10 at a time
       $pubs = tripal_pub_get_remote_search_results($remote_db, $criteria, $num_to_retrieve, $pager_id, $page);
-      $reports[$import->name] = tripal_pub_add_publications($pubs, $import->do_contact);             
+      $reports[$import->name] = tripal_pub_add_publications($pubs, $import->do_contact, $do_update);             
       $page++;
     } 
     // continue looping until we have a $pubs array that does not have
@@ -291,7 +291,7 @@ function tripal_pub_import_publications($report_email = FALSE) {
 /*
  * @ingroup tripal_pub_api
  */
-function tripal_pub_import_by_dbxref($pub_dbxref, $do_contact = FALSE) {
+function tripal_pub_import_by_dbxref($pub_dbxref, $do_contact = FALSE, $do_update) {
   $num_to_retrieve = 1;
   $pager_id = 0;
   $page = 0;
@@ -329,7 +329,7 @@ function tripal_pub_import_by_dbxref($pub_dbxref, $do_contact = FALSE) {
     );
     $remote_db = $criteria['remote_db'];
     $pubs = tripal_pub_get_remote_search_results($remote_db, $criteria, $num_to_retrieve, $pager_id, $page);
-    $pub_id = tripal_pub_add_publications($pubs, $do_contact);
+    $pub_id = tripal_pub_add_publications($pubs, $do_contact, $do_update);
           
   }
   

+ 10 - 1
tripal_pub/tripal_pub.drush.inc

@@ -32,6 +32,7 @@ function tripal_pub_drush_command() {
       'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
       'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642).'),
       'report' => dt("Set to the email address of the recipient who should receive an HTML report of the publications that have been added."),
+      'update' => dt("Set to 'Y' to update existing pubs.  By default only new pubs are inserted."),
     ),
     'examples' => array(
       'Standard example' => 'drush tripal-pubs-import',
@@ -67,12 +68,20 @@ function drush_tripal_pub_tripal_pubs_import() {
   $create_contacts = drush_get_option('create_contacts');
   $dbxref = drush_get_option('dbxref');
   $do_report = drush_get_option('report');
+  $update = drush_get_option('$update');
+  
+  if($update == 'Y') {
+    $update = TRUE;
+  }
+  else {
+    $update = FALSE;
+  }
   
   if ($dbxref) {
     tripal_pub_import_by_dbxref($dbxref, $create_contacts);  
   }
   else {
-    tripal_pub_import_publications($do_report);
+    tripal_pub_import_publications($do_report, $update);
   }
 }
 /**