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"; } }
public function index_image($pid) { $dom = new DOMDocument('1.0', 'iso-8859-1'); $addElement = $dom->createElement('add', ''); $dom->appendChild($addElement); $docElement = $dom->createElement('doc', ''); $addElement->appendChild($docElement); $fieldElement = $dom->createElement('field', $pid); $fieldElement->setAttribute("name", "id"); $docElement->appendChild($fieldElement); $curr_pid = new roiHandler($pid); //we may need to create an imageHandler but should decide on moving ahead with the curl route or using islandora and stick with one route if ($curr_pid->ifExist("RELS-EXT")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("RELS-EXT")); $ip_string = $xml->getElementsByTagName("hasModel")->item(0)->getAttributeNode("rdf:resource")->value; $specimen_pid = str_replace("info:fedora/", "", $ip_string); $fieldElement = $dom->createElement('field', $specimen_pid); $fieldElement->setAttribute("name", "parent_id"); $docElement->appendChild($fieldElement); } if ($curr_pid->ifExist("status")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("status")); $StatusesElement = $xml->getElementsByTagName("statuses")->item(0); foreach ($StatusesElement->childNodes as $theTerm) { $searchValue = $theTerm->nodeValue; if ($theTerm->nodeName != "locked_time") { $searchField = "status_" . $theTerm->nodeName; } else { $searchField = "locked_time"; } $fieldElement = $dom->createElement('field', $searchValue); $fieldElement->setAttribute("name", $searchField); $docElement->appendChild($fieldElement); } } if ($curr_pid->ifExist("imageMetadata")) { $xml = new DOMDocument('1.0', 'iso-8859-1'); $xml->loadXML($curr_pid->getDatastream("imageMetadata")); $imageMetadataElement = $xml->getElementsByTagName("imageMetadata_record")->item(0); foreach ($imageMetadataElement->childNodes as $theTerm) { if ($theTerm->nodeName != '#text') { $searchValue = $theTerm->nodeValue; $searchField = "imageMetadata_" . str_replace("api:", "", $theTerm->nodeName); $fieldElement = $dom->createElement('field', $searchValue); $fieldElement->setAttribute("name", $searchField); $docElement->appendChild($fieldElement); } } } $this->result_doc = $dom; if (!$this->update_index()) { echo "Error Occurred while update index of Image: {$pid}"; } }
function herbis_parse($roi_pid) { $apiary_project_herbis_dir = variable_get('apiary_project_herbis_dir', '/var/www/drupal/modules/apiary_project/herbis'); $apiary_project_herbis_url = variable_get('apiary_project_herbis_url', 'http://txcdk3g.unt.edu:8080/HERBIS'); $returnJSON = ""; $roi_obj = new roiHandler($roi_pid); $herbis_result = $roi_obj->get_herbis($apiary_project_herbis_dir, $apiary_project_herbis_url); //echo $herbis_result; $returnJSON['herbis_result'] = $herbis_result; echo json_encode($returnJSON); }
function get_transcribe_content($roi_pid, $size, $workflow_id) { global $user; list($height, $width) = explode(":", $size); $returnJSON = ""; if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canTranscribe")) { $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid); $roiURL = $roiMetadata_record['roiURL']; if ($height > $roiMetadata_record['h'] / $roiMetadata_record['w'] * $width) { $roi_image_url = scaleDjatokaURL($roiURL, $width, '0'); //$roi_image_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $roiMetadata_record['h'], $roiMetadata_record['w'], $width, '0'); $returnJSON['image_html'] = "<img class='transcribe_roi_image' src='{$roi_image_url}' />"; } else { $roi_image_url = scaleDjatokaURL($roiURL, '0', $height); //$roi_image_url = getDjatokaURL($roiMetadata_record['sourceURL'], 'getRegion', '100', $roiMetadata_record['y'], $roiMetadata_record['x'], $roiMetadata_record['h'], $roiMetadata_record['w'], '0', $height); $returnJSON['image_html'] = "<img class='transcribe_roi_image' src='{$roi_image_url}' />"; } $roi_obj = new roiHandler($roi_pid); $returnJSON['gocr'] = ""; $returnJSON['ocrad'] = ""; $returnJSON['ocropus'] = ""; $returnJSON['text'] = ""; if ($roi_obj->ifExist("GOCR")) { $returnJSON['gocr'] = $roi_obj->getDatastream("GOCR"); } if ($roi_obj->ifExist("ocrad")) { $returnJSON['ocrad'] = $roi_obj->getDatastream("ocrad"); } if ($roi_obj->ifExist("OCRopus")) { $returnJSON['ocropus'] = $roi_obj->getDatastream("OCRopus"); } if ($roi_obj->ifExist("Text")) { $returnJSON['text'] = $roi_obj->getDatastream("Text"); } } else { echo "Sorry! You do not have permission for this operation"; } echo json_encode($returnJSON); }
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; } }