123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- function hook_handle_uploaded_file($filename, $filepath, $type) {
- }
- function tripal_get_importers() {
- $importers = array();
- $modules = module_list(TRUE);
- foreach ($modules as $module) {
-
- $loader_path = drupal_get_path('module', $module) . '/includes/TripalImporter';
- $loader_files = file_scan_directory($loader_path, '/.inc$/');
-
- foreach ($loader_files as $file) {
- $class = $file->name;
- module_load_include('inc', $module, 'includes/TripalImporter/' . $class);
- if (class_exists($class) and is_subclass_of($class, 'TripalImporter')) {
- $importers[] = $class;
- }
- }
- }
- return $importers;
- }
- function tripal_load_include_importer_class($class) {
- $modules = module_list(TRUE);
- foreach ($modules as $module) {
- $file_path = realpath(".") . '/' . drupal_get_path('module', $module) . '/includes/TripalImporter/' . $class . '.inc';
- if (file_exists($file_path)) {
- module_load_include('inc', $module, 'includes/TripalImporter/' . $class);
- if (class_exists($class)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- 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 {
-
- tripal_run_importer_run($loader, $job);
-
- tripal_run_importer_post_run($loader, $job);
-
- print "Remapping Chado Controlled vocabularies to Tripal Terms...";
- tripal_chado_map_cvterms();
-
- tripal_tripal_cron_notification();
-
- cache_clear_all();
- }
- catch (Exception $e) {
- if ($job) {
- $job->logMessage($e->getMessage(), array(), TRIPAL_ERROR);
- }
- if ($loader) {
- $loader->cleanFile();
- }
- }
- }
- function tripal_run_importer_run($loader, $job) {
- try {
-
- $transaction = db_transaction();
- $loader->run();
- if ($job) {
- $job->logMessage("\nDone.\n");
- }
-
- if (!empty($details->arguments['file_url'])) {
- $loader->logMessage('Removing downloaded file...');
- unlink($temp);
- }
- }
- catch (Exception $e) {
-
- $transaction->rollback();
- throw $e;
- }
- }
- function tripal_run_importer_post_run($loader, $job) {
- try {
-
- $transaction = db_transaction();
- $loader->postRun();
- }
- catch (Exception $e) {
-
- $transaction->rollback();
- throw $e;
- }
- }
|