Преглед на файлове

Cleaned up tripal_library, tripal_organism code that has been moved to tripal_chado.

Chun-Huai Cheng преди 9 години
родител
ревизия
231b36a1b0

+ 0 - 250
legacy/tripal_library/tripal_library.install

@@ -48,9 +48,6 @@ function tripal_library_requirements($phase) {
  */
 function tripal_library_install() {
 
-  // add the materialized view
-  tripal_library_add_mview_library_feature_count();
-
   // add cvterms
   tripal_library_add_cvs();
   tripal_library_add_cvterms();
@@ -107,58 +104,6 @@ function tripal_library_schema() {
   return $schema;
 }
 
-/**
- * Adds a materialized view keeping track of the type of features associated with each library
- *
- * @ingroup tripal_library
- */
-function tripal_library_add_mview_library_feature_count(){
-  $view_name = 'library_feature_count';
-  $comment = 'Provides count of feature by type that are associated with all libraries';
-
-  $schema = array(
-    'table' => $view_name,
-    'description' => $comment,
-    'fields' => array(
-      'library_id' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'name' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-      ),
-      'num_features' => array(
-        'type' => 'int',
-        'not null' => TRUE,
-      ),
-      'feature_type' => array(
-        'type' => 'varchar',
-        'length' => 255,
-        'not null' => TRUE,
-      ),
-    ),
-    'indexes' => array(
-      'library_feature_count_idx1' => array('library_id'),
-    ),
-  );
-
-  $sql = "
-    SELECT
-      L.library_id, L.name,
-      count(F.feature_id) as num_features,
-      CVT.name as feature_type
-    FROM library L
-      INNER JOIN library_feature LF  ON LF.library_id = L.library_id
-      INNER JOIN feature F           ON LF.feature_id = F.feature_id
-      INNER JOIN cvterm CVT          ON F.type_id     = CVT.cvterm_id
-    GROUP BY L.library_id, L.name, CVT.name
-  ";
-
-  tripal_add_mview($view_name, 'tripal_library', $schema, $sql, $comment);
-}
-
 /**
  * Adds new CV's used by this module
  *
@@ -257,199 +202,4 @@ function tripal_library_add_cvterms() {
     ),
     array('update_existing' => TRUE)
   );
-}
-
-/**
- * This is the required update for tripal_library when upgrading from Drupal core API 6.x.
- *
- */
-function tripal_library_update_7200() {
-
-  // the library types were formerly in a vocabulary named 'tripal_library_types'.
-  // rename that to just be 'library_type'. We cannot use the Tripal API calls
-  // because during upgrade the tripal_core should also be disabled
-  try {
-    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_type'")->fetchObject();
-    if (!$check->cv_id) {
-      $sql = "UPDATE chado.cv SET name = 'library_type' WHERE name = 'tripal_library_types'";
-      db_query($sql);
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to change the vocabulary from tripal_library_types to library_type: '. $error);
-  }
-
-  // add the library_property CV
-  try {
-    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_property'")->fetchObject();
-    if (!$check->cv_id) {
-      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-        'library_property',
-        'Contains properties for libraries.')
-      ";
-      db_query($sql);
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add library_property vocabulary: '. $error);
-  }
-
-  // add the library_type CV
-  try {
-    $check = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_type'")->fetchObject();
-    if (!$check->cv_id) {
-      $sql = "INSERT INTO chado.cv (name, definition) VALUES (
-        'library_type',
-        'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).')
-      ";
-      db_query($sql);
-    }
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to add library_type vocabulary: '. $error);
-  }
-
-  // For Tripal in Drupal 6 the library_description cvterm was stored in the
-  // 'tripal' CV.  It should be stored in the new library_property CV that
-  // is added by this module for Tripal 2.0 and Drupal 7.  So, we need to
-  // reset the CV ID for that term and rename the term to 'Library Description'
-  // We cannot use the Tripal API calls in the 7000 update
-  // because during upgrade the tripal_core should also be disabled
-  $sql = "
-    UPDATE chado.cvterm
-    SET
-      name = 'Library Description',
-      cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'library_property')
-    WHERE
-      name = 'library_description' AND
-      cv_id = (SELECT cv_id FROM chado.cv WHERE name = 'tripal')
-  ";
-  try {
-    db_query($sql);
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to change library_description property type to the library_property CV and update the name: '. $error);
-  }
-
-  // During the upgrade from D6 to D7 the vocabulary terms assigned to libraries were
-  // copied to the field_data_taxonomyextra table rather than to the correct
-  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
-  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Library'")->fetchField();
-  if ($vid) {
-    try {
-      // first move from the field_data_taxonomyextra table
-      $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_library'";
-      db_query($sql);
-
-      // next move from the field_revision_taxonomyextra table
-      $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_library'";
-      db_query($sql);
-    }
-    catch (\PDOException $e) {
-      $error = $e->getMessage();
-      throw new DrupalUpdateException('Could not move library taxonomy terms: '. $error);
-    }
-  }
-
-  // set the default vocabularies
-  // library_type
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_type'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'library',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set library_type vocabulary as default: '. $error);
-  }
-  // library_property
-  try {
-    $cv_id = db_query("SELECT cv_id FROM chado.cv WHERE name = 'library_property'")->fetchField();
-    db_insert('tripal_cv_defaults')
-      ->fields(array(
-        'table_name' => 'libraryprop',
-        'field_name' => 'type_id',
-        'cv_id' => $cv_id
-      ))
-      ->execute();
-  }
-  catch (\PDOException $e) {
-    $error = $e->getMessage();
-    throw new DrupalUpdateException('Failed to set the library_property vocabulary as default: '. $error);
-  }
-
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_library_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_library'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
-}
-
-/**
- * Fixes an error with the materialized view installation
- *
- */
-function tripal_library_update_7201() {
-
-  // there is a bug in the Tripal v2.0-alpha release that didn't add the
-  // materialized view schema to the mviews table.
-  // get the schema for the materialized view from the custom_tables table
-  // as there is a copy there, but only if the schema is missing from the
-  // materialized view table
-  $view_name = 'library_feature_count';
-  $schema = db_select('tripal_mviews', 'tm')
-    ->fields('tm', array('mv_schema'))
-    ->condition('name', $view_name)
-    ->execute()
-    ->fetchField();
-  if (!$schema or $schema == 'Array') {
-    $schema = db_select('tripal_custom_tables', 'tct')
-      ->fields('tct', array('schema'))
-      ->condition('table_name', $view_name)
-      ->execute()
-      ->fetchField();
-    $schema_str = var_export(unserialize($schema), TRUE);
-    $schema_str = preg_replace('/=>\s+\n\s+array/', '=> array', $schema_str);
-    db_update('tripal_mviews')
-      ->fields(array(
-      'mv_schema' => $schema_str
-      ))
-      ->condition('name', $view_name)
-      ->execute();
-  }
 }

+ 4 - 1
legacy/tripal_library/tripal_library.module

@@ -30,6 +30,7 @@ require_once 'includes/tripal_library.chado_node.inc';
  */
 function tripal_library_permission() {
   return array(
+    /*
     'access chado_library content' => array(
       'title' => t('View Libraries'),
       'description' => t('Allow users to view library pages.'),
@@ -50,6 +51,7 @@ function tripal_library_permission() {
       'title' => t('Administer Libraries'),
       'description' => t('Allow users to administer all libraries.'),
     ),
+    */
   );
 }
 
@@ -65,6 +67,7 @@ function tripal_library_permission() {
 function tripal_library_menu() {
   $items = array();
   // The administative settings menu
+  /*
   $items['admin/tripal/chado/tripal_library'] = array(
     'title' => 'Libraries',
     'description' => 'Any biological library. Examples of genomic libraries include BAC, cDNA, FOSMID, etc.',
@@ -121,7 +124,7 @@ function tripal_library_menu() {
     'access arguments' => array('administer tripal library'),
     'type' => MENU_CALLBACK,
   );
-
+  */
   return $items;
 }
 

+ 0 - 85
legacy/tripal_organism/tripal_organism.install

@@ -122,89 +122,4 @@ function tripal_organism_add_cvs() {
  */
 function tripal_organism_add_cvterms() {
 
-}
-
-/**
- * This is the required update for tripal_organism when upgrading from Drupal core API 6.x.
- *
- */
-function tripal_organism_update_7200() {
-
-  // add the new organism_property vocabulary
-  // We cannot use the Tripal API calls in the 7000 update
-  // because during upgrade the tripal_core should also be disabled
-  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);
-    }
-    // add in the default vocabulary
-    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);
-  }
-
-
-  // During the upgrade from D6 to D7 the vocabulary terms assigned to organisms were
-  // copied to the field_data_taxonomyextra table rather than to the correct
-  // field_data_taxonomy_vocabulary_[vid] table. We'll move them.
-  $vid = db_query("SELECT vid FROM {taxonomy_vocabulary} WHERE name = 'Organism'")->fetchField();
-  if ($vid) {
-    try {
-      // first move from the field_data_taxonomyextra table
-      $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);
-
-      // next move from the field_revision_taxonomyextra table
-      $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);
-    }
-  }
-}
-
-/**
- * Implementation of hook_update_dependencies().  It specifies a list of
- * other modules whose updates must be run prior to this one.
- */
-function tripal_organism_update_dependencies() {
-  $dependencies = array();
-
-  // the tripal_cv update 7200 must run prior to update 7200 of this module
-  $dependencies['tripal_organism'][7200] = array(
-    'tripal_cv' => 7200
-  );
-
-  return $dependencies;
 }

+ 4 - 3
legacy/tripal_organism/tripal_organism.module

@@ -4,7 +4,6 @@
  * Integrates the Chado Organism module with Drupal Nodes & Views
  */
 
-require_once 'api/tripal_organism.api.inc';
 require_once 'api/tripal_organism.DEPRECATED.inc';
 
 require_once 'includes/tripal_organism.admin.inc';
@@ -30,7 +29,7 @@ require_once 'includes/tripal_organism.chado_node.inc';
  */
 function tripal_organism_menu() {
   $items = array();
-
+/*
   // the administative settings menu
   $items['admin/tripal/chado/tripal_organism'] = array(
     'title' => 'Organisms',
@@ -102,7 +101,7 @@ function tripal_organism_menu() {
     'access arguments' => array('administer tripal organism'),
     'type' => MENU_CALLBACK,
   );
-
+*/
   return $items;
 }
 
@@ -193,6 +192,7 @@ function tripal_organism_theme($existing, $type, $theme, $path) {
   */
 function tripal_organism_permission() {
   return array(
+    /*
     'access chado_organism content' => array(
       'title' => t('View Organisms'),
       'description' => t('Allow users to view organism pages.'),
@@ -213,6 +213,7 @@ function tripal_organism_permission() {
       'title' => t('Administer Organisms'),
       'description' => t('Allow users to administer all organisms.'),
     ),
+    */
   );
 }