function chado_library_update
2.x tripal_library.chado_node.inc | chado_library_update($node) |
3.x tripal_library.chado_node.inc | chado_library_update($node) |
1.x tripal_library.module | chado_library_update($node) |
Implements hook_update().
Related topics
File
- legacy/
tripal_library/ includes/ tripal_library.chado_node.inc, line 352 - Implements the library node content type
Code
function chado_library_update($node) {
$node->libraryname = trim($node->libraryname);
$node->uniquename = trim($node->uniquename);
$node->description = trim($node->description['value']);
// update the library record
$library_id = chado_get_id_from_nid('library', $node->nid);
$match = array(
'library_id' => $library_id,
);
$values = array(
'name' => $node->libraryname,
'uniquename' => $node->uniquename,
'organism_id' => $node->organism_id,
'type_id' => $node->library_type,
);
$status = chado_update_record('library', $match, $values);
if (!$status) {
drupal_set_message(t('Unable to update library.', 'warning'));
watchdog('tripal_library', 'Update library: Unable to update library where values: %values',
array('%values' => print_r($values, TRUE)), WATCHDOG_ERROR);
}
// * Properties Form *
// add the description property
$properties = chado_retrieve_node_form_properties($node);
$descrip_id = tripal_get_cvterm(array(
'name' => 'Library Description',
'cv_id' => array('name' => 'library_property')
));
$properties[$descrip_id->cvterm_id][0] = $node->description;
$details = array(
'property_table' => 'libraryprop', // the name of the prop table
'base_table' => 'library', // the name of your chado base table
'foreignkey_name' => 'library_id', // the name of the key in your base table
'foreignkey_value' => $library_id // the value of the library_id key
);
chado_update_node_form_properties($node, $details, $properties);
// * Additional DBxrefs Form *
$details = array(
'linking_table' => 'library_dbxref', // the name of your _dbxref table
'foreignkey_name' => 'library_id', // the name of the key in your base table
'foreignkey_value' => $library_id // the value of the library_id key
);
chado_update_node_form_dbxrefs($node, $details);
}