function chado_organism_update
2.x tripal_organism.chado_node.inc | chado_organism_update($node) |
3.x tripal_organism.chado_node.inc | chado_organism_update($node) |
1.x tripal_organism.module | chado_organism_update($node) |
Implements hook_update().
Related topics
File
- legacy/
tripal_organism/ includes/ tripal_organism.chado_node.inc, line 469 - Implements the organims node content type
Code
function chado_organism_update($node) {
$chado_version = chado_get_version(TRUE);
// remove any white space around values
$node->genus = trim($node->genus);
$node->species = trim($node->species);
$node->abbreviation = trim($node->abbreviation);
$node->common_name = trim($node->common_name);
$node->description = trim($node->description['value']);
if ($chado_version > 1.2) {
$node->type_id = trim($node->type_id);
$node->infraspecific_name = trim($node->infraspecific_name);
}
$organism_id = chado_get_id_from_nid('organism', $node->nid);
if ($node->revision) {
// there is no way to handle revisions in Chado but leave
// this here just to make not we've addressed it.
}
$match = array(
'organism_id' => $organism_id,
);
$values = array(
'genus' => $node->genus,
'species' => $node->species,
'abbreviation' => $node->abbreviation,
'common_name' => $node->common_name,
'comment' => $node->description
);
if ($chado_version > 1.2) {
if ($node->type_id) {
$values['type_id'] = $node->type_id;
}
else {
$values['type_id'] = '__NULL__';
}
if ($node->infraspecific_name) {
$values['infraspecific_name'] = $node->infraspecific_name;
}
else {
$values['infraspecific_name'] = '__NULL__';
}
}
$org_status = chado_update_record('organism', $match, $values);
if ($node->organism_image != '') {
chado_organism_add_image($node);
}
// * Properties Form *
$details = array(
'property_table' => 'organismprop', // the name of the prop table
'base_table' => 'organism', // the name of your chado base table
'foreignkey_name' => 'organism_id', // the name of the key in your base table
'foreignkey_value' => $organism_id // the value of the example_id key
);
chado_update_node_form_properties($node, $details);
// * Additional DBxrefs Form *
$details = array(
'linking_table' => 'organism_dbxref', // the name of your _dbxref table
'foreignkey_name' => 'organism_id', // the name of the key in your base table
'foreignkey_value' => $organism_id // the value of the organism_id key
);
chado_update_node_form_dbxrefs($node, $details);
}