瀏覽代碼

add fields

bradfordcondon 6 年之前
父節點
當前提交
4418c16219

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

@@ -11,8 +11,8 @@ class local__child_properties extends ChadoField {
 
   public static $default_label = 'Child Properties';
   public static $default_description = 'All of the properties associated with child features.';
-  public static $default_widget = 'local__child_properties_widget';
-  public static $default_formatter = 'local__child_properties_formatter';
+  public static $default_widget = 'local__child_annotations_widget';
+  public static $default_formatter = 'local__child_annotations_formatter';
   public static $module = 'tripal_chado';
   public static $default_settings = [
     'storage' => 'field_chado_storage',

+ 0 - 62
tripal_chado/includes/TripalFields/sio__annotation/sio__annotation_formatter.inc

@@ -78,66 +78,4 @@ class sio__annotation_formatter extends ChadoFieldFormatter {
       );
     }
   }
-
-
-
-  /**
-   * Get annotations for child features, from the data__sequence_features field.
-   * Possibly not used.
-   *
-   * @param $data
-   */
-  private function getAnnotationRows($data) {
-
-    $rows = [];
-
-    $info = $data['info'];
-
-    $children = $data['children'] ?? NULL;
-
-    $annotations = $info->feature_cvterm;
-
-    if ($annotations) {
-
-      if (is_array($annotations)) {
-        foreach ($annotations as $ann) {
-
-          $annotation_name = $ann->cvterm_id->name;
-          if ($ann->is_not) {
-            $annotation_name = "is not " . $annotation_name;
-          }
-
-          $rows[] = [
-            $info->uniquename,
-            $info->type_id->name,
-            $annotation_name,
-          ];
-        }
-      }
-      else {
-        $annotation_name = $annotations->cvterm_id->name;
-        if ($annotations->is_not) {
-          $annotation_name = "is not " . $annotation_name;
-        }
-
-        $rows[] = [
-          $info->uniquename,
-          $info->type_id->name,
-          $annotation_name,
-        ];
-
-      }
-
-    }
-
-    if ($children && !empty($children)) {
-
-      foreach ($children as $child) {
-        $rows = array_merge($this->getAnnotationRows($child), $rows);
-      }
-    }
-    return $rows;
-
-  }
-
 }

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

@@ -628,6 +628,23 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
         'type' => 'field_chado_storage',
       ],
     ];
+    tripal_insert_cvterm([
+      'id' => 'local:child_annotations',
+      'name' => 'child_annotations',
+      'cv_name' => 'local',
+      'definition' => 'Annotations associated with children of a feature.',
+    ]);
+    $field_name = 'local__child_annotations';
+    $field_type = 'local__child_annotations';
+    $info[$field_name] = [
+      'field_name' => $field_name,
+      'type' => $field_type,
+      'cardinality' => 1,
+      'locked' => FALSE,
+      'storage' => [
+        'type' => 'field_chado_storage',
+      ],
+    ];
   }
 
 }
@@ -2275,7 +2292,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
         'default' => [
           'label' => 'hidden',
           'type' => 'data__sequence_features_formatter',
-          'settings' => [],
+          'settings' => ['weight' => 1],
         ],
       ],
     ];
@@ -2306,6 +2323,39 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
           'type' => 'local__child_properties_formatter',
           // This field depends on the data__sequence_features field.
           // The weight must be set to ensure it loads after this field.
+          'settings' => ['weight' => 490],
+        ],
+      ],
+    ];
+
+
+    $field_name = 'local__child_annotations';
+    $info[$field_name] = [
+      'field_name' => $field_name,
+      'entity_type' => $entity_type,
+      'bundle' => $bundle->name,
+      'label' => 'Child Annotations',
+      'description' => 'Displays annotation information associated with recursive children of this feature.',
+      'required' => FALSE,
+      'settings' => [
+        'term_vocabulary' => 'local',
+        'term_name' => 'child_annotations',
+        'term_accession' => 'child_annotations',
+        'auto_attach' => FALSE,
+        'chado_table' => 'feature_cvterm',
+        'chado_column' => 'feature_id',
+        'base_table' => $bundle->data_table,
+      ],
+      'widget' => [
+        'type' => 'local__child_annotations_widget',
+        'settings' => [],
+      ],
+      'display' => [
+        'default' => [
+          'label' => 'hidden',
+          'type' => 'local__child_annotations_formatter',
+          // This field depends on the data__sequence_features field.
+          // The weight must be set to ensure it loads after this field.
           'settings' => ['weight' => 500],
         ],
       ],