|
Tripal
|

Public Member Functions | |
| __construct (ChadoFieldDebugger $field_debugger, TripalLogger $logger, ChadoConnection $connection) | |
| addColumn (array $elements, bool $is_link=FALSE, bool $read_only=FALSE) | |
| addCondition (array $elements, bool $is_or_condition=FALSE) | |
| setConditionValue (string $base_table, string $table_alias, int $delta, string $column_alias, $value, $is_or_condition=FALSE) | |
| addJoin (array &$elements) | |
| addJoinColumn (array $elements) | |
| setLinks (string $base_table) | |
| getRecordID (string $base_table) | |
| hasRecordID (string $base_table) | |
| getBaseTables () | |
| getTableFromAlias (string $base_table, string $table_alias) | |
| getAncillaryTables (string $base_table) | |
| getAncillaryTablesWithCond (string $base_table) | |
| getTables (string $base_table) | |
| getNumTableItems (string $base_table, string $table_alias) | |
| getTableFields (string $base_table, string $table_alias) | |
| getFieldAliasColumn (string $base_table, string $table_alias, int $delta, string $column_alias) | |
| getColumnFieldAliases (string $base_table, string $table_alias, int $delta, string $chado_column) | |
| getColumnValue (string $base_table, string $table_alias, int $delta, string $column_alias) | |
| getRecordsArray () | |
| copyRecords (ChadoRecords $records) | |
| validate () | |
| insertRecords (string $base_table, string $table_alias) | |
| findRecords (string $base_table, string $base_table_alias, array $record_ids) | |
| updateRecords ($base_table, $table_alias) | |
| deleteRecords (string $base_table, string $table_alias, bool $graceful=FALSE) | |
| selectItems (string $base_table, string $table_alias, array $options=[]) | |
| getChadoTableDef (string $table_name) | |
| getPrimaryKey (string $table_name) | |
Protected Member Functions | |
| checkElement ($elements, $key, $method, $what) | |
| initTable ($elements) | |
| getJoinAliases (array $elements) | |
| generateJoinHash (int $length=20) | |
| setRecordID (string $base_table, int $record_id) | |
| getTableItems (string $base_table, string $table_alias) | |
| addEmptyTableItem (string $base_table, string $table_alias) | |
| setColumnValue (string $base_table, string $table_alias, int $delta, string $column_alias, $value, $set_value=TRUE,) | |
| validateFKs ($base_table, $delta, $record_id, $record) | |
| validateTypes ($base_table, $delta, $record_id, $record) | |
| validateSize ($base_table, $delta, $record_id, $record) | |
| validateUnique ($base_table, $delta, $record_id, $record) | |
| validateRequired ($base_table, $delta, $record_id, $record) | |
| isSkipInsert (array $record) | |
| addConditions (Select &$select, array $record, string $table_alias) | |
| hasValidConditions ($record) | |
| isEmptyRecord ($record) | |
Protected Attributes | |
| array | $records = [] |
| array | $violations = [] |
| array | $join_aliases = [] |
| ChadoFieldDebugger | $field_debugger |
| ChadoConnection | $connection |
| TripalLogger | $logger |
A helper class for use by the ChadoStorage Plugin.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::__construct | ( | ChadoFieldDebugger | $field_debugger, |
| TripalLogger | $logger, | ||
| ChadoConnection | $connection | ||
| ) |
Constructor.
| \Drupal\tripal_chado\Services\ChadoFieldDebugger | $field_debugger | The chado field debugger object. |
| Drupal\tripal\Services\TripalLogger | $logger | The Tripal logger object for logging debugging messages. |
| Drupal\tripal_chado\Database\ChadoConnection | $connection | The current connection to chado. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::addColumn | ( | array | $elements, |
| bool | $is_link = FALSE, |
||
| bool | $read_only = FALSE |
||
| ) |
Adds a field to this ChadoRecords object.
A field here corresponds to a column in a Chado table.
| array | $elements | The list of key/value pairs describing the element. These keys are required:
|
| bool | $is_link | Indicates if this field stores a link (or foreign key) to the base table. If TRUE, and if the "value" key is NULL then a placeholder will be used to fill in the record. The value will be set automatically once it's known. Defaults to FALSE. |
| bool | $read_only | If the column requested has a read-only value then we want to make sure that the column is present in the query and we get results for it but any value that might be set coming in should be ignored. |
Exception If the any required fields are missing an error is thrown.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::addCondition | ( | array | $elements, |
| bool | $is_or_condition = FALSE |
||
| ) |
Adds a condition to this ChadoRecords object.
A condition is used when querying to limit the set of records returned.
| array | $elements | The list of key/value pairs describing the element. |
These keys are required:
| bool | $is_or_condition | Indicates that this condition should be wrapped inside an OR condition group along with any others with this flag set. |
|
protected |
Adds conditions to the join.
Checks if there is more than one OR condition with a value, and if so creates an or condition group. If only one, and for remaining conditions with a value, added directly, i.e. as an AND condition.
| \Drupal\pgsql\Driver\Database\pgsql\Select | &$select | An existing database select query. |
| array | $record | The record being considered. |
| string | $table_alias | The alias of the table used in the condition. |
|
protected |
This function adds a new item to the table.
This function gets called internally during a find operation when we need to add recrods beyond the original element used for searching. It simply copies the item for delta 0 and clears the values so they can get set.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::addJoin | ( | array & | $elements | ) |
Adds a join to this ChadoRecords object.
| array | $elements | The list of key/value pairs describing the element. |
These keys are required:
Exception If the any required fields are missing an error is thrown.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::addJoinColumn | ( | array | $elements | ) |
Adds a fields to extract from a join in this ChadoRecords object.
This function is used after an addJoin() function to indicate the fields (or table columns) that should be added to the fields retrieved after a query.
| array | $elements | The list of key/value pairs describing the element. |
These keys are required:
Exception If the any required fields are missing an error is thrown.
|
protected |
A helper function used to check incoming $elements for various functions.
| array | $elements | The array of elements to check. |
| string | $key | The array key to check. |
| string | $method | The method being formed (e.g.. Initalzing, Adding, Setting, etc.) |
| string | $what | The type of element being added (e.g., 'field', 'condition', etc.) |
Exception
| Drupal\tripal_chado\TripalStorage\ChadoRecords::copyRecords | ( | ChadoRecords | $records | ) |
Allows the caller to copy the records from another ChadoRecords object.
| ChadoRecords | $records | The ChadoRecords object whose records should be copied. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::deleteRecords | ( | string | $base_table, |
| string | $table_alias, | ||
| bool | $graceful = FALSE |
||
| ) |
Deletes record for a given table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| bool | $graceful | Set to TRUE to not throw an exception if valid conditions are not set. If TRUE then it skips the record rather than performs the delete. |
Exception
| Drupal\tripal_chado\TripalStorage\ChadoRecords::findRecords | ( | string | $base_table, |
| string | $base_table_alias, | ||
| array | $record_ids | ||
| ) |
Queries for multiple records in Chado for a given table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $base_table_alias | The alias of the base table. |
| array | $record_ids | When specified, only return records where the primary key is present in this array. Used by publish to publish in batches. |
Exception
|
protected |
Generates a random character string.
| int | $length | The length of the unique string. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getAncillaryTables | ( | string | $base_table | ) |
For the given base table, returns non base tables.
| string | $base_table | The name of the Chado table used as a base table. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getAncillaryTablesWithCond | ( | string | $base_table | ) |
For the given base table, returns non base tables that have conditions set.
| string | $base_table | The name of the Chado table used as a base table. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getBaseTables | ( | ) |
Returns the list of base tables.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getChadoTableDef | ( | string | $table_name | ) |
Get a table definition from the chado schema.
| string | $table_name | The table name. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getColumnFieldAliases | ( | string | $base_table, |
| string | $table_alias, | ||
| int | $delta, | ||
| string | $chado_column | ||
| ) |
Retrieves all of the column aliases for a given chado column.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| int | $delta | The numeric index of the item. |
| string | $chado_column | The chado column to retrieve an alias for. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getColumnValue | ( | string | $base_table, |
| string | $table_alias, | ||
| int | $delta, | ||
| string | $column_alias | ||
| ) |
Gets a value for a given field.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| int | $delta | The numeric index of the item. |
| string | $column_alias | The alias for the column. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getFieldAliasColumn | ( | string | $base_table, |
| string | $table_alias, | ||
| int | $delta, | ||
| string | $column_alias | ||
| ) |
Retrieves the Chado column for a given base table and table alis.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| int | $delta | The numeric index of the item. |
| string | $column_alias | The alias for the column. |
|
protected |
Generates unique aliases for tables used in joins.
This function will generate unique aliases if the callee did not provide them.
| array | $elements | The array of elements passed to the addJoin() function. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getNumTableItems | ( | string | $base_table, |
| string | $table_alias | ||
| ) |
Gets an array of records (one per field item)
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getPrimaryKey | ( | string | $table_name | ) |
Retrieves the name of the primary key for a Chado table.
| string | $table_name | The chado table to look up the primary key for. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getRecordID | ( | string | $base_table | ) |
Gets the record ID for a given base table.
| string | $base_table | The name of the Chado table used as a base table. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getRecordsArray | ( | ) |
Returns the records object as an array.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getTableFields | ( | string | $base_table, |
| string | $table_alias | ||
| ) |
Returns the list of fields that require values from the given table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getTableFromAlias | ( | string | $base_table, |
| string | $table_alias | ||
| ) |
Gets the true Chado table name from an alias.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
|
protected |
Gets an array of records (one per field item)
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::getTables | ( | string | $base_table | ) |
Returns the list of tables currently handled by this object.
| string | $base_table | The name of the Chado table used as a base table. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::hasRecordID | ( | string | $base_table | ) |
Indicates if the given base table has a record ID.
| string | $base_table | The name of the Chado table used as a base table. |
|
protected |
Indicates if the record has any valid conditions.
For the record to have valid conditions it must first have at least one condition, and the value on which that condition relies is not empty.
| array | $record | The field item to validate. |
|
protected |
Initalizes the records.
| array | $elements | An array of items used to initalize the internal records array. |
Exception
| Drupal\tripal_chado\TripalStorage\ChadoRecords::insertRecords | ( | string | $base_table, |
| string | $table_alias | ||
| ) |
Inserts all records for a single Chado table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
Exception
|
protected |
Indicates if we should keep this record for inserts/updates.
| array | $record | The field item to validate. |
|
protected |
A helper function for the insetTable() function.
Checks to see if the record should not be inserted.
| array | $record | The record being considered for insertion. |
| Drupal\tripal_chado\TripalStorage\ChadoRecords::selectItems | ( | string | $base_table, |
| string | $table_alias, | ||
| array | $options = [] |
||
| ) |
Selects the items for a given table in a record object.
This function is used for the findValues() and loadValues() functions so it needs to be able to find multiple records from the base table and multiple items from an ancillary table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| array | $options |
|
Exception
|
protected |
Sets a value for a field that has already been added.
This is useful for after a query is run and the value needs to be set.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
| int | $delta | The numeric index of the item. |
| string | $column_alias | The alias for the column. |
| mixed | $value | The value to set for the field. |
| bool | $set_value | The value that is being set is a valid value. Set to FALSE when clearing a value by setting it to zero. |
Exception If the base_table, table_alias or delta don't exist then an error is thrown.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::setConditionValue | ( | string | $base_table, |
| string | $table_alias, | ||
| int | $delta, | ||
| string | $column_alias, | ||
| $value, | |||
$is_or_condition = FALSE |
|||
| ) |
Sets the value for a condition that has been added.
A condition is used when querying to limit the set of records returned. A condition should not be added if the field for the same field has not been added first.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. |
| int | $delta | The numeric index of the item. |
| string | $column_alias | The alias for the column. |
| mixed | $value | The value to set for the condition. |
| bool | $is_or_condition | True if part of an OR condition group. |
Exception If the item has not yet been added for the base table, table alias and delta then an exception is thrown.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::setLinks | ( | string | $base_table | ) |
Sets the record ID for all fields.
Record IDs may not be known when ChadoRecords is setup. For example, a field may be added that needs a link to a base table, but it may not yet be known, especially before an insert of the base record. This function should be run before a database operation like an insert, select, update, or delete, this function can be used to populate IDs that may have been set somewhere along the way for base tables.
| string | $base_table | The name of the Chado table used as a base table. |
|
protected |
Sets the record ID for a given base table.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $record_id | The numeric record ID. |
Exception If the base table is unknown then an error is thrown.
| Drupal\tripal_chado\TripalStorage\ChadoRecords::updateRecords | ( | $base_table, | |
| $table_alias | |||
| ) |
Updates all records for a single Chado table.
| string | $base_table | The name of the Chado table used as a base table. |
| string | $table_alias | The alias of the table. For the base table, use the same table name as base tables don't have aliases. |
Exception
| Drupal\tripal_chado\TripalStorage\ChadoRecords::validate | ( | ) |
Provides a series of validation checks on the ChadoRecord records.
If any of the records do not pass a validation check then these are returned as an array of violations.
|
protected |
Checks that foreign key fields exist in the record for the given table.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $delta | The numeric index of the item. |
| int | $record_id | The record ID for the base table. |
| array | $record | The field item to validate. |
|
protected |
Checks that required fields have values.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $delta | The numeric index of the item. |
| int | $record_id | The record ID for the base table. |
| array | $record | The field item to validate. |
|
protected |
Checks that size of the value isn't too large.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $delta | The numeric index of the item. |
| int | $record_id | The record ID for the base table. |
| array | $record | The field item to validate. |
|
protected |
Checks that foreign key values exist.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $delta | The numeric index of the item. |
| int | $record_id | The record ID for the base table. |
| array | $record | The field item to validate. |
|
protected |
Checks the unique constraint of the table.
| string | $base_table | The name of the Chado table used as a base table. |
| int | $delta | The numeric index of the item. |
| int | $record_id | The record ID for the base table. |
| array | $record | The field item to validate. |