private function update_eol_xml($lifedesk_name) { /* taxon = 434 dwc:ScientificName = 434 reference = 614 synonym = 68 commonName = 2 dataObjects = 1705 reference = 0 texts = 1146 images = 559 videos = 0 sounds = 0 */ require_library('ResourceDataObjectElementsSetting'); $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $lifedesk_name . ".xml"; $func = new ResourceDataObjectElementsSetting($lifedesk_name, $resource_path); $xml = file_get_contents($this->text_path["eol_xml"]); $xml = $func->replace_taxon_element_value("dc:source", "replace any existing value", "", $xml, false); $xml = $func->replace_data_object_element_value("dc:source", "replace any existing value", "", $xml, false); $xml = self::remove_tags_in_references($xml); $func->save_resource_document($xml); // zip the xml $command_line = "gzip -c " . CONTENT_RESOURCE_LOCAL_PATH . $lifedesk_name . ".xml >" . CONTENT_RESOURCE_LOCAL_PATH . $lifedesk_name . ".xml.gz"; $output = shell_exec($command_line); }
function remove_dataObject() { require_library('ResourceDataObjectElementsSetting'); $resource_id = 346; $resource_path = "http://localhost/eol_php_code/applications/content_server/resources/346.xml.gz"; $nmnh = new ResourceDataObjectElementsSetting($resource_id, $resource_path); $xml = $nmnh->load_xml_string(); $xml = $nmnh->remove_data_object_of_certain_element_value("mimeType", "image/x-adobe-dng", $xml); $nmnh->save_resource_document($xml); }
<?php namespace php_active_record; /* connector for Royal Botanic Garden Edinburgh: Herbarium Specimen Images (E) estimated execution time: There is already a published data for this resource that is set to 'import once'. The connector modifies the 336.xml in Beast. */ include_once dirname(__FILE__) . "/../../config/environment.php"; $timestart = time_elapsed(); $resource_id = 336; //-------------- /* set rating to 2 */ require_library('ResourceDataObjectElementsSetting'); $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml"; $func = new ResourceDataObjectElementsSetting($resource_id, $resource_path, 'http://purl.org/dc/dcmitype/StillImage', 2); $xml = $func->set_data_object_rating_on_xml_document(); $func->save_resource_document($xml); //-------------- Functions::set_resource_status_to_force_harvest($resource_id); $elapsed_time_sec = time_elapsed() - $timestart; echo "\n"; echo "elapsed time = {$elapsed_time_sec} seconds \n"; echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n"; echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n"; echo "\n\n Done processing.";
<?php namespace php_active_record; /* connector for BOLDS images estimated execution time: 3 minutes Provider provides a big text file. */ include_once dirname(__FILE__) . "/../../config/environment.php"; require_library('connectors/BoldsImagesAPI'); $timestart = time_elapsed(); $resource_id = 329; BoldsImagesAPI::get_all_taxa($resource_id); //-------------- /* set rating to 2 */ require_library('ResourceDataObjectElementsSetting'); $resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml"; $bolds = new ResourceDataObjectElementsSetting($resource_id, $resource_path, 'http://purl.org/dc/dcmitype/StillImage', 2); $xml = $bolds->set_data_object_rating_on_xml_document(); $bolds->save_resource_document($xml); //-------------- Functions::set_resource_status_to_force_harvest($resource_id); $elapsed_time_sec = time_elapsed() - $timestart; echo "\n"; echo "elapsed time = {$elapsed_time_sec} seconds \n"; echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n"; echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n"; echo "\n\n Done processing.";
/* connector for National Museum of Natural History Image Collection estimated execution time: 1.5 mins. Connector reads the XML provided by partner and - sets the image rating. - If needed ingests TypeInformation text dataObjects */ include_once dirname(__FILE__) . "/../../config/environment.php"; require_library('ResourceDataObjectElementsSetting'); $timestart = time_elapsed(); $resource_id = 120; $resource_path = "http://collections.mnh.si.edu/services/eol/nmnh-iz-response.xml.gz"; //NMNH Invertebrate Zoology resource $result = $GLOBALS['db_connection']->select("SELECT accesspoint_url FROM resources WHERE id={$resource_id}"); $row = $result->fetch_row(); $new_resource_path = $row[0]; if ($resource_path != $new_resource_path && $new_resource_path != '') { $resource_path = $new_resource_path; } echo "\n processing resource:\n {$resource_path} \n\n"; $nmnh = new ResourceDataObjectElementsSetting($resource_id, $resource_path, 'http://purl.org/dc/dcmitype/StillImage', 2); $xml = $nmnh->set_data_object_rating_on_xml_document(); require_library('connectors/INBioAPI'); $xml = INBioAPI::assign_eol_subjects($xml); $nmnh->save_resource_document($xml); Functions::set_resource_status_to_force_harvest($resource_id); $elapsed_time_sec = time_elapsed() - $timestart; echo "\n"; echo "elapsed time = {$elapsed_time_sec} seconds \n"; echo "elapsed time = " . $elapsed_time_sec / 60 . " minutes \n"; echo "elapsed time = " . $elapsed_time_sec / 60 / 60 . " hours \n"; echo "\n\n Done processing.";