Sfoglia il codice sorgente

Fixed issue #1699022. Took out all code that tried to distinguish a revision.

spficklin 12 anni fa
parent
commit
9bb94c3748

+ 42 - 42
tripal_feature/tripal_feature.module

@@ -507,54 +507,54 @@ function chado_feature_insert($node) {
  */
 function chado_feature_update($node) {
   if ($node->revision) {
-    // TODO -- decide what to do about revisions
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
   }
-  else {
-    $residues = preg_replace("/[\n\r\s]/", "", $node->residues);
-    $obsolete = 'FALSE';
-    if ($node->is_obsolete) {
-      $obsolete = 'TRUE';
-    }
 
-    // get the feature type id
-    $values = array(
-      'cv_id' => array(
-        'name' => 'sequence'
-        ),
-      'name' => $node->feature_type
-    );
-    $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
+  $residues = preg_replace("/[\n\r\s]/", "", $node->residues);
+  $obsolete = 'FALSE';
+  if ($node->is_obsolete) {
+    $obsolete = 'TRUE';
+  }
 
-    $feature_id = chado_get_id_for_node('feature', $node) ;
+  // get the feature type id
+  $values = array(
+    'cv_id' => array(
+      'name' => 'sequence'
+      ),
+    'name' => $node->feature_type
+  );
+  $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
 
-    if (sizeof($type) > 0) {
-      $match = array(
-        'feature_id' => $feature_id,
-      );
-      $values = array(
-        'organism_id' => $node->organism_id,
-        'name' => $node->fname,
-        'uniquename' => $node->uniquename,
-        'residues' => $residues,
-        'seqlen' => drupal_strlen($residues),
-        'is_obsolete' => $obsolete,
-        'type_id' => $type[0]->cvterm_id,
-        'md5checksum' => md5($residues)
-      );
-        $status = tripal_core_chado_update('feature', $match, $values);
+  $feature_id = chado_get_id_for_node('feature', $node) ;
 
-        // add the genbank synonyms
-        chado_feature_add_synonyms($node->synonyms, $feature_id);
-    }
-    else {
-      drupal_set_message(t('Unable to update feature.'), 'warning');
-      watchdog('tripal_feature',
-      'Update feature: Unable to update feature where values: %values',
-      array('%values' => print_r($values, TRUE)),
-      WATCHDOG_WARNING
-      );
-    }
+  if (sizeof($type) > 0) {
+    $match = array(
+      'feature_id' => $feature_id,
+    );
+    $values = array(
+      'organism_id' => $node->organism_id,
+      'name' => $node->fname,
+      'uniquename' => $node->uniquename,
+      'residues' => $residues,
+      'seqlen' => drupal_strlen($residues),
+      'is_obsolete' => $obsolete,
+      'type_id' => $type[0]->cvterm_id,
+      'md5checksum' => md5($residues)
+    );
+      $status = tripal_core_chado_update('feature', $match, $values);
+
+      // add the genbank synonyms
+      chado_feature_add_synonyms($node->synonyms, $feature_id);
   }
+  else {
+    drupal_set_message(t('Unable to update feature.'), 'warning');
+    watchdog('tripal_feature',
+    'Update feature: Unable to update feature where values: %values',
+    array('%values' => print_r($values, TRUE)),
+    WATCHDOG_WARNING
+    );
+  }  
 }
 /**
  *

+ 11 - 12
tripal_featuremap/tripal_featuremap.module

@@ -745,20 +745,19 @@ function chado_featuremap_insert($node) {
  */
 function chado_featuremap_update($node) {
   if ($node->revision) {
-    // TODO -- decide what to do about revisions
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
   }
-  else {
-    $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
+  $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
 
-    // update the map record
-    $match = array(
-       'featuremap_id' => $featuremap_id,
-    );
-    $values = array(
-       'name' => $node->title,
-    );
-    $status = tripal_core_chado_update('featuremap', $match, $values);
-  }
+  // update the map record
+  $match = array(
+     'featuremap_id' => $featuremap_id,
+  );
+  $values = array(
+     'name' => $node->title,
+  );
+  $status = tripal_core_chado_update('featuremap', $match, $values);  
 }
 
 

+ 25 - 24
tripal_library/tripal_library.module

@@ -907,34 +907,35 @@ function chado_library_insert($node) {
  */
 function chado_library_update($node) {
   if ($node->revision) {
-    // TODO -- decide what to do about revisions
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
   }
-  else {
-    $library_id = chado_get_id_for_node('library', $node) ;
+  
+  $library_id = chado_get_id_for_node('library', $node) ;
 
-    // get the library type id
-    $values = array(
-       'cv_id' => array(
-          'name' => 'tripal'
-        ),
-       'name' => $node->library_type
-    );
-    $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
+  // get the library type id
+  $values = array(
+     'cv_id' => array(
+        'name' => 'tripal'
+      ),
+     'name' => $node->library_type
+  );
+  $type = tripal_core_chado_select('cvterm', array('cvterm_id'), $values);
 
-    // update the library record
-    $match = array(
-       'library_id' => $library_id,
-    );
-    $values = array(
-       'name' => $node->title,
-       'uniquename' => $node->uniquename,
-       'organism_id' => $node->organism_id,
-       'type_id' => $type[0]->cvterm_id
-    );
-    $status = tripal_core_chado_update('library', $match, $values);
+  // update the library record
+  $match = array(
+     'library_id' => $library_id,
+  );
+  $values = array(
+     'name' => $node->title,
+     'uniquename' => $node->uniquename,
+     'organism_id' => $node->organism_id,
+     'type_id' => $type[0]->cvterm_id
+  );
+  $status = tripal_core_chado_update('library', $match, $values);
+
+  tripal_library_update_property($library_id, 'library_description', $node->library_description);
 
-    tripal_library_update_property($library_id, 'library_description', $node->library_description);
-  }
 }
 
 

+ 2 - 1
tripal_organism/tripal_organism.module

@@ -757,7 +757,8 @@ function chado_organism_insert($node) {
  */
 function chado_organism_update($node) {
   if ($node->revision) {
-    // TODO -- decide what to do about revisions
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
   }
   $match = array(
     'organism_id' => chado_get_id_for_node('organism', $node),

+ 4 - 1
tripal_project/tripal_project.module

@@ -249,7 +249,10 @@ function chado_project_delete($node) {
  *
  */
 function chado_project_update($node) {
-
+  if ($node->revision) {
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
+  }
   // Find the project to update
   $match= array(
     'project_id' => $node->project_id,

+ 79 - 77
tripal_stock/tripal_stock.module

@@ -705,103 +705,105 @@ function chado_stock_insert($node) {
 function chado_stock_update($node) {
 
   if ($node->revision) {
-    chado_stock_insert($node);
+    // there is no way to handle revisions in Chado but leave
+    // this here just to make not we've addressed it.
   }
-  else {
+//  if ($node->revision) {
+//    chado_stock_insert($node);
+//  }
+//  else {
+
+  //update dbxref
+  if ($node->database) {
+    if ($node->accession) {
+      $dbxref_mode = '';
+      $stock = tripal_core_chado_select(
+        'stock',
+        array('dbxref_id', 'type_id'),
+        array('stock_id' => $node->stock_id)
+      );
 
-    //update dbxref
-    if ($node->database) {
-      if ($node->accession) {
-        $dbxref_mode = '';
-        $stock = tripal_core_chado_select(
-          'stock',
-          array('dbxref_id', 'type_id'),
-          array('stock_id' => $node->stock_id)
+      if ($stock[0]->dbxref_id) {
+        $values = array(
+          'db_id' => $node->database,
+          'accession' => $node->accession,
+          'description' => $node->db_description
         );
-
-        if ($stock[0]->dbxref_id) {
+        $dbxref_status = tripal_core_chado_update(
+          'dbxref',
+          array('dbxref_id' => $stock[0]->dbxref_id),
+          $values
+        );
+        $dbxref_mode = 'Update';
+      }
+      else {
+        if ($stock[0]->type_id) {
+          //create the dbxref
+          //used the type_id as a control to check we have a stock but not a dbxref
           $values = array(
             'db_id' => $node->database,
             'accession' => $node->accession,
-            'description' => $node->db_description
+            'description' => $node->db_description,
+            'version' => '1',
           );
-          $dbxref_status = tripal_core_chado_update(
+          $dbxref_status = tripal_core_chado_insert(
             'dbxref',
-            array('dbxref_id' => $stock[0]->dbxref_id),
             $values
           );
-          $dbxref_mode = 'Update';
+          $dbxref_mode = 'Create';
         }
         else {
-          if ($stock[0]->type_id) {
-            //create the dbxref
-            //used the type_id as a control to check we have a stock but not a dbxref
-            $values = array(
-              'db_id' => $node->database,
-              'accession' => $node->accession,
-              'description' => $node->db_description,
-              'version' => '1',
-            );
-            $dbxref_status = tripal_core_chado_insert(
-              'dbxref',
-              $values
-            );
-            $dbxref_mode = 'Create';
-          }
-          else {
-            drupal_set_message(t('Unable to find stock to Update'), 'error');
-            watchdog(
-              'tripal_stock',
-              'Stock Update: Unable to find stock to update using values: %values',
-              array('%values', print_r($values, TRUE)),
-              WATCHDOG_ERROR
-            );
-            return FALSE;
-          }
+          drupal_set_message(t('Unable to find stock to Update'), 'error');
+          watchdog(
+            'tripal_stock',
+            'Stock Update: Unable to find stock to update using values: %values',
+            array('%values', print_r($values, TRUE)),
+            WATCHDOG_ERROR
+          );
+          return FALSE;
         }
       }
     }
+  }
 
-    if (!$dbxref_status) {
-      watchdog(
-        'tripal_stock',
-        'Stock Update: Unable to %mode main stock dbxref with values: %values',
-        array('%values' => print_r($values, TRUE), '%mode' => $dbxref_mode),
-        WATCHDOG_WARNING
-      );
-    }
-
-    //can't change stock id which is all thats stored in drupal thus only update chado
-    $update_values = array(
-      'organism_id' => $node->organism_id,
-      'name' => $node->title,
-      'uniquename' => $node->uniquename,
-      'description' => $node->stock_description,
-      'type_id' => $node->type_id,
-    );
-    if ($dbxref_status) {
-      $update_values['dbxref_id'] = array(
-        'db_id' => $node->database,
-        'accession' => $node->accession
-      );
-    }
-    $status = tripal_core_chado_update(
-      'stock',
-      array('stock_id' => $node->stock_id),
-      $update_values
+  if (!$dbxref_status) {
+    watchdog(
+      'tripal_stock',
+      'Stock Update: Unable to %mode main stock dbxref with values: %values',
+      array('%values' => print_r($values, TRUE), '%mode' => $dbxref_mode),
+      WATCHDOG_WARNING
     );
+  }
 
-    if (!$status) {
-      drupal_set_message(t('Unable to update stock'), 'error');
-      watchdog(
-        'tripal_stock',
-        'Stock Update: Unable to update stock using match values: %mvalues and update values: %uvalues',
-        array('%mvalues' => print_r(array('stock_id' => $node->stock_id), TRUE), '%uvalues' => print_r($update_values, TRUE)),
-        WATCHDOG_ERROR
-      );
-    }
+  //can't change stock id which is all thats stored in drupal thus only update chado
+  $update_values = array(
+    'organism_id' => $node->organism_id,
+    'name' => $node->title,
+    'uniquename' => $node->uniquename,
+    'description' => $node->stock_description,
+    'type_id' => $node->type_id,
+  );
+  if ($dbxref_status) {
+    $update_values['dbxref_id'] = array(
+      'db_id' => $node->database,
+      'accession' => $node->accession
+    );
   }
+  $status = tripal_core_chado_update(
+    'stock',
+    array('stock_id' => $node->stock_id),
+    $update_values
+  );
 
+  if (!$status) {
+    drupal_set_message(t('Unable to update stock'), 'error');
+    watchdog(
+      'tripal_stock',
+      'Stock Update: Unable to update stock using match values: %mvalues and update values: %uvalues',
+      array('%mvalues' => print_r(array('stock_id' => $node->stock_id), TRUE), '%uvalues' => print_r($update_values, TRUE)),
+      WATCHDOG_ERROR
+    );
+  }
 }
 
 /**