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

Made sure that selecting a different vocabulary wiped the autocompleted term. If a value doesn't exist in the Relationship Type dropdown, show a message to contact site administrators. Removed all _info() function.

Chun-Huai Cheng пре 8 година
родитељ
комит
78bfa9b04b

+ 67 - 159
tripal_chado/includes/TripalFields/chado_base__dbxref_id.inc

@@ -23,101 +23,6 @@ class chado_base__dbxref_id 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_base__dbxref_id',
-//       'cardinality' => 1,
-//       'locked' => FALSE,
-//       'storage' => array(
-//         'type' => 'field_chado_storage',
-//       ),
-//       'settings' => array(
-//         'chado_table' => $table_name,
-//         'chado_column' => 'dbxref_id',
-//         'semantic_web' => tripal_get_chado_semweb_term($table_name, 'dbxref_id'),
-//       ),
-//     );
-//   }
-
-//   /**
-//    * @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' => 'Accession',
-//       'description' => 'This field specifies the unique stable accession (ID) for
-//         this record. It requires that this site have a database entry.',
-//       'required' => FALSE,
-//       'settings' => array(
-//         'auto_attach' => TRUE,
-//       ),
-//       'widget' => array(
-//         'type' => 'chado_base__dbxref_id_widget',
-//         'settings' => array(
-//           'display_label' => 1,
-//         ),
-//       ),
-//       'display' => array(
-//         'default' => array(
-//           'label' => 'inline',
-//           'type' => 'chado_base__dbxref_id_formatter',
-//           'settings' => array(),
-//         ),
-//       ),
-//     );
-//   }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_base__dbxref_id_widget' => array(
-        'label' => t('Accession'),
-        'field types' => array('chado_base__dbxref_id'),
-        'description' => t('This field specifies the unique stable accession (ID) for
-          this record. It requires that this site have a database entry.'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_base__dbxref_id_formatter' => array(
-        'label' => t('Accession'),
-        'field types' => array('chado_base__dbxref_id'),
-        'settings' => array(),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */
@@ -266,6 +171,73 @@ class chado_base__dbxref_id extends TripalField {
       '#markup' => l('Add a new database', 'admin/tripal/legacy/tripal_db/add', array('attributes' => array('target' => '_blank')))
     );
   }
+  
+  /**
+   * Callback function for validating the tripal_chado_dbxref_select_widget.
+   */
+  /**
+   * @see TripalField::submit()
+   */
+  public function widgetFormSubmit($entity_type, $entity, $langcode, &$items, $form, &$form_state) {
+    $field_name = $this->field['field_name'];
+    $field = $form_state['field'][$field_name]['und']['field'];
+    $settings = $field['settings'];
+    $field_name = $field['field_name'];
+    $field_type = $field['type'];
+    $field_table = $field['settings']['chado_table'];
+    $field_column = $field['settings']['chado_column'];
+    $field_prefix = $field_table . '__' . $field_column;
+  
+  
+    // If the form ID is field_ui_field_edit_form, then the user is editing the
+    // field's values in the manage fields form of Drupal.  We don't want
+    // to validate it as if it were being used in a data entry form.
+    if ($form_state['build_info']['form_id'] =='field_ui_field_edit_form') {
+      return;
+    }
+  
+    // Get the field values.
+    //   $fk_value = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_table . '__' . $field_column);
+    //   $dbxref_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--dbxref_id');
+    //   $db_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--db_id');
+    //   $accession = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--accession');
+    //   $version = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--version');
+    //   $description = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--description');
+  
+    // Make sure that if a database ID is provided that an accession is also
+    // provided.  Here we use the form_set_error function rather than the
+    // form_error function because the form_error will add a red_highlight
+    // around all of the fields in the fieldset which is confusing as it's not
+    // 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) {
+      form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--db_id', t("A database and the accession must both be provided for the primary cross reference."));
+    }
+    if ($db_id and !$accession) {
+      form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--accession', t("A database and the accession must both be provided for the primary cross reference."));
+    }
+    if (!$db_id and !$accession and ($version or $description)) {
+      form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--db_id', t("A database and the accession must both be provided for the primary cross reference."));
+    }
+  
+    // If user did not select a database, we want to remove dbxref_id from the
+    // field.
+    if (!$db_id) {
+      tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__', 0, $field_prefix . '--dbxref_id');
+      tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__', 0, $field_table . '__' . $field_column);
+    }
+    // If the dbxref_id does not match the db_id + accession then the user
+    // has selected a new dbxref record and we need to update the hidden
+    // value accordingly.
+    if ($db_id and $accession) {
+      $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
+      if ($dbxref and $dbxref->dbxref_id != $dbxref_id) {
+        tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, 0, $field_table . '__' . $field_column);
+        tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, 0, $field_prefix . '--dbxref_id');
+      }
+    }
+  }
 
   /**
    * @see TripalField::load()
@@ -317,70 +289,6 @@ class chado_base__dbxref_id extends TripalField {
   }
 }
 
-/**
- * Callback function for validating the tripal_chado_dbxref_select_widget.
- */
-function chado_base__dbxref_id_widget_validate($element, &$form_state) {
-  $field_name = $element['#parents'][0];
-  $field = $form_state['field'][$field_name]['und']['field'];
-  $settings = $field['settings'];
-  $field_name = $field['field_name'];
-  $field_type = $field['type'];
-  $field_table = $field['settings']['chado_table'];
-  $field_column = $field['settings']['chado_column'];
-  $field_prefix = $field_table . '__' . $field_column;
-
-
-  // If the form ID is field_ui_field_edit_form, then the user is editing the
-  // field's values in the manage fields form of Drupal.  We don't want
-  // to validate it as if it were being used in a data entry form.
-  if ($form_state['build_info']['form_id'] =='field_ui_field_edit_form') {
-    return;
-  }
-
-  // Get the field values.
-//   $fk_value = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_table . '__' . $field_column);
-//   $dbxref_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--dbxref_id');
-//   $db_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--db_id');
-//   $accession = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--accession');
-//   $version = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--version');
-//   $description = tripal_chado_get_field_form_values($field_name, $form_state, 0, $field_prefix . '--description');
-
-  // Make sure that if a database ID is provided that an accession is also
-  // provided.  Here we use the form_set_error function rather than the
-  // form_error function because the form_error will add a red_highlight
-  // around all of the fields in the fieldset which is confusing as it's not
-  // 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) {
-    form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--db_id', t("A database and the accession must both be provided for the primary cross reference."));
-  }
-  if ($db_id and !$accession) {
-    form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--accession', t("A database and the accession must both be provided for the primary cross reference."));
-  }
-  if (!$db_id and !$accession and ($version or $description)) {
-    form_set_error(implode('][', $element ['#parents']) . '][' . $field_prefix . '--db_id', t("A database and the accession must both be provided for the primary cross reference."));
-  }
-
-  // If user did not select a database, we want to remove dbxref_id from the
-  // field.
-  if (!$db_id) {
-    tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__', 0, $field_prefix . '--dbxref_id');
-    tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__', 0, $field_table . '__' . $field_column);
-  }
-  // If the dbxref_id does not match the db_id + accession then the user
-  // has selected a new dbxref record and we need to update the hidden
-  // value accordingly.
-  if ($db_id and $accession) {
-    $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
-    if ($dbxref and $dbxref->dbxref_id != $dbxref_id) {
-      tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, 0, $field_table . '__' . $field_column);
-      tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, 0, $field_prefix . '--dbxref_id');
-    }
-  }
-}
-
 /**
  * An Ajax callback for the tripal_chado_admin_publish_form..
  */

+ 0 - 46
tripal_chado/includes/TripalFields/chado_linker__cvterm.inc

@@ -23,52 +23,6 @@ class chado_linker__cvterm extends TripalField {
   // this field.
   public static $default_storage = 'field_chado_storage';
 
-
-  /**
-   * @see TripalField::create_info()
-   */
-  function createInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-    // This field is only attached by the chado_linker__cvterm_addr field.
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->can_attach) {
-      return;
-    }
-
-    // This field is only attached by the chado_linker__cvterm_addr field.
-  }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__cvterm_widget' => array(
-        'label' => t('Annotations'),
-        'field types' => array('chado_linker__cvterm'),
-        'description' => t('This record can be annotated with terms
-              from other vocabularies.'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_linker__cvterm_formatter' => array(
-        'label' => t('Annotations'),
-        'field types' => array('chado_linker__cvterm'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */

+ 0 - 103
tripal_chado/includes/TripalFields/chado_linker__dbxref.inc

@@ -34,109 +34,6 @@ class chado_linker__dbxref 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'];
-
-    $dbxref_table = $table_name . '_dbxref';
-    $schema = chado_get_schema($dbxref_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' =>  $this->field_name,
-      'type' => 'chado_linker__dbxref',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $dbxref_table,
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-        'semantic_web' => 'SBO:0000554',
-      ),
-    );
-  }
-  /**
-   * @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'];
-
-    $dbxref_table = $table_name . '_dbxref';
-    return array(
-      'field_name' =>  $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Cross References',
-      'description' => 'The IDs where this record may be available in other external online databases.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__dbxref_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_linker__dbxref_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__dbxref_widget' => array(
-        'label' => t('Cross references'),
-        'field types' => array('chado_linker__dbxref'),
-        'description' => t('This record can be cross referenced with a record
-            in another online database. This field is intended for the most
-            prominent reference.  At a minimum, the database and accession
-            must be provided.'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_linker__dbxref_formatter' => array(
-        'label' => t('Cross references'),
-        'field types' => array('chado_linker__dbxref'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */

+ 1 - 100
tripal_chado/includes/TripalFields/chado_linker__expression.inc

@@ -22,106 +22,7 @@ class chado_linker__expression extends TripalField {
   // Set this to the name of the storage backend that by default will support
   // 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'];
-
-    $schema = chado_get_schema('featureloc');
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__expression',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $table_name . '_expression',
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-        'semantic_web' => 'local:expression',
-      ),
-    );
-  }
-  /**
-   * @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' => 'Expression',
-      'description' => 'Information about the expression of this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__expression_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__expression_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
- public static function widgetInfo() {
-    return array(
-      'chado_linker__expression_widget' => array(
-        'label' => t('Expressions'),
-        'field types' => array('chado_linker__expression'),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_linker__expression_formatter' => array(
-        'label' => t('Expression'),
-        'field types' => array('chado_linker__expression'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
+  
   /**
    * @see TripalField::formatterView()
    */

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

@@ -23,106 +23,6 @@ class chado_linker__featureloc 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'];
-
-    $schema = chado_get_schema('featureloc');
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__featureloc',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => 'featureloc',
-        'chado_column' => $pkey,
-        'base_table' => 'feature',
-        'semantic_web' => 'SO:position_of',
-      ),
-    );
-  }
-  /**
-   * @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' => 'Aligned Locations',
-      'description' => 'The locations on other genomic sequences where this
-        record has been aligned.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__featureloc_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__featureloc_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__featureloc_widget' => array(
-        'label' => t('Aligned Locations'),
-        'field types' => array('chado_linker__featureloc')
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_linker__featureloc_formatter' => array(
-        'label' => t('Aligned Locations'),
-        'field types' => array('chado_linker__featureloc'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
-
   /**
    * @see TripalField::formatter_settings_summary()
    */

+ 0 - 73
tripal_chado/includes/TripalFields/chado_linker__genotype.inc

@@ -23,79 +23,6 @@ class chado_linker__genotype 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'];
-
-    $genotype_table = $table_name . '_genotype';
-    $schema = chado_get_schema($genotype_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__genotype',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $genotype_table,
-        'chado_column' => $pkey,
-        'semantic_web' => 'SO:0001027',
-        'base_table' => $table_name,
-      ),
-    );
-  }
-  /**
-   * @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' => 'Genotypes',
-      'description' => 'The genotypes associated with this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__genotype_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__genotype_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
   /**
    * @see TripalField::formatterView()
    */

+ 0 - 74
tripal_chado/includes/TripalFields/chado_linker__phenotype.inc

@@ -23,80 +23,6 @@ class chado_linker__phenotype 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'];
-
-    $phenotype_table = $table_name . '_phenotype';
-    $schema = chado_get_schema($phenotype_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__phenotype',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $phenotype_table,
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-        'semantic_web' => 'SBO:0000358',
-      ),
-    );
-  }
-  /**
-   * @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' => 'Phenotypes',
-      'description' => 'The phenotypes associated with this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__phenotype_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__phenotype_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-
-  }
-
   /**
    * @see TripalField::formatterView()
    */

+ 0 - 78
tripal_chado/includes/TripalFields/chado_linker__prop_adder.inc

@@ -23,84 +23,6 @@ class chado_linker__prop_adder 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'];
-
-    $prop_table = $table_name . 'prop';
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__prop_adder',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-      ),
-    );
-  }
-  /**
-   * @see TripalField::createInstanceInfo()
-   */
-  function createInstanceInfo() {
-    if (!$this->canAttach()) {
-      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'];
-
-    $prop_table = $table_name . 'prop';
-    return array(
-      'field_name' => $this->field_name,
-      'entity_type' => $this->entity_type,
-      'bundle' => $this->bundle->name,
-      'label' => 'Add Properties',
-      'description' => 'Add additional property types to this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__prop_adder_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__prop_adder_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__prop_adder_widget' => array(
-        'label' => t('Add a Property'),
-        'field types' => array('chado_linker__prop_adder'),
-      ),
-    );
-  }
   /**
    * @see TripalField::widgetForm()
    */

+ 0 - 98
tripal_chado/includes/TripalFields/chado_linker__pub.inc

@@ -24,104 +24,6 @@ class chado_linker__pub 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'];
-
-    $pub_table = $table_name . '_pub';
-    $schema = chado_get_schema($pub_table);
-    $pkey = $schema['primary key'][0];
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__pub',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $pub_table,
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-        'semantic_web' => 'schema:publication',
-      ),
-    );
-  }
-  /**
-   * @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' => 'Publications',
-      'description' => 'This record has been referenced or is sourced from
-        these publications.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__pub_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'above',
-          'type' => 'chado_linker__pub_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-
-  }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__pub_widget' => array(
-        'label' => t('Publications'),
-        'field types' => array('chado_linker__pub'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_linker__pub_formatter' => array(
-        'label' => t('Publications'),
-        'field types' => array('chado_linker__pub'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */

+ 18 - 6
tripal_chado/includes/TripalFields/chado_linker__relationship.inc

@@ -251,8 +251,9 @@ class chado_linker__relationship extends TripalField {
     if (isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_name'])) {
       $default_term = $form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_name'];
     }
-    $default_type_id = '';
-    if (isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_id'])) {
+
+    $default_type_id = $type_id;
+    if (!$type_id && isset($form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_id'])) {
       $default_type_id = $form_state['field'][$field_name]['und']['instance']['default_value'][0]['type_id'];
     }
     // Option 3: Custom list of Relationship Types
@@ -281,6 +282,9 @@ class chado_linker__relationship extends TripalField {
         '#options' => $rtype_options,
         '#default_value' => $default_type_id,
       );
+      if ($type_id && !key_exists($type_id, $rtype_options)) {
+        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
+      }
     }
     // Option 2: Child terms of a selected cvterm
     else if ($option2_vocab) {
@@ -328,6 +332,9 @@ class chado_linker__relationship extends TripalField {
         '#options' => $rtype_options,
         '#default_value' => $default_type_id,
       );
+      if ($type_id && !key_exists($type_id, $rtype_options)) {
+        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
+      }
     }
     // Option 1: All terms of selected vocabularies
     else if ($option1_test && array_pop($option1_test)) {
@@ -342,6 +349,9 @@ class chado_linker__relationship extends TripalField {
         '#options' => $rtype_options,
         '#default_value' => $default_type_id,
       );
+      if ($type_id && !key_exists($type_id, $rtype_options)) {
+        form_set_error($this->field['field_name'] . '[' . $langcode . '][' . $delta . '][type_id]', 'Illegal option detected for Relationship Type. Please contact site administrator to fix the problem');
+      }
     }
     // Default option:
     else {
@@ -412,7 +422,7 @@ class chado_linker__relationship extends TripalField {
       $subject_id = $item[$field_table . '__subject_id'];
       $object_id = $item[ $field_table . '__object_id'];
       $type_id = $item[$field_table . '__type_id'];
-      $type_id = $type_id ? $type_id : $item['type_id'];
+      $type_id = isset($item['type_id']) ? $item['type_id'] : $type_id;
       $type_name = isset($item['type_name']) ? $item['type_name'] : '';
       $subject_name = $item['subject_name'];
       $object_name = $item['object_name'];
@@ -558,7 +568,7 @@ class chado_linker__relationship extends TripalField {
       $subject_id = $item[$field_table . '__subject_id'];
       $object_id = $item[ $field_table . '__object_id'];
       $type_id = $item[$field_table . '__type_id'];
-      $type_id = $type_id ? $type_id : $item['type_id'];
+      $type_id = isset($item['type_id']) ? $type_id : $item['type_id'];
       $type_name = $item['type_name'];
       $subject_name = $item['subject_name'];
       $object_name = $item['object_name'];
@@ -1174,12 +1184,14 @@ function chado_linker__relationship_widget_form_ajax_callback(&$form, $form_stat
 /**
  * An Ajax callback for the relationshp instance setting form.
  */
-function chado_linker__relationship_instance_settings_form_ajax_callback(&$form, $form_state) {
+function chado_linker__relationship_instance_settings_form_ajax_callback(&$form, &$form_state) {
   $acpath  = $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_path'];
   $acpath .=  $form_state['values']['instance']['settings']['relationships']['option2_vocab'] . '/';
   $urlval  = $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_input']['#url_value'];
   $urlval .=  $form_state['values']['instance']['settings']['relationships']['option2_vocab'];
-
+  // Reset value if a different vocabulary is selected
+  $form['instance']['settings']['relationships']['option2_parent']['#value'] = NULL;
+  $form_state['values']['instance']['settings']['relationships']['option2_parent'] = NULL;
   $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_path'] = $acpath;
   $form['instance']['settings']['relationships']['option2_parent']['#autocomplete_input']['#url_value'] = $urlval;
   return $form['instance']['settings']['relationships']['option2_parent'];

+ 0 - 97
tripal_chado/includes/TripalFields/chado_linker__synonym.inc

@@ -23,103 +23,6 @@ class chado_linker__synonym 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'];
-
-    $syn_table = $table_name . '_synonym';
-    $schema = chado_get_schema($syn_table);
-    $pkey = $schema['primary key'][0];
-
-    return array(
-      'field_name' => $this->field_name,
-      'type' => 'chado_linker__synonym',
-      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => $syn_table,
-        'chado_column' => $pkey,
-        'base_table' => $table_name,
-        'semantic_web' => 'schema:alternateName',
-      ),
-    );
-  }
-  /**
-   * @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' => 'Synonyms',
-      'description' => 'Alternate names, aliases or synonyms for this record.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => FALSE,
-      ),
-      'widget' => array(
-        'type' => 'chado_linker__synonym_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_linker__synonym_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_linker__synonym_widget' => array(
-        'label' => t('Synonyms'),
-        'field types' => array('chado_linker__synonym'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  static function formatterInfo() {
-    return array(
-      'chado_linker__synonym_formatter' => array(
-        'label' => t('Synonyms'),
-        'field types' => array('chado_linker__synonym'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
   /**
    * @see TripalField::formatterView()
    */

+ 0 - 93
tripal_chado/includes/TripalFields/chado_organism__type_id.inc

@@ -22,99 +22,6 @@ class chado_organism__type_id extends TripalField {
   // Set this to the name of the storage backend that by default will support
   // 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_organism__type_id',
-      'cardinality' => 1,
-      'locked' => FALSE,
-      'storage' => array(
-        'type' => 'field_chado_storage',
-      ),
-      'settings' => array(
-        'chado_table' => 'organism',
-        'chado_column' => 'type_id',
-        'semantic_web' => tripal_get_chado_semweb_term('organism', 'type_id'),
-      ),
-    );
-  }
-  /**
-   * @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' => 'Infraspecific Type',
-      'description' => 'The Infraspecific Type.',
-      'required' => FALSE,
-      'settings' => array(
-        'auto_attach' => TRUE,
-      ),
-      'widget' => array(
-        'type' => 'chado_organism__type_id_widget',
-        'settings' => array(
-          'display_label' => 1,
-        ),
-      ),
-      'display' => array(
-        'default' => array(
-          'label' => 'inline',
-          'type' => 'chado_organism__type_id_formatter',
-          'settings' => array(),
-        ),
-      ),
-    );
-  }
-
-  /**
-   * @see TripalField::widgetInfo()
-   */
-  public static function widgetInfo() {
-    return array(
-      'chado_organism__type_id_widget' => array(
-        'label' => t('Infraspecific Type'),
-        'field types' => array('chado_organism__type_id'),
-      ),
-    );
-  }
-  /**
-   * @see TripalField::formatterInfo()
-   */
-  public static function formatterInfo() {
-    return array(
-      'chado_organism__type_id_formatter' => array(
-        'label' => t('Infraspecific Type'),
-        'field types' => array('chado_organism__type_id'),
-        'settings' => array(
-        ),
-      ),
-    );
-  }
 
   /**
    * @see TripalField::widget()