Tripal
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage Class Reference
Inheritance diagram for Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage:
Collaboration graph
[legend]

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, TripalLogger $logger, ChadoConnection $connection, ChadoFieldDebugger $field_debugger)
 
- Public Member Functions inherited from Drupal\tripal\TripalStorage\TripalStorageBase
 __construct (array $configuration, $plugin_id, $plugin_definition, TripalLogger $logger)
 
 getFieldDefinition (string $field_name)
 
 addTypes (string $field_name, array $types)
 
 getTypes ()
 
 getPropertyType (string $field_name, string $key)
 
 removeTypes (string $field_name, array $types)
 
 publishFormValidate ($form, FormStateInterface &$form_state)
 
 publishFromSubmit ($form, FormStateInterface &$form_state)
 
- Public Member Functions inherited from Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface
 getStoredValues ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 

Protected Attributes

 $connection
 
 $field_debugger
 
 $records = NULL
 
- Protected Attributes inherited from Drupal\tripal\TripalStorage\TripalStorageBase
 $logger
 
 $field_definitions = []
 
 $property_types = []
 
 addFieldDefinition (string $field_name, object $field_definition)
 
 getStoredTypes ()
 
 insertValues (&$values)
 
 updateValues (&$values)
 
 loadValues (&$values)
 
 deleteValues ($values)
 
 findValues ($values)
 
 validateValues ($values)
 
 publishForm ($form, FormStateInterface &$form_state)
 
 setPropValues (&$values, ChadoRecords $records)
 
 buildChadoRecords ($values, bool $is_find=FALSE)
 
 handleStoreID (array $context, StoragePropertyValue $prop_value)
 
 handleStorePkey (array $context, StoragePropertyValue $prop_value)
 
 handleStoreLink (array $context, StoragePropertyValue $prop_value)
 
 handleStore (array $context, StoragePropertyValue $prop_value)
 
 handleReadValue (array $context, StoragePropertyValue $prop_value)
 
 parsePath (string $field_name, string $base_table, mixed $path, array $aliases=[], string $as='', string $full_path='')
 
 getPathValueColumn (array $path)
 
 handleJoins (array $path_array, array $context)
 

Additional Inherited Members

- Protected Member Functions inherited from Drupal\tripal\TripalStorage\TripalStorageBase
 cloneValues ($values)
 
 addEmptyValuesItem (&$values, $field_name)
 

Detailed Description

Chado implementation of the TripalStorageInterface.

@TripalStorage( id = "chado_storage", label = @Translation("Chado Storage"), description = @Translation("Interfaces with GMOD Chado for field values."), )

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
TripalLogger  $logger,
ChadoConnection  $connection,
ChadoFieldDebugger  $field_debugger 
)

Implements __contruct().

Since we have implemented the ContainerFactoryPluginInterface, the constructor will be passed additional parameters added by the create() function. This allows our plugin to use dependency injection without our plugin manager service needing to worry about it.

Parameters
array$configuration
string$plugin_id
mixed$plugin_definition
\Drupal\tripal\Services\TripalLogger$logger
\Drupal\tripal_chado\Database\ChadoConnection$connection

Member Function Documentation

◆ addFieldDefinition()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::addFieldDefinition ( string  $field_name,
object  $field_definition 
)

◆ buildChadoRecords()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::buildChadoRecords (   $values,
bool  $is_find = FALSE 
)
protected

Indexes a values array for easy lookup.

Parameters
array$valuesAssociative array 5-levels deep. The 1st level is the field name (e.g. ncbitaxon__common_name). The 2nd level is the delta value (e.g. 0). The 3rd level is a field key name (i.e. record_id and value). The 4th level must contain the following three keys/value pairs
  • "value": a \Drupal\tripal\TripalStorage\StoragePropertyValue object
  • "type": a\Drupal\tripal\TripalStorage\StoragePropertyType object
  • "definition": a \Drupal\Field\Entity\FieldConfig object When the function returns, any values retrieved from the data store will be set in the StoragePropertyValue object.
bool$is_findSet to TRUE if we are building the record array for finding records.

◆ create()

static Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition 
)
static

Implements ContainerFactoryPluginInterface->create().

Since we have implemented the ContainerFactoryPluginInterface this static function will be called behind the scenes when a Plugin Manager uses createInstance(). Specifically this method is used to determine the parameters to pass to the contructor.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$container
array$configuration
string$plugin_id
mixed$plugin_definition
Returns
static

Reimplemented from Drupal\tripal\TripalStorage\TripalStorageBase.

◆ deleteValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::deleteValues (   $values)

◆ findValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::findValues (   $values)

◆ getPathValueColumn()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::getPathValueColumn ( array  $path)
protected

A helper function to quickly get the value column information from a path.

Parameters
array$pathThe parsed path of the field property.

◆ getStoredTypes()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::getStoredTypes ( )

Returns a list of property types that should be stored.In order to link data in the storage backend, the storage system must link the record in someway with Drupal entities. This most likely happens in tables in the Drupal schema (usually the public schema). This function should return the list of properties that must be stored in order to uniquely identify an entity in the datastore.

Returns
@array Array of \Drupal\tripal\Base\StoragePropertyTypeBase objects.

See also
\Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::getStoredTypes()

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ handleJoins()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleJoins ( array  $path_array,
array  $context 
)
protected

A helper function for the buildChadoRecords() function.

Adds the joins to the ChadoRecord object.

Parameters
array$path_arrayThe join path array
array$contextThe field/property context provided by the buildChadoRecords() function.

◆ handleReadValue()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleReadValue ( array  $context,
StoragePropertyValue  $prop_value 
)
protected

A helper function for the buildChadoRecords() function.

Add chado record information for a specific ChadoStorageProperty where the action is read_value.

READ_VALUE: selecting a single column. This cannot be used for inserting or updating values. Instead we use store actions for that. If reading a value from a non-base table, then the path should be provided.

Parameters
array$contextThe field/property context provided by the buildChadoRecords() function.
StoragePropertyValue$prop_valueThe value object for the property we are adding records for. Note: We will always have a StoragePropertyValue for a property even if the value is not set. This method is expected to check if the value is empty or not.

◆ handleStore()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleStore ( array  $context,
StoragePropertyValue  $prop_value 
)
protected

A helper function for the buildChadoRecords() function.

Add chado record information for a specific ChadoStorageProperty where the action is store.

STORE: indicates that the value of this property can be loaded and stored in the Chado table indicated by this property.

Parameters
array$contextThe field/property context provided by the buildChadoRecords() function.
StoragePropertyValue$prop_valueThe value object for the property we are adding records for. Note: We will always have a StoragePropertyValue for a property even if the value is not set. This method is expected to check if the value is empty or not.

◆ handleStoreID()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleStoreID ( array  $context,
StoragePropertyValue  $prop_value 
)
protected

A helper function for the buildChadoRecords() function.

Add chado record information for a specific ChadoStorageProperty where the action is store_id.

STORE ID: stores the primary key value for a core table in chado.

Note: There may be more core tables in properties for this field then just the base table. For example, a field involving a two-join linker table will include two core tables.

Parameters
array$contextThe field/property context provided by the buildChadoRecords() function.
StoragePropertyValue$prop_valueThe value object for the property we are adding records for. Note: We will always have a StoragePropertyValue for a property even if the value is not set. This method is expected to check if the value is empty or not.

◆ handleStoreLink()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleStoreLink ( array  $context,
StoragePropertyValue  $prop_value 
)
protected

A helper function for the buildChadoRecords() function.

Add chado record information for a specific ChadoStorageProperty where the action is store_link.

STORE LINK: performs a join between two tables, one of which is a core table and one of which is a linking table. The value which is saved in this property is the left_table_id indicated in other key/value pairs.

NOTE: A JOIN is not added to the query but rather this property stores the id that a join would normally look up. This is much more performant.

Parameters
array$contextThe field/property context provided by the buildChadoRecords() function.
StoragePropertyValue$prop_valueThe value object for the property we are adding records for. Note: We will always have a StoragePropertyValue for a property even if the value is not set. This method is expected to check if the value is empty or not.

◆ handleStorePkey()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::handleStorePkey ( array  $context,
StoragePropertyValue  $prop_value 
)
protected

A helper function for the buildChadoRecords() function.

Add chado record information for a specific ChadoStorageProperty where the action is store_pkey.

STORE PKEY: stores the primary key value of a linking table.

NOTE: A linking table is not a core table. This is important because during insert and update, the core tables are handled first and then linking tables are handled after.

Parameters
array$contextThe field/property context provided by the buildChadoRecords() function.
StoragePropertyValue$prop_valueThe value object for the property we are adding records for. Note: We will always have a StoragePropertyValue for a property even if the value is not set. This method is expected to check if the value is empty or not.

◆ insertValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::insertValues ( $values)

◆ loadValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::loadValues ( $values)

◆ parsePath()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::parsePath ( string  $field_name,
string  $base_table,
mixed  $path,
array  $aliases = [],
string  $as = '',
string  $full_path = '' 
)
protected

Takes a path string for a field property and converts it to an array structure.

Parameters
mixed$pathA string continaining the path. Note: this is a recursive function and on recursive calls this variable will be n array. Hence, the type is "mixed".*
array$aliasesOptional. The list of table aliases provdied by the table_alias_mapping argument of a field. If this variable is an empty array then the function will use the table name provided in the path.
string$asAn alias to be used for the Chado table column that contains the value. This argument will rename the column.
string$full_pathThis argument is used by recursion to build the string path for each level. It should not be set by the callee.
Returns
array

◆ publishForm()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::publishForm (   $form,
FormStateInterface &  $form_state 
)

Provides form elements to be added to the Tripal entity publish form.

Parameters
array$formThe form array definition.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.
Returns
array A new form array definition containing the form elements to add to the publish form.

See also
\Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface::publishFrom()

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.

◆ setPropValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::setPropValues ( $values,
ChadoRecords  $records 
)
protected

Sets the property values using the records returned from Chado.

Parameters
array$valuesArray of \Drupal\tripal\TripalStorage\StoragePropertyValue objects.
ChadoRecords$recordsAn instance of a ChadoRecords object from which values will be pulled. We don't use the built in member variable and instead allow it to be passed in because the findValues() functino can generate copies of the $records array and use that to set multiple values.

◆ updateValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::updateValues ( $values)

◆ validateValues()

Drupal\tripal_chado\Plugin\TripalStorage\ChadoStorage::validateValues (   $values)

Performs validation checks on values.

Parameters
array$valuesArray of \Drupal\tripal\TripalStorage\StoragePropertyValue objects.
Returns
array An array of \Symfony\Component\Validator\ConstraintViolation objects.

Implements Drupal\tripal\TripalStorage\Interfaces\TripalStorageInterface.


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