|
| | publish (array $options) |
| |
| | unpublish (array $options) |
| |
| | __construct (array $configuration, $plugin_id, $plugin_definition, \Drupal\Core\Database\Connection $connection, \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager, \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager, \Drupal\Core\Field\FieldTypePluginManager $field_type_manager, \Drupal\tripal\Services\TripalLogger $logger, \Drupal\tripal\TripalStorage\PluginManager\TripalStorageManager $storage_manager, \Drupal\tripal\Services\TripalEntityLookup $entity_lookup_manager, \Drupal\tripal\Services\TripalTokenParser $token_parser) |
| |
|
| | loadMigrationData (string $filename) |
| |
| | set_tripal_entity_id_seq () |
| |
| | getObjectTable (string $field_name, array $storage_plugin_settings) |
| |
| | addRequiredValues () |
| |
| | addNonRequiredValues () |
| |
| | checkFieldIsSupported (string $field_name) |
| |
| | getChadoRecordID (array $match) |
| |
| | getEntityTitles (array $matches, string $title_format) |
| |
| | getEntityIds () |
| |
| | findOrphanedEntities (array $entity_ids) |
| |
| | getBundleTokenValues (string $tokenized_string, ?int $entity_id) |
| |
| | updateExistingTitles (array $titles, array $existing_titles) |
| |
| | findEntities (array $record_ids) |
| |
| | validateMigrationData (array &$matches, bool $lenient) |
| |
| | insertEntities ($matches, $titles) |
| |
| | deleteEntities (array $entity_ids) |
| |
| | findFieldItems ($field_name, $record_ids) |
| |
| | countFieldMatches (string $field_name, array $matches) |
| |
| | insertFieldItems ($field_name, $matches, $existing, $titles) |
| |
| | deleteFieldItems (string $field_name, array $entity_ids) |
| |
| | excludeExisting ($matches) |
| |
| | divideIntoBatches ($record_ids) |
| |
| | getRecordIds () |
| |
| | publish_summarize (bool $success, array $stats) |
| |
| | getFindValuesOptions () |
| |
|
| static | create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) |
| |
◆ addNonRequiredValues()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::addNonRequiredValues |
( |
| ) |
|
|
protected |
Adds to the search values array any remaining property values.
◆ addRequiredValues()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::addRequiredValues |
( |
| ) |
|
|
protected |
Adds to the search values array the required property values.
◆ checkFieldIsSupported()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::checkFieldIsSupported |
( |
string |
$field_name | ) |
|
|
protected |
Determines whether a field is supported for publishing.
- Parameters
-
| string | $field_name | The name of the field to check. |
- Returns
- bool TRUE if supported, FALSE if not.
◆ countFieldMatches()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::countFieldMatches |
( |
string |
$field_name, |
|
|
array |
$matches |
|
) |
| |
|
protected |
Counts the total items to insert for a field.
The matches array returned by the TripalStorage is organized by entity but fields can have a cardinality > 1. This function counts the number of items for the given field.
- Parameters
-
| string | $field_name | The name of the field |
| array | $matches | The array of matches for each entity. |
- Returns
- int The number of items for the field
◆ deleteEntities()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::deleteEntities |
( |
array |
$entity_ids | ) |
|
|
protected |
Performs bulk deletion of existing entities from the tripal_entity table.
- Parameters
-
| array | $entity_ids | A list of entities to delete. |
- Returns
- int The number of entities deleted.
◆ deleteFieldItems()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::deleteFieldItems |
( |
string |
$field_name, |
|
|
array |
$entity_ids |
|
) |
| |
|
protected |
Deletes records from the field tables for entities.
- Parameters
-
| string | $field_name | The name of the field. |
| array | $entity_ids | One or more entities having the field removed. |
- Returns
- int The number of items deleted for the field.
◆ divideIntoBatches()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::divideIntoBatches |
( |
|
$record_ids | ) |
|
|
protected |
Divides up a long list of record IDs into smaller batches for publishing, to reduce memory requirements.
- Parameters
-
| array | $record_ids | A list of primary key values. |
- Returns
- array Original array values divided into a 2-D array of several batches. First level array key is a delta value starting at zero.
◆ excludeExisting()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::excludeExisting |
( |
|
$matches | ) |
|
|
protected |
Removes existing records from the set of matched records.
- Parameters
-
| array | $matches | The array of matches for each entity. |
- Returns
- array The passed $matches with already published entities excluded.
◆ findEntities()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::findEntities |
( |
array |
$record_ids | ) |
|
|
protected |
Retrieves a list of chado record IDs that have already been published.
- Parameters
-
| array | $record_ids | A list of chado record IDs to process. |
- Returns
- array An associative array of published entities keyed by the chado record ID with a value of the existing entity title.
◆ findFieldItems()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::findFieldItems |
( |
|
$field_name, |
|
|
|
$record_ids |
|
) |
| |
|
protected |
Finds existing fields so that we will not be adding any duplicate fields.
- Parameters
-
| string | $field_name | The name of the field |
| array | $record_ids | Chado record IDs to process |
- Returns
- array An associative array of matched entities keyed first by the entity_id and then by the delta. Value is always TRUE.
◆ findOrphanedEntities()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::findOrphanedEntities |
( |
array |
$entity_ids | ) |
|
|
protected |
Filter entities for only those that are orphaned.
Orphaned entities are those without an underlying chado record.
- Returns
- array A list of orphaned numeric entity IDs.
◆ getBundleTokenValues()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getBundleTokenValues |
( |
string |
$tokenized_string, |
|
|
?int |
$entity_id |
|
) |
| |
|
protected |
Implements bundle token lookup similar to that done in Drupal\tripal\Entity\getBundleEntityTokenValues getBundleEntityTokenValues()
- Parameters
-
| string | $tokenized_string | The title format template |
| int | null | $entity_id | The drupal entity numeric ID. Not known for a newly published entity. |
- Returns
- array Associative array of all tokens and their values, ready to use for token replacement.
◆ getChadoRecordID()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getChadoRecordID |
( |
array |
$match | ) |
|
|
protected |
Retrieve the chado record ID for a single match record.
- Parameters
-
- Returns
- int The chado record ID
◆ getEntityIds()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getEntityIds |
( |
| ) |
|
|
protected |
Retrieves a list of numeric entity ID values for the current bundle.
- Returns
- array A list of numeric entity IDs.
◆ getEntityTitles()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getEntityTitles |
( |
array |
$matches, |
|
|
string |
$title_format |
|
) |
| |
|
protected |
Retrieves a list of titles for the entities that should be published.
- Parameters
-
| array | $matches | The array of matches for each entity. |
| string | $title_format | The format for titles for this bundle, contains one or more tokens. |
- Returns
- array A list of titles in order of the entities provided by the $matches array.
◆ getFindValuesOptions()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getFindValuesOptions |
( |
| ) |
|
|
protected |
Generates the options array for chado storage findValues().
These options include appropriate max_delta specifications. The cardinality value, if a positive integer greater than 1, will override the global setting.
- Returns
- array The options to pass to findValues().
◆ getObjectTable()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getObjectTable |
( |
string |
$field_name, |
|
|
array |
$storage_plugin_settings |
|
) |
| |
|
protected |
Retrieves the object_table storage plugin setting value for linking fields.
- Parameters
-
| string | $field_name | The name of the field. |
| array | $storage_plugin_settings | Storage settings for a field. |
- Returns
- string The name of the linked object table, or an empty string for non-linking fields.
◆ getRecordIds()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::getRecordIds |
( |
| ) |
|
|
protected |
Retrieves an array of chado record pkeys eligible for publishing.
- Returns
- array An array of chado record IDs in no particular order
◆ insertEntities()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::insertEntities |
( |
|
$matches, |
|
|
|
$titles |
|
) |
| |
|
protected |
Performs bulk insert of new entities into the tripal_entity table
- Parameters
-
| array | $matches | The array of new matches for each entity. |
| array | $titles | The array of entity titles keyed by the record ID. |
◆ insertFieldItems()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::insertFieldItems |
( |
|
$field_name, |
|
|
|
$matches, |
|
|
|
$existing, |
|
|
|
$titles |
|
) |
| |
|
protected |
Inserts records into the field tables for entities.
- Parameters
-
| string | $field_name | The name of the field |
| array | $matches | The array of matches for each entity. |
| array | $existing | An associative array of entities that already have an existing item for this field. |
| array | $titles | The array of entity titles keyed by the record ID. |
- Returns
- int The number of items inserted for the field.
◆ loadMigrationData()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::loadMigrationData |
( |
string |
$filename | ) |
|
|
protected |
Loads migration data for preserving Tripal 3 entity IDs.
- Parameters
-
| string | $filename | If not an empty string, load this data file. If an empty string, do nothing. |
- Returns
- string Empty string if successful, including no file specified. Error message if something went wrong.
◆ publish()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::publish |
( |
array |
$options | ) |
|
Publishes Chado content to Tripal entities.
- Parameters
-
| array | $options | Associative array defining what and how to publish. Required keys are: 'bundle' - The id of the bundle or entity type 'datastore' - The id of the TripalStorage plugin Optional keys are: 'republish' - If true, then republish existing entitites. 'job' - A Tripal job object 'batch_size' - Maximum number of records to publish per batch, defaults to 1000 'migration_file' - During migration of a Tripal 3 site, we would like to preserve the numeric entity IDs. This option specifies the name of a file generated by the tripal_chado/migration/export_tripal3_entity_mapping.php utility that was run on the Tripal 3 site. 'lenient_migration' - Do not stop if there are missing records in the migration data, rather just skip over them. 'unpublish' - A true value to instead unpublish content. 'orphaned' - Used for unpublish to only unpublish orphaned content. |
- Returns
- array An associative array of the first 100 entities that were published, keyed by their titles, and the value being the entity_id.
◆ publish_summarize()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::publish_summarize |
( |
bool |
$success, |
|
|
array |
$stats |
|
) |
| |
|
protected |
Provides a final summary message for publish
- Parameters
-
| bool | $success | TRUE if no errors encountered |
| array | $stats | Various statistics to display |
- Returns
- void
◆ set_tripal_entity_id_seq()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::set_tripal_entity_id_seq |
( |
| ) |
|
|
protected |
When migrating Tripal 3 entity ID values, makes sure the sequence "tripal_entity_id_seq" next value is higher than the maximum from the migration data.
◆ unpublish()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::unpublish |
( |
array |
$options | ) |
|
Unpublishes Tripal entities.
- Parameters
-
| array | $options | Associative array defining what and how to unpublish. Required keys are: 'bundle' - The id of the bundle or entity type 'datastore' - The id of the TripalStorage plugin Optional keys are: 'job' - A Tripal job object 'batch_size' - Max number of records per batch, defaults to 1000. 'unpublish' - When true unpublish content (i.e. delete entities) instead of publishing it. Must be present for this function to be called. 'orphaned' - When unpublishing, only unpublish orphaned content which are entities missing their chado record, defaults to TRUE. |
- Returns
- array For publish the returned array is a list of titles. Here it is just a list of the entity ID values unpublished. This return value is only used for automated tests.
◆ updateExistingTitles()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::updateExistingTitles |
( |
array |
$titles, |
|
|
array |
$existing_titles |
|
) |
| |
|
protected |
Check if the new title does not match the existing published title, and if so, update it. This can happen if the title format has been changed. Array keys for both input arrays are the chado record ID, array values are the titles.
- Parameters
-
| array | $titles | A list of new titles to check, key is chado record ID. |
| array | $existing_titles | A list of already published titles, key is chado record ID. |
- Returns
- int Number of titles that were updated.
◆ validateMigrationData()
| Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::validateMigrationData |
( |
array & |
$matches, |
|
|
bool |
$lenient |
|
) |
| |
|
protected |
When using Tripal 3 migration data, validate that all values are present and available.
- Parameters
-
| array | &$matches | The array of matches for each entity. |
| bool | $lenient | If TRUE, allow records to be missing from migration data. This can happen if you had unpublished records on your Tripal 3 site. |
- Returns
- bool Returns TRUE if validation passes, FALSE if not.
◆ $base_table
| string Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$base_table = '' |
|
protected |
The base table of the bundle
◆ $count_blank_titles
| int Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$count_blank_titles = 0 |
|
protected |
Number of entities with blank titles.
◆ $entity_type
| Drupal tripal Entity TripalEntityType Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$entity_type = NULL |
|
protected |
Stores the bundle (entity type) object.
◆ $existing_published_entities
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$existing_published_entities = [] |
|
protected |
All published entities for the current bundle. The key will be the chado record ID, the values will be the entity IDs.
◆ $lenient_migration
| bool Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$lenient_migration = FALSE |
|
protected |
Flag to permit a more lenient Tripal 3 migration. If a record is missing in the migration data, then skip it.
◆ $main_property_names
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$main_property_names = [] |
|
protected |
A list of the main properties for each field. The key is the field name, and the value is the name of the main property.
◆ $max_migrated_entity_id
| int Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$max_migrated_entity_id = 0 |
|
protected |
Stores the maximum entity ID value present in $this->migration_data
◆ $migration_data
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$migration_data = [] |
|
protected |
Information used to migrate Tripal 3 entity values when first publishing a migrated chado instance.
◆ $non_required_types
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$non_required_types = [] |
|
protected |
A list of property types that are not one of the required types.
◆ $published_or_updated_entities
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$published_or_updated_entities = [] |
|
protected |
The first 100 published entities, key is entity_id, value is title. These are only used for unit tests, so don't need to use memory to store them all.
◆ $required_types
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$required_types = [] |
|
protected |
A list of property types that are required to uniquely identify an entity.
◆ $search_values
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$search_values = [] |
|
protected |
Array of values to search in chado storage.
◆ $storage
| Drupal tripal TripalStorage TripalStorageBase Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$storage = NULL |
|
protected |
The TripalStorage object.
◆ $supported_actions
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$supported_actions = ['store_id', 'store', 'store_link', 'store_pkey', 'read_value', 'replace', 'function'] |
|
protected |
Supported actions during publishing. Any field containing properties that are not in this list, will not be published!
◆ $token_values
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$token_values = [] |
|
protected |
Entity and field values used for token replacement, keyed by record_id.
◆ $uid
| int Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$uid = NULL |
|
protected |
Stores the user that is publishing content.
◆ $unsupported_fields
| array Drupal\tripal_chado\Plugin\TripalBackendPublish\ChadoPublish::$unsupported_fields = [] |
|
protected |
Keep track of fields which are not supported in order to let the user know.
The documentation for this class was generated from the following file:
- tripal_chado/src/Plugin/TripalBackendPublish/ChadoPublish.php