Преглед изворни кода

Fixed bug with custom base fields in Chado. Cleaning up field classes

Stephen Ficklin пре 8 година
родитељ
комит
309930218c

+ 1 - 0
tripal/includes/TripalField.inc

@@ -365,6 +365,7 @@ class TripalField {
       '#type' => 'value',
       '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
     );
+
   }
 
   /**

+ 0 - 1
tripal/includes/tripal.fields.inc

@@ -309,7 +309,6 @@ function tripal_formatter_settings_form($field, $instance,
  */
 function tripal_field_widget_form(&$form, &$form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
-
   $widget = $element;
   $field_type = $field['type'];
   $is_loaded = tripal_load_include_field_type($field_type);

+ 0 - 111
tripal_chado/includes/TripalFields/chado_base__organism_id.inc

@@ -24,109 +24,6 @@ class chado_base__organism_id extends TripalField {
   public static $default_storage = 'field_chado_storage';
 
 
-  /**
-   * @see TripalField::create_info()
-   */
-  public function createInfo() {
-
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_base__organism_id',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $table_name,
-        'chado_column' => 'organism_id',
-        'semantic_web' => tripal_get_chado_semweb_term($table_name, 'organism_id'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  public function createInstanceInfo() {
-
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    $is_required = FALSE;
-    $schema = chado_get_schema($table_name);
-    if (array_key_exists('not null', $schema['fields']['organism_id']) and
-        $schema['fields']['organism_id']['not null']) {
-      $is_required = TRUE;
-    }
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Organism',
-      'description' => 'Select an organism.',
-      'required' => $is_required,
-      'settings' => array(
-        'auto_attach' => TRUE,
-      ),
-      'widget' => array(
-        'type' => 'chado_base__organism_id_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_base__organism_id_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_base__organism_id_widget' => array(
-        'label' => t('Organism Select'),
-        'field types' => array('chado_base__organism_id')
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_base__organism_id_formatter' => array(
-        'label' => t('Organism'),
-        'field types' => array('chado_base__organism_id'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
   /**
    * @see TripalField::formatterView()
    */
@@ -311,14 +208,6 @@ class chado_base__organism_id extends TripalField {
     return $element;
   }
 
-  /**
-   *
-   * @param unknown $data
-   * @param string $criteria
-   */
-  public static function sort(&$data, $criteria = 'ASC') {
-
-  }
 }
 
 

+ 0 - 100
tripal_chado/includes/TripalFields/chado_feature__md5checksum.inc

@@ -23,106 +23,6 @@ class chado_feature__md5checksum  extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_feature__md5checksum',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $table_name,
-        'chado_column' => 'md5checksum',
-        'semantic_web' => tripal_get_chado_semweb_term($table_name, 'md5checksum'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Sequence Checksum',
-      'description' => 'The MD5 checksum for the sequence. The checksum here
-        will always be unique for the raw unformatted sequence. To verify that the
-        sequence has not been corrupted, download the raw sequence and use an MD5 tool
-        to calculate the value. If the value calculated is identical the one shown
-        here, then the downloaded sequence is uncorrupted.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => TRUE,
-      ),
-      'widget' => array(
-        'type' => 'chado_feature__md5checksum_widget',
-        'settings' => array(
-          'display_label' => 1,
-          'md5_fieldname' => 'feature__md5checksum',
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_feature__md5checksum_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_feature__md5checksum_widget' => array(
-        'label' => t('MD5 Checksum'),
-        'field types' => array('chado_feature__md5checksum'),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-        'chado_feature__md5checksum_formatter' => array(
-        'label' => t('MD5 Checksum'),
-        'field types' => array('chado_feature__md5checksum'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
   /**
    * @see TripalField::formatterView()
    */

+ 8 - 110
tripal_chado/includes/TripalFields/chado_feature__residues.inc

@@ -24,109 +24,7 @@ class chado_feature__residues extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-  /**
-   * @see TripalField::setFieldName()
-   */
-  protected function setFieldName() {
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    $this->field_name = 'feature__residues';
-  }
-
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_feature__residues',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $table_name,
-        'chado_column' => 'residues',
-        'semantic_web' => tripal_get_chado_semweb_term($table_name, 'residues'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Sequences',
-      'description' => 'All available sequences for this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_feature__residues_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_feature__residues_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
 
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_feature__residues_widget' => array(
-        'label' => t('Sequence'),
-        'field types' => array('chado_feature__residues'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_feature__residues_formatter' => array(
-        'label' => t('Sequences'),
-        'field types' => array('chado_feature__residues'),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */
@@ -285,7 +183,7 @@ class chado_feature__residues extends TripalField {
       ),
     );
     $feature = chado_expand_var($feature, 'table', 'featureloc', $options);
-    $featureloc_sequences = self::get_featureloc_sequences($feature->feature_id, $feature->featureloc->feature_id);
+    $featureloc_sequences = $this->get_featureloc_sequences($feature->feature_id, $feature->featureloc->feature_id);
 
     // Add in the coding sequences. It's faster to provide the SQL rather than
     // to use chado_generate_var based on the type.
@@ -376,7 +274,7 @@ class chado_feature__residues extends TripalField {
    * @param unknown $featurelocs
    * @return multitype:|Ambigous <multitype:, an>
    */
-  private static function get_featureloc_sequences($feature_id, $featurelocs) {
+  private function get_featureloc_sequences($feature_id, $featurelocs) {
 
     // if we don't have any featurelocs then no point in continuing
     if (!$featurelocs) {
@@ -385,7 +283,7 @@ class chado_feature__residues extends TripalField {
 
     // get the list of relationships (including any aggregators) and iterate
     // through each one to find information needed to color-code the reference sequence
-    $relationships = self::get_aggregate_relationships($feature_id);
+    $relationships = $this->get_aggregate_relationships($feature_id);
     if (!$relationships) {
       return array();
     }
@@ -395,7 +293,7 @@ class chado_feature__residues extends TripalField {
     // locations
     foreach ($relationships as $rindex => $rel) {
       // get the featurelocs for each of the relationship features
-      $rel_featurelocs = self::get_featurelocs($rel->subject_id, 'as_child', 0);
+      $rel_featurelocs = $this->get_featurelocs($rel->subject_id, 'as_child', 0);
       foreach ($rel_featurelocs as $rfindex => $rel_featureloc) {
         // keep track of this unique source feature
         $src = $rel_featureloc->src_feature_id . "-" . $rel_featureloc->src_cvterm_id;
@@ -520,7 +418,7 @@ class chado_feature__residues extends TripalField {
    *
    * @ingroup tripal_feature
    */
-  private static function get_aggregate_relationships($feature_id, $substitute=1,
+  private function get_aggregate_relationships($feature_id, $substitute=1,
       $levels=0, $base_type_id=NULL, $depth=0) {
 
     // we only want to recurse to as many levels deep as indicated by the
@@ -531,7 +429,7 @@ class chado_feature__residues extends TripalField {
     }
 
     // first get the relationships for this feature
-    return self::get_relationships($feature_id, 'as_object');
+    return $this->get_relationships($feature_id, 'as_object');
 
   }
 
@@ -545,7 +443,7 @@ class chado_feature__residues extends TripalField {
    *
    * @ingroup tripal_feature
    */
-  private static function get_relationships($feature_id, $side = 'as_subject') {
+  private function get_relationships($feature_id, $side = 'as_subject') {
     // get the relationships for this feature.  The query below is used for both
     // querying the object and subject relationships
     $sql = "
@@ -609,7 +507,7 @@ class chado_feature__residues extends TripalField {
    *
    * @ingroup tripal_feature
    */
-  private static function get_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) {
+  private function get_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) {
 
     $sql = "
     SELECT

+ 1 - 96
tripal_chado/includes/TripalFields/chado_feature__seqlen.inc

@@ -22,102 +22,7 @@ class chado_feature__seqlen extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_feature__seqlen',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $table_name,
-        'chado_column' => 'seqlen',
-        'semantic_web' => tripal_get_chado_semweb_term($table_name, 'seqlen'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Raw Sequence Length',
-      'description' => 'The number of residues in the raw sequence.  This length
-        is only for the assigned raw sequence and does not represent the length of any
-        sequences derived from alignments. If this value is zero but aligned sequences
-        are present then this record has no official assigned sequence.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => TRUE,
-      ),
-      'widget' => array(
-        'type' => 'chado_feature__seqlen_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_feature__seqlen_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_feature__seqlen_widget' => array(
-        'label' => t('Sequence Length'),
-        'field types' => array('chado_feature__seqlen'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_feature__seqlen_formatter' => array(
-        'label' => t('Residues Length'),
-        'field types' => array('chado_feature__seqlen'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
-  /**
+   /**
    * @see TripalField::formatterView()
    */
   public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) {

+ 0 - 100
tripal_chado/includes/TripalFields/chado_gene__transcripts.inc

@@ -22,106 +22,6 @@ class chado_gene__transcripts extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    $rel_table = $table_name . '_relationship';
-    $schema = chado_get_schema($rel_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_gene__transcripts',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $rel_table,
-        'chado_column' => 'md5checksum',
-        'base_table' => $table_name,
-        'semantic_web' => 'SO:0000673',
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Transcripts',
-      'description' => 'These transcripts are associated with this gene.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_gene__transcripts_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_gene__transcripts_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_gene__transcripts_widget' => array(
-        'label' => t('Transcripts Settings'),
-        'field types' => array('chado_gene__transcripts')
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_gene__transcripts_formatter' => array(
-        'label' => t('Transcripts'),
-        'field types' => array('chado_gene__transcripts'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
   /**
    * @see TripalField::formatter_settings_summary()
    */

+ 0 - 105
tripal_chado/includes/TripalFields/chado_linker__contact.inc

@@ -24,111 +24,6 @@ class chado_linker__contact extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-
-
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    $contact_table = $table_name . '_contact';
-    $schema = chado_get_schema($contact_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__contact',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $contact_table,
-        'chado_column' => 'contact_id',
-        'base_table' => $table_name,
-        'semantic_web' => 'local:contact'
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];;
-
-    $contact_table = $table_name . '_contact';
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Contacts',
-      'description' => 'An individual, organization or entity that has had
-        some responsibility for the creation, delivery or maintenance of
-        the associated data.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__contact_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__contact_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__contact_widget' => array(
-        'label' => t('Contacts'),
-        'field types' => array('chado_linker__contact'),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_linker__contact_formatter' => array(
-        'label' => t('Contacts'),
-        'field types' => array('chado_linker__contact'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
-
   /**
    * @see TripalField::formatterView()
    */

+ 0 - 76
tripal_chado/includes/TripalFields/chado_linker__cvterm_adder.inc

@@ -24,82 +24,6 @@ class chado_linker__cvterm_adder extends TripalField {
   public static $default_storage = 'field_chado_storage';
 
 
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__cvterm_adder',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    $table_name = $this->details['chado_table'];
-    $type_table = $this->details['chado_type_table'];
-    $type_field = $this->details['chado_type_column'];
-    $cv_id      = $this->details['chado_cv_id'];
-    $cvterm_id  = $this->details['chado_cvterm_id'];
-
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Add Annotation Types',
-      'description' => 'Add additional annotations types to this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__cvterm_adder_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__cvterm_adder_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__cvterm_adder_widget' => array(
-        'label' => t('Add an Annotation'),
-        'field types' => array('chado_linker__cvterm_adder'),
-      ),
-    );
-  }
   /**
    * @see TripalField::widgetForm()
    */

+ 34 - 26
tripal_chado/includes/tripal_chado.fields.inc

@@ -185,7 +185,7 @@ function tripal_chado_create_tripalfields_custom(&$info, $details, $entity_type,
   if (array_key_exists('dbxref_id', $schema['fields'])) {
     $field_name = $table_name . '__dbxref_id';
     $field_type = 'chado_base__dbxref_id';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'type' => $field_type,
       'cardinality' => 1,
@@ -589,6 +589,7 @@ function tripal_chado_create_tripalfields_linker(&$info, $details, $entity_type,
 }
 
 /**
+ * Impelments hook_create_tripalfield_instance().
  *
  * This is a Tripal defined hook that supports integration with the
  * TripalEntity field.
@@ -619,10 +620,13 @@ function tripal_chado_create_tripalfield_instance($entity_type, $bundle) {
   return $info;
 }
 /**
+ * Helper function for the hook_create_tripalfield_instance().
  *
- * @param unknown $entity_type
- * @param unknown $bundle
- * @param unknown $details
+ * Add the field instances that corresond to the columns of the base table.
+ *
+ * @param $entity_type
+ * @param $bundle
+ * @param $details
  */
 function tripal_chado_create_tripalfield_instance_base(&$info, $entity_type, $bundle, $details) {
   $fields = array();
@@ -785,15 +789,19 @@ function tripal_chado_create_tripalfield_instance_base(&$info, $entity_type, $bu
     elseif ($table_name == 'project' and $column_name == 'description') {
       $base_info['label'] = 'Short Description';
     }
-    $info[] = $base_info;
+    $info[$field_name] = $base_info;
   }
 }
 
 /**
+ * Helper function for the hook_create_tripalfield_instance().
  *
- * @param unknown $entity_type
- * @param unknown $bundle
- * @param unknown $details
+ * Adds custom fields for base fields.  These override the settings provided
+ * in the tripal_chado_create_tripalfield_instance_base() function.
+ *
+ * @param $entity_type
+ * @param $bundle
+ * @param $details
  */
 function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $bundle, $details) {
   $table_name = $details['chado_table'];
@@ -806,7 +814,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   // BASE DBXREF
   if (array_key_exists('dbxref_id', $schema['fields'])) {
     $field_name = $table_name . '__dbxref_id';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -841,7 +849,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
         $schema['fields']['organism_id']['not null']) {
       $is_required = TRUE;
     }
-    $info[] =  array(
+    $info[$field_name] =  array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -870,7 +878,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   // FEATURE MD5CHECKSUM
   if ($table_name == 'feature') {
     $field_name = $table_name . '__md5checksum';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -904,7 +912,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   // FEATURE RESIDUES
   if ($table_name == 'feature') {
     $field_name = 'feature__residues';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -933,7 +941,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   // FEATURE SEQLEN
   if ($table_name == 'feature') {
     $field_name = 'feature__seqlen';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -966,7 +974,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   $rel_table = $table_name . '_relationship';
   if (chado_table_exists($rel_table) and $bundle->label == 'gene') {
     $field_name = 'gene_transcripts';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -995,7 +1003,7 @@ function tripal_chado_create_tripalfield_instance_custom(&$info, $entity_type, $
   // ORGANISM TYPE_ID
   if ($table_name == 'organism' and array_key_exists('type_id', $schema['fields'])) {
     $field_name = 'organism__type_id';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1040,7 +1048,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $contact_table = $table_name . '_contact';
   if (chado_table_exists($contact_table)) {
     $field_name = $table_name . '_contact';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1072,7 +1080,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $cvterm_table = $table_name . '_cvterm';
   if (chado_table_exists($cvterm_table)) {
     $field_name = $table_name . '_cvterm';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1101,7 +1109,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   // DBXREF
   $dbxref_table = $table_name . '_dbxref';
   if (chado_table_exists($dbxref_table)) {
-    $info[] =  array(
+    $info[$field_name] =  array(
       'field_name' =>  $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1131,7 +1139,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $expression_table = $table_name . '_expression';
   if (chado_table_exists($expression_table)) {
     $field_name = $table_name . '_expression';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1160,7 +1168,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   // FEATURELOC
   if ($table_name == 'feature') {
     $field_name = 'featureloc';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1190,7 +1198,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $genotype_table = $table_name . '_genotype';
   if (chado_table_exists($genotype_table)) {
     $field_name = $table_name . '_genotype';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1220,7 +1228,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $phenotype_table = $table_name . '_phenotype';
   if (chado_table_exists($phenotype_table)) {
     $field_name = $table_name . '_phenotype';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1250,7 +1258,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $prop_table = $table_name . 'prop';
   if (chado_table_exists($prop_table)) {
     $field_name = $table_name . 'prop';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1280,7 +1288,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $pub_table = $table_name . '_pub';
   if (chado_table_exists($pub_table)) {
     $field_name = $table_name . '_pub';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1312,7 +1320,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $rel_table = $table_name . '_relationship';
   if (chado_table_exists($rel_table)) {
     $field_name = $table_name . '_relationship';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,
@@ -1342,7 +1350,7 @@ function tripal_chado_create_tripalfield_instance_linker(&$info, $entity_type, $
   $syn_table = $table_name . '_synonym';
   if (chado_table_exists($syn_table)) {
     $field_name = $table_name . '_synonym';
-    $info[] = array(
+    $info[$field_name] = array(
       'field_name' => $field_name,
       'entity_type' => $entity_type,
       'bundle' => $bundle->name,