Tripal
Functions
Legacy Chado CV

Functions

 tripal_get_default_cv ($table, $field)
 
 tripal_get_default_cv_table ($cv_id)
 
 tripal_get_cvterm_default_select_options ($table, $field, $field_desc)
 
 tripal_set_default_cv ($table, $field, $cv_name, $cv_id=FALSE)
 

Detailed Description

Provides an application programming interface (API) to manage entities that use Chado as their base data.

Function Documentation

◆ tripal_get_cvterm_default_select_options()

tripal_get_cvterm_default_select_options (   $table,
  $field,
  $field_desc 
)

Create an options array to be used in a form element which provides a list of all chado cvterms. Unlike the tripal_get_cvterm_select_option, this function retrieves the cvterms using the default vocabulary set for a given table and field. It will also notify the administrative user if a default vocabulary is missing for the field and if the vocabulary is empty.

Parameters
$tableThe name of the table that contains the field with a foreign key relationship to the cvterm table
$fieldThe table field name that has the foreign key relationship to the cvterm table for which the default vocabulary will be set
$field_descA human readable descriptive name for the field
Returns
An array(cvterm_id => name) for each cvterm in the chado cvterm table where cv_id=that supplied

◆ tripal_get_default_cv()

tripal_get_default_cv (   $table,
  $field 
)

Retrieves the default vocabulary for a given table and field.

Each table in Chado that has a 'type_id' (or foreign key constraint to the cvterm table) will have a default vocabulary assigned. This indicates to Tripal that terms in that vocabulary are used to set the type_id for that table. An example where this is used is the tripal_get_cvterm_select_options() function which generates a list of options for a select box used in a Drupal form. The select box will list the terms from the default vocabulary in the drop down.

This function uses the Chado table and field name (e.g. 'type_id') to retrieve the vocabulary assgined.

Parameters
$tableThe name of the table that contains a field with a foreign key relationship to the cvterm table
$fieldThe table field name that has the foreign key relationship to the cvterm table for which the default vocabulary will be set
Returns
The cv object of the default vocabulary or an empty array if not available.

◆ tripal_get_default_cv_table()

tripal_get_default_cv_table (   $cv_id)

Retrieves the Chado table to which a vocbulary is set as default.

Each table in Chado that has a 'type_id' (or foreign key constraint to the cvterm table) will have a default vocabulary assigned. This indicates to Tripal that terms in that vocabulary are used to set the type_id for that table. An example where this is used is the tripal_get_cvterm_select_options() function which generates a list of options for a select box used in a Drupal form. The select box will list the terms from the default vocabulary in the drop down.

This function uses the vocabulary ID to get the Chado table to which it is assigned.

Parameters
$cv_idThe ID of the vocabulary.
Returns
If an assignment is present, an object containing the 'table_name' and 'field_name' is returned.

◆ tripal_set_default_cv()

tripal_set_default_cv (   $table,
  $field,
  $cv_name,
  $cv_id = FALSE 
)

This function sets the default vocabulary for a given table and field.

Parameters
$tableThe name of the table that contains a field with a foreign key relationship to the cvterm table
$fieldThe table field name that has the foreign key relationship to the cvterm table for which the default vocabulary will be set
$cv_nameThe name of the vocabulary
Returns
TRUE if set, FALSE if an error occured