function loadWorkflowPools() { module_load_include('php', 'apiary_project', 'workflow/include/class.Object_Pool'); $this->object_pool = new Object_Pool($this->object_pool_id); $specimens = array(); $images = array(); $rois = array(); $specimen_pids = array(); $image_pids = array(); $roi_pids = array(); $queued_image_pids = array(); $queued_roi_pids = array(); $workflow_pids = array(); $workflow_dom = new DOMDocument('1.0', 'iso-8859-1'); $workflowElement = $workflow_dom->createElement('workflow', ''); //rootElement $workflow_dom->appendChild($workflowElement); //$time_start = $this->microtime_float(); include_once drupal_get_path('module', 'apiary_project') . '/workflow/include/search.php'; $solr_search = new search(); foreach ($this->object_pool->object_pool_pids as $pid) { switch ($pid) { case strpos($pid, 'ap-specimen:') > -1: $specimenElement = $workflow_dom->createElement("specimen"); $specimen_pidElement = $workflow_dom->createElement("pid", $pid); $specimenElement->appendChild($specimen_pidElement); array_push($specimen_pids, $pid); array_push($workflow_pids, $pid); $specimen['pid'] = $pid; if ($this->fill_fedora) { $specimenMetadata = AP_Specimen::getspecimenMetadata_record($pid); $specimen['specimenMetadata'] = $specimenMetadata; } $specimen_images = AP_Specimen::getImageListForSpecimen($pid); //$specimen['images'] = $specimen_images; if (sizeOf($specimen_images) > 0) { foreach ($specimen_images as $image_pid) { $image = array(); $image['pid'] = $image_pid; $imageElement = $workflow_dom->createElement("image"); $image_pidElement = $workflow_dom->createElement("pid", $image_pid); $imageElement->appendChild($image_pidElement); $this->addSolrIndexItems($solr_search, $image_pid, $workflow_dom, $imageElement); if ($this->canAnalyzeSpecimen || $this->canQC) { array_push($image_pids, $image_pid); array_push($workflow_pids, $image_pid); } $specimen_image_rois = AP_Image::getROIListForImage($image_pid); $image['rois'] = $specimen_image_rois; $specimen['rois'] .= $specimen_image_rois; if (sizeOf($specimen_image_rois) > 0) { foreach ($specimen_image_rois as $roi_pid) { $roiElement = $workflow_dom->createElement("roi"); $roi_pidElement = $workflow_dom->createElement("pid", $roi_pid); $roiElement->appendChild($roi_pidElement); $this->addSolrIndexItems($solr_search, $roi_pid, $workflow_dom, $roiElement); array_push($roi_pids, $roi_pid); array_push($workflow_pids, $roi_pid); $imageElement->appendChild($roiElement); } } // $specimen['images'] .= $specimen_images; $specimenElement->appendChild($imageElement); } } array_push($specimens, $specimen); $workflowElement->appendChild($specimenElement); break; case strpos($pid, 'ap-image:') > -1: //see if already loaded array_push($image_pids, $pid); array_push($workflow_pids, $pid); break; case strpos($pid, 'ap-roi:') > -1: //see if already loaded array_push($roi_pids, $pid); array_push($workflow_pids, $pid); break; } } //echo "Session_ID = ".$_SESSION['apiary_session_id']."<br>\n"; //echo $workflow_dom->saveXML()."<br>\n"; //$time_end = $this->microtime_float(); //$time = $time_end - $time_start; //echo "Did it in $time seconds\n"; $this->workflow_dom = $workflow_dom; //echo $workflow_dom->saveXML(); $this->specimens = $specimens; $this->specimen_pids = $specimen_pids; $this->image_pids = $image_pids; //$this->queued_image_pids = $queued_image_pids; $this->roi_pids = $roi_pids; //$this->queued_roi_pids = $queued_roi_pids; $this->workflow_pool = $workflow_pids; }
function get_roi_boxes($image_pid, $nothing, $workflow_id) { global $user; $returnBoxes = ""; if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canAnalyzeSpecimen")) { $roi_pids = AP_Image::getROIListForImage($image_pid); foreach ($roi_pids as $roi_pid) { $roiMetadata_record = AP_ROI::getroiMetadata_record($roi_pid); $returnBoxes[] = array("y" => $roiMetadata_record['y'], "h" => $roiMetadata_record['h'], "x" => $roiMetadata_record['x'], "w" => $roiMetadata_record['w'], "type" => $roiMetadata_record['roiType'], "pid" => $roi_pid); } echo json_encode($returnBoxes); } else { http_send_status(401); echo "You do not have sufficient permission"; } }
function add_next_image_with_rois_to_queue($workflow_id) { $timeout = date("YmdHis", strtotime('now') - 1800); $workflow = new Workflow($workflow_id, true); $workflow_dom = $workflow->workflow_dom; $image_pids = $workflow->image_pids; $totalEntries = sizeOf($image_pids); $specimen_elements = $workflow_dom->getElementsByTagName('specimen'); foreach ($specimen_elements as $specimen) { $specimen_pid = $specimen->getElementsByTagName('pid')->item(0)->nodeValue; $specimen_image_elements = $specimen->getElementsByTagName('image'); foreach ($specimen_image_elements as $image) { $image_pid = $image->getElementsByTagName('pid')->item(0)->nodeValue; $status_dom = AP_Image::getImageStatusDom($image_pid); if ($status_dom != false && ($status_dom->getElementsByTagName('locked')->item(0)->nodeValue == "false" || $status_dom->getElementsByTagName('locked_time')->item(0)->nodeValue < $timeout)) { $status_dom = AP_Image::getImageLock($image_pid); $analyzedStatus = $status_dom->getElementsByTagName('analyzedStatus')->item(0)->nodeValue; $locked_by = $status_dom->getElementsByTagName('locked_by')->item(0)->nodeValue; $locked = $status_dom->getElementsByTagName('locked')->item(0)->nodeValue; $locked_time = $status_dom->getElementsByTagName('locked_time')->item(0)->nodeValue; $locked_session = $status_dom->getElementsByTagName('locked_session')->item(0)->nodeValue; $workflow_status = workflow_status($locked, $locked_time, $locked_session); $roi_pids = AP_Image::getROIListForImage($image_pid); $roi_count = sizeOf($roi_pids); $queue_item_html .= create_queue_list_image($image_pid, $specimen_pid, $analyzedStatus, $roi_count, $locked_by, $workflow_status, $workflow_id); //$queue_item_html .= '<div class="widget-content" id="content-'.str_replace(':', '__', $image_pid).'">'."\n"; $found_queued_roi = false; foreach ($roi_pids as $roi_pid) { $roi_status_dom = AP_ROI::getROILock($roi_pid); if ($roi_status_dom != false) { if (!$found_queued_roi) { $queue_item_html .= '<div class="widget-content" id="content-' . str_replace(':', '__', $image_pid) . '">' . "\n"; $found_queued_roi = true; } $transcribedStatus = $roi_status_dom->getElementsByTagName('transcribedStatus')->item(0)->nodeValue; $parsedL1Status = $roi_status_dom->getElementsByTagName('parsedL1Status')->item(0)->nodeValue; $locked_by = $roi_status_dom->getElementsByTagName('locked_by')->item(0)->nodeValue; $locked = $roi_status_dom->getElementsByTagName('locked')->item(0)->nodeValue; $locked_time = $roi_status_dom->getElementsByTagName('locked_time')->item(0)->nodeValue; $locked_session = $roi_status_dom->getElementsByTagName('locked_session')->item(0)->nodeValue; $workflow_status = workflow_status($locked, $locked_time, $locked_session); $queue_item_html .= create_queue_list_roi($roi_pid, $image_pid, $transcribedStatus, $parsedL1Status, $locked_by, $workflow_status, $workflow_id); } } if ($found_queued_roi) { $queue_item_html .= '</div><!-- widget-content -->' . "\n"; } break 2; } } } echo $queue_item_html; }