Tripal
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal\TripalImporter\TripalImporterBase Class Reference
Inheritance diagram for Drupal\tripal\TripalImporter\TripalImporterBase:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal\TripalImporter\TripalImporterBase:
Collaboration graph
[legend]

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 describeUploadFileFormat ()
 
 setJob ($job)
 
 createImportJob ($run_args, $file_details=[])
 
 load ($import_id)
 
 submitJob ()
 
 prepareFiles ()
 
 cleanFile ()
 
 getArguments ()
 
- Public Member Functions inherited from Drupal\tripal\TripalImporter\Interfaces\TripalImporterInterface
 form ($form, &$form_state)
 
 formSubmit ($form, &$form_state)
 
 formValidate ($form, &$form_state)
 
 run ()
 
 postRun ()
 
 addAnalysis ($form, &$form_state)
 

Protected Member Functions

 setTotalItems ($total_items)
 
 addItemsHandled ($num_handled)
 
 setItemsHandled ($total_handled)
 
 setInterval ($interval)
 

Protected Attributes

 $job
 
 $logger
 
 $arguments
 
 $import_id
 
 $is_prepared
 
 $messenger = NULL
 
 $reported
 
 $plugin_id
 
 $plugin_definition
 

Detailed Description

Defines an interface for tripal impoerter plugins.

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal\TripalImporter\TripalImporterBase::__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition 
)

{}

Member Function Documentation

◆ addItemsHandled()

Drupal\tripal\TripalImporter\TripalImporterBase::addItemsHandled (   $num_handled)
protected

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

Parameters
int$num_handled

◆ cleanFile()

Drupal\tripal\TripalImporter\TripalImporterBase::cleanFile ( )

Cleans up any temporary files that were created by the prepareFile().

This function should be called after a run() to remove any temporary files and keep them from building up on the server.

◆ createImportJob()

Drupal\tripal\TripalImporter\TripalImporterBase::createImportJob (   $run_args,
  $file_details = [] 
)

Creates a new importer record.

Parameters
array$run_argsAn associative array of the arguments needed to run the importer. Each importer will have its own defined set of arguments.
array$file_detailsAn associative array with one of the following keys: -fid: provides the Drupal managed File ID for the file. -file_local: provides the full path to the file on the server. -file_remote: provides the remote URL for the file. This argument is optional if the loader does not use the built-in file loader.
Returns
int Returns the import_id.

◆ describeUploadFileFormat()

Drupal\tripal\TripalImporter\TripalImporterBase::describeUploadFileFormat ( )

Provide more informative description than is ideal in the annotation alone.

NOTE: Supports full HTML.

Returns
A fully formatted string describing the format of the file to be uploaded and providing any additional upload file information.

◆ getArguments()

Drupal\tripal\TripalImporter\TripalImporterBase::getArguments ( )

Retrieves the list of arguments that were provided to the importer.

Returns
array The array of arguments as passed to create function.

◆ load()

Drupal\tripal\TripalImporter\TripalImporterBase::load (   $import_id)

Loads an existing import record into this object.

Parameters
int$import_idThe ID of the import record.

◆ prepareFiles()

Drupal\tripal\TripalImporter\TripalImporterBase::prepareFiles ( )

Prepares the importer files for execution.

This function must be run prior to the run() function to ensure that the import file is ready to go.

◆ setInterval()

Drupal\tripal\TripalImporter\TripalImporterBase::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\TripalImporter\TripalImporterBase::setItemsHandled (   $total_handled)
protected

Sets the number of items that have been processed.

This should be called anytime the loader wants to indicate how many items have been processed. The amount of progress will be calculated using this number. If the amount of items handled exceeds the interval specified then the progress is reported to the user. If this loader is associated with a job then the job progress is also updated.

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

◆ setJob()

Drupal\tripal\TripalImporter\TripalImporterBase::setJob (   $job)

Associate this importer with the Tripal job that is running it.

Associating an import with a job will allow the importer to log messages to the job log.

Parameters
\Drupal\tripal\Services\TripalJob$jobAn instance of a TripalJob.

◆ setTotalItems()

Drupal\tripal\TripalImporter\TripalImporterBase::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.

◆ submitJob()

Drupal\tripal\TripalImporter\TripalImporterBase::submitJob ( )

Submits the importer for execution as a job.

Returns
int The ID of the newly submitted job.

Member Data Documentation

◆ $arguments

Drupal\tripal\TripalImporter\TripalImporterBase::$arguments
protected

The arguments needed for the importer. This is a list of key/value pairs in an associative array.

◆ $import_id

Drupal\tripal\TripalImporter\TripalImporterBase::$import_id
protected

The ID for this import record.

◆ $is_prepared

Drupal\tripal\TripalImporter\TripalImporterBase::$is_prepared
protected

Prior to running an importer it must be prepared to make sure the file is available. Preparing the importer will download all the necessary files. This value is set to TRUE after the importer is prepared for funning.

◆ $job

Drupal\tripal\TripalImporter\TripalImporterBase::$job
protected

The job that this importer is associated with. This is needed for updating the status of the job.

◆ $logger

Drupal\tripal\TripalImporter\TripalImporterBase::$logger
protected

The drupal logger for tripal. This allows any of the importers to send log messages.


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