tripal_pub.drush.inc

  1. 2.x tripal_pub/tripal_pub.drush.inc
  2. 3.x legacy/tripal_pub/tripal_pub.drush.inc
  3. 1.x tripal_pub/tripal_pub.drush.inc

Contains function relating to drush-integration of this module.

File

tripal_pub/tripal_pub.drush.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Contains function relating to drush-integration of this module.
  5. */
  6. /**
  7. * Describes each drush command implemented by the module
  8. *
  9. * @return
  10. * The first line of description when executing the help for a given command
  11. *
  12. * @ingroup tripal_drush
  13. */
  14. function tripal_pub_drush_help($command) {
  15. switch ($command) {
  16. case 'drush:tripal-import-pubs':
  17. return dt('Imports publications from remote databases using saved configuration settings.');
  18. case 'drush:tripal-update-pubs':
  19. return dt('Updates publication information for publications with a supported database cross-reference.');
  20. }
  21. }
  22. /**
  23. * Registers a drush command and constructs the full help for that command
  24. *
  25. * @return
  26. * And array of command descriptions
  27. *
  28. * @ingroup tripal_drush
  29. */
  30. function tripal_pub_drush_command() {
  31. $items = array();
  32. $items['trp-import-pubs'] = array(
  33. 'description' => dt('Imports publications from remote databases using saved configuration settings.'),
  34. 'options' => array(
  35. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  36. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642).'),
  37. 'report' => dt("Set to the email address of the recipient who should receive an HTML report of the publications that have been added."),
  38. 'update' => dt("Set to 'Y' to update existing pubs. By default only new pubs are inserted."),
  39. 'username' => array(
  40. 'description' => dt('The Drupal user name for which the job should be run. The permissions for this user will be used.'),
  41. ),
  42. ),
  43. 'examples' => array(
  44. 'Standard example' => 'drush tripal-pubs-import',
  45. 'Standard example' => 'drush -l http://[site url] tripal-pubs-import --report=[email]. Where [site url] is the URL of the website and [email] is the email address of the recipient to receive the HTML report',
  46. 'Import single publication' => 'drush tripal-pub-import --dbxref=PMID:23582642',
  47. ),
  48. );
  49. $items['trp-update-pubs'] = array(
  50. 'description' => dt('Updates publication information for publications with a supported database cross-reference.'),
  51. 'options' => array(
  52. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  53. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642)'),
  54. 'db' => dt('The database name (e.g. PMID or AGL)'),
  55. ),
  56. 'examples' => array(
  57. 'Standard example' => 'drush tripal-pubs-update',
  58. 'Create contacts during update' => 'drush tripal-pubs-update --create_contacts=1',
  59. 'Update a single record' => 'drush tripal-pubs-update --dbxref=PMID:23582642',
  60. 'Update all records for a single database' => 'drush tripal-pubs-update --db=PMID'
  61. ),
  62. );
  63. // Deprecated commands
  64. $items['tripal-pubs-import'] = array(
  65. 'description' => dt('DEPRECATED. Please see: trp-import-pubs.'),
  66. 'options' => array(
  67. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  68. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642).'),
  69. 'report' => dt("Set to the email address of the recipient who should receive an HTML report of the publications that have been added."),
  70. 'update' => dt("Set to 'Y' to update existing pubs. By default only new pubs are inserted."),
  71. ),
  72. 'examples' => array(
  73. 'Standard example' => 'drush tripal-pubs-import',
  74. 'Standard example' => 'drush -l http://[site url] tripal-pubs-import --report=[email]. Where [site url] is the URL of the website and [email] is the email address of the recipient to receive the HTML report',
  75. 'Import single publication' => 'drush tripal-pub-import --dbxref=PMID:23582642',
  76. ),
  77. 'aliases' => array('tpubs-import'),
  78. );
  79. $items['tripal-pubs-update'] = array(
  80. 'description' => dt('DEPRECATED. Please see: trp-update-pubs.'),
  81. 'options' => array(
  82. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  83. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642)'),
  84. 'db' => dt('The database name (e.g. PMID or AGL)'),
  85. ),
  86. 'examples' => array(
  87. 'Standard example' => 'drush tripal-pubs-update',
  88. 'Create contacts during update' => 'drush tripal-pubs-update --create_contacts=1',
  89. 'Update a single record' => 'drush tripal-pubs-update --dbxref=PMID:23582642',
  90. 'Update all records for a single database' => 'drush tripal-pubs-update --db=PMID'
  91. ),
  92. 'aliases' => array('tpubs-update'),
  93. );
  94. return $items;
  95. }
  96. /**
  97. * Imports publications into Chado
  98. *
  99. * @ingroup tripal_drush
  100. */
  101. function drush_tripal_pub_trp_import_pubs() {
  102. $create_contacts = drush_get_option('create_contacts');
  103. $dbxref = drush_get_option('dbxref');
  104. $do_report = drush_get_option('report');
  105. $update = drush_get_option('update');
  106. $uname = drush_get_option('username');
  107. drush_tripal_core_set_user($uname);
  108. if($update == 'Y') {
  109. $update = TRUE;
  110. }
  111. else {
  112. $update = FALSE;
  113. }
  114. if ($dbxref) {
  115. tripal_import_pub_by_dbxref($dbxref, $create_contacts, $update);
  116. }
  117. else {
  118. tripal_execute_active_pub_importers($do_report, $update);
  119. }
  120. }
  121. /**
  122. * DEPRECATED. Imports publications into Chado
  123. *
  124. * @ingroup tripal_drush
  125. */
  126. function drush_tripal_pub_tripal_pubs_import() {
  127. drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
  128. "continue to work but please consider using the 'trp-import-pubs' command.\n\n");
  129. drush_tripal_pub_trp_import_pubs();
  130. }
  131. /**
  132. * Imports publications into Chado
  133. *
  134. * @ingroup tripal_drush
  135. */
  136. function drush_tripal_pub_trp_update_pubs() {
  137. $create_contacts = drush_get_option('create_contacts');
  138. $dbxref = drush_get_option('dbxref');
  139. $db = drush_get_option('db');
  140. tripal_reimport_publications($create_contacts, $dbxref, $db);
  141. }
  142. /**
  143. * DEPRECATED. Imports publications into Chado
  144. *
  145. * @ingroup tripal_drush
  146. */
  147. function drush_tripal_pub_tripal_pubs_update() {
  148. drush_print("\n\nDEPRECATED: This drush command is outdated.\nIt will ".
  149. "continue to work but please consider using the 'trp-update-pubs' command.\n\n");
  150. drush_tripal_pub_trp_update_pubs();
  151. }