123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <?php
- function tripal_organism_disable() {
-
- require_once("tripal_organism.views_default.inc");
- $views = tripal_organism_views_default_views();
- foreach (array_keys($views) as $view_name) {
- tripal_disable_view($view_name,FALSE,array('suppress_error' => TRUE));
- }
- }
- function tripal_organism_install() {
-
- tripal_organism_add_cvs();
- tripal_organism_add_cvterms();
-
- tripal_set_default_cv('organismprop', 'type_id', 'organism_property');
- }
- function tripal_organism_schema() {
- $schema['chado_organism'] = 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
- ),
- 'organism_id' => array(
- 'type' => 'int',
- 'not null' => TRUE,
- 'default' => 0
- )
- ),
- 'indexes' => array(
- 'organism_id' => array('organism_id')
- ),
- 'unique keys' => array(
- 'nid_vid' => array('nid', 'vid'),
- 'vid' => array('vid')
- ),
- 'primary key' => array('nid'),
- );
- return $schema;
- }
- function tripal_organism_uninstall() {
- }
- function tripal_organism_requirements($phase) {
- $requirements = array();
- if ($phase == 'install') {
-
- if (!$GLOBALS["chado_is_installed"]) {
- $requirements ['tripal_organism'] = array(
- 'title' => "tripal_organism",
- 'value' => "ERROR: Chado must be installed before this module can be enabled",
- 'severity' => REQUIREMENT_ERROR,
- );
- }
- }
- return $requirements;
- }
- function tripal_organism_add_cvs() {
- tripal_insert_cv(
- 'organism_property',
- 'Contains properties for organisms'
- );
- }
- function tripal_organism_add_cvterms() {
- }
- function tripal_organism_update_7200() {
-
-
-
- try {
- $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'organism_property'")->fetchField();
- if (!$cv_id) {
- $sql = "INSERT INTO chado.cv (name, definition) VALUES (
- 'organism_property',
- 'Contains properties for organisms.')
- ";
- db_query($sql);
- }
-
- db_insert('tripal_cv_defaults')
- ->fields(array(
- 'table_name' => 'organismprop',
- 'field_name' => 'type_id',
- 'cv_id' => $cv_id
- ))
- ->execute();
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Failed to add organism_property vocabulary: '. $error);
- }
-
-
-
- $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Organism'")->fetchField();
- if ($vid) {
- try {
-
- $sql = "
- INSERT INTO {field_data_taxonomy_vocabulary_$vid}
- (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
- (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
- FROM field_data_taxonomyextra
- WHERE bundle = 'chado_feature')
- ";
- db_query($sql);
- $sql = "DELETE FROM field_data_taxonomyextra WHERE bundle = 'chado_organism'";
- db_query($sql);
-
- $sql = "
- INSERT INTO {field_revision_taxonomy_vocabulary_$vid}
- (entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomy_vocabulary_" . $vid. "_tid)
- (SELECT entity_type, bundle, deleted, entity_id, revision_id, language, delta, taxonomyextra_tid
- FROM field_revision_taxonomyextra
- WHERE bundle = 'chado_feature')
- ";
- db_query($sql);
- $sql = "DELETE FROM field_revision_taxonomyextra WHERE bundle = 'chado_organism'";
- db_query($sql);
- }
- catch (\PDOException $e) {
- $error = $e->getMessage();
- throw new DrupalUpdateException('Could not move organism taxonomy terms: '. $error);
- }
- }
- }
- function tripal_organism_update_dependencies() {
- $dependencies = array();
-
- $dependencies['tripal_organism'][7200] = array(
- 'tripal_cv' => 7200
- );
- return $dependencies;
- }
|