Tripal
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
TripalFieldDownloader Class Reference
Inheritance diagram for TripalFieldDownloader:
Inheritance graph
[legend]

Public Member Functions

 __construct ($collection_id, $outfile_name)
 
 isFieldSupported ($field, $instance)
 
 getURL ()
 
 delete ()
 
 writeInit (TripalJob $job=NULL)
 
 writeEntity ($entity, TripalJob $job=NULL)
 
 writeDone (TripalJob $job=NULL)
 
 write (TripalJob $job=NULL)
 
 download ()
 

Static Public Attributes

static $label = 'Generic'
 
static $full_label = 'Generic File format'
 
static $default_extension = 'txt'
 

Protected Member Functions

 setFields ()
 
 setFields2Terms ()
 
 setPrintableFields ()
 
 formatEntity ($entity)
 
 getHeader ()
 

Protected Attributes

 $collection = NULL
 
 $collection_id = NULL
 
 $collection_bundles = NULL
 
 $outfile = ''
 
 $printable_fields = []
 
 $remote_entity = ''
 
 $fields2terms = []
 
 $fields = []
 
 $fh
 

Constructor & Destructor Documentation

◆ __construct()

TripalFieldDownloader::__construct (   $collection_id,
  $outfile_name 
)

Constructs a new instance of the TripalFieldDownloader class.

Parameters
$collection_idThe ID for the collection.
$outfile_nameThe name of the output file to create. The name should not include a path.

Member Function Documentation

◆ delete()

TripalFieldDownloader::delete ( )

Removes the downloadable file.

◆ download()

TripalFieldDownloader::download ( )

Setups a download stream for the file.

◆ formatEntity()

TripalFieldDownloader::formatEntity (   $entity)
abstractprotected

Formats the entity and the specified fields for output.

This function should be implemented by a child class. It should iterate over the fields for the entity and return the appropriate format. It may return multiple lines of output if necessary.

Parameters
$entityThe entity object. The fields that should be formatted are already loaded.
Returns
An array of strings (one per line of output.

Reimplemented in TripalTabDownloader, TripalProteinFASTADownloader, TripalNucFASTADownloader, TripalGFF3Downloader, and TripalCSVDownloader.

◆ getHeader()

TripalFieldDownloader::getHeader ( )
abstractprotected

Retrieves header lines

This function should be implemented by a child class. It should return the header lines for an output file.

Reimplemented in TripalTabDownloader, TripalProteinFASTADownloader, TripalNucFASTADownloader, TripalGFF3Downloader, and TripalCSVDownloader.

◆ getURL()

TripalFieldDownloader::getURL ( )

Retrieves the URL for the downloadable file.

◆ isFieldSupported()

TripalFieldDownloader::isFieldSupported (   $field,
  $instance 
)

Inidcates if a given field is supported by this Downloader class.

Parameters
$fieldA field info array.

Reimplemented in TripalTabDownloader, and TripalCSVDownloader.

◆ setFields()

TripalFieldDownloader::setFields ( )
protected

Sets the fields array

◆ setFields2Terms()

TripalFieldDownloader::setFields2Terms ( )
protected

Sets the fields2term array.

The fields2term array provides an easy lookup for mapping a term to it's accession number.

◆ setPrintableFields()

TripalFieldDownloader::setPrintableFields ( )
protected

Conslidates all the fields into a single list of accession numbers.

The array of printable fields will contain an array containing the accession number and the label. The title used is from the first occurance of an accession.

◆ write()

TripalFieldDownloader::write ( TripalJob  $job = NULL)

Creates the downloadable file.

Parameters
$jobIf this function is run as a Tripal Job then this argument can be set to the Tripaljob object for keeping track of progress.

◆ writeDone()

TripalFieldDownloader::writeDone ( TripalJob  $job = NULL)

Closes the output file once writing of all entities is completed.

Parameters
TripalJob$job

◆ writeEntity()

TripalFieldDownloader::writeEntity (   $entity,
TripalJob  $job = NULL 
)

Write a single entity to the file.

Before calling this function call the initWrite() function to establish the file and write headers.

Parameters
$entityThe Entity to write.
TripalJob$job

◆ writeInit()

TripalFieldDownloader::writeInit ( TripalJob  $job = NULL)
Parameters
TripalJob$job

Member Data Documentation

◆ $collection

TripalFieldDownloader::$collection = NULL
protected

The data collection assigned to this downloader.

◆ $collection_bundles

TripalFieldDownloader::$collection_bundles = NULL
protected

An array of collection_bundle records for the content types that belong to this data collection.

◆ $collection_id

TripalFieldDownloader::$collection_id = NULL
protected

The collection ID

◆ $default_extension

TripalFieldDownloader::$default_extension = 'txt'
static

Indicates the default extension for the outputfile.

◆ $fh

TripalFieldDownloader::$fh
protected

The file handle for an opeend file using during writing.

◆ $fields

TripalFieldDownloader::$fields = []
protected

A list of field and instance items, indexed first by site_id with 'local' being the key for local fields and the numeric site_id for remote fields. The second-levle key is the bundle_name and the the field_id. Below the field_id are the keys 'field' or 'instance' where the value of each is the field or instance details respectively.

◆ $fields2terms

TripalFieldDownloader::$fields2terms = []
protected

An array that associates a field ID with a term.

The first-level key is the site ID. For the local site this will be the word 'local' for all others it will be the numeric id. The second level key is the bundle bundle name. For local bundles this will always be bio_data_xxxx. Third, are two subkeys: by_field and by_accession. To lookup a field's term you use the 'by_field' subkey with the field_id as the next level. To lookup the field ID for a term use the 'by_accession' subkey with the accession as the next level. Below is an example of the structure of this array.

Array (
[local] => Array(
[bio_data_7] => Array(
[by_field] => Array(
[56] => data:2091,
[57] => OBI:0100026,
[17] => schema:name,
[58] => data:2044,
[34] => data:0842,
[67] => schema:alternateName,
),
[by_accession] => Array (
[data:2091] => 56,
[OBI:0100026] => 57,
[schema:name] => 17,
[data:2044] => 58,
[data:0842] => 34,
[schema:alternateName] => 67,
),
),
),
)

◆ $full_label

TripalFieldDownloader::$full_label = 'Generic File format'
static

A more verbose label that better describes the formatter.

◆ $label

TripalFieldDownloader::$label = 'Generic'
static

Sets the label shown to the user describing this formatter. It should be a short identifier. Use the $full_label for a more descriptive label.

◆ $outfile

TripalFieldDownloader::$outfile = ''
protected

The output file URI.

◆ $printable_fields

TripalFieldDownloader::$printable_fields = []
protected

An array of printable fields. Because fields can come from multiple bundles and those bundles can be from multiple sites, it is possible that 1) two bundles use the same field and we want to conslidate to a single printable field; and 2) that a remote site may use the same term for a field as a bundle on the local site. The only way to sort out this mess is to use the term accession numbers. Therefore, the array contains a unique list of printable fields using their accession numbers as keys and a field label as the value.

◆ $remote_entity

TripalFieldDownloader::$remote_entity = ''
protected

The remote site json data returned for the entity


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