瀏覽代碼

Fixed bug in the chado schema definitions for the featuremap_dbxref and featuremap_pub tables. These bugs are actually in the Chado schema but cause problems if not fixed. Also fixed issues with database cross reference and relationship fields

Stephen Ficklin 7 年之前
父節點
當前提交
166bc948e7

+ 4 - 2
tripal/includes/tripal.fields.inc

@@ -731,7 +731,8 @@ function tripal_field_settings_form_validate($element, &$form_state, $form) {
  * Implements hook_field_formatter_settings_summary().
  */
 function tripal_field_formatter_settings_summary($field, $instance, $view_mode) {
-  $formatter_class = $field['type'] . '_formatter';
+
+  $formatter_class = $instance['display']['default']['type'];
   if (tripal_load_include_field_class($formatter_class)) {
     $formatter = new $formatter_class($field, $instance);
     return $formatter->settingsSummary($view_mode);
@@ -743,8 +744,9 @@ function tripal_field_formatter_settings_summary($field, $instance, $view_mode)
  */
 function tripal_field_formatter_settings_form($field, $instance,
     $view_mode, $form, &$form_state) {
-  if (tripal_load_include_field_class($formatter_class)) {
 
+  $formatter_class = $instance['display']['default']['type'];
+  if (tripal_load_include_field_class($formatter_class)) {
     $formatter = new $formatter_class($field, $instance);
     $elements = $formatter->settingsForm($view_mode, $form, $form_state);
   }

+ 16 - 0
tripal_chado/api/tripal_chado.schema_v1.3.api.inc

@@ -7019,6 +7019,14 @@ function tripal_chado_chado_schema_v1_3_featuremap_dbxref() {
         'default' => 'true',
       ),
     ),
+    // TODO: this unique constraint is missing from the actual Chado schema.
+    // It should be included.
+    'unique keys' => array(
+      'feature_dbxref_c1' => array(
+        0 => 'featuremap_id',
+        1 => 'dbxref_id',
+      ),
+    ),
     'indexes' => array(
       'featuremap_dbxref_idx1' => array(
         0 => 'featuremap_id',
@@ -7244,6 +7252,14 @@ function tripal_chado_chado_schema_v1_3_featuremap_pub() {
         'not null' => TRUE,
       ),
     ),
+    // TODO: this unique constraint is missing from the actual Chado schema.
+    // It should be included.
+    'unique keys' => array(
+      'feature_pub_c1' => array(
+        0 => 'featuremap_id',
+        1 => 'pub_id',
+      ),
+    ),
     'indexes' => array(
       'featuremap_pub_idx1' => array(
         0 => 'featuremap_id',

+ 4 - 4
tripal_chado/includes/TripalFields/ogi__location_on_map/ogi__location_on_map.inc

@@ -119,6 +119,7 @@ class ogi__location_on_map extends ChadoField {
     $field_name = $this->field['field_name'];
     $field_type = $this->field['type'];
 
+    $map_term = 'data:1274';
     $name_term = tripal_get_chado_semweb_term('featuremap', 'name');
     $description_term = tripal_get_chado_semweb_term('featuremap', 'description');
     $mappos_term = tripal_get_chado_semweb_term('featurepos', 'mappos');
@@ -148,18 +149,17 @@ class ogi__location_on_map extends ChadoField {
       foreach ($feature->featurepos->feature_id AS $featurepos) {
         // Get details about the map
         $featuremap = chado_generate_var('featuremap', array('featuremap_id' => $featurepos->featuremap_id));
-        $value = array (
+        $entity->{$field_name}['und'][$i]['value'] = array (
           // Map.
-          'data:1274' => array(
+          $map_term => array(
             $name_term => $featuremap->name,
             $description_term => $featuremap->description,
           ),
           $mappos_term => $featurepos->mappos
         );
         if (property_exists($featuremap, 'entity_id')) {
-          $value['data:1274']['entity'] = 'TripalEntity:' . $featuremap->entity_id;
+          $entity->{$field_name}['und'][$i]['value'][$map_term]['entity'] = 'TripalEntity:' . $featuremap->entity_id;
         }
-        $entity->{$field_name}['und'][$i]['value'] = $value;
         $i++;
       }
     }

+ 2 - 2
tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference.inc

@@ -262,9 +262,9 @@ class sbo__database_cross_reference extends ChadoField {
       // clear to the user what field is required and which isn't. Therefore,
       // we borrow the code from the 'form_error' function and append the field
       // so that the proper field is highlighted on error.
-      if (!$db_id and $accession) {
+      if (!$db_id) {
         $errors[$field_name][$delta]['und'][] = array(
-          'message' => t("A database and the accession must both be provided."),
+          'message' => t("A database must be provided for the cross reference."),
           'error' => 'sbo__database_cross_reference',
         );
       }

+ 3 - 0
tripal_chado/includes/TripalFields/sbo__database_cross_reference/sbo__database_cross_reference_widget.inc

@@ -100,6 +100,9 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
     );
   }
 
+  /**
+   * @see TripalFieldWidget::validate()
+   */
   public function validate($element, $form, &$form_state, $langcode, $delta) {
 
     $field_name = $this->field['field_name'];

+ 6 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

@@ -18,6 +18,7 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
    * @see TripalFieldFormatter::settingsForm()
    */
   public function settingsForm($view_mode, $form, &$form_state) {
+
     $display = $this->instance['display'][$view_mode];
     $settings = $display['settings'];
     $element = array();
@@ -42,7 +43,11 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
     $display = $this->instance['display'][$view_mode];
     $settings = $display['settings'];
 
-    $summary = t('Title: @title<br>Empty: @empty', array('@title' => $settings['title'], '@empty' => $settings['empty']));
+    $summary = t('Title: @title<br>Empty: @empty',
+        array(
+          '@title' => $settings['title'],
+          '@empty' => $settings['empty'])
+        );
 
     return $summary;
   }

+ 1 - 0
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -146,6 +146,7 @@ function tripal_chado_field_storage_write_table($table_name, $values, $base_tabl
 
   // If the primary key column does not have a value then this is an insert.
   if (!array_key_exists($pkey, $values) or !$values[$pkey] or !isset($values[$pkey])) {
+
     // Before inserting, we want to make sure the record does not
     // already exist.  Using the unique constraint check for a matching record.
     $options = array('is_duplicate' => TRUE);

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

@@ -870,6 +870,12 @@ function tripal_chado_bundle_instances_info_base(&$info, $entity_type, $bundle,
       $base_info['label'] = 'Description';
     }
     //
+    // FEATUREMAP TABLE
+    //
+    if ($table_name == 'featuremap' and $column_name == 'name') {
+      $base_info['required'] = TRUE;
+    }
+    //
     // PUB TABLE
     //
     if ($table_name == 'pub') {
@@ -1349,7 +1355,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
   }
 
 
-  // FEATURE SEQLEN
+  // FEATURE MAP UNITS
   if ($table_name == 'featuremap') {
     $field_name = 'uo__unit';
     $info[$field_name] = array(