|
| __construct (ChadoFieldDebugger $field_debugger, TripalLogger $logger, ChadoConnection $connection) |
|
| addColumn (array $elements, bool $is_link=FALSE, bool $read_only=FALSE) |
|
| addCondition (array $elements) |
|
| setConditionValue (string $base_table, string $table_alias, int $delta, $column_alias, $value) |
|
| 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, $column_alias) |
|
| getRecordsArray () |
|
| copyRecords (ChadoRecords $records) |
|
| validate () |
|
| insertRecords (string $base_table, string $table_alias) |
|
| findRecords (string $base_table, string $table_alias) |
|
| updateRecords ($base_table, $table_alias) |
|
| deleteRecords (string $base_table, string $table_alias, bool $graceful=FALSE) |
|
| selectRecords (string $base_table, string $table_alias) |
|
|
| 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) |
|
| 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) |
|
| hasValidConditions ($record) |
|
| isEmptyRecord ($record) |
|
A helper class for use by the ChadoStorage Plugin.
◆ __construct()
Constructor
- Parameters
-
ChadoFieldDebugger | $field_debugger | |
◆ addColumn()
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.
- Parameters
-
array | $elements | The list of key/value pairs describing the element. |
These keys are required:
- base_table: the base table the field should be added to.
- chado_table: the chado table the field should be added to. This can be the base table or an anciallary table.
- table_alias: the alias fo the table. A base table alias will always be the same as the as the base table name.
- delta: the detla index of the field item being added.
- chado_column: the name of the column that the field is for.
- column_alias: an alias for the column.
- value: a value for the column. If the value is not known this should be NULL.
These keys are optional:
- delete_if_empty: for updates, if the "value" is empty then delete the item.
- empty_value: only used if "delete_if_empty" is used. It indicates the value to use to determine if the field is empty.
- Parameters
-
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. |
- Exceptions
-
◆ addCondition()
Drupal\tripal_chado\TripalStorage\ChadoRecords::addCondition |
( |
array |
$elements | ) |
|
Adds a condition to this ChadoRecords object.
A condition is used when querying to limit the set of records returned.
- Parameters
-
array | $elements | The list of key/value pairs describing the element. |
These keys are required:
- base_table: the base table the field should be added to.
- chado_table: the chado table the field should be added to. This can be the base table or an anciallary table.
- table_alias: the alias fo the table. A base table alias will always be the same as the as the base table name.
- delta: the detla index of the field item being added.
- column_alias: the alias used for the column (set via the setField() function.
- value: a value for the column to use as the condition.
- Exceptions
-
◆ addEmptyTableItem()
Drupal\tripal_chado\TripalStorage\ChadoRecords::addEmptyTableItem |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
|
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.
- Parameters
-
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. |
◆ addJoin()
Drupal\tripal_chado\TripalStorage\ChadoRecords::addJoin |
( |
array |
$elements | ) |
|
Adds a join to this ChadoRecords object.
- Parameters
-
array | $elements | The list of key/value pairs describing the element. |
These keys are required:
- base_table: the base table the field should be added to.
- chado_table: the chado table the field should be added to. This can be the base table or an anciallary table.
- table_alias: the alias fo the table. A base table alias will always be the same as the as the base table name.
- delta: the detla index of the field item being added.
- join_path: the path from the StoragePropertyType that indicates the sequences of tables joined together.
- join_type: corresponds to 'inner', 'outer', etc. Currently, only 'outer' is supported.
- left_table: the left table in the join.
- left_column: the left column in the join.
- right_table: the right table in the join.
- right_column: the right column in the join.
- left_alias: the alias of the left column in the join.
- right_alias: the alias of the right column in the join.
- Exceptions
-
◆ addJoinColumn()
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 fileds (or table columns) that should be added to the fields retrieved after a query.
- Parameters
-
array | $elements | The list of key/value pairs describing the element. |
These keys are required:
- base_table: the base table the field should be added to.
- chado_table: the chado table the field should be added to. This can be the base table or an anciallary table.
- table_alias: the alias fo the table. A base table alias will always be the same as the as the base table name.
- delta: the detla index of the field item being added.
- join_path: the path from the StoragePropertyType that indicates the sequences of tables joined together.
- chado_column: the column name in the table to add as a field.
- column_alias: the alias of the column.
- field_name: the name of the TripalFieldItemBase field. that requested the join.
- key: The property key of the StoragePropertyType. that requested the join.
- Exceptions
-
◆ checkElement()
Drupal\tripal_chado\TripalStorage\ChadoRecords::checkElement |
( |
|
$elements, |
|
|
|
$key, |
|
|
|
$method, |
|
|
|
$what |
|
) |
| |
|
protected |
A helper function used to check incoming $elements for various functions.
- Parameters
-
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.) |
- Exceptions
-
◆ copyRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::copyRecords |
( |
ChadoRecords |
$records | ) |
|
Allows the caller to copy the records from another ChadoRecords object.
- Parameters
-
◆ deleteRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::deleteRecords |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
bool |
$graceful = FALSE |
|
) |
| |
Deletes record for a given table.
- Parameters
-
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 not not throw na exception of valid conditions are not set. If TRUE then it skips the record rather than performs the delete. |
- Exceptions
-
◆ findRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::findRecords |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Queries for multiple records in Chado for a given table..
- Parameters
-
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. |
- Exceptions
-
◆ generateJoinHash()
Drupal\tripal_chado\TripalStorage\ChadoRecords::generateJoinHash |
( |
int |
$length = 20 | ) |
|
|
protected |
Generates a random character string.
- Parameters
-
int | $length | The length of the unique string. |
- Returns
- string
◆ getAncillaryTables()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getAncillaryTables |
( |
string |
$base_table | ) |
|
For the given base table, returns non base tables.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
- Returns
- array The list of tables linked to the base table but does not include the base table.
◆ getAncillaryTablesWithCond()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getAncillaryTablesWithCond |
( |
string |
$base_table | ) |
|
For the given base table, returns non base tables that have conditions set.
Excludes tables whose only condition is the linker column to the base table. This function is useful when finding values. We don't want to iterate through tables that won't have any records to filter so we can use this function results to exclude those tables.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
- Returns
- array The list of tables linked to the base table but does not include the base table.
◆ getBaseTables()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getBaseTables |
( |
| ) |
|
Returns the list of base tables.
- Returns
- array
◆ getColumnFieldAliases()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getColumnFieldAliases |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
int |
$delta, |
|
|
string |
$chado_column |
|
) |
| |
Retreives all of the column aliases for a given chado column.
- Parameters
-
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. |
- Returns
- array An array containing all of the alias mappings for fields in the table whose column namthces the $chado_column provided.
◆ getColumnValue()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getColumnValue |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
int |
$delta, |
|
|
|
$column_alias |
|
) |
| |
Gets a value for a given field.
- Parameters
-
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. |
- Returns
- mixed The value of the field.
◆ getFieldAliasColumn()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getFieldAliasColumn |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
int |
$delta, |
|
|
string |
$column_alias |
|
) |
| |
Retreives the Chado column for a given base table and table alis.
- Parameters
-
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. |
- Returns
- string The name of the chado column
◆ getJoinAliases()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getJoinAliases |
( |
array |
$elements | ) |
|
|
protected |
Generates unique aliases for tables used in joins.
This function will generate unique aliases if the callee did not provide them.
- Parameters
-
array | $elements | The array of elements passed to the addJoin() function |
- Returns
- array An array of two strings: the left table alias and the right table alias.
◆ getNumTableItems()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getNumTableItems |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Gets an array of records (one per field item)
- Parameters
-
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. |
- Returns
- mixed The value of the field.
◆ getRecordID()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getRecordID |
( |
string |
$base_table | ) |
|
Gets the record ID for a given base table.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
- Returns
- int A numeric record ID for the base table. If the value is 0 then the value has not been set.
◆ getRecordsArray()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getRecordsArray |
( |
| ) |
|
Returns the records object as an array.
- Returns
- array An array representation of this ChadoRecords object.
◆ getTableFields()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getTableFields |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Returns the list of fields that require values from the given table.
- Parameters
-
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. |
◆ getTableFromAlias()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getTableFromAlias |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Gets the true Chado table name from an alias.
- Parameters
-
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. |
- Returns
- string The Chado table name.
◆ getTableItems()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getTableItems |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
|
protected |
Gets an array of records (one per field item)
- Parameters
-
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. |
- Returns
- mixed The value of the field.
◆ getTables()
Drupal\tripal_chado\TripalStorage\ChadoRecords::getTables |
( |
string |
$base_table | ) |
|
Returns the list of tables currently handled by this object.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
- Returns
- array The list of tables linked to the base table and including the base table.
◆ hasRecordID()
Drupal\tripal_chado\TripalStorage\ChadoRecords::hasRecordID |
( |
string |
$base_table | ) |
|
Indicates if the given base table has a record ID
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
- Returns
- bool TRUE if the record ID is set, otherwise FALSE
◆ hasValidConditions()
Drupal\tripal_chado\TripalStorage\ChadoRecords::hasValidConditions |
( |
|
$record | ) |
|
|
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.
- Parameters
-
array | $record | The field item to validate |
- Returns
- bool Return TRUE if the conditions are valid. FALSE otherwise.
◆ initTable()
Drupal\tripal_chado\TripalStorage\ChadoRecords::initTable |
( |
|
$elements | ) |
|
|
protected |
Initalies the records
- Parameters
-
array | $elements | An array of items used to initalize the internal records array. |
- Exceptions
-
◆ insertRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::insertRecords |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Inserts all records for a single Chado table.
- Parameters
-
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. |
- Exceptions
-
◆ isEmptyRecord()
Drupal\tripal_chado\TripalStorage\ChadoRecords::isEmptyRecord |
( |
|
$record | ) |
|
|
protected |
Indicates if we should keep this record for inserts/updates.
- Parameters
-
array | $record | The field item to validate |
- Returns
- bool Return TRUE if the record is empty. FALSE otherwise.
◆ isSkipInsert()
Drupal\tripal_chado\TripalStorage\ChadoRecords::isSkipInsert |
( |
array |
$record | ) |
|
|
protected |
A helper function for the insetTable() function.
Checks to see if the record should not be inserted.
- Parameters
-
array | $record | The record being considered for insertion. |
- Returns
- bool Returns TRUE if the record should be skipped, FALSE otherwise.
◆ selectRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::selectRecords |
( |
string |
$base_table, |
|
|
string |
$table_alias |
|
) |
| |
Selects a single record from Chado.
- Parameters
-
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. |
- Exceptions
-
◆ setColumnValue()
Drupal\tripal_chado\TripalStorage\ChadoRecords::setColumnValue |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
int |
$delta, |
|
|
string |
$column_alias, |
|
|
|
$value |
|
) |
| |
|
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.
- Parameters
-
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 t oset for the field. |
- Exceptions
-
◆ setConditionValue()
Drupal\tripal_chado\TripalStorage\ChadoRecords::setConditionValue |
( |
string |
$base_table, |
|
|
string |
$table_alias, |
|
|
int |
$delta, |
|
|
|
$column_alias, |
|
|
|
$value |
|
) |
| |
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 sould not be added if the field for the same foe;d has not been added first.
- Parameters
-
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 |
- Exceptions
-
◆ setLinks()
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 bse 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.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
◆ setRecordID()
Drupal\tripal_chado\TripalStorage\ChadoRecords::setRecordID |
( |
string |
$base_table, |
|
|
int |
$record_id |
|
) |
| |
|
protected |
Sets the record ID for a given base table.
- Parameters
-
string | $base_table | The name of the Chado table used as a base table. |
int | $record_id | The numeric record ID. |
- Exceptions
-
◆ updateRecords()
Drupal\tripal_chado\TripalStorage\ChadoRecords::updateRecords |
( |
|
$base_table, |
|
|
|
$table_alias |
|
) |
| |
Updates all records for a single Chado table.
- Parameters
-
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. |
- Exceptions
-
◆ validate()
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 violoations.
- Returns
- array of ConstraintViolation
◆ validateFKs()
Drupal\tripal_chado\TripalStorage\ChadoRecords::validateFKs |
( |
|
$base_table, |
|
|
|
$delta, |
|
|
|
$record_id, |
|
|
|
$record |
|
) |
| |
|
protected |
Checks that foreign key fields exist in the record for the given table.
- Parameters
-
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 |
◆ validateRequired()
Drupal\tripal_chado\TripalStorage\ChadoRecords::validateRequired |
( |
|
$base_table, |
|
|
|
$delta, |
|
|
|
$record_id, |
|
|
|
$record |
|
) |
| |
|
protected |
Checks that required fields have values.
- Parameters
-
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 |
◆ validateSize()
Drupal\tripal_chado\TripalStorage\ChadoRecords::validateSize |
( |
|
$base_table, |
|
|
|
$delta, |
|
|
|
$record_id, |
|
|
|
$record |
|
) |
| |
|
protected |
Checks that size of the value isn't too large
- Parameters
-
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 |
◆ validateTypes()
Drupal\tripal_chado\TripalStorage\ChadoRecords::validateTypes |
( |
|
$base_table, |
|
|
|
$delta, |
|
|
|
$record_id, |
|
|
|
$record |
|
) |
| |
|
protected |
Checks that foreign key values exist.
- Parameters
-
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 |
◆ validateUnique()
Drupal\tripal_chado\TripalStorage\ChadoRecords::validateUnique |
( |
|
$base_table, |
|
|
|
$delta, |
|
|
|
$record_id, |
|
|
|
$record |
|
) |
| |
|
protected |
Checks the unique constraint of the table.
- Parameters
-
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 |
The documentation for this class was generated from the following file:
- tripal_chado/src/TripalStorage/ChadoRecords.php