Browse Source

Merge branch '6.x-analysisprop' of git.drupal.org:sandbox/spficklin/1337878 into 6.x-analysisprop

Chun-Huai Cheng 12 years ago
parent
commit
cbe8a86b98
2 changed files with 48 additions and 44 deletions
  1. 46 42
      tripal_analysis/tripal_analysis.install
  2. 2 2
      tripal_core/api/tripal_core_chado.api.inc

+ 46 - 42
tripal_analysis/tripal_analysis.install

@@ -25,48 +25,6 @@ function tripal_analysis_install() {
   tripal_analysis_add_mview_analysis_organism();
 }
 
-/**
- *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
- *  This update adds a new analysis_organism materialized view
- *
- */
-function tripal_analysis_update_6100() {
-  // add the new materialized view
-  tripal_analysis_add_mview_analysis_organism();
-  
-  // move the analysis_type property into a new CV so that user's can change this property if
-  // they want too  
-  tripal_cv_add_cv('tripal_analysis', 'Terms used for managing analyses in Tripal');
-  
-  $sql = "
-    UPDATE {cvterm} SET cv_id = 
-      (SELECT cv_id FROM {cv} WHERE name = 'tripal_analysis')
-    WHERE cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal') AND
-      name = 'analysis_type'
-  ";
-  chado_query($sql);
-  
-  $ret = array(
-    '#finished' => 1,
-  );
-
-  return $ret;
-}
-
-/**
- *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
- *  This update adds a new analysis_property cv and 'Analysis Type' cvterm
- */
-function tripal_analysis_update_6101() {
-   tripal_cv_add_cvterm(array('name' => 'Analysis Type','def' => 'The type of analysis was performed.'), 
-     'analysis_property', 0, 1, 'tripal');
-
-	$ret = array(
-			'#finished' => 1,
-	);
-	return $ret;
-}
-
 /*
  * 
  */
@@ -205,6 +163,34 @@ function tripal_analysis_schema() {
   return $schema;
 }
 
+/**
+ *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
+ *  This update adds a new analysis_organism materialized view
+ *
+ */
+function tripal_analysis_update_6100() {
+  // add the new materialized view
+  tripal_analysis_add_mview_analysis_organism();
+  
+  // move the analysis_type property into a new CV so that user's can change this property if
+  // they want too  
+  tripal_cv_add_cv('tripal_analysis', 'Terms used for managing analyses in Tripal');
+  
+  $sql = "
+    UPDATE {cvterm} SET cv_id = 
+      (SELECT cv_id FROM {cv} WHERE name = 'tripal_analysis')
+    WHERE cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal') AND
+      name = 'analysis_type'
+  ";
+  chado_query($sql);
+  
+  $ret = array(
+    '#finished' => 1,
+  );
+
+  return $ret;
+}
+
 /**
  * Provide update script for adding new cvterms
  */
@@ -217,6 +203,24 @@ function tripal_analysis_update_6001() {
   );
   return $ret;
 }
+
+/**
+ *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
+ *  This update adds a new analysis_property cv and 'Analysis Type' cvterm
+ */
+function tripal_analysis_update_6101() {
+  // the 'analysis_property' vocabulary is for user definable properties.  Even though we already have
+  // an analysis_type term in the 'tripal_analysis' vocabular we duplicate it here because the 
+  // tripal_analysis vocabulary is intended for use by the extension modules.  user's should not be able
+  // to directly modify properties set by extension modules for an analysis.
+   tripal_cv_add_cvterm(array('name' => 'Analysis Type','def' => 'The type of analysis was performed.'), 
+     'analysis_property', 0, 1, 'tripal');
+
+  $ret = array(
+      '#finished' => 1,
+  );
+  return $ret;
+}
 /**
  * Implementation of hook_requirements(). 
  */

+ 2 - 2
tripal_core/api/tripal_core_chado.api.inc

@@ -347,7 +347,7 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
     if (array_key_exists('primary key', $table_desc) and is_array($table_desc['primary key'])) {
       foreach ($table_desc['primary key'] as $field) {
         $sql = '';
-        $psql = "PREPARE currval_" . $table . "_" . $field . " AS SELECT CURRVAL('" . $table . "_" . $field . "_seq')";
+        $psql = "PREPARE currval_" . $table . "_" . $field . " AS SELECT CURRVAL('{" . $table . "}_" . $field . "_seq')";
         $is_prepared = tripal_core_chado_prepare("currval_" . $table . "_" . $field, $psql, array());
         $value = '';
         if ($is_prepared) {
@@ -359,7 +359,7 @@ function tripal_core_chado_insert($table, $values, $options = array()) {
           }
         }
         else {
-          $sql = "SELECT CURRVAL('" . $table . "_" . $field . "_seq')";
+          $sql = "SELECT CURRVAL('{" . $table . "}_" . $field . "_seq')";
           $value =  db_result(chado_query($sql));
           if (!$value) {
             watchdog('tripal_core', "tripal_core_chado_insert: not able to retrieve primary key after insert: %sql",