Tripal
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal\Services\TripalPublish Class Reference

Public Member Functions

 publish ($filters=[])
 

Protected Member Functions

 setInterval ($interval)
 
 addItemsHandled ($num_handled)
 
 setTotalItems ($total_items)
 
 setItemsHandled ($total_handled)
 
 addRequiredValues (&$search_values)
 
 getEntityTitles ($matches)
 
 findEntities ($matches, $titles)
 
 insertEntities ($matches, $titles)
 
 findFieldItems ($field_name, $entities)
 
 countFieldMatches (string $field_name, array $matches)
 
 insertFieldItems ($field_name, $matches, $titles, $entities, $existing)
 
 excludeExisting ($matches, $titles, $existing)
 

Protected Attributes

 $job = NULL
 
 $logger = NULL
 
 $bundle = ''
 
 $datastore = ''
 
 $field_info = []
 
 $entity_type = NULL
 
 $storage = NULL
 
 $required_types = []
 
 $supported_actions = ['store_id', 'store', 'store_link', 'store_pkey', 'read_value', 'replace', 'function']
 
 $unsupported_fields
 
 $reported
 

Member Function Documentation

◆ addItemsHandled()

Drupal\tripal\Services\TripalPublish::addItemsHandled (   $num_handled)
protected

Adds to the count of the total number of items that have been handled.

Parameters
int$num_handled

◆ addRequiredValues()

Drupal\tripal\Services\TripalPublish::addRequiredValues ( $search_values)
protected

Adds to the search values array the required proprty values.

Parameters
array$seach_values

◆ countFieldMatches()

Drupal\tripal\Services\TripalPublish::countFieldMatches ( string  $field_name,
array  $matches 
)
protected

Counts the total items to insert for a field.

The matches array returned by the TripalStorage is orgnized by entity but fields can have a cardinality > 1. This function counts the number of items for the given field.

Parameters
string$field_nameThe name of the field
array$matchesThe array of matches for each entity.
Returns
int The number of items for the field

◆ excludeExisting()

Drupal\tripal\Services\TripalPublish::excludeExisting (   $matches,
  $titles,
  $existing 
)
protected

Removes existing records from the set of matched records.

Parameters
array$matchesThe array of matches for each entity.
array$titlesThe array of entity titles in the same order as the matches.
array$existingThe array of existing records.
Returns
array A new array of two elements: the matches and titles arrays but with existing records excluded.

◆ findEntities()

Drupal\tripal\Services\TripalPublish::findEntities (   $matches,
  $titles 
)
protected

Makes sure that we will not be adding any dupliate entities.

Parameters
array$matchesThe array of matches for each entity.
array$titlesThe array of entity titles in the same order as the matches.
Returns
array An associative array of matched entities keyed by the entity title with a value of the entity id.

◆ findFieldItems()

Drupal\tripal\Services\TripalPublish::findFieldItems (   $field_name,
  $entities 
)
protected

Makes sure that we will not be adding any dupliate entities.

Parameters
string$field_nameThe name of the field
array$entitiesAn associative array of entities
Returns
array An associative array of matched entities keyed by the entity_id with a value of the entity id. This is an associative array to take advantage of quick lookups.

◆ getEntityTitles()

Drupal\tripal\Services\TripalPublish::getEntityTitles (   $matches)
protected

Retrieves a list of titles for the entities that should be published.

Parameters
array$matchesThe array of matches for each entity.
Returns
array A list of titles in order of the entities provided by the $matches array.

◆ insertEntities()

Drupal\tripal\Services\TripalPublish::insertEntities (   $matches,
  $titles 
)
protected

Performs bulk insert of new entities into the tripal_entity table

Parameters
array$matchesThe array of matches for each entity.
array$titlesThe array of entity titles in the same order as the matches.

◆ insertFieldItems()

Drupal\tripal\Services\TripalPublish::insertFieldItems (   $field_name,
  $matches,
  $titles,
  $entities,
  $existing 
)
protected

Inserts records into the field tables for entities.

Parameters
string$field_nameThe name of the field
array$matchesThe array of matches for each entity.
array$titlesThe array of entity titles in the same order as the matches.
array$entitiesAn associative array that maps entity titles to their keys.
array$existingAn associative array of entities that already have an existing item for this field.

◆ publish()

Drupal\tripal\Services\TripalPublish::publish (   $filters = [])

Publishes Tripal entities.

Publishes content to Tripal from Chado or another specified datastore that matches the provided filters.

Parameters
array$filtersFilters that determine which content will be published.
Returns
array An associative array of the entities that were published, keyed by their titles, and the value being the entity_id.

◆ setInterval()

Drupal\tripal\Services\TripalPublish::setInterval (   $interval)
protected

Updates the percent interval when the job progress is updated.

Updating the job progress incurrs a database write which takes time and if it occurs to frequently can slow down the loader. This should be a value between 0 and 100 to indicate a percent interval (e.g. 1 means update the progress every time the num_handled increases by 1%).

Parameters
int$intervalA number between 0 and 100.

◆ setItemsHandled()

Drupal\tripal\Services\TripalPublish::setItemsHandled (   $total_handled)
protected

Sets the number of items that have been processed.

This code was shamelessly copied from the TripalImporterBase class.

Parameters
int$total_handledThe total number of items that have been processed.

◆ setTotalItems()

Drupal\tripal\Services\TripalPublish::setTotalItems (   $total_items)
protected

Sets the total number if items to be processed.

This should typically be called near the beginning of the loading process to indicate the number of items that must be processed.

Parameters
int$total_itemsThe total number of items to process.

Member Data Documentation

◆ $bundle

string Drupal\tripal\Services\TripalPublish::$bundle = ''
protected

The id of the entity type (bundle)

◆ $datastore

string Drupal\tripal\Services\TripalPublish::$datastore = ''
protected

The id of the TripalStorage plugin.

◆ $entity_type

Drupal tripal Entity TripalEntityType Drupal\tripal\Services\TripalPublish::$entity_type = NULL
protected

Stores the bundle (entity type) object.

◆ $job

Drupal tripal Services TripalJob Drupal\tripal\Services\TripalPublish::$job = NULL
protected

The TripalJob object.

◆ $logger

Drupal tripal Services TripalLogger Drupal\tripal\Services\TripalPublish::$logger = NULL
protected

The TripalLogger object.

◆ $required_types

array Drupal\tripal\Services\TripalPublish::$required_types = []
protected

A list of property types that are required to uniquely identify an entity.

◆ $storage

Drupal tripal TripalStorage TripalStorageBase Drupal\tripal\Services\TripalPublish::$storage = NULL
protected

The TripalStorage object.

◆ $supported_actions

array Drupal\tripal\Services\TripalPublish::$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!

◆ $unsupported_fields

array Drupal\tripal\Services\TripalPublish::$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: