From d3cb449f5c6ab2b625b3774208efa476dbb04553 Mon Sep 17 00:00:00 2001 From: Stephen Ficklin Date: Wed, 5 Oct 2016 12:13:53 -0700 Subject: [PATCH] Bug fix in chado_select_record() and some in-line document changes --- .../api/tripal_core.chado_query.api.inc | 5 +- tripal_cv/api/tripal_cv.api.inc | 53 ++++++++++++------- tripal_db/api/tripal_db.api.inc | 14 ++--- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/tripal_core/api/tripal_core.chado_query.api.inc b/tripal_core/api/tripal_core.chado_query.api.inc index 183b676c5..849444ef4 100644 --- a/tripal_core/api/tripal_core.chado_query.api.inc +++ b/tripal_core/api/tripal_core.chado_query.api.inc @@ -1082,11 +1082,12 @@ function chado_select_record($table, $columns, $values, $options = NULL) { // Get the table description. $table_desc = chado_get_schema($table); - if (empty($table_desc)) { - tripal_report_error('tripal_core', TRIPAL_WARNING, + if (!is_array($table_desc)) { + tripal_report_error('tripal_chado', TRIPAL_WARNING, 'chado_insert_record; There is no table description for !table_name', array('!table_name' => $table), array('print' => $print_errors) ); + return FALSE; } $select = ''; diff --git a/tripal_cv/api/tripal_cv.api.inc b/tripal_cv/api/tripal_cv.api.inc index 03b62debe..a48cee60f 100644 --- a/tripal_cv/api/tripal_cv.api.inc +++ b/tripal_cv/api/tripal_cv.api.inc @@ -128,30 +128,31 @@ function tripal_get_cv_select_options() { * Retrieves a chado controlled vocabulary term variable * * @param $identifier - * An array with the key stating what the identifier is. Supported keys (only one of the - * following unique keys are required): - * - cvterm_id: the chado cv.cvterm_id primary key - * - name: the chado cvterm.name field (assume unique) - * There are also some specially handled keys. They are: - * - cv_id: an integer indicating the cv_id or an array with 'name' => the name of the cv. - * - synonym: an array with 'name' => the name of the synonym of the cvterm you want - * returned; 'cv_id' => the cv_id of the synonym; 'cv_name' => the name of the cv - * of the synonym - * - property: An array/object describing the property to select records for. It - * should at least have either a type_name (if unique across cvs) or type_id. Other - * supported keys include: cv_id/cv_name (of the type), value and rank + * An array apropriate for use with the chado_generate_var for uniquely + * identifying a cvterm record. Alternativley, there are also some specially + * handled keys. They are: + * - cv_id: an integer indicating the cv_id or an array with 'name' => the + * name of the cv. + * - synonym: an array with 'name' => the name of the synonym of the cvterm + * you want returned; 'cv_id' => the cv_id of the synonym; 'cv_name' => + * the name of the cv of the synonym + * - property: An array/object describing the property to select records + * for. It should at least have either a type_name (if unique across cvs) + * or type_id. Other supported keys include: cv_id/cv_name (of the type), + * value and rank * @param $options * An array of options. Supported keys include: - * - Any keys supported by chado_generate_var(). See that function definition for - * additional details. + * - Any keys supported by chado_generate_var(). See that function + * definition for additional details. * - * NOTE: the $identifier parameter can really be any array similar to $values passed into - * chado_select_record(). It should fully specify the cvterm record to be returned. + * NOTE: the $identifier parameter can really be any array similar to $values + * passed into chado_select_record(). It should fully specify the cvterm + * record to be returned. * * @return - * If unique values were passed in as an identifier then an object describing the cvterm - * will be returned (will be a chado variable from chado_generate_var()). Otherwise, - * FALSE will be returned. + * If unique values were passed in as an identifier then an object describing + * the cvterm will be returned (will be a chado variable from + * chado_generate_var()). Otherwise, FALSE will be returned. * * @ingroup tripal_cv_api */ @@ -1082,7 +1083,19 @@ function tripal_set_default_cv($table, $field, $cv_name, $cv_id = FALSE) { } /** - * Retreives the default vocabulary for a given table and field + * Retreives 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 + * retreive the vocabulary assgined. + * * @param $table * The name of the table that contains a field with a foreign key * relationship to the cvterm table diff --git a/tripal_db/api/tripal_db.api.inc b/tripal_db/api/tripal_db.api.inc index d237eb42c..c1dcff6ac 100644 --- a/tripal_db/api/tripal_db.api.inc +++ b/tripal_db/api/tripal_db.api.inc @@ -141,7 +141,7 @@ function tripal_get_db_select_options() { $options = array(); $options[] = 'Select a Database'; - + foreach ($dbs as $db) { $options[$db->db_id] = $db->name; } @@ -179,10 +179,12 @@ function tripal_get_db_select_options() { * @endcode * * @param $identifier - * An array with the key stating what the identifier is. Supported keys (only one of the - * following unique keys is required): - * - dbxref_id: the chado dbxref.dbxref_id primary key - * - accession: the chado dbxref.accession field (assume unique) + * An array apropriate for use with the chado_generate_var for uniquely + * identifying a dbxref record. Alternatively, there are also some specially + * handled keys. They are: + * - property: An array/object describing the property to select records for. It + * should at least have either a type_name (if unique across cvs) or type_id. Other + * supported keys include: cv_id/cv_name (of the type), value and rank * There are also some specially handled keys. They are: * - property: An array/object describing the property to select records for. It * should at least have either a type_name (if unique across cvs) or type_id. Other @@ -240,7 +242,7 @@ function tripal_get_dbxref($identifiers, $options = array()) { $property = $identifiers['property']; unset($identifiers['property']); $dbxref = chado_get_record_with_property( - array('table' => 'dbxref', 'base_records' => $identifiers), + array('table' => 'dbxref', 'base_records' => $identifiers), array('type_name' => $property), $options );