Exemplo n.º 1
0
function get_images_list($specimen_pid, $nothing, $workflow_id)
{
    global $user;
    if (Workflow_Users::doesWorkflowHaveUserName($workflow_id, $user->name) && Workflow_Permission::doesWorkflowHavePermission($workflow_id, "canAnalyzeSpecimen")) {
        $image_pids = AP_Specimen::getImageListForSpecimen($specimen_pid);
        echo json_encode($image_pids);
    }
}
Exemplo n.º 2
0
function ingest_specimen_image()
{
    $specimen_image_successfully_ingested = "false";
    $rft_id = $_POST['rft_id'];
    $original_url = $_POST['original_url'];
    $jp2_url = $_POST['jp2_url'];
    $institution = $_POST['institution'];
    $collector = $_POST['collector'];
    $collection_number = $_POST['collection_number'];
    $collection_date = $_POST['collection_date'];
    $scientific_name = $_POST['scientific_name'];
    if (isset($_POST['rft_id'])) {
        include_once drupal_get_path('module', 'apiary_project') . '/adore-djatoka/functions_djatoka.php';
        module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Specimen');
        $new_specimen = new AP_Specimen();
        $specimen_label = '';
        if ($new_specimen->createSpecimenObject($collector, $collection_number, $collection_date, $scientific_name, $specimen_label)) {
            $specimen_image_successfully_ingested = "true";
            module_load_include('php', 'Apiary_Project', 'fedora_commons/class.AP_Image');
            $new_image = new AP_Image();
            list($width, $height) = getimagesize($jp2_url);
            $image_label = '';
            $jpeg_datastream_url = getDjatokaURL($rft_id, 'getRegion', '4', '0', '0', $height, $width, '', '');
            if ($new_image->createImageObject($new_specimen->pid, $jp2_url, $rft_id, $original_url, $width, $height, $jpeg_datastream_url, $image_label)) {
                $msg = 'Specimen ' . $new_specimen->pid . ' and image ' . $new_image->pid . ' successfully created.<br>';
            } else {
                $msg = 'Unable to create a new image. Specimen ' . $new_specimen->pid . ' successfully created.<br>';
            }
        } else {
            $msg = 'Unable to create a new specimen or image object.<br>';
        }
    }
    $returnJSON['specimen_image_successfully_ingested'] = $specimen_image_successfully_ingested;
    $returnJSON['msg'] = $msg;
    echo json_encode($returnJSON);
}
Exemplo n.º 3
0
 function addROIsForImage($image_pid)
 {
     $image_rois = AP_Specimen::getImageListForSpecimen($specimen_pid);
     $rois = array();
     for ($i; $i < sizeOf($image_rois); $i++) {
         $roi_pid = $image_rois[$i];
         if (array_search($roi_pid, $this->permission_list) > -1) {
             //don't add anything, it's already there!
         } else {
             //array_push((array) $this->roi_pids, $roi_pid);
             $roi['pid'] = $roi_pid;
             $roiMetadata = AP_ROI::getROIMetadata_record($roi_pid);
             $roi['roiMetadata'] = $roiMetadata;
             array_push($rois, $roi);
         }
     }
     return $rois;
 }
    }
    else {
      $max = 1000000;
    }
    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>';;
              }
            }