Tripal
Functions
tripal_core.chado_nodes.relationships.api.inc File Reference

Functions

 chado_add_node_form_relationships (&$form, &$form_state, $details)
 
 chado_add_node_form_relationships_add_button_validate ($form, &$form_state)
 
 chado_add_node_form_relationships_add_button_submit ($form, &$form_state)
 
 chado_add_node_form_relationships_remove_button_validate ($form, &$form_state)
 
 chado_add_node_form_relationships_remove_button_submit (&$form, &$form_state)
 
 chado_add_node_form_relationships_create_relationship_formstate_array ($form, &$form_state)
 
 theme_chado_add_node_form_relationships_table ($variables)
 
 chado_retrieve_node_form_relationships ($node)
 
 chado_update_node_form_relationships ($node, $details, $retrieved_relationships=FALSE)
 
 chado_add_node_form_relationships_name_to_id_callback ($base_table, $name_field, $string)
 

Detailed Description

API to manage the chado _relationship table for various Tripal Node Types

How To Use:

function chado_example_form($form, &$form_state) {
// Default values for form elements can come in the following ways:
//
// 1) as elements of the $node object. This occurs when editing an existing
node
// 2) in the $form_state['values'] array which occurs on a failed validation
or
// ajax callbacks when the ajax call originates from non-submit fields
other
// than button
// 3) in the $form_state['input'] array which occurs on ajax callbacks from
submit
// form elements (e.g. buttons) and the form is being rebuilt but has not
yet
// been validated
//
// The reference elements added by this function do use AJAX calls from
buttons,
// therefore, it is important to check for form values in the
$form_state['values']
// for case #2 above, and in the $form_state['input'] for case #3.
// See the chado analysis node form for an example.
// Next, add in all the form array definition particular to your node type
// To add in the relationship form elements, you first need to prepare the
arguments
// for the function call.
$details = array(
'relationship_table' => 'example_relationship', // the name of the table
linking additional dbxrefs to this node
'base_table' => 'example', // the name of the chado
table this node links to
'base_foreign_key' => 'example_id', // key to link to the
chado content created by this node
'base_key_value' => $example_id, // the value of the above
key
'fieldset_title' => 'Relationships', // the non-translated
title for this fieldset
'additional_instructions' => '' // a non-stranslated
string providing additional instructions
);
// Finally, and add the additional form elements to the form
chado_add_node_form_relationships($form, $form_state, $details);
return $form;
}
function chado_example_insert($node) {
// if there is an example_id in the $node object then this must be a sync so
// we can skip adding the chado_example as it is already there, although
// we do need to proceed with the rest of the insert
if (!property_exists($node, 'example_id')) {
// Add record to chado example table
// Add to any other tables needed
// Add all relationships
// Existing _relationship links with the current example as either the
subject_id
// or object_id will be cleared and then re-added
$node,
'example_relationship',
$node->example_id
);
}
// Add record to chado_example linking example_id to new node
}
function chado_example_update($node) {
// Update record in chado example table
// Update any other tables needed
// Update all additional database references
// Existing _relationship links with the current example as either the
subject_id
// or object_id will be cleared and then re-added
$node,
'example_relationship',
$node->example_id
);
// Don't need to update chado_example linking table since niether example_id
or nid can be changed in update
}
chado_add_node_form_relationships(&$form, &$form_state, $details)
Definition: tripal_core.chado_nodes.relationships.api.inc:153
chado_update_node_form_relationships($node, $details, $retrieved_relationships=FALSE)
Definition: tripal_core.chado_nodes.relationships.api.inc:995

Function Documentation

◆ chado_add_node_form_relationships_add_button_submit()

chado_add_node_form_relationships_add_button_submit (   $form,
$form_state 
)

Called by the add button in chado_add_node_form_relationships

Create an array of additional relationships in the form state. This array will then be used to rebuild the form in subsequent builds

◆ chado_add_node_form_relationships_add_button_validate()

chado_add_node_form_relationships_add_button_validate (   $form,
$form_state 
)

Validate the user input for creating a new relationship. Called by the add button in chado_add_node_form_relationships.

◆ chado_add_node_form_relationships_create_relationship_formstate_array()

chado_add_node_form_relationships_create_relationship_formstate_array (   $form,
$form_state 
)

Creates an array in form_state containing the existing relationships. This array is then modified by the add/remove buttons and used as a source for rebuilding the form.

$form_state['chado_relationships'] = array( '[type_id]-[rank]' => array( 'object_id' => [the _relationship.object_id value], 'object_name' => [the base_table.uniquename value linked on base_foreign_key=object_id], 'subject_id' => [the _relationship.subject_id value], 'subject_name' => [the base_table.uniquename value linked on base_foreign_key=subject_id], 'type_id' => [the _relationship.type_id value], 'type_name' => [the cvterm.name value linked on type_id], 'rank' => [the _relationship.rank value], ), );

◆ chado_add_node_form_relationships_name_to_id_callback()

chado_add_node_form_relationships_name_to_id_callback (   $base_table,
  $name_field,
  $string 
)

Handles autocomplete for subject & object id

Parameters
$stringThe part of the string already typed in the textfield

◆ chado_add_node_form_relationships_remove_button_submit()

chado_add_node_form_relationships_remove_button_submit ( $form,
$form_state 
)

Remove the correct relationship from the form Called by the many remove buttons in chado_add_node_form_relationships

◆ chado_add_node_form_relationships_remove_button_validate()

chado_add_node_form_relationships_remove_button_validate (   $form,
$form_state 
)

Called by the many remove buttons in chado_add_node_form_relationships

◆ theme_chado_add_node_form_relationships_table()

theme_chado_add_node_form_relationships_table (   $variables)

Function to theme the add/remove relationships form into a table