ソースを参照

Fixed the assay.operator_id column so the field works appropriately for it

Stephen Ficklin 6 年 前
コミット
6e3941b018

+ 3 - 11
tripal_chado/includes/TripalFields/local__contact/local__contact.inc

@@ -139,16 +139,8 @@ class local__contact extends ChadoField {
     }
       
     $linker_field = 'chado-' . $field_table . '__' . $field_column;
-    if ($field_table == 'biomaterial') {
-      $contact = $record->biosourceprovider_id;      
-    }
-    elseif ($field_table == 'arraydesign') {
-      $contact = $record->manufacturer_id;
-    }
-    else {
-      $contact = $record->contact_id;
-    }
-  
+    $contact = $record->{$field_column};
+    
     if ($contact) {
       $entity->{$field_name}['und'][0] = array(
         'value' => array(
@@ -157,7 +149,7 @@ class local__contact extends ChadoField {
           $description_term => $contact->description,
         ),
         $entity->{$field_name}['und'][0][$linker_field] = $contact->contact_id,
-        );
+      );
       if (property_exists($contact, 'entity_id')) {
         $entity->{$field_name}['und'][0]['value']['entity'] = 'TripalEntity:' . $contact->entity_id;
       }

+ 1 - 2
tripal_chado/includes/TripalFields/schema__publication/schema__publication.inc

@@ -88,8 +88,7 @@ class schema__publication extends ChadoField {
     $pkey = '';
     $fkey_lcolumn = '';
     $fkey_rcolumn = '';
-    $linker_table = '';
-       
+    $linker_table = '';   
     
     // If the field table and the base table are not the same thing then
     // we are going through a linker table.

+ 6 - 0
tripal_chado/includes/tripal_chado.entity.inc

@@ -163,6 +163,12 @@ function tripal_chado_tripal_default_title_format($bundle, $available_tokens) {
       'weight' => -5
     );
   }
+  if ($table == 'assay') {
+    $format[] = array(
+      'format' => '[schema__name]',
+      'weight' => -5
+    );
+  }
   if ($table == 'biomaterial') {
     $format[] = array(
       'format' => '[schema__name]',

+ 54 - 1
tripal_chado/includes/tripal_chado.fields.inc

@@ -519,6 +519,21 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
     );
   }
   
+  // Assay operator.
+  if ($table_name == 'assay') {
+      $field_name = 'assay__operator_id';
+      $field_type = 'local__contact';
+      $info[$field_name] = array(
+        'field_name' => $field_name,
+        'type' => $field_type,
+        'cardinality' => 1,
+        'locked' => FALSE,
+        'storage' => array(
+          'type' => 'field_chado_storage',
+        ),
+      );
+    }
+  
   // For the pub_id field in the base table.
   $schema = chado_get_schema($table_name);
   if (array_key_exists('pub_id', $schema['fields'])) {
@@ -1974,7 +1989,45 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
       ),
     );
   } 
-
+  
+  if ($table_name == 'assay') {      
+    // Remove the ncit__operator added by the
+    // tripal_chado_bunde_instnaces_info_base function.
+    unset($info['ncit__operator']);
+    
+    $field_name = 'assay__operator_id';
+    $info[$field_name] =  array(
+      'field_name' => $field_name,
+      'entity_type' => $entity_type,
+      'bundle' => $bundle->name,
+      'label' => 'Operator',
+      'description' => 'The individual responsible for performing the assay.',
+      'required' => TRUE,
+      'settings' => array(
+        'auto_attach' => TRUE,
+        'chado_table' => 'assay',
+        'chado_column' => 'operator_id',
+        'base_table' => 'assay',
+        'term_vocabulary' => 'NCIT',
+        'term_name' => 'Operator',
+        'term_accession' => 'C48036',
+        
+      ),
+      'widget' => array(
+        'type' => 'local__contact_widget',
+        'settings' => array(
+          'display_label' => 1,
+        ),
+      ),
+      'display' => array(
+        'default' => array(
+          'label' => 'inline',
+          'type' => 'local__contact_formatter',
+          'settings' => array(),
+        ),
+      ),
+    );
+  } 
 }
 
 /**