Browse Source

minor chang

Stephen Ficklin 9 năm trước cách đây
mục cha
commit
7000dde726

+ 19 - 0
README.txt

@@ -39,6 +39,25 @@ Installation
 Please follow the instructions in the online Tripal User's Guide:
 http://tripal.info/tutorials/v2.0/installation
 
+
+Upgrade from Tripal v2.x to v3.x
+---------------------------------
+Note:  Upgrade can only be performed using 'drush' command.
+
+Step 1: Put the site in maintenance mode.
+Step 2: Remove old Tripal v2 package and replace with Tripal v3 package
+Step 3: Enable the tripal module
+
+  drush pm-enable tripal
+ 
+Step 4:  
+
+  drush pm-enable tripal_chado
+
+Note: Use of deprecated API functions from Tripal v1 will cause a template
+to not work because Tripal v1 deprecated API fucntions have been removed
+in Tripal v3.
+
 Customization
 --------------
 Tripal can be used “as is” but also allows for complete customization.

+ 5 - 5
tripal/tripal.install

@@ -101,7 +101,7 @@ function tripal_enable() {
     $sql = "ALTER INDEX tripal_token_formats_type_application_key2 RENAME TO tripal_token_formats_type_application_key";
     db_query($sql);
   }
-  
+
   if (db_table_exists('tripal_variables2')) {
     $sql = "DROP TABLE tripal_variables";
     db_query($sql);
@@ -127,7 +127,7 @@ function tripal_schema() {
   // will try and recreate some of the tables created with tripal_core and the
   // installation will fail.  Therefore, we need to temporarily move those
   // tables out of the way, let the module install and then move them back.
-  $migrated = variable_get ('tripal_v2_schema_migrated', FALSE);
+  $migrated = variable_get ('tripal_v2_upgrade_v3_check', FALSE);
   if (!$migrated) {
     if (db_table_exists('tripal_jobs')) {
       // Move the tripal_jobs table out of the way.
@@ -140,7 +140,7 @@ function tripal_schema() {
       $sql = "ALTER INDEX tripal_jobs_pkey RENAME TO tripal_jobs_pkey2";
       db_query($sql);
     }
-  
+
     if (db_table_exists('tripal_token_formats')) {
       // Move the tripal_token_formats table out of the way.
       $sql = "ALTER TABLE tripal_token_formats RENAME TO tripal_token_formats2";
@@ -150,7 +150,7 @@ function tripal_schema() {
       $sql = "ALTER INDEX tripal_token_formats_type_application_key RENAME TO tripal_token_formats_type_application_key2";
       db_query($sql);
     }
-  
+
     if (db_table_exists('tripal_variables')) {
       // Move the tripal_variables table out of the way.
       $sql = "ALTER TABLE tripal_variables RENAME TO tripal_variables2";
@@ -162,7 +162,7 @@ function tripal_schema() {
       $sql = "ALTER INDEX tripal_variables_tripal_variables_c1_key RENAME TO tripal_variables_tripal_variables_c1_key2";
       db_query($sql);
     }
-    variable_set ('tripal_v2_schema_migrated', TRUE);
+    variable_set ('tripal_v2_upgrade_v3_check', TRUE);
   }
   $schema = array();
 

+ 27 - 39
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -369,28 +369,25 @@ function tripal_insert_cv($name, $definition) {
 
   // see if the CV (default-namespace) exists already in the database
   $sel_values = array('name' => $name);
-  $sel_options = array('statement_name' => 'sel_cv_na');
-  $results = chado_select_record('cv', array('*'), $sel_values, $sel_options);
+  $results = chado_select_record('cv', array('*'), $sel_values);
 
   // if it does not exists then add it
   if (count($results) == 0) {
-    $ins_options = array('statement_name' => 'ins_cv_nade');
-    $success = chado_insert_record('cv', $ins_values, $ins_options);
+    $success = chado_insert_record('cv', $ins_values);
     if (!$success) {
       tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to create the CV record", NULL);
       return FALSE;
     }
-    $results = chado_select_record('cv', array('*'), $sel_values, $sel_options);
+    $results = chado_select_record('cv', array('*'), $sel_values);
   }
   // if it already exists then do an update
   else {
-    $upd_options = array('statement_name' => 'upd_cv_nade');
-    $success = chado_update_record('cv', $sel_values, $ins_values, $upd_options);
+    $success = chado_update_record('cv', $sel_values, $ins_values);
     if (!$success) {
       tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to update the CV record", NULL);
       return FALSE;
     }
-    $results = chado_select_record('cv', array('*'), $sel_values, $sel_options);
+    $results = chado_select_record('cv', array('*'), $sel_values);
   }
 
   // return the cv object
@@ -572,8 +569,8 @@ function tripal_insert_cvterm($term, $options = array()) {
     return 0;
   }
 
-  // the cvterm table has two unique dependencies. We need to check both.
-  // first check the (name, cv_id, is_obsolete) constraint
+  // The cvterm table has two unique dependencies. We need to check both.
+  // first check the (name, cv_id, is_obsolete) constraint.
   $values = array(
     'name' => $name,
     'is_obsolete' => $is_obsolete,
@@ -581,60 +578,56 @@ function tripal_insert_cvterm($term, $options = array()) {
       'name' => $cvname,
     ),
   );
-  $options = array('statement_name' => 'sel_cvterm_c1');
-  $result = chado_select_record('cvterm', array('*'), $values, $options);
+  $result = chado_select_record('cvterm', array('*'), $values);
 
-  // if the constraint is met then let's check it to see if
+  // If the constraint is met then let's check it to see if
   // the database name matches the one we have been provided
   if (count($result) == 1) {
     $cvterm = $result[0];
 
     // get the dbxref record
     $values = array('dbxref_id' => $cvterm->dbxref_id);
-    $options = array('statement_name' => 'sel_dbxref_id');
-    $result = chado_select_record('dbxref', array('*'), $values, $options);
+    $result = chado_select_record('dbxref', array('*'), $values);
     $dbxref = $result[0];
 
     // get the db
     $values = array('db_id' => $dbxref->db_id);
-    $options = array('statement_name' => 'sel_db_id');
-    $result = chado_select_record('db', array('*'), $values, $options);
+    $result = chado_select_record('db', array('*'), $values);
     $db_check = $result[0];
 
-    // the database name for this existing term does not match that of the
+    // The database name for this existing term does not match that of the
     // one provided to this function.  The CV name matches otherwise we
     // wouldn't have made it this far. So, let's swap the database for
-    // this term
+    // this term.
     if ($db_check->name != $db->name) {
 
-      // look to see if the correct dbxref record already exists for this database
+      // Look to see if the correct dbxref record already exists for this
+      // database.
       $values = array(
         'db_id' => $db->db_id,
         'accession' => $accession,
       );
-      $options = array('statement_name' => 'sel_dbxref_idac');
-      $result = chado_select_record('dbxref', array('*'), $values, $options);
 
-      // if we already have a good dbxref then we want to update our cvterm
-      // to use this dbxref
+      $result = chado_select_record('dbxref', array('*'), $values);
+
+      // If we already have a good dbxref then we want to update our cvterm
+      // to use this dbxref.
       if (count($result) > 0) {
         $dbxref = $result[0];
         $match = array('cvterm_id' => $cvterm->cvterm_id);
         $values = array('dbxref_id' => $dbxref->dbxref_id);
-        $options = array('statement_name' => 'upd_cvterm_db');
-        $success = chado_update_record('cvterm', $match, $values, $options);
+        $success = chado_update_record('cvterm', $match, $values);
         if (!$success) {
           tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to correct the dbxref id for the cvterm " .
             "'$name' (id: $accession), for database $dbname", NULL);
           return 0;
         }
       }
-      // if we don't have the record then we want to delete our cvterm and let the code
-      // below recreate it with the correct info
+      // If we don't have the dbxref then we want to delete our cvterm and let
+      // the code below recreate it with the correct info.
       else {
         $match = array('cvterm_id' => $cvterm->cvterm_id);
-        $options = array('statement_name' => 'del_cvterm_cv');
-        chado_delete_record('cvterm', $match, $options);
+        chado_delete_record('cvterm', $match);
       }
     }
 
@@ -661,13 +654,11 @@ function tripal_insert_cvterm($term, $options = array()) {
         'dbxref_id' => $dbxref_new->dbxref_id,
         'is_for_definition' => 1,
       );
-      $options = array('statement_name' => 'sel_cvtermdbxref_cvdbis');
-      $result = chado_select_record('cvterm_dbxref', array('*'), $values, $options);
+      $result = chado_select_record('cvterm_dbxref', array('*'), $values);
 
       // if the cvterm_dbxref record does not exists then add it
       if (count($result)==0) {
         $options = array(
-          'statement_name' => 'ins_cvtermdbxref_cvdbis',
           'return_record' => FALSE,
         );
         $success = chado_insert_record('cvterm_dbxref', $values, $options);
@@ -706,8 +697,7 @@ function tripal_insert_cvterm($term, $options = array()) {
     // check to see if the dbxref already has an entry in the cvterm table
     // this is the second constraint in the cvterm table
     $values = array('dbxref_id' => $dbxref->dbxref_id);
-    $options = array('statement_name' => 'sel_cvterm_db');
-    $check = chado_select_record('cvterm', array('cvterm_id'), $values, $options);
+    $check = chado_select_record('cvterm', array('cvterm_id'), $values);
     if (count($check) == 0) {
       // now add the cvterm
       $ins_values = array(
@@ -718,8 +708,7 @@ function tripal_insert_cvterm($term, $options = array()) {
         'is_obsolete'          => $is_obsolete,
         'is_relationshiptype'  => $is_relationship,
       );
-      $ins_options = array('statement_name' => 'ins_cvterm_all');
-      $success = chado_insert_record('cvterm', $ins_values, $ins_options);
+      $success = chado_insert_record('cvterm', $ins_values);
       if (!$success) {
         if (!$is_relationship) {
           tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to insert the term: $name ($dbname)", NULL);
@@ -748,8 +737,7 @@ function tripal_insert_cvterm($term, $options = array()) {
       'is_obsolete'         => $is_obsolete,
       'is_relationshiptype' => $is_relationship,
     );
-    $upd_options = array('statement_name' => 'upd_cvterm_nadeisis');
-    $success = chado_update_record('cvterm', $match, $upd_values, $upd_options);
+    $success = chado_update_record('cvterm', $match, $upd_values);
     if (!$success) {
       tripal_report_error('tripal_chado', TRIPAL_WARNING, "Failed to update the term: $name", NULL);
       return 0;

+ 0 - 1
tripal_chado/api/tripal_chado.variables.api.inc

@@ -498,7 +498,6 @@ function chado_expand_var($object, $type, $to_expand, $table_options = array())
       TRIPAL_ERROR,
       'Cannot pass non array as argument, $object, to chado_expand_var function.',
       array());
-    print_r(debug_backtrace());
     return $object;
   }
 

+ 12 - 0
tripal_chado/includes/tripal_chado.setup.inc

@@ -107,6 +107,11 @@ function tripal_chado_install_form($form, $form_state) {
   return $form;
 }
 
+/**
+ *
+ * @param $form
+ * @param $form_state
+ */
 function tripal_chado_install_form_validate($form, &$form_state) {
   // We do not want to allow re-installation of Chado if other
   // Tripal modules are installed.  This is because the install files
@@ -1150,6 +1155,7 @@ function tripal_library_add_cvterms() {
   // description in the libraryprop table.
   tripal_insert_cvterm(
       array(
+        'id' => 'local:library_description',
         'name' => 'Library Description',
         'definition' => 'Description of a library',
         'cv_name' => 'library_property',
@@ -1162,6 +1168,7 @@ function tripal_library_add_cvterms() {
   // add cvterms for the map unit types
   tripal_insert_cvterm(
       array(
+        'id' => 'local:cdna_library',
         'name' => 'cdna_library',
         'definition' => 'cDNA library',
         'cv_name' => 'library_type',
@@ -1172,6 +1179,7 @@ function tripal_library_add_cvterms() {
   );
   tripal_insert_cvterm(
       array(
+        'id' => 'local:bac_library',
         'name' => 'bac_library',
         'definition' => 'Bacterial Artifical Chromsome (BAC) library',
         'cv_name' => 'library_type',
@@ -1182,6 +1190,7 @@ function tripal_library_add_cvterms() {
   );
   tripal_insert_cvterm(
       array(
+        'id' => 'local:fosmid_library',
         'name' => 'fosmid_library',
         'definition' => 'Fosmid library',
         'cv_name' => 'library_type',
@@ -1192,6 +1201,7 @@ function tripal_library_add_cvterms() {
   );
   tripal_insert_cvterm(
       array(
+        'id' => 'local:cosmid_library',
         'name' => 'cosmid_library',
         'definition' => 'Cosmid library',
         'cv_name' => 'library_type',
@@ -1202,6 +1212,7 @@ function tripal_library_add_cvterms() {
   );
   tripal_insert_cvterm(
       array(
+        'id' => 'local:yac_library',
         'name' => 'yac_library',
         'definition' => 'Yeast Artificial Chromosome (YAC) library',
         'cv_name' => 'library_type',
@@ -1212,6 +1223,7 @@ function tripal_library_add_cvterms() {
   );
   tripal_insert_cvterm(
       array(
+        'id' => 'local:genomic_library',
         'name' => 'genomic_library',
         'definition' => 'Genomic Library',
         'cv_name' => 'library_type',

+ 20 - 13
tripal_chado/tripal_chado.install

@@ -114,7 +114,7 @@ function tripal_chado_enable() {
     $sql = "ALTER INDEX tripal_mviews_pkey2 RENAME TO tripal_mviews_pkey";
     db_query($sql);
   }
-    
+
     // tripal_custom_tables
   if (db_table_exists('tripal_custom_tables2')) {
     $sql = "DROP TABLE tripal_custom_tables";
@@ -126,7 +126,7 @@ function tripal_chado_enable() {
     $sql = "ALTER INDEX tripal_custom_tables_table_id_idx2 RENAME TO tripal_custom_tables_table_id_idx";
     db_query($sql);
   }
-    
+
     // tripal_cv_obo
   if (db_table_exists('tripal_cv_obo2')) {
     $sql = "DROP TABLE tripal_cv_obo";
@@ -138,7 +138,7 @@ function tripal_chado_enable() {
     $sql = "ALTER INDEX tripal_cv_obo_pkey2 RENAME TO tripal_cv_obo_pkey";
     db_query($sql);
   }
-    
+
     // tripal_cv_defaults
   if (db_table_exists('tripal_cv_defaults2')) {
     $sql = "DROP TABLE tripal_cv_defaults";
@@ -152,7 +152,7 @@ function tripal_chado_enable() {
     $sql = "ALTER INDEX tripal_cv_defaults_tripal_cv_defaults_unq1_key2 RENAME TO tripal_cv_defaults_tripal_cv_defaults_unq1_key";
     db_query($sql);
   }
-    
+
     // tripal_pub_import
   if (db_table_exists('tripal_pub_import2')) {
     $sql = "DROP TABLE tripal_pub_import";
@@ -170,12 +170,12 @@ function tripal_chado_enable() {
  * Implements hook_schema().
  */
 function tripal_chado_schema() {
-  
+
   // If Tripal v2 is already installed, the installation of this module
   // will try and recreate some of the tables created with tripal_core and the
   // installation will fail.  Therefore, we need to temporarily move those
   // tables out of the way, let the module install and then move them back.
-  $migrated = variable_get ('tripal_chado_v2_schema_migrated', FALSE);
+  $migrated = variable_get ('tripal_v2_upgrade_v3_check_chado', FALSE);
   if (!$migrated) {
     if (db_table_exists('tripal_mviews')) {
       // Move the tripal_mviews table out of the way.
@@ -190,7 +190,7 @@ function tripal_chado_schema() {
       $sql = "ALTER INDEX tripal_mviews_pkey RENAME TO tripal_mviews_pkey2";
       db_query($sql);
     }
-     
+
     if (db_table_exists('tripal_custom_tables')) {
       // Move the tripal_custom_tables table out of the way.
       $sql = "ALTER TABLE tripal_custom_tables RENAME TO tripal_custom_tables2";
@@ -200,7 +200,7 @@ function tripal_chado_schema() {
       $sql = "ALTER INDEX tripal_custom_tables_table_id_idx RENAME TO tripal_custom_tables_table_id_idx2";
       db_query($sql);
     }
-    
+
     if (db_table_exists('tripal_cv_obo')) {
       // Move the tripal_cv_obo table out of the way.
       $sql = "ALTER TABLE tripal_cv_obo RENAME TO tripal_cv_obo2";
@@ -210,7 +210,7 @@ function tripal_chado_schema() {
       $sql = "ALTER INDEX tripal_cv_obo_pkey RENAME TO tripal_cv_obo_pkey2";
       db_query($sql);
     }
-      
+
     if (db_table_exists('tripal_cv_defaults')) {
       // Move the tripal_cv_defaults table out of the way.
       $sql = "ALTER TABLE tripal_cv_defaults RENAME TO tripal_cv_defaults2";
@@ -222,7 +222,7 @@ function tripal_chado_schema() {
       $sql = "ALTER INDEX tripal_cv_defaults_tripal_cv_defaults_unq1_key RENAME TO tripal_cv_defaults_tripal_cv_defaults_unq1_key2";
       db_query($sql);
     }
-      
+
     if (db_table_exists('tripal_pub_import')) {
       // Move the tripal_pub_import table out of the way.
       $sql = "ALTER TABLE tripal_pub_import RENAME TO tripal_pub_import2";
@@ -232,8 +232,8 @@ function tripal_chado_schema() {
       $sql = "ALTER INDEX tripal_pub_import_pkey RENAME TO tripal_pub_import_pkey2";
       db_query($sql);
     }
-    
-    variable_set ('tripal_chado_v2_schema_migrated', TRUE);
+
+    variable_set ('tripal_v2_upgrade_v3_check_chado', TRUE);
   }
   // Links TripalEntity entities to the chado record.
   $schema['chado_entity'] = tripal_chado_chado_entity_schema();
@@ -493,4 +493,11 @@ function tripal_chado_chado_entity_schema() {
     'primary key' => array('chado_entity_id'),
   );
   return $schema;
-}
+}
+
+/**
+ * Moves vocabulary terms from the 'tripal' vocabulary to the 'local' vocabulary.
+ */
+function tripal_chado_update_7300() {
+  // Move all terms in the 'tripal' cv' over to 'local'.
+}