Browse Source

Fixed bug in loader

spficklin 12 years ago
parent
commit
ff97c79d38

+ 14 - 8
tripal_bulk_loader/tripal_bulk_loader.admin.templates.inc

@@ -1025,7 +1025,6 @@ function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
     $chado_fields[$field_name] = $field_name;
   }  
 
-  $ref_chado_fields = array();
   $fk_options = array();
   $fk_options['NULL'] = 'None';
   if ($field_type == 'foreign key' and !$show_all) {
@@ -1067,12 +1066,16 @@ function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
     }
   }
     
-  // build the list of referrer table fields
+  // build the list of referrer table fields. This list is used
+  // for the referring table field drop down. It has two groups
+  // one for foreign keys and another for additional fields.
+  $ref_chado_fields = array();  
   if ($field_type == 'foreign key') {
     $fk_rec = $form_state['values']['foreign_record']; 
     if ($fk_rec and $fk_rec != 'None' and $fk_rec != 'NULL') {
     
-      // first add in the primary keys
+      // first add in the foreign key field in the referring table
+      // that corresponds to this field (if one exists).
       $fk_priority = $form_state['storage']['record2priority'][$fk_rec];
       $fk_table = $form_state['storage']['template_array'][$fk_priority]['table'];
       foreach ($table_description['foreign keys'] as $key_table => $key_array) {
@@ -1082,13 +1085,16 @@ function tripal_bulk_loader_add_template_field_form(&$form_state = NULL) {
           }
         }
       }      
+      // now add in the remaining fields of the referring record's table.
       $fk_description = tripal_core_get_chado_table_schema($fk_table);
       foreach ($fk_description['fields'] as $fk_field_name => $fk_farray){
-         // don't include the FK field it's included above
-         if (in_array($fk_field_name,$ref_chado_fields['Foreign Key'])) {
-           continue;
-         }
-         $ref_chado_fields['Additional Table Fields'][$fk_field_name] = $fk_field_name;
+        // don't include the FK field it's included above
+        if (in_arrray('Foreign Key', $ref_chado_fields)) {
+          if (in_array($fk_field_name, $ref_chado_fields['Foreign Key'])) {
+            continue;
+          }
+        }
+        $ref_chado_fields['Additional Table Fields'][$fk_field_name] = $fk_field_name;
       }
     }
   }

+ 13 - 4
tripal_core/api/tripal_core.api.inc

@@ -1864,6 +1864,8 @@ function tripal_core_exclude_field_from_feature_by_default() {
  */
 function chado_query($sql) {
 
+//print memory_get_usage() . "\n";
+	
   $args = func_get_args();
   array_shift($args); // remove the $sql from the argument list
   $sql = db_prefix_tables($sql);
@@ -2473,24 +2475,31 @@ function tripal_core_chado_execute_prepared($statement_name, $sql, $values) {
           case 'text':
             $check = is_string($v);
             if (!$check) {
-              watchdog('tripal_core', "chado_execute_prepared:wrong argument type supplied for '%name' statement. Expected %required but recieved %value", array('%name' => $statement_name, '%required' => $required_values[$k], '%value' => print_r($v,TRUE)), WATCHDOG_ERROR);
+              watchdog('tripal_core', "chado_execute_prepared: wrong argument type supplied for '%name' statement. Expected %required but recieved %value", array('%name' => $statement_name, '%required' => $required_values[$k], '%value' => print_r($v,TRUE)), WATCHDOG_ERROR);
               return FALSE;
             }
             break;
           case 'int':
             $check = is_numeric($v);
             if (!$check) {
-              watchdog('tripal_core', "chado_execute_prepared:wrong argument type supplied for '%name' statement. Expected %required but recieved %value", array('%name' => $statement_name, '%required' => $required_values[$k], '%value' => print_r($v,TRUE)), WATCHDOG_ERROR);
+              watchdog('tripal_core', "chado_execute_prepared: wrong argument type supplied for '%name' statement. Expected %required but recieved %value", array('%name' => $statement_name, '%required' => $required_values[$k], '%value' => print_r($v,TRUE)), WATCHDOG_ERROR);
               return FALSE;
             }
             break;
+          case 'numeric':
+            $check = is_numeric($v);
+            if (!$check) {
+              watchdog('tripal_core', "chado_execute_prepared: wrong argument type supplied for '%name' statement. Expected %required but recieved %value", array('%name' => $statement_name, '%required' => $required_values[$k], '%value' => print_r($v,TRUE)), WATCHDOG_ERROR);
+              return FALSE;
+            }
+            break;                     
           default:
-            watchdog('tripal_core', "chado_execute_prepared:unsupported argument type supplied for '%name' statement %type", array('%name' => $statement_name, '%type' => $required_values[$k]), WATCHDOG_WARNING);
+            watchdog('tripal_core', "chado_execute_prepared: unsupported argument type (supplied for '%name' statement %type", array('%name' => $statement_name, '%type' => $required_values[$k]), WATCHDOG_WARNING);
             break;
         }
       }
       else {
-        watchdog('tripal_core', "chado_execute_prepared:wrong number of arguments supplied for '%name' statement. Expected %required but recieved %values", array('%name' => $statement_name, '%required' => print_r($required_values,TRUE), '%values' => print_r($values,TRUE)), WATCHDOG_ERROR);
+        watchdog('tripal_core', "chado_execute_prepared: wrong number of arguments supplied for '%name' statement. Expected %required but recieved %values", array('%name' => $statement_name, '%required' => print_r($required_values,TRUE), '%values' => print_r($values,TRUE)), WATCHDOG_ERROR);
         return FALSE;
       }
     }