Tripal
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy Class Reference
Inheritance diagram for Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy:
Collaboration graph
[legend]

Public Member Functions

 getDb (array $conditions, array $options=[])
 
 getDbxref (array $conditions, array $options=[])
 
 getDbxrefUrl (ChadoBuddyRecord $dbxref, array $options=[])
 
 insertDb (array $values, array $options=[])
 
 insertDbxref (array $values, array $options=[])
 
 updateDb (array $values, array $conditions, array $options=[])
 
 updateDbxref (array $values, array $conditions, array $options=[])
 
 upsertDb (array $values, array $options=[])
 
 upsertDbxref (array $values, array $options=[])
 
 associateDbxref (string $base_table, int $record_id, ChadoBuddyRecord $dbxref, array $options=[])
 
- Public Member Functions inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
 __construct (array $configuration, $plugin_id, $plugin_definition, ChadoConnection $connection)
 
 label ()
 
 description ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
- Public Attributes inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
ChadoConnection $connection
 
- Protected Member Functions inherited from Drupal\tripal_chado\ChadoBuddy\ChadoBuddyPluginBase
 getTableColumns (array $chado_tables, string $filter='all')
 
 getTableCache ()
 
 addTableToCache (string $chado_table, array &$cached_tables)
 
 makeUpsertConditions (array $values, array $key_columns)
 
 makeAlias (string $name)
 
 unmakeAlias (string $name)
 
 removeTablePrefix (array $values)
 
 addConditions (object &$query, array $conditions, array $options)
 
 validateInput (array $user_values, array $valid_values)
 
 dereferenceBuddyRecord (array $values)
 
 subsetInput (array $user_values, array $valid_tables)
 
 validateOutput ($output_records, array $values)
 

Member Function Documentation

◆ associateDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::associateDbxref ( string  $base_table,
int  $record_id,
ChadoBuddyRecord  $dbxref,
array  $options = [] 
)

Add a record to a database reference linking table (ie: feature_dbxref).

Parameters
string$base_tableThe base table for which the dbxref should be associated. Thus to associate a dbxref with a feature the basetable=feature and dbxref_id is added to the feature_dbxref table.
int$record_idThe primary key of the basetable to associate the dbxref with.
ChadoBuddyRecord$dbxrefA dbxref object returned by any of the *Dbxref() in this service.
$options'pkey': Looking up the primary key for the base table is costly. If it is known, then pass it in as this option for better performance. Also pass in any other columns used in the linking table, some of which may have a NOT NULL constraint.
Returns
bool Returns true if successful. Both the dbxref and the chado record indicated by $record_id MUST ALREADY EXIST.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ getDb()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::getDb ( array  $conditions,
array  $options = [] 
)

Retrieves a chado database record.

Parameters
array$conditionsAn array where the key is a chado table name+dot+column name. Valid keys include:
  • db.db_id
  • db.name
  • db.description
  • db.urlprefix
  • db.url
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) Associative array of options.
  • 'case_insensitive' - a single key, or an array of keys to query case insensitively.
Returns
array An array of ChadoBuddyRecord objects. More specifically, (1) if the select values return a single record then we return an array containing a single ChadoBuddyRecord describing the record. (2) if the select values return multiple records, then we return an array of ChadoBuddyRecords describing the results. (3) if there are no results then we return an empty array.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ getDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::getDbxref ( array  $conditions,
array  $options = [] 
)

Retrieves a chado database reference.

Parameters
array$conditionsAn array where the key is a column in chado and the value describes the dbxref you want to select. Valid keys include:
  • dbxref.dbxref_id
  • dbxref.db_id
  • dbxref.description
  • dbxref.accession
  • dbxref.version
  • db.db_id
  • db.name
  • db.description
  • db.urlprefix
  • db.url
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) Associative array of options.
  • 'case_insensitive' - a single key, or an array of keys to query case insensitively.
Returns
array An array of ChadoBuddyRecord objects. More specifically, (1) if the select values return a single record then we return an array containing a single ChadoBuddyRecord describing the record. (2) if the select values return multiple records, then we return an array of ChadoBuddyRecords describing the results. (3) if there are no results then we return an empty array.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ getDbxrefUrl()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::getDbxrefUrl ( ChadoBuddyRecord  $dbxref,
array  $options = [] 
)

Generates a URL for a database reference (e.g. the reference for a cvterm).

If the URL prefix is provided for the database record of a cvterm, then a URL can be created for the term. By default, the db name and dbxref accession are concatenated and appended to the end of the urlprefix. But Tripal supports the use of {db} and {accession} tokens in the db.urlprefix string. If present, they will be replaced with the db name and dbxref accession, respectively.

Parameters
ChadoBuddyRecord$dbxrefA dbxref object retrieved by getDbxref().
array$options(Optional) None supported yet. Here for consistency.
Returns
string A string containing the URL. If this database doesn't have a URL prefix, then the built in version for your Tripal site will be used.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

Todo:
the built in page for cv/lookup is not yet implemented for Tripal 4

◆ insertDb()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::insertDb ( array  $values,
array  $options = [] 
)

Adds a new database to the Chado DB table and returns the DB object.

Parameters
$valuesAn associative array of the values of the db (those to be inserted):
  • db.db_id: not valid for an insert.
  • db.name: The name of the database. This name is usually used as the prefix for CV term accessions.
  • db.description: (Optional) A description of the database. By default no description is required.
  • db.url: (Optional) The URL for the database.
  • db.urlprefix: (Optional) The URL that is to be used as a prefix when constructing a link to a database term.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted ChadoBuddyRecord will be returned on success and an exception will be thrown if an error is encountered. If the record already exists then an error will be thrown... if this is not the desired behaviour then use the upsert version of this method.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ insertDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::insertDbxref ( array  $values,
array  $options = [] 
)

Add a database cross reference. The database must already exist. If necessary first create it with insertDb().

Parameters
$valuesAn associative array of the values to be inserted including:
  • dbxref.dbxref_id: not valid for an insert.
  • dbxref.db_id or db.db_id: (Required) the database_id of the database the reference is to.
  • dbxref.description: (Optional) description.
  • dbxref.accession: (Requried) the accession.
  • dbxref.version: (Optional) The version of the database reference.
  • db.name: may be used in place of db.db_id or dbxref.db_id if that is not available.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted ChadoBuddyRecord will be returned on success and an exception will be thrown if an error is encountered. If the record already exists then an error will be thrown... if this is not the desired behaviour then use the upsert version of this method.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ updateDb()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::updateDb ( array  $values,
array  $conditions,
array  $options = [] 
)

Updates an existing database. Generally use either the db.db_id or db.name in the $conditions array to select the existing record. db.db_id in the $values array will be ignored.

Parameters
array$valuesAn associative array of the values for the final record (i.e what you want to update the record to be) including:
  • db.db_id: primary key for db table.
  • db.name: The name of the database. This name is usually used as the prefix for CV term accessions.
  • db.description: (Optional) A description of the database. By default no description is required.
  • db.url: (Optional) The URL for the database.
  • db.urlprefix: (Optional) The URL that is to be used as a prefix when constructing a link to a database term.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$conditionsAn associative array of the conditions to find the record to update. The same keys are supported as those indicated for the $values.
array$options(Optional) None supported yet. Here for consistency.
Returns
bool|ChadoBuddyRecord The updated ChadoBuddyRecord will be returned on success, FALSE will be returned if no record was found to update.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ updateDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::updateDbxref ( array  $values,
array  $conditions,
array  $options = [] 
)

Updates an existing database reference.

Generally use either dbxref.dbxref_id or a combination of dbxref.db_id and dbxref.accession in the $conditions to select the existing record. dbxref.dbxref_id in the $values array will be ignored.

Parameters
array$valuesAn associative array of the values for the final record (i.e what you want to update the record to be) including:
  • dbxref.dbxref_id: the primary key of the dbxref table.
  • dbxref.db_id or db.db_id: The database_id of the database the reference is to.
  • dbxref.description: Description.
  • dbxref.accession: The accession.
  • dbxref.version: The version of the database reference.
  • db.name: may be used in place of db.db_id or dbxref.db_id if that is not available.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$conditionsAn associative array of the conditions to find the record to update. The same keys are supported as those indicated for the $values.
array$options(Optional) None supported yet. Here for consistency.
Returns
bool|ChadoBuddyRecord The updated ChadoBuddyRecord will be returned on success, FALSE will be returned if no record was found to update.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertDb()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::upsertDb ( array  $values,
array  $options = [] 
)

Insert a database if it doesn't yet exist OR update it if it does.

Parameters
array$valuesAn associative array of the values for the final record including:
  • db.db_id: primary key for db table.
  • db.name: The name of the database. This name is usually used as the prefix for CV term accessions.
  • db.description: (Optional) A description of the database. By default no description is required.
  • db.url: (Optional) The URL for the database.
  • db.urlprefix: (Optional) The URL that is to be used as a prefix when constructing a link to a database term.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted/updated ChadoBuddyRecord will be returned on success.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.

◆ upsertDbxref()

Drupal\tripal_chado\Plugin\ChadoBuddy\ChadoDbxrefBuddy::upsertDbxref ( array  $values,
array  $options = [] 
)

Insert a database reference if it doesn't yet exist OR update it if it does.

Parameters
array$valuesAn associative array of the values for the final record including:
  • dbxref.dbxref_id: the primary key of the dbxref table.
  • dbxref.db_id or db.db_id: The database_id of the database the reference is to.
  • dbxref.description: Description.
  • dbxref.accession: The accession.
  • dbxref.version: The version of the database reference.
  • db.name: may be used in place of db.db_id or dbxref.db_id if that is not available.
  • db.description: valid, but has no effect for this function.
  • db.urlprefix: valid, but has no effect for this function.
  • db.url: valid, but has no effect for this function.
  • buddy_record = a ChadoBuddyRecord can be used in place of or in addition to other keys
array$options(Optional) None supported yet. Here for consistency.
Returns
ChadoBuddyRecord The inserted/updated ChadoBuddyRecord will be returned on success.
Exceptions
Drupal

tripal_chado\ChadoBuddy\Exceptions\ChadoBuddyException If an error is encountered.


The documentation for this class was generated from the following file: