tripal_bulk_loader.admin.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * @file
  4. * Bulk Loader Administration (Miscellaneous)
  5. *
  6. * @ingroup tripal_bulk_loader
  7. */
  8. /**
  9. * Landing page for bulk loader admin. Ensures views are enabled and if not provides links to do so.
  10. *
  11. * @ingroup tripal_bulk_loader
  12. */
  13. function tripal_bulk_loader_admin_jobs_listing() {
  14. $output = '';
  15. // set the breadcrumb
  16. $breadcrumb = array();
  17. $breadcrumb[] = l('Home', '<front>');
  18. $breadcrumb[] = l('Administration', 'admin');
  19. $breadcrumb[] = l('Tripal', 'admin/tripal');
  20. $breadcrumb[] = l('Chado Data Loaders', 'admin/tripal/loaders');
  21. $breadcrumb[] = l('Bulk Loader', 'admin/tripal/loaders/bulk');
  22. drupal_set_breadcrumb($breadcrumb);
  23. // Add the view
  24. $jobs_view = views_embed_view('tripal_bulk_loading_jobs','default');
  25. $template_view = views_embed_view('tripal_bulk_loader_templates','default');
  26. if (isset($jobs_view) && isset($template_view)) {
  27. $output .= $jobs_view;
  28. }
  29. else {
  30. $output .= '<p>The Tripal Bulk Loader uses primarily views to provide an '
  31. . 'administrative interface. Currently one or more views needed for this '
  32. . 'administrative interface are disabled. <strong>Click each of the following links to '
  33. . 'enable the pertinent views</strong>:</p>';
  34. $output .= '<ul>';
  35. if (!isset($jobs_view)) {
  36. $output .= '<li>'.l('Tripal Bulk Loading Jobs', 'admin/tripal/loaders/bulk/views/jobs/enable').'</li>';
  37. }
  38. if (!isset($template_view)) {
  39. $output .= '<li>'.l('Tripal Bulk Loader Templates', 'admin/tripal/loaders/bulk/views/templates/enable').'</li>';
  40. }
  41. $output .= '</ul>';
  42. }
  43. return $output;
  44. }
  45. /**
  46. * @section
  47. * Configuration Form
  48. */
  49. /**
  50. * A Configuration form for this module
  51. *
  52. * @ingroup tripal_bulk_loader
  53. */
  54. function tripal_bulk_loader_configuration_form($form_state = NULL) {
  55. $form = array();
  56. $form['space'] = array(
  57. '#type' => 'fieldset',
  58. '#title' => t('Enable/Disable Functionality'),
  59. );
  60. $form['space']['keep_track_inserted'] = array(
  61. '#type' => 'checkbox',
  62. '#title' => t('Keep track of inserted record IDs'),
  63. '#description' => t('This enables the ability to revert an entire loading job even if '
  64. .'it completed successfully. Furthermore, it displays the number of records '
  65. .'successfully inserted into each table.'),
  66. '#default_value' => variable_get('tripal_bulk_loader_keep_track_inserted', FALSE),
  67. );
  68. $form['speed'] = array(
  69. '#type' => 'fieldset',
  70. '#title' => t('Possible Speed Improvements'),
  71. );
  72. $form['speed']['prepare'] = array(
  73. '#type' => 'checkbox',
  74. '#title' => t('Use Prepared Statements'),
  75. '#description' => t('SQL Prepared Statements allow for SQL queries which will be run '
  76. .'many times to be parsed, rewritten and planned only once rather then every time '
  77. .'the query is run. In the case of the bulk loader, this ensures that planning only '
  78. .'occurs once for each "record" in your bulk loading template.'),
  79. '#default_value' => variable_get('tripal_bulk_loader_prepare', TRUE),
  80. );
  81. $form['speed']['disable_triggers'] = array(
  82. '#type' => 'checkbox',
  83. '#title' => t('Delay Constraint Checking during loading job.'),
  84. '#description' => t('This delays the constraint checking until the end of the
  85. loading proccess.'),
  86. '#default_value' => variable_get('tripal_bulk_loader_disable_triggers', TRUE),
  87. );
  88. $form['speed']['no_validate'] = array(
  89. '#type' => 'checkbox',
  90. '#title' => t('Skip Validation at the Tripal Core API level'),
  91. '#description' => t('If an error is encountered, the Tripal core API will try
  92. to provide informative error messages. With this turned off, you will not benifit
  93. from these more informative error messages; however, your job will load faster
  94. since it doesn\'t have to do the additional checking before inserting.'),
  95. '#default_value' => variable_get('tripal_bulk_loader_skip_validation', FALSE),
  96. );
  97. $form['speed']['transactions'] = array(
  98. '#type' => 'radios',
  99. '#title' => t('Transaction Rollback when an error is encountered'),
  100. '#options' => array(
  101. 'all' => t('Rollback the last constant set.'
  102. .'<div class="description"If you added more then one constant set then the
  103. successfully loaded constant sets will not be rolled back. However, once an error
  104. is encountered no further constant sets will be loaded either.</div>'),
  105. 'row' => t('Only Rollback the last line of the input file.'
  106. .'<div class="description">This option may allow you to restart the job after
  107. fixing the error (manual intervention needed).</div>'),
  108. 'none' => t('Do not use transactions<div class="description">This is not recommended.</div>')
  109. ),
  110. '#default_value' => variable_get('tripal_bulk_loader_transactions', 'row')
  111. );
  112. $form['speed']['lock'] = array(
  113. '#type' => 'radios',
  114. '#title' => t('Lock Type'),
  115. '#description' => t('The type of lock used by the bulk loading jobs. The lock is '
  116. .'acquired at the beginning of the job and kept till the end. A lock of the type '
  117. .'selected will be acquired for every table being inserted into.'),
  118. '#options' => array(
  119. 'ROW EXCLUSIVE' => t('ROW EXCLUSIVE: The default lock type for insert queries.'),
  120. 'EXCLUSIVE' => t('EXCLUSIVE: Only Select Queries can access the table.'),
  121. 'ACCESS EXCLUSIVE' => t('ACCESS EXCLUSIVE: No other queries can access the table.'),
  122. ),
  123. '#default_value' => variable_get('tripal_bulk_loader_lock', 'ROW EXCLUSIVE'),
  124. );
  125. $form['submit1'] = array(
  126. '#type' => 'submit',
  127. '#value' => t('Save')
  128. );
  129. return $form;
  130. }
  131. /**
  132. * A Configuration form for this module (Submit)
  133. *
  134. * @ingroup tripal_bulk_loader
  135. */
  136. function tripal_bulk_loader_configuration_form_submit($form, $form_state) {
  137. variable_set('tripal_bulk_loader_prepare', $form_state['values']['prepare']);
  138. variable_set('tripal_bulk_loader_disable_triggers', $form_state['values']['disable_triggers']);
  139. variable_set('tripal_bulk_loader_skip_validation', $form_state['values']['no_validate']);
  140. variable_set('tripal_bulk_loader_transactions', $form_state['values']['transactions']);
  141. variable_set('tripal_bulk_loader_lock', $form_state['values']['lock']);
  142. variable_set('tripal_bulk_loader_keep_track_inserted', $form_state['values']['keep_track_inserted']);
  143. }