Tripal
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter Class Reference
Inheritance diagram for Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter:
Inheritance graph
[legend]
Collaboration diagram for Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter:
Collaboration graph
[legend]

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, TripalPubLibraryManager $pub_library_manager, Connection $public, ChadoConnection $connection, Messenger $messenger, TripalLogger $logger, TripalFileRetriever $fileretriever, TripalBackendPublishManager $publish_manager,)
 
 form ($form, &$form_state)
 
 formValidate ($form, &$form_state)
 
 formSubmit ($form, &$form_state)
 
 findExistingPublications (array $publications)
 
 run ()
 
- Public Member Functions inherited from Drupal\tripal_chado\TripalImporter\ChadoImporterBase
 __construct (array $configuration, $plugin_id, $plugin_definition, ChadoConnection $connection, ?Messenger $messenger=NULL, ?TripalLogger $logger=NULL, ?TripalFileRetriever $fileretriever=NULL, ?TripalBackendPublishManager $publish_manager=NULL,)
 
 getChadoConnection ()
 
 startTransactions ()
 
 addAnalysis ($form, &$form_state)
 
 postRun ()
 
- Public Member Functions inherited from Drupal\tripal\TripalImporter\TripalImporterBase
 __construct (array $configuration, $plugin_id, $plugin_definition, ?Messenger $messenger=NULL, ?TripalLogger $logger=NULL, ?TripalFileRetriever $fileretriever=NULL, ?TripalBackendPublishManager $publish_manager=NULL,)
 
 describeUploadFileFormat ()
 
 setJob ($job)
 
 rollbackTransaction (string $stage)
 
 createImportJob ($run_args, $file_details=[])
 
 load ($import_id)
 
 submitJob ()
 
 prepareFiles ()
 
 cleanFile ()
 
 setArguments (array $arguments)
 
 getArguments ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static test_click_on_change (array &$form, $form_state)
 
static database_on_change (array &$form, $form_state)
 

Protected Member Functions

 formQueryIdNotSet (&$form, $form_state)
 
 getRemoteDbId (string $db_name)
 
 cachePublicationCvterms ()
 
 insertMissingPublicationsDbxref (array $publications)
 
 getNewPublicationAccessions (array $publications)
 
 insertPublications (array &$publications)
 
 getPublicationTypeId (array &$publications, int $index)
 
 insertPubDbxrefs ()
 
 insertPubProps (array $publications)
 
 specialCaseProps (&$publications)
 
 checkIfSupportedProperty (string $key, string|array $value, array &$missing_cvterms)
 
 insertContacts (array $publications, bool $do_contact)
 
 addAuthors (string $accession, array $publication, bool $do_contact=FALSE)
 
 getContact (string $contact_name, string $type)
 
 getContactType (string $type_name)
 
 run_init ()
 
- Protected Member Functions inherited from Drupal\tripal_chado\TripalImporter\ChadoImporterBase
 addBundleTypeProperty (string $pkey, int $record_id, string $property_table, string $termIdSpace, string $termAccession, string $value='', ?int $rank=NULL)
 
- Protected Member Functions inherited from Drupal\tripal\TripalImporter\TripalImporterBase
 setTotalItems ($total_items)
 
 addItemsHandled ($num_handled)
 
 setItemsHandled ($total_handled)
 
 setInterval ($interval)
 
 xmlIsValid (string $xml)
 

Protected Attributes

 $public = NULL
 
 $pub_library_manager = NULL
 
 $db_id = NULL
 
 $cvterm_lookups = NULL
 
 $contact_lookups = []
 
array $pub_index = []
 
array $new_accessions = []
 
int $batch_size = 100
 
- Protected Attributes inherited from Drupal\tripal_chado\TripalImporter\ChadoImporterBase
 $chado_schema_main
 
 $messenger = NULL
 
 $connection
 
array $bundle_type_id = []
 
- Protected Attributes inherited from Drupal\tripal\TripalImporter\TripalImporterBase
 $messenger = NULL
 
 $logger = NULL
 
 $fileretriever = NULL
 
 $publish_manager = NULL
 
 $job
 
 $arguments
 
 $import_id
 
 $is_prepared
 
 $reported
 
 $plugin_id
 
 $plugin_definition
 

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
TripalPubLibraryManager  $pub_library_manager,
Connection  $public,
ChadoConnection  $connection,
Messenger  $messenger,
TripalLogger  $logger,
TripalFileRetriever  $fileretriever,
TripalBackendPublishManager  $publish_manager 
)

{}

Member Function Documentation

◆ addAuthors()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::addAuthors ( string  $accession,
array  $publication,
bool  $do_contact = FALSE 
)
protected

Add one or more authors to a publication through the pubauthor table, and optionally the pubauthor_contact and contact tables

Parameters
string$accessionThe external database accession for this publication
array$publicationA single publication query result.
bool$do_contactIf TRUE, then create and link an entry in the chado.contact table
Returns
int A count of the number of records added Example PMID with a suffix: 38266644 Example PMID that is a collective: 12773082

◆ cachePublicationCvterms()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::cachePublicationCvterms ( )
protected

Caches cvterm_id values for all cvterms in the "tripal_pub" vocabulary, saving them in the class variable $this->cvterm_lookups

◆ checkIfSupportedProperty()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::checkIfSupportedProperty ( string  $key,
string|array  $value,
array &  $missing_cvterms 
)
protected

Helper function for insertPubProps to determine if the property CV term is supported.

Parameters
string$keyThe property key, which is a CV term.
string | array$valueThe property value or values.
array&$missing_cvtermsArray keys define a list of non-supported CV terms.
Returns
array An array of values to be saved, or NULL if the $key is not supported.

◆ create()

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

Implements ContainerFactoryPluginInterface->create().

We are injecting an additional dependency here, the TripalPubLibraryManager.

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 constructor.

Parameters
Symfony\Component\DependencyInjection\ContainerInterface$containerThe container.
array$configurationA configuration array containing information about the plugin instance.
string$plugin_idThe plugin ID for the plugin instance.
mixed$plugin_definitionThe plugin implementation definition.
Returns
static

Reimplemented from Drupal\tripal_chado\TripalImporter\ChadoImporterBase.

◆ findExistingPublications()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::findExistingPublications ( array  $publications)

Finds publication accessions that already are stored in Chado.

Results are stored in $this->pub_index

Parameters
array$publicationsPublications loaded from the external database
Returns
int The number of publications not currently stored in Chado

◆ form()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::form (   $form,
$form_state 
)
See also
TripalImporter::form()

Reimplemented from Drupal\tripal_chado\TripalImporter\ChadoImporterBase.

◆ formQueryIdNotSet()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::formQueryIdNotSet ( $form,
  $form_state 
)
protected

Helper function for form(), code to handle the case where the query ID is not yet set.

Parameters
array&$formThe form array definition.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.

◆ formSubmit()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::formSubmit (   $form,
$form_state 
)

{Handles submission of the form elements.The form elements provided in the implementation of the form() function can be used for special submit if needed.

Parameters
array$formThe form array definition.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state object.
}

Implements Drupal\tripal\TripalImporter\Interfaces\TripalImporterInterface.

◆ formValidate()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::formValidate (   $form,
$form_state 
)
See also
TripalImporter::formValidate()

Implements Drupal\tripal\TripalImporter\Interfaces\TripalImporterInterface.

◆ getContact()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::getContact ( string  $contact_name,
string  $type 
)
protected

Gets the contact_id of a person, will create the contact if it does not already exist

Parameters
string$contact_nameThe name of a contact
string$typeThe type of contact in the tripal_contact ontology, most commonly 'Person'
Returns
int The contact_id value

◆ getContactType()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::getContactType ( string  $type_name)
protected

Gets a cvterm_id from the tripal_contact ontology.

Parameters
string$type_nameCorresponds to the 'name' column of the cvterm table
Returns
int Corresponds to the 'cvterm_id' column of the cvterm table.

◆ getNewPublicationAccessions()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::getNewPublicationAccessions ( array  $publications)
protected

Extract a list of new publication accessions that need to be imported

Parameters
array$publicationsThe publications returned from the external database
Returns
void The list is stored at $this->new_accessions

◆ getPublicationTypeId()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::getPublicationTypeId ( array &  $publications,
int  $index 
)
protected

Get the cvterm_id for the publication type

Parameters
array&$publicationsArray of publication records returned by the external database.
int$indexArray key for the publication of interest.
Returns
int The corresponding cvterm_id value
Exceptions

Exception If type is not defined in the publication, or if the type is not available in the tripal_pub ontology

◆ getRemoteDbId()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::getRemoteDbId ( string  $db_name)
protected

Retrieves the pkey value from the chado.db table of the specified databse

Parameters
string$db_nameThe name of the remote database
Returns
void Stores the returned value in $this->db_id
Exceptions

Exception Exception if the database name does not exist

◆ insertContacts()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::insertContacts ( array  $publications,
bool  $do_contact 
)
protected

Add authors to all specified publications

Parameters
array$publicationsResults from the publication external database query
bool$do_contactIf TRUE, then create and link an entry in the chado.contact table
Returns
int Count of number of contacts added

◆ insertMissingPublicationsDbxref()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::insertMissingPublicationsDbxref ( array  $publications)
protected

Inserts new publication accessions into the dbxref table.

Parameters
array$publicationsAll publications returned by the external database
Returns
int A count of the number of records inserted Inserted dbxref_id pkey values are stored in $this->pub_index

◆ insertPubDbxrefs()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::insertPubDbxrefs ( )
protected

Link publications to the database accessions through pub_dbxref table

◆ insertPublications()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::insertPublications ( array &  $publications)
protected

Inserts new publications into the pub table

Parameters
array&$publicationsAll publications returned by the external database
Returns
int A count of the number of publications inserted

◆ insertPubProps()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::insertPubProps ( array  $publications)
protected

Add publication properties to the chado.pubprop table

Parameters
array$publicationsAll publications returned by the external database
Returns
int A count of the number of properties inserted

◆ run()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::run ( )
See also
TripalImporter::run()

n.b. the calling function will wrap this in a database transaction

Implements Drupal\tripal\TripalImporter\Interfaces\TripalImporterInterface.

◆ run_init()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::run_init ( )
protected

Handles initialization for the run() function

Returns
array|NULL The criteria array, or NULL if an error occurred

◆ specialCaseProps()

Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::specialCaseProps ( $publications)
protected

Special case handling for specific properties

Parameters
array&$publicationsThe array of publications being imported

Member Data Documentation

◆ $batch_size

int Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$batch_size = 100
protected

Stores the maximum size of database query batches

◆ $contact_lookups

array Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$contact_lookups = []
protected

Stores a few cached cvterm_id values for the tripal_contact ontology

Key is CV name, value is cvterm_id

◆ $cvterm_lookups

array Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$cvterm_lookups = NULL
protected

Stores all of the cvterm_id values for the tripal_pub ontology

Key is CV name, value is cvterm_id

◆ $db_id

int Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$db_id = NULL
protected

db_id value from the chado.db table for the external database

◆ $new_accessions

array Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$new_accessions = []
protected

Stores accessions of new publications not already stored in chado

◆ $pub_index

array Drupal\tripal_chado\Plugin\TripalImporter\PubSearchQueryImporter::$pub_index = []
protected

Stores information for retrieved publications keyed by the accession

First key is accession, second level keys implemented are:

  • 'index' - int, the $publications array index
  • 'pub_id' - int, the pkey of the chado.pub table
  • 'is_new' - boolean, if TRUE we need to insert this as a new publication
  • 'dbxref_id' - int, the pkey of the chado.dbxref table

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