function change_roi_type($roi_pid, $roi_type) { if ($roi_type == "Annotation") { $roi_type = "Annotation/Other"; } $roi = new roiHandler($roi_pid); $roiMetadata = $roi->getDatastream("roiMetadata"); $dom = new DOMDocument(); $dom->loadXML($roiMetadata); $dom->getElementsByTagName("roiType")->item(0)->nodeValue = $roi_type; $result = $roi->setDatastream("roiMetadata", "roi_Metadata", "text/xml", $dom->saveXML(), FEDORA_DATABASE_USERNAME . ":" . FEDORA_DATABASE_PASSWORD); if ($result) { echo "Success"; } else { echo "Failed"; } }
function save_parsed_text($roi_pid, $nothing, $workflow_id) { global $user; $returnjs = ""; if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canTranscribe")) { $query_string = $_SERVER['QUERY_STRING']; log_to_db($_SERVER['QUERY_STRING'], 'save_parsed_text QUERY_STRING'); log_to_db($_REQUEST['specimenMetadata'], 'save_parsed_text specimenMetadata'); $specimenMetadata = $_REQUEST['specimenMetadata']; $file_path = drupal_get_path('module', 'apiary_project') . "/workflow/assets/xml/metadata_template.xml"; $doc = new DOMDocument(); $doc->load($file_path); $pairs = explode('&', $specimenMetadata); foreach ($pairs as $pair) { if (!empty($pair)) { list($name, $value) = explode("=", $pair, 2); if ($name != "q") { $element = $doc->getElementsByTagName($name)->item(0); $element->nodeValue = urldecode($value); } } } $roi_obj = new roiHandler($roi_pid); log_to_db($doc->saveXML(), 'save_parsed_text doc_saveXML'); $success = $roi_obj->setDatastream("specimenMetadata", "Label-Information", "text/xml", $doc->saveXML(), FEDORA_DATABASE_USERNAME . ":" . FEDORA_DATABASE_PASSWORD); log_to_db($_REQUEST['text'], 'save_parsed_text text'); $success = $roi_obj->setDatastream("Text", "Parsed", "text/plain", $_POST['text'], FEDORA_DATABASE_USERNAME . ":" . FEDORA_DATABASE_PASSWORD); if ($success) { $solr_search = new search(); $solr_search->index($roi_pid); $returnjs .= "\$.jGrowl('Parsed text for ROI [{$roi_pid}] saved successfully.');"; } else { $returnjs .= "\$.jGrowl('Parsed text for ROI [{$roi_pid}] failed to save.');"; } } else { $returnjs .= "\$.jGrowl('Sorry! You do not have permission for this operation');"; } echo $returnjs; }
function save_transcribe_text($roi_pid, $nothing, $workflow_id) { global $user; $returnjs = ""; if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canTranscribe")) { $roi_obj = new roiHandler($roi_pid); $text = $_REQUEST['text']; $text = str_replace(' ', ' ', $text); $success = $roi_obj->setDatastream("Text", "Transcribed", "text/plain", $text, FEDORA_DATABASE_USERNAME . ":" . FEDORA_DATABASE_PASSWORD); if ($success) { $returnjs .= "\$.jGrowl('Trascribed Text for ROI [{$roi_pid}] saved successfully.');"; } else { $returnjs .= "\$.jGrowl('Trascribed Text for ROI [{$roi_pid}] failed to save.');"; } } else { $returnjs .= "\$.jGrowl('Sorry! You do not have permission for this operation');"; } echo $returnjs; }
function saveSpecimenGroundtruth($specimen_pid, $groundtruth_dom) { $roi_obj = new roiHandler($specimen_pid); $result = $roi_obj->setDatastream("groundtruth", "Specimen+Ground+Truth", "text/xml", $groundtruth_dom->saveXML(), FEDORA_DATABASE_USERNAME . ":" . FEDORA_DATABASE_PASSWORD); if ($result) { return true; } else { return false; } }