Exemplo n.º 1
0
function get_specimen_pid($image_pid, $nothing, $workflow_id)
{
    $returnJSON[] = AP_Image::get_specimen_pid($image_pid);
    echo json_encode($returnJSON);
}
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 static function releaseImageLock($image_pid)
 {
     global $user;
     $now = date("YmdHis");
     $datastream_name = "status";
     $datastream_label = "Image Status";
     $session_id = $_SESSION['apiary_session_id'];
     if ($session_id == '') {
         $session_id = $_SESSION['apiary_cleared_session_id'];
     }
     $dom = FedoraObject::getManagedXMLDom($image_pid, $datastream_name);
     if ($dom != false) {
         if ($dom->getElementsByTagName('locked')->item(0)->nodeValue != "false") {
             if (!empty($dom->getElementsByTagName('locked_session')->item(0)->nodeValue)) {
                 $locked_session = $dom->getElementsByTagName('locked_session')->item(0)->nodeValue;
                 if ($dom->getElementsByTagName('locked_by')->item(0)->nodeValue == $user->name && $locked_session == $session_id) {
                     $dom->getElementsByTagName('locked')->item(0)->nodeValue = "false";
                 } else {
                     if (false) {
                         //could add an override if the user has some admin right
                     } else {
                         $last_locked_time = $dom->getElementsByTagName('locked_time')->item(0)->nodeValue;
                         $apiary_timeout = variable_get('apiary_object_timeout', '1800');
                         $last_locked_timeout = $last_locked_time + $apiary_timeout;
                         if ($now > $last_locked_timeout || !Workflow_Sessions::active_session($locked_session)) {
                             $dom->getElementsByTagName('locked')->item(0)->nodeValue = "false";
                         } else {
                             //cannot unlock this record
                             return false;
                         }
                     }
                 }
             }
         }
         $dom->getElementsByTagName('locked')->item(0)->nodeValue = "false";
     } else {
         //create status datastream!
         $dom = AP_Image::generateImageStatusDom("false", $user->name, $now, $session_id);
     }
     //We don't get here if we fail
     if (FedoraObject::createManagedXMLDom($image_pid, $datastream_name, $datastream_label, $dom)) {
         include_once drupal_get_path('module', 'apiary_project') . '/workflow/include/search.php';
         $search_instance = new search();
         $search_instance->index($image_pid);
         return FedoraObject::getManagedXMLDom($image_pid, $datastream_name);
     }
 }
Exemplo n.º 4
0
 public function index_all()
 {
     $image_list = AP_Image::getImageList();
     foreach ($image_list as $image) {
         $this->index($image);
     }
     $roi_list = AP_ROI::getROIList();
     foreach ($roi_list as $roi) {
         $this->index($roi);
     }
 }
Exemplo n.º 5
0
function specimenMetadata_details_content($roi_pid = null)
{
    global $base_url;
    $fedora_base_url = variable_get("fedora_base_url", "http://localhost:8080/fedora");
    $html = '';
    $html .= '<div id="specimenMetadata_details_content">' . "\n";
    if ($roi_pid != null && $roi_pid != "0") {
        $roi = new AP_ROI();
        $image_pid = $roi->get_image_pid($roi_pid);
        $sp_pid = AP_Image::get_specimen_pid($image_pid);
        $roiMetadata_record = $roi->getroiMetadata_record($roi_pid);
        $roiURL = $roiMetadata_record['roiURL'];
        $djatoka_url = scaleDjatokaURL($roiURL, '300', '0');
        $html .= "<h3>Details: {$roi_pid}</h3>";
        $html .= "<table><tr><td valign='top' width='300'>";
        $html .= "<img src='{$djatoka_url}'/></td>";
        $html .= "<td>Specimen: {$sp_pid}<br/>Image: {$image_pid}<br/>ROI: {$roi_pid}<br/>Datastream: specimenMetadata<br/><br/>";
        $text = shell_exec("curl -H - XGET {$fedora_base_url}/get/{$roi_pid}/specimenMetadata");
        $check = strpos($text, "404 Not Found");
        if ($check === FALSE) {
            $specimenMetadata_xml_url = $server_base . '/drupal/modules/apiary_project/workflow/include/specimenMetadata_xml.php?pid=' . $roi_pid;
            $html .= '<textarea style="width:500px; height:200px">' . $text . '</textarea></td>';
            $html .= "</tr></table>";
        } else {
            $html .= "No specimenMetadata found";
        }
    } else {
    }
    $html .= '</div><!-- specimenMetadata_details_content -->' . "\n";
    echo $html;
}
Exemplo n.º 6
0
function ROISearchResults($roi_pids)
{
    $found_result = false;
    foreach ($roi_pids as $roi_pid) {
        if (!$found_result) {
            $results_html .= "<div align='left'>";
            $results_html .= "<table id='roi_results_table' class='tablesorter' style='width:800px'><thead><tr><th>ROI</th><th>Image</th><th>Specimen</th><th>Datastream</th></tr><thead>";
            $found_result = true;
        }
        $results_html .= "<tbody><tr>";
        //$results_html .= '<td><a class="preview" href="'.$server_base.'/drupal/apiary?ref=specimenMetadata_details&pid='.$roi_pid.'">'.$roi_pid.'</a></td>';
        $results_html .= '<td><a href="#" class="preview" onclick="display_specimenMetadata_details(\'' . $roi_pid . '\');">' . $roi_pid . '</a></td>';
        $roi_ob = new AP_ROI();
        $image_pid = $roi_ob->get_image_pid($roi_pid);
        $results_html .= "<td>{$image_pid}</td>";
        $sp_pid = AP_Image::get_specimen_pid($image_pid);
        $results_html .= "<td>{$sp_pid}</td>";
        $fedora_base_url = variable_get('fedora_base_url', 'http://localhost:8080/fedora');
        $text = shell_exec("curl -H - XGET {$fedora_base_url}/get/{$roi_pid}/specimenMetadata");
        $check = strpos($text, "404 Not Found");
        if ($check === FALSE) {
            $results_html .= "<td><a href='" . $fedora_base_url . "/get/{$roi_pid}/specimenMetadata'>specimenMetadata</a></td></tr>";
        } else {
            $results_html .= "<td>No specimenMetadata found</td></tr>";
        }
    }
    if ($found_result) {
        $server_base = variable_get('apiary_research_base_url', 'http://localhost');
        $results_html .= "</tbody></table></div>";
        $results_html .= '<div id="pager" class="pager">';
        $results_html .= '<form>';
        $results_html .= '<img src="' . variable_get('apiary_research_base_url', 'http://localhost') . '/drupal/modules/apiary_project/workflow/assets/img/first.png" class="first"/>';
        $results_html .= '<img src="' . variable_get('apiary_research_base_url', 'http://localhost') . '/drupal/modules/apiary_project/workflow/assets/img/prev.png" class="prev"/>';
        $results_html .= '<input type="text"  class="pagedisplay"/>';
        $results_html .= '<img src="' . variable_get('apiary_research_base_url', 'http://localhost') . '/drupal/modules/apiary_project/workflow/assets/img/next.png"  class="next"/>';
        $results_html .= '<img src="' . variable_get('apiary_research_base_url', 'http://localhost') . '/drupal/modules/apiary_project/workflow/assets/img/last.png"  class="last"/>';
        $results_html .= '<select class="pagesize">';
        $results_html .= '<option selected="selected"  value="10">10</option>';
        $results_html .= '<option value="20">20</option>';
        $results_html .= '<option value="30">30</option>';
        $results_html .= '<option value="40">40</option>';
        $results_html .= '</select>';
        $results_html .= '</form>';
        $results_html .= '</div><!--pager-->';
    } else {
        $results_html .= "<br/><br/><b>No Results found!</b>";
    }
    return $results_html;
}
Exemplo n.º 7
0
 function get_specimen_pid($roi_pid)
 {
     $image_pid = $this->get_image_pid($roi_pid);
     $specimen_pid = AP_Image::get_specimen_pid($image_pid);
     return $specimen_pid;
 }
    if($max > 0) {
      include_once(drupal_get_path('module', 'apiary_project') . '/adore-djatoka/functions_djatoka.php');
      $i = 0;
      if($file = @fopen($source_file, 'r')) {
        while(!feof($file) && $i < $max) {
          $jp2_file = trim(fgets($file));
          $jp2URL = $jp2URL_base.$jp2_file;
          $sourceURL = $sourceURL_base.substr($jp2_file, 0, -4).'.tif';
          $jp2_rft_id = $rft_id . substr($jp2_file, 0, -4);
          if($handle = @fopen($jp2URL, 'r')) {
            module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Specimen');
            $new_specimen = new AP_Specimen();
            $specimen_label = '';
            if($new_specimen->createSpecimenObject('', '', '', '', $specimen_label)) {
              module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Image');
              $new_image = new AP_Image();
              //Ultimately this will have a djatoka plugin check the resolver db and add records as needed
	          list($width, $height) = getimagesize($jp2URL);
              $image_label = '';
              $jpeg_datastream_url = getDjatokaURL($jp2_rft_id, 'getRegion', '4', '0', '0', $height, $width, '', '');
              if($new_image->createImageObject($new_specimen->pid, $jp2URL, $jp2_rft_id, $sourceURL, $width, $height, $jpeg_datastream_url, $image_label)) {
                echo 'Specimen '.$new_specimen->pid.' and image '.$new_image->pid.' successfully created.<br>';
              }
              else {
                echo 'Unable to create a new image. Specimen '.$new_specimen->pid.' successfully created.<br>';;
              }
            }
            else {
              echo 'Unable to create a new specimen.<br>';
            }
            fclose($handle);