123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <?php
- /**
- * @file
- * Install/Uninstalls, Enables/Disables this module.
- *
- * @ingroup tripal_bulk_loader
- */
- /**
- * Implements hook_disable().
- * Disable default views when module is disabled
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_disable() {
- // Disable all default views provided by this module
- require_once("tripal_bulk_loader.views_default.inc");
- $views = tripal_bulk_loader_views_default_views();
- foreach (array_keys($views) as $view_name) {
- tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
- }
- }
- /**
- * Implements hook_schema().
- *
- * Creates the following tables in the Drupal database:
- * - tripal_bulk_loader: Stores extra details for bulk loading jobs (nodes)
- * - tripal_bulk_loader_template: Stores all loading templates
- * - tripal_bulk_loader_inserted: Keeps track of all records inserted for a given bulk loading job
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_schema() {
- $schema = array();
- $schema['tripal_bulk_loader'] = array(
- 'fields' => array(
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'loader_name' => array(
- 'type' => 'varchar',
- ),
- 'template_id' => array(
- 'type' => 'int',
- ),
- 'file' => array(
- 'type' => 'varchar',
- 'not null' => TRUE
- ),
- 'job_id' => array(
- 'type' => 'int',
- ),
- 'job_status' => array(
- 'type' => 'varchar',
- ),
- 'file_has_header' => array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'keep_track_inserted' => array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'not null' => TRUE,
- 'default' => 1
- ),
- ),
- 'primary key' => array('nid'),
- 'unique keys' => array(
- 'name' => array('loader_name')
- ),
- );
- $schema['tripal_bulk_loader_template'] = array(
- 'fields' => array(
- 'template_id' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'name' => array(
- 'type' => 'varchar',
- ),
- 'template_array' => array(
- 'type' => 'varchar',
- ),
- 'created' => array(
- 'description' => 'The Unix timestamp when the template was created.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- 'changed' => array(
- 'description' => 'The Unix timestamp when the template was most recently saved.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- )
- ),
- 'primary key' => array('template_id'),
- 'unique keys' => array(
- 'name' => array('name')
- ),
- );
- $schema['tripal_bulk_loader_inserted'] = array(
- 'fields' => array(
- 'tripal_bulk_loader_inserted_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'table_inserted_into' => array(
- 'type' => 'varchar',
- 'not null' => TRUE,
- ),
- 'table_primary_key' => array(
- 'type' => 'varchar',
- 'not null' => TRUE,
- ),
- 'ids_inserted' => array(
- 'type' => 'text',
- 'not null' => TRUE
- ),
- ),
- 'primary key' => array('tripal_bulk_loader_inserted_id'),
- );
- $schema['tripal_bulk_loader_constants'] = array(
- 'fields' => array(
- 'constant_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE
- ),
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- ),
- 'group_id' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'chado_table' => array(
- 'type' => 'varchar',
- 'not null' => TRUE,
- ),
- 'chado_field' => array(
- 'type' => 'varchar',
- 'not null' => TRUE,
- ),
- 'record_id' => array(
- 'type' => 'int',
- 'not null' => TRUE
- ),
- 'field_id' => array(
- 'type' => 'int',
- 'not null' => TRUE
- ),
- 'value' => array(
- 'type' => 'text',
- ),
- ),
- 'primary key' => array('constant_id'),
- );
- return $schema;
- }
- /**
- * Implements hook_update_N().
- *
- * Update schema for version 6.x-0.3.1b-1.5
- * - Add the tripal_bulk_loader_constants table
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_update_6150() {
- // Create tripal_bulk_loader_constants table
- $schema = tripal_bulk_loader_schema();
- db_create_table('tripal_bulk_loader_constants', $schema['tripal_bulk_loader_constants']);
- return 'Added support for loader-specific constants.';
- }
- /**
- * Implements hook_update_N().
- *
- * Update schema for version 6.x-0.3.1b-1.5
- * - Add the tripal_bulk_loader_constants.group_id column
- * to allow multiple sets of constants per job
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_update_6151() {
- $schema = tripal_bulk_loader_schema();
- db_add_field(
- 'tripal_bulk_loader_constants',
- 'group_id',
- array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- )
- );
- return 'Added support for multiple sets of loader-specific constants.';
- }
- /**
- * Implements hook_update_N().
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_update_6152() {
- db_add_field(
- 'tripal_bulk_loader',
- 'keep_track_inserted',
- array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'not null' => TRUE,
- 'default' => 1
- )
- );
- return 'Added ability to rollback loading job based on storing loaded ids.';
- }
- /**
- * Implements hook_update_N().
- *
- * Update to 7.x-2.0
- * -Cast tripal_bulk_loader.template_id to int field
- *
- */
- function tripal_bulk_loader_update_7200() {
- db_change_field(
- 'tripal_bulk_loader',
- 'template_id',
- 'template_id',
- array('type' => 'int')
- );
- db_add_field(
- 'tripal_bulk_loader_template',
- 'created',
- array(
- 'description' => 'The Unix timestamp when the template was created.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- )
- );
- db_add_field(
- 'tripal_bulk_loader_template',
- 'changed',
- array(
- 'description' => 'The Unix timestamp when the template was most recently saved.',
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- )
- );
- return 'Updated tripal_bulk_loader.template_id from character to integer '
- . 'and added time created/updated track to templates.';
- }
- /**
- * Implementation of hook_requirements().
- *
- * @ingroup tripal_bulk_loader
- */
- function tripal_bulk_loader_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
- // make sure chado is installed
- if (!$GLOBALS["chado_is_installed"]) {
- $requirements ['tripal_bulk_loader'] = array(
- 'title' => "tripal_bulk_loader",
- 'value' => "ERROR: Chado must be installed before this module can be enabled",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
|