tripal_pub.drush.inc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. function tripal_pub_drush_help($command) {
  13. switch ($command) {
  14. case 'drush:tripal-pub-import':
  15. return dt('Imports publications from remote databases using saved configuration settings.');
  16. }
  17. }
  18. /**
  19. * Registers a drush command and constructs the full help for that command
  20. *
  21. * @return
  22. * And array of command descriptions
  23. */
  24. function tripal_pub_drush_command() {
  25. $items = array();
  26. $items['tripal-pubs-import'] = array(
  27. 'description' => dt('Imports publications from remote databases using saved configuration settings.'),
  28. 'examples' => array(
  29. 'Standard example' => 'drush tripal-pubs-import',
  30. 'Import single publication' => 'drush tripal-pub-import --dbxref=PMID:23582642',
  31. ),
  32. 'options' => array(
  33. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  34. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642).'),
  35. 'report' => dt("Set to 'Y' to generate an HTML report of the publications that have been added."),
  36. ),
  37. 'aliases' => array('tpubs-import'),
  38. );
  39. $items['tripal-pubs-update'] = array(
  40. 'description' => dt('Updates publication information for publications with a supported database cross-reference.'),
  41. 'options' => array(
  42. 'create_contacts' => dt('provide this option to create or update contacts for authors. By default contacts are not created or updated.'),
  43. 'dbxref' => dt('An accession number for a publication from a remote database (e.g. PMID:23582642)'),
  44. 'db' => dt('The database name (e.g. PMID or AGL)'),
  45. ),
  46. 'examples' => array(
  47. 'Standard example' => 'drush tripal-pubs-update',
  48. 'Create contacts during update' => 'drush tripal-pubs-update --create_contacts=1',
  49. 'Update a single record' => 'drush tripal-pubs-update --dbxref=PMID:23582642',
  50. 'Update all records for a single database' => 'drush tripal-pubs-update --db=PMID'
  51. ),
  52. 'aliases' => array('tpubs-update'),
  53. );
  54. return $items;
  55. }
  56. /**
  57. * Imports publications into Chado
  58. *
  59. */
  60. function drush_tripal_pub_tripal_pubs_import() {
  61. $create_contacts = drush_get_option('create_contacts');
  62. $dbxref = drush_get_option('dbxref');
  63. $do_report = drush_get_option('report');
  64. if ($dbxref) {
  65. tripal_pub_import_by_dbxref($dbxref, $create_contacts);
  66. }
  67. else {
  68. tripal_pub_import_publications($do_report);
  69. }
  70. }
  71. /**
  72. * Imports publications into Chado
  73. *
  74. */
  75. function drush_tripal_pub_tripal_pubs_update() {
  76. $create_contacts = drush_get_option('create_contacts');
  77. $dbxref = drush_get_option('dbxref');
  78. $db = drush_get_option('db');
  79. tripal_pub_update_publications($create_contacts, $dbxref, $db);
  80. }