protected function TripalImporter::setItemsHandled

3.x TripalImporter.inc protected TripalImporter::setItemsHandled($total_handled)

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

$total_handled: The total number of items that have been processed.

6 calls to TripalImporter::setItemsHandled()
FASTAImporter::loadFasta in tripal_chado/includes/TripalImporter/FASTAImporter.inc
Load a fasta file.
OBOImporter::loadTypeDefs in tripal_chado/includes/TripalImporter/OBOImporter.inc
OBO files are divided into a typedefs terms section and vocabulary terms section. This function loads the typedef terms from the OBO.
OBOImporter::parse in tripal_chado/includes/TripalImporter/OBOImporter.inc
Parse the OBO file and populate the templ loading table
OBOImporter::processTerms in tripal_chado/includes/TripalImporter/OBOImporter.inc
OBO files are divided into a typedefs section and a terms section.
TaxonomyImporter::run in tripal_chado/includes/TripalImporter/TaxonomyImporter.inc
Performs the import.

... See full list

File

tripal/includes/TripalImporter.inc, line 599

Class

TripalImporter

Code

protected function setItemsHandled($total_handled) {
  // First set the number of items handled.
  $this->num_handled = $total_handled;

  if ($total_handled == 0) {
    $memory = number_format(memory_get_usage());
    print "Percent complete: 0%. Memory: " . $memory . " bytes.\r";
    return;
  }

  // Now see if we need to report to the user the percent done.  A message
  // will be printed on the command-line if the job is run there.
  $percent = sprintf("%.2f", ($this->num_handled / $this->total_items) * 100);
  $diff = $percent - $this->prev_update;

  if ($diff >= $this->interval) {

    $memory = number_format(memory_get_usage());
    print "Percent complete: " . $percent . "%. Memory: " . $memory . " bytes.\r";

    // If we have a job the update the job progress too.
    if ($this->job) {
      $this->job->setProgress($percent);
    }

    $this->prev_update = $diff;
  }
}