123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- /************************************************************************
- * Implementation of hook_install();
- *
- * @ingroup tripal_core
- */
- function tripal_core_install(){
- // make the data directory for this module
- $data_dir = file_directory_path() . "/tripal";
- if(!file_check_directory($data_dir,FILE_CREATE_DIRECTORY)){
- $message = "Cannot create directory $data_dir. This module may not ".
- "behave correctly without this directory. Please create ".
- "the directory manually or fix the problem and reinstall.";
- drupal_set_message($message,'error');
- watchdog('tripal_core',$message,array(),WATCHDOG_ERROR);
- }
- // create the tables that manage materialized views and jobs
- drupal_install_schema('tripal_core');
- }
- /**
- * Update for Drupal 6.x, Tripal 0.4
- * This update adjusts the materialized view by adding a 'cvterm_id' column
- *
- * @ingroup tripal_feature
- */
- function tripal_core_update_6000(){
- // recreate the materialized view
- db_add_field($ret, 'tripal_mviews', 'status', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
- db_add_field($ret, 'tripal_mviews', 'comment', array('type' => 'text', 'size' => 'normal', 'not null' => FALSE));
- $ret = array(
- '#finished' => 1,
- );
-
- return $ret;
- }
- /************************************************************************
- * Implementation of hook_schema().
- *
- * @ingroup tripal_core
- */
- function tripal_core_schema() {
- $schema = tripal_core_get_schemas();
- return $schema;
- }
- /************************************************************************
- * Implementation of hook_uninstall()
- *
- * @ingroup tripal_core
- */
- function tripal_core_uninstall(){
- drupal_uninstall_schema('tripal_core');
- }
- /************************************************************************
- * This function simply defines all tables needed for the module to work
- * correctly. By putting the table definitions in a separate function we
- * can easily provide the entire list for hook_install or individual
- * tables for an update.
- *
- * @ingroup tripal_core
- */
- function tripal_core_get_schemas (){
- $schema = array();
- // get all the various schema parts and join them together
- $temp = tripal_core_jobs_schema();
- foreach ($temp as $table => $arr){
- $schema[$table] = $arr;
- }
- $temp = tripal_core_mviews_schema();
- foreach ($temp as $table => $arr){
- $schema[$table] = $arr;
- }
- return $schema;
- }
- /************************************************************************
- *
- *
- * @ingroup tripal_core
- */
- function tripal_core_mviews_schema(){
- $schema = array();
- $schema['tripal_mviews'] = array(
- 'fields' => array(
- 'mview_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
- 'name' => array('type' => 'varchar','length' => 255, 'not null' => TRUE),
- 'modulename' => array('type' => 'varchar','length' => 50, 'not null' => TRUE, 'description' => 'The module name that provides the callback for this job'),
- 'mv_table' => array('type' => 'varchar','length' => 128, 'not null' => TRUE),
- 'mv_specs' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
- 'indexed' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
- 'query' => array('type' => 'text', 'size' => 'normal', 'not null' => TRUE),
- 'special_index' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
- 'last_update' => array('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer time'),
- 'status' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
- 'comment' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
- ),
- 'indexes' => array(
- 'mview_id' => array('mview_id')
- ),
- 'unique keys' => array(
- 'mv_table' => array('mv_table'),
- 'mv_name' => array('name'),
- ),
- 'primary key' => array('mview_id'),
- );
- return $schema;
- }
- /************************************************************************
- *
- *
- * @ingroup tripal_core
- */
- function tripal_core_jobs_schema(){
- $schema = array();
- $schema['tripal_jobs'] = array(
- 'fields' => array(
- 'job_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
- 'uid' => array ('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The Drupal userid of the submitee'),
- 'job_name' => array('type' => 'varchar','length' => 255, 'not null' => TRUE),
- 'modulename' => array('type' => 'varchar','length' => 50, 'not null' => TRUE, 'description' => 'The module name that provides the callback for this job'),
- 'callback' => array('type' => 'varchar','length' => 255, 'not null' => TRUE),
- 'arguments' => array('type' => 'text', 'size' => 'normal', 'not null' => FALSE),
- 'progress' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0, 'not null' => FALSE, 'description' => 'a value from 0 to 100 indicating percent complete'),
- 'status' => array('type' => 'varchar','length' => 50, 'not null' => TRUE),
- 'submit_date' => array ('type' => 'int', 'not null' => TRUE, 'description' => 'UNIX integer submit time'),
- 'start_time' => array ('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer start time'),
- 'end_time' => array ('type' => 'int', 'not null' => FALSE, 'description' => 'UNIX integer end time'),
- 'error_msg' => array('type' => 'text','size' => 'normal', 'not null' => FALSE),
- 'pid' => array ('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'description' => 'The process id for the job'),
- 'priority' => array ('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => '0', 'description' => 'The job priority'),
- 'mlock' => array ('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'description' => 'If set to 1 then all jobs for the module are held until this one finishes'),
- 'lock' => array ('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'description' => 'If set to 1 then all jobs are held until this one finishes'),
- ),
- 'indexes' => array(
- 'job_id' => array('job_id'),
- 'job_name' => array('job_name')
- ),
- 'primary key' => array('job_id'),
- );
- return $schema;
- }
- ?>
|