public function get_all_taxa_keys($resource_id)
 {
     require_library('connectors/DiscoverLifeAPIv2');
     $func = new DiscoverLifeAPIv2();
     $taxa_objects = self::process_keys_spreadsheet();
     $all_taxa = array();
     $used_collection_ids = array();
     //initialize text file for DiscoverLife: save names without a page in EOL
     self::initialize_text_file(DOC_ROOT . self::TEXT_FILE_FOR_DL . "_" . "id_keys" . ".txt");
     $i = 0;
     $save_count = 0;
     $no_eol_page = 0;
     foreach ($taxa_objects as $name => $fields) {
         $i++;
         //filter names. Process only those who already have a page in EOL. Report back to DiscoverLife names not found in EOL
         if (!($taxon = $func->with_eol_page($name))) {
             print "\n {$i} - no EOL page ({$name})";
             $no_eol_page++;
             self::store_name_to_text_file($name, "ID_Keys");
             continue;
         }
         $taxon["keys"] = array();
         foreach ($fields as $field) {
             $taxon["keys"][] = $field;
         }
         print "\n {$i} -- " . $taxon['orig_sciname'];
         //================================
         $arr = self::get_discoverlife_taxa($taxon, $used_collection_ids);
         $page_taxa = $arr[0];
         $used_collection_ids = $arr[1];
         if ($page_taxa) {
             $all_taxa = array_merge($all_taxa, $page_taxa);
         }
         unset($page_taxa);
     }
     $xml = \SchemaDocument::get_taxon_xml($all_taxa);
     $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml";
     if (!($OUT = fopen($resource_path, "w"))) {
         debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $resource_path);
         return;
     }
     fwrite($OUT, $xml);
     fclose($OUT);
     $with_eol_page = $i - $no_eol_page;
     print "\n\n total = {$i} \n With EOL page = {$with_eol_page} \n No EOL page = {$no_eol_page} \n\n";
 }
Example #2
0
<?php

namespace php_active_record;

/* connector for DiscoverLife Maps
This script is called if the main script calls for another instance of the connector.
*/
set_time_limit(0);
include_once dirname(__FILE__) . "/../../config/environment.php";
$timestart = time_elapsed();
require_library('connectors/DiscoverLifeAPIv2');
$resource_id = 223;
if (isset($argv[1])) {
    $call_multiple_instance = false;
} else {
    $call_multiple_instance = true;
}
$dl = new DiscoverLifeAPIv2();
$dl->start_process($resource_id, $call_multiple_instance);
$elapsed_time_sec = time_elapsed() - $timestart;
echo "\n";
echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n";
echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n";
echo "elapsed time = " . $elapsed_time_sec / 60 / 60 / 24 . " days \n";
echo "\n\n Done processing.";
Example #3
0
<?php

namespace php_active_record;

/* connector for DiscoverLife Maps
estimated execution time: 20 mins.
*/
set_time_limit(0);
include_once dirname(__FILE__) . "/../../config/environment.php";
$timestart = time_elapsed();
require_library('connectors/DiscoverLifeAPIv2');
$resource_id = 223;
$folder = DOC_ROOT . "update_resources/connectors/files/DiscoverLife";
if (!file_exists($folder)) {
    mkdir($folder, 0777);
}
$dl = new DiscoverLifeAPIv2();
$dl->initialize_text_files();
$dl->start_process($resource_id, false);
Functions::set_resource_status_to_force_harvest($resource_id);
$elapsed_time_sec = time_elapsed() - $timestart;
echo "\n";
echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n";
echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n";
echo "elapsed time = " . $elapsed_time_sec / 60 / 60 / 24 . " days \n";
echo "\n\n Done processing.";