소스 검색

incremental commit to keep from losing work

Stephen Ficklin 13 년 전
부모
커밋
c0d1e82f08
2개의 변경된 파일16개의 추가작업 그리고 5개의 파일을 삭제
  1. 16 4
      tripal_core/tripal_core.api.inc
  2. 0 1
      tripal_feature/tripal_feature.api.inc

+ 16 - 4
tripal_core/tripal_core.api.inc

@@ -1359,7 +1359,7 @@ function chado_get_node_id ($table, $id) {
  *   The base table for which the property should be retrieved. Thus to retrieve a property
  *   for a feature the basetable=feature and property is retrieved from featureprop
  * @param $record_id
- *   The primary key of the basetable to retrieve properties for. This should be in integer.
+ *   The foriegn key field of the base table. This should be in integer.
  * @param $property
  *   The cvterm name describing the type of properties to be retrieved
  * @param $cv_name
@@ -1371,7 +1371,7 @@ function chado_get_node_id ($table, $id) {
  * @ingroup tripal_chado_api
  */
 function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
-
+  
    // get the foreign key for this property table
    $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
    $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);
@@ -1387,6 +1387,7 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
          'is_obsolete' => 0
       ),
    );
+
    $results = tripal_core_generate_chado_var($basetable.'prop',$values);
    $results = tripal_core_expand_chado_vars($results,'field',$basetable.'prop.value');
    return $results;
@@ -1401,7 +1402,7 @@ function tripal_core_get_property($basetable, $record_id, $property, $cv_name){
  *   The base table for which the property should be inserted. Thus to insert a property
  *   for a feature the basetable=feature and property is inserted into featureprop
  * @param $record_id
- *   The primary key of the basetable to insert a property for. This should be in integer.
+ *   The foriegn key field of the base table. This should be in integer. 
  * @param $property
  *   The cvterm name describing the type of properties to be inserted
  * @param $cv_name
@@ -1426,21 +1427,32 @@ function tripal_core_insert_property($basetable, $record_id, $property,
    // insert
    $prop = tripal_core_get_property($basetable,$record_id,$property,$cv_name);
    $rank = 0;
+   $exists = 0;
    if(count($prop)>0){ 
       if($update_if_present){
          return tripal_core_update_property($basetable,$record_id,$property,$cv_name,$value) ;
       } else {
-         // iterate through the properties returned and get the largest rank
+         // iterate through the properties returned and check to see if the
+         // property with this value already exists if not, get the largest rank
+         // and insert the same property but with this new value
          foreach($prop as $p){
             if($p->rank > $rank){
                $rank = $p->rank;
             }
+            if(strcmp($p->value,$value)==0){
+               $exists = 1;
+            }
          }
          // now add 1 to the rank
          $rank++;
       }
    }
 
+   // if the property with this value exists then we return TRUE as if the
+   // insert was successful.
+   if($exists){
+      return TRUE;
+   }
    // get the foreign key for this property table
    $table_desc = module_invoke_all('chado_'.$basetable.'prop_schema');
    $fkcol = key($table_desc['foreign keys'][$basetable]['columns']);

+ 0 - 1
tripal_feature/tripal_feature.api.inc

@@ -481,7 +481,6 @@ function tripal_feature_analysis_update_property_by_id($analysisfeatureprop_id,
 function tripal_feature_analysis_delete_property($analysis_id = NULL, $feature_id = NUll, 
    $analysisfeature_id = NULL, $property, $cv_name = 'tripal')
 {
-     
    // check that the incoming arguments are correct
    if(($analysis_id and !$feature_id) or
        (!$analysis_id and $feature_id)){