123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- <?php
- function tripal_example_disable() {
-
-
-
-
-
-
-
- require_once("tripal_example.views_default.inc");
- $views = tripal_example_views_default_views();
- foreach (array_keys($views) as $view_name) {
- tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
- }
- }
- function tripal_example_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
-
-
-
-
-
- if (!$GLOBALS["chado_is_installed"]) {
- $requirements ['tripal_example'] = array(
- 'title' => "tripal_example",
- 'value' => "ERROR: Chado must be installed before this module can be enabled",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
- function tripal_example_install() {
-
-
-
-
-
-
- tripal_create_files_dir('tripal_example');
-
-
-
-
-
- tripal_example_add_mviews();
-
- tripal_example_add_dbs();
-
-
-
-
-
-
-
- tripal_example_add_cvs();
-
- tripal_example_add_cvterms();
-
-
-
-
-
-
-
- tripal_set_default_cv('example', 'type_id', 'example_type');
- tripal_set_default_cv('exampleprop', 'type_id', 'example_property');
- tripal_set_default_cv('example_relationship', 'type_id', 'example_relationship');
-
-
- tripal_example_add_custom_tables();
- }
- function tripal_example_uninstall() {
- }
- function tripal_example_schema() {
-
-
-
-
-
-
-
- $schema['chado_example'] = array(
- 'fields' => array(
- 'vid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'nid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'example_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0
- ),
- 'sync_date' => array(
- 'type' => 'int',
- 'not null' => FALSE,
- 'description' => 'UNIX integer sync date/time'
- ),
- ),
- 'indexes' => array(
- 'chado_example_idx1' => array('example_id')
- ),
- 'unique keys' => array(
- 'chado_example_uq1' => array('nid', 'vid'),
- 'chado_example_uq2' => array('vid')
- ),
- 'primary key' => array('nid'),
- );
- return $schema;
- };
- function tripal_example_add_mviews() {
-
-
-
-
- }
- function tripal_example_add_dbs() {
-
-
-
- tripal_insert_db(array(
- 'name' => 'example_db',
- 'description' => 'An example database.'
- ));
- }
- function tripal_example_add_cvs() {
-
-
-
-
- tripal_insert_cv(
- 'example_property',
- 'Contains property terms for examples.'
- );
- tripal_insert_cv(
- 'example_type',
- 'Contains terms describing types of examples.'
- );
- tripal_insert_cv(
- 'example_relationship',
- 'Contains terms for describing relationship types between examples.'
- );
- }
- function tripal_example_add_cvterms() {
-
-
-
-
- tripal_insert_cvterm(array(
- 'id' => 'test',
- 'name' => 'Test type',
- 'cv_name' => 'example_type',
- 'definition' => 'A test type for the example modlue.',
- 'db_name' => 'example_db',
- ));
- }
- function tripal_example_add_custom_tables() {
-
-
-
-
-
-
-
-
-
-
- tripal_example_add_example_table();
- tripal_example_add_exampleprop_table();
- tripal_example_add_example_relationship_table();
- tripal_example_add_example_dbxref_table();
- }
- function tripal_example_add_example_table() {
-
-
- $schema = array(
- 'table' => 'example',
- 'fields' => array(
- 'example_id' => array(
- 'type' => 'serial',
- 'not null' => true,
- ),
- 'uniquename' => array(
- 'type' => 'varchar',
- 'length' => '255',
- 'not null' => TRUE,
- ),
- 'type_id' => array(
- 'type' => 'int',
- 'not null' => true,
- ),
- 'organism_id' => array(
- 'type' => 'int',
- 'not null' => true,
- ),
- 'description' => array(
- 'type' => 'text',
- ),
- ),
- 'primary key' => array(
- 0 => 'example_id',
- ),
- 'unique keys' => array(
- 'example_uq1' => array(
- 0 => 'uniquename',
- 1 => 'type_id',
- 2 => 'organism_id',
- ),
- ),
- 'indexes' => array(
- 'example_idx1' => array(
- 0 => 'example_id',
- ),
- 'example_idx2' => array(
- 0 => 'uniquename',
- ),
- ),
- 'foreign keys' => array(
- 'cvterm' => array(
- 'table' => 'cvterm',
- 'columns' => array(
- 'type_id' => 'cvterm_id',
- ),
- ),
- 'organism' => array(
- 'table' => 'organism',
- 'columns' => array(
- 'organism_id' => 'organism_id',
- ),
- ),
- ),
-
-
-
-
- 'referring_tables' => array(
- 0 => 'example_relationship',
- 1 => 'exampleprop',
- 2 => 'example_dbxref',
- ),
- );
- chado_create_custom_table('example', $schema, TRUE);
- }
- function tripal_example_add_exampleprop_table() {
-
-
-
- $schema = array(
- 'table' => 'exampleprop',
- 'fields' => array(
- 'exampleprop_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'example_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'type_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'value' => array(
- 'type' => 'text',
- 'not null' => FALSE,
- ),
- 'rank' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- ),
- 'primary key' => array(
- 0 => 'exampleprop_id',
- ),
- 'unique keys' => array(
- 'example_id_type_id_rank' => array(
- 0 => 'example_id',
- 1 => 'type_id',
- 2 => 'rank',
- ),
- ),
- 'foreign keys' => array(
- 'cvterm' => array(
- 'table' => 'cvterm',
- 'columns' => array(
- 'type_id' => 'cvterm_id',
- ),
- ),
- 'example' => array(
- 'table' => 'example',
- 'columns' => array(
- 'example_id' => 'example_id',
- ),
- ),
- ),
- );
- chado_create_custom_table('exampleprop', $schema, TRUE);
- }
- function tripal_example_add_example_relationship_table() {
-
-
- $schema = array(
- 'table' => 'example_relationship',
- 'fields' => array(
- 'example_relationship_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'subject_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'object_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'type_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'value' => array(
- 'type' => 'text',
- 'not null' => FALSE,
- ),
- 'rank' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0,
- ),
- ),
- 'primary key' => array(
- 0 => 'example_relationship_id',
- ),
- 'unique keys' => array(
- 'example_relationship_c1' => array(
- 0 => 'subject_id',
- 1 => 'object_id',
- 2 => 'type_id',
- 3 => 'rank',
- ),
- ),
- 'indexes' => array(
- 'example_relationship_idx1' => array(
- 0 => 'subject_id',
- ),
- 'example_relationship_idx2' => array(
- 0 => 'object_id',
- ),
- 'example_relationship_idx3' => array(
- 0 => 'type_id',
- ),
- ),
- 'foreign keys' => array(
- 'cvterm' => array(
- 'table' => 'cvterm',
- 'columns' => array(
- 'type_id' => 'cvterm_id',
- ),
- ),
- 'example' => array(
- 'table' => 'example',
- 'columns' => array(
- 'subject_id' => 'example_id',
- 'object_id' => 'example_id',
- ),
- ),
- ),
- );
- chado_create_custom_table('example_relationship', $schema, TRUE);
- }
- function tripal_example_add_example_dbxref_table() {
-
-
- $schema = array(
- 'table' => 'example_dbxref',
- 'fields' => array(
- 'example_dbxref_id' => array(
- 'type' => 'serial',
- 'not null' => TRUE,
- ),
- 'example_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'dbxref_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- ),
- 'is_current' => array(
- 'type' => 'int',
- 'size' => 'tiny',
- 'not null' => TRUE,
- 'default' => 1,
- ),
- ),
- 'primary key' => array(
- 0 => 'example_dbxref_id',
- ),
- 'unique keys' => array(
- 'example_dbxref_unq1' => array(
- 0 => 'example_id',
- 1 => 'dbxref_id',
- ),
- ),
- 'indexes' => array(
- 'example_dbxref_idx1' => array(
- 0 => 'example_id',
- ),
- 'example_dbxref_idx2' => array(
- 0 => 'dbxref_id',
- ),
- ),
- 'foreign keys' => array(
- 'dbxref' => array(
- 'table' => 'dbxref',
- 'columns' => array(
- 'dbxref_id' => 'dbxref_id',
- ),
- ),
- 'example' => array(
- 'table' => 'example',
- 'columns' => array(
- 'example_id' => 'example_id',
- ),
- ),
- ),
- );
- chado_create_custom_table('example_dbxref', $schema, TRUE);
- }
- function tripal_example_update_7200() {
-
-
-
-
-
-
-
-
-
-
-
-
- try {
-
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not apply updates: '. $error);
- }
- }
- function tripal_example_update_dependencies() {
- $dependencies = array();
-
-
-
-
-
- $dependencies['tripal_example'][7200] = array(
- 'tripal_cv' => 7200
- );
- return $dependencies;
- }
|