Tripal
|
Public Member Functions | |
__construct (?\Drupal\Core\Database\Connection $database=NULL, ?\Psr\Log\LoggerInterface $logger=NULL, ?\Drupal\tripal_biodb\Lock\SharedLockBackendInterface $locker=NULL, ?\Drupal\Core\State\StateInterface $state=NULL) | |
setParameters (array $parameters=[]) | |
getTripalDbxClass ($class) | |
performTask () | |
getId () | |
getStatus () | |
getLogger () | |
![]() | |
validateParameters () | |
getProgress () | |
Public Attributes | |
const | TASK_NAME = 'task' |
const | STATE_KEY_DATA_PREFIX = 'tripal_biodb_' |
Protected Member Functions | |
prepareSchemas (array $schema_list) | |
getSchemaLockName (\Drupal\tripal\TripalDBX\TripalDbxConnection $db) | |
initId () | |
acquireTaskLocks () | |
releaseTaskLocks () | |
Protected Attributes | |
$id | |
$connection | |
$logger | |
$locker | |
$state | |
$parameters = ['input_schemas' => [], 'output_schemas' => [], ] | |
$inputSchemas = [] | |
$outputSchemas = [] | |
Defines the base class for tasks on one or more biological schemas.
Drupal\tripal_biodb\Task\BioTaskBase::__construct | ( | ?\Drupal\Core\Database\Connection | $database = NULL , |
?\Psr\Log\LoggerInterface | $logger = NULL , |
||
?\Drupal\tripal_biodb\Lock\SharedLockBackendInterface | $locker = NULL , |
||
?\Drupal\Core\State\StateInterface | $state = NULL |
||
) |
Creates a BioTaskBase object.
\Drupal\Core\Database\Connection | ?,$connection | The main database connection. |
\Psr\Log\LoggerInterface | ?,$logger | The logger. |
\Drupal\tripal_biodb\Lock\SharedLockBackendInterface | ?,$locker | The lock backend used to lock task and used schemas. |
\Drupal\Core\State\StateInterface | $state | Drupal state service. |
|
protected |
Lock what is needed before performing the task.
This method should be called by extending classes before starting their job on schemas (ie. in performTask()
) as it will make sure a same task is not already running and it will also lock the schemas as needed.
Drupal\tripal_biodb\Task\BioTaskBase::getId | ( | ) |
{Returns the task identifier.This identifier is unique for a given task on a given set of schemas. It can be used to identify and retrieve an task to get its status while running from another independant process. It must only contain lower case alpha-numeric characters, underscores, dashes and dots. The task identifier should follow the following scheme: <task_name>-<dash_separated_schema_list> When a task works with more than one schema, the schema names should be ordered. The order could be alpha-numeric if it is not important or schema names could be ordered by argument order if this order is important. Schema name should be prefixed by the associated database name followed by a dot when it is not the default one.For example, a schema cloning task that clones the "chado" schema to a new schema named "alpha_chado" would use the task identifier: "clone-chado-alpha_chado".Another example would be a Chado data merging task that would merge the data of 2 Chado instances (chado1 and chado2)into a new schema (big_chado). The order of the 2 merged schema names is not relevant so they will be sorted alpha-numericaly. The target schema would come first as it will be unique while there could be more than 2 schemas to merge. So its task identifier would look like: "merge-big_chado-chado1-chado2"
Implements Drupal\tripal_biodb\Task\BioTaskInterface.
Drupal\tripal_biodb\Task\BioTaskBase::getLogger | ( | ) |
{Returns the logger used by this task.
Implements Drupal\tripal_biodb\Task\BioTaskInterface.
|
protected |
Returns the lock name to use for the given schema.
\Drupal\tripal\TripalDBX\TripalDbxConnection | $db | A schema connection. |
Drupal\tripal_biodb\Task\BioTaskBase::getStatus | ( | ) |
{Returns a string describing current status of the performed task.This function returns the last known status, even if the task ended. In case of failure, this function may return the reason of the failure.
Implements Drupal\tripal_biodb\Task\BioTaskInterface.
Reimplemented in Drupal\tripal_chado\Task\ChadoUpgrader, Drupal\tripal_chado\Task\ChadoRenamer, Drupal\tripal_chado\Task\ChadoRemover, Drupal\tripal_chado\Task\ChadoPreparer, Drupal\tripal_chado\Task\ChadoIntegrator, Drupal\tripal_chado\Task\ChadoInstaller, and Drupal\tripal_chado\Task\ChadoCloner.
Drupal\tripal_biodb\Task\BioTaskBase::getTripalDbxClass | ( | $class | ) |
Gets the task-specific class for the specified category.
Returns the task-specific override class if any for the specified class category.
string | $class | The class category for which we want the specific class. |
Reimplemented in Drupal\tripal_chado\Task\ChadoTaskBase.
|
protected |
Initializes task identifier.
Drupal\tripal_biodb\Task\BioTaskBase::performTask | ( | ) |
Example implementation of performTask().
This implementation should be replaced by extending classes (do not call parent::performTask method as it throws an error). It is provided as an example skeleton and for testing: first, it check parameters by calling ::validateParameters, it acquires required locks by calling ::acquireTaskLocks, manages lock failures, then it performs the task and finally releases the locks by calling ::releaseTaskLocks.
Implements Drupal\tripal_biodb\Task\BioTaskInterface.
Reimplemented in Drupal\tripal_chado\Task\ChadoUpgrader, Drupal\tripal_chado\Task\ChadoRenamer, Drupal\tripal_chado\Task\ChadoRemover, Drupal\tripal_chado\Task\ChadoPreparer, Drupal\tripal_chado\Task\ChadoIntegrator, Drupal\tripal_chado\Task\ChadoInstaller, and Drupal\tripal_chado\Task\ChadoCloner.
|
protected |
Parses schema names and extract the database name if one.
array | $schema_list | An ordered array of biological schema names that may be prefixed by a Drupal database key followed by a dot (see \Drupal\Core\Database\Database::getConnection()). |
|
protected |
Release the locks used by the task.
This method should be called by extending classes once their job on schemas (ie. in performTask()
) is over.
Drupal\tripal_biodb\Task\BioTaskBase::setParameters | ( | array | $parameters = [] | ) |
{Sets task parameters.It sets (or sets again) task parameter before task execution. Only schema names are checked here, no other parameter validation are performed. Parameters are validate at runtime by ::performTask, just before the actual task is started.
$parameters | A associative array of parameters used to configure the task. The array should include the keys 'input_schemas' and 'output_schemas', both containing an array of ordered schema names (or an empty array). 'input_schemas' are biological schemas used for reading only which may be shared for reading with other concurrent tasks. 'output_schemas' are schemas that will be created or modified and must not be shared ( exclusive use) during the task. If a schema comes from a different database than the default one (ie. the one used by Drupal), the schema name must be prefixed by the database key name (and not the "target", as describbed in \Drupal\Core\Database\Database::getConnection()) followed by a dot. |
Implements Drupal\tripal_biodb\Task\BioTaskInterface.
const Drupal\tripal_biodb\Task\BioTaskBase::STATE_KEY_DATA_PREFIX = 'tripal_biodb_' |
Prefix for state keys to store data in Drupal State API.
const Drupal\tripal_biodb\Task\BioTaskBase::TASK_NAME = 'task' |
Name of the task.
Should be overridden by implementing classes.