function tripal_run_importer
3.x tripal.importer.api.inc | tripal_run_importer($import_id, TripalJob $job = NULL) |
Imports data into the database.
Tripal provides the TripalImporter class to allow site developers to create their own data loaders. Site users can then use any data loader implemented for the site by submitting the form that comes with the TripalImporter impelmentation. This function runs the importer using the arguments provided by the user.
Parameters
$import_id: The ID of the import record.
Throws
Exception
Related topics
1 string reference to 'tripal_run_importer'
- TripalImporter::submitJob in tripal/
includes/ TripalImporter.inc - Submits the importer for execution as a job.
File
- tripal/
api/ tripal.importer.api.inc, line 115 - Provides an application programming interface (API) for working with data file importers using the TripalImporter class.
Code
function tripal_run_importer($import_id, TripalJob $job = NULL) {
$loader = NULL;
$loader = TripalImporter::byID($import_id);
$loader->setJob($job);
$loader->prepareFiles();
print "\nRunning '" . $loader::$name . "' importer";
print "\nNOTE: Loading of file is performed using a database transaction. \n" .
"If it fails or is terminated prematurely then all insertions and \n" .
"updates are rolled back and will not be found in the database\n\n";
try {
// Run the loader
tripal_run_importer_run($loader, $job);
// Handle the post run.
tripal_run_importer_post_run($loader, $job);
// Check for tables with new cvterms
print "Remapping Chado Controlled vocabularies to Tripal Terms...";
tripal_chado_map_cvterms();
// Check for new fields and notify the user.
tripal_tripal_cron_notification();
// Clear the Drupal cache
cache_clear_all();
}
catch (Exception $e) {
if ($job) {
$job->logMessage($e->getMessage(), array(), TRIPAL_ERROR);
}
if ($loader) {
$loader->cleanFile();
}
}
}