Esempio n. 1
0
 public function getMyAnnotationsByCeHim($ceHim = 0, $state = null, $imageId = 0)
 {
     $annotationTable = new Annotations();
     $dbAdapter = $annotationTable->getAdapter();
     $select = $dbAdapter->select();
     $select->from(array('annos' => Annotations::TABLE_NAME));
     $fetch = true;
     if ($state == null) {
         $select->where(Annotations::COL_CE_HAS_IMAGE_ID . "=?", $ceHim, 'int') . $select->where(Annotations::COL_PART_ID . "=?", $this->getParticipantId(), 'int');
         $select->where(Annotations::COL_GROUP . "!=?", 1, 'int');
         $select->where(Annotations::COL_WS_REF . "!=?", 1, 'int');
         $select->where(Annotations::COL_WEBGR_REF . "!=?", 1, 'int');
     } else {
         if ($state == 'groupState') {
             $select->where(Annotations::COL_CE_HAS_IMAGE_ID . "=?", $ceHim, 'int');
             $select->where(Annotations::COL_GROUP . "=?", 1, 'int');
         } else {
             if ($state == 'ws-refState') {
                 // check for user roles
                 $storage = Zend_Auth::getInstance()->getStorage()->read();
                 $roleConst = User::COL_ROLE;
                 if ($storage->{$roleConst} == 'admin' || $storage->{$roleConst} == 'manager' || $this->getParticipantRole() == 'Coordinator') {
                     $ceTable = new CalibrationExercise();
                     $ceArray = $ceTable->find($this->getCurrentCeID())->toArray();
                     $select->join(array('ceHim' => CeHasImage::TABLE_NAME), 'annos.' . Annotations::COL_CE_HAS_IMAGE_ID . "=" . 'ceHim.' . CeHasImage::COL_ID);
                     $select->join(array('caex' => CalibrationExercise::TABLE_NAME), 'ceHim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID . "=" . 'caex.' . CalibrationExercise::COL_ID);
                     $select->join(array('im' => Image::TABLE_NAME), 'ceHim.' . CeHasImage::COL_IMAGE_ID . "=" . 'im.' . Image::COL_ID);
                     $select->where(CalibrationExercise::COL_EXPERTISE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_EXPERTISE_ID]);
                     $select->where(CalibrationExercise::COL_KEY_TABLE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_KEY_TABLE_ID]);
                     $select->where('im.' . Image::COL_ID . "=?", $imageId, 'int');
                     $select->where('caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=?", $ceArray[0][CalibrationExercise::COL_WORKSHOP_ID], 'int');
                     $select->where(Annotations::COL_WS_REF . "=?", 1, 'int');
                 } else {
                     $fetch = false;
                 }
             } else {
                 if ($state == 'webgr-refState') {
                     // check for user roles
                     $storage = Zend_Auth::getInstance()->getStorage()->read();
                     $roleConst = User::COL_ROLE;
                     if ($storage->{$roleConst} == 'admin' || $storage->{$roleConst} == 'manager' || $this->getParticipantRole() == 'Coordinator') {
                         $select->join(array('ceHim' => CeHasImage::TABLE_NAME), 'annos.' . Annotations::COL_CE_HAS_IMAGE_ID . "=" . 'ceHim.' . CeHasImage::COL_ID);
                         $select->join(array('caex' => CalibrationExercise::TABLE_NAME), 'ceHim.' . CeHasImage::COL_CALIBRATION_EXERCISE_ID . "=" . 'caex.' . CalibrationExercise::COL_ID);
                         $select->join(array('im' => Image::TABLE_NAME), 'ceHim.' . CeHasImage::COL_IMAGE_ID . "=" . 'im.' . Image::COL_ID);
                         $select->where(CalibrationExercise::COL_EXPERTISE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_EXPERTISE_ID]);
                         $select->where(CalibrationExercise::COL_KEY_TABLE_ID . "=?", $this->namespace->ceArray[0][CalibrationExercise::COL_KEY_TABLE_ID]);
                         $select->where('im.' . Image::COL_ID . "=?", $imageId, 'int');
                         $select->where(Annotations::COL_WEBGR_REF . "=?", 1, 'int');
                     } else {
                         $fetch = false;
                     }
                 }
             }
         }
     }
     //return $select->__toString();
     if ($fetch) {
         return $dbAdapter->fetchAll($select);
     } else {
         return array();
     }
 }
Esempio n. 2
0
 public function trainingannotationAction()
 {
     $ceId = intval($this->getRequest()->getParam(CalibrationExercise::COL_ID));
     $ceTable = new CalibrationExercise();
     $ceArray = $ceTable->find($ceId)->toArray();
     $resultSelect = $this->dbAdapter->select();
     $resultSelect->from('v_all_annotations');
     $resultSelect->where(CalibrationExercise::COL_ID . '=?', $ceId);
     $resultSelect->where(Annotations::COL_FINAL . '=?', 1);
     $resultAnnos = $this->dbAdapter->fetchAll($resultSelect);
     $imageIdString = '';
     $assocResult = array();
     foreach ($resultAnnos as $resultAnno) {
         // get all image ids
         if ($imageIdString != '') {
             $seperator = ',';
         } else {
             $seperator = '';
         }
         $imageIdString .= $seperator . $resultAnno[Image::COL_ID];
         // create a assoc array to create the result array later on
         $assocResult += array($resultAnno[Image::COL_ID] => array(Annotations::COL_DECIMAL => $resultAnno[Annotations::COL_DECIMAL], Annotations::COL_ID => $resultAnno[Annotations::COL_ID]));
     }
     // get the all references for the images
     $refSelect = $this->dbAdapter->select();
     $refSelect->from('v_all_annotations');
     $refSelect->where('(' . Annotations::COL_WEBGR_REF . '=?', 1);
     $refSelect->orWhere(Annotations::COL_WS_REF . '=? )', 1);
     $refSelect->where(CalibrationExercise::COL_EXPERTISE_ID . '=?', $ceArray[0][CalibrationExercise::COL_EXPERTISE_ID]);
     $refSelect->where(CalibrationExercise::COL_KEY_TABLE_ID . '=?', $ceArray[0][CalibrationExercise::COL_KEY_TABLE_ID]);
     if ($imageIdString) {
         $refSelect->where(Image::COL_ID . ' IN (' . $imageIdString . ')');
     } else {
         $refSelect->where(Image::COL_ID . ' IN (\'\')');
     }
     $refAnnos = $this->dbAdapter->fetchAll($refSelect);
     // create the header
     $headerArray = array(Image::COL_ORIGINAL_FILENAME => 'original file name', Annotations::COL_DECIMAL => 'own result', 'bia' => 'bia', 'reference' => 'reference', 'ref. type' => 'ref. type', Annotations::COL_ID => 'Anno. ID');
     //create the resultArray
     $csvArray = array($headerArray);
     foreach ($refAnnos as $refAnno) {
         if ($refAnno[Annotations::COL_WS_REF] == 1) {
             $refType = 'WS-Ref';
         } else {
             $refType = 'WebGR-Ref';
         }
         $bia = abs($refAnno[Annotations::COL_DECIMAL] - $assocResult[$refAnno[Image::COL_ID]][Annotations::COL_DECIMAL]);
         $rowArray = array(Image::COL_ORIGINAL_FILENAME => $refAnno[Image::COL_ORIGINAL_FILENAME], Annotations::COL_DECIMAL => $assocResult[$refAnno[Image::COL_ID]][Annotations::COL_DECIMAL], 'bia' => $bia, 'reference' => $refAnno[Annotations::COL_DECIMAL], 'ref. type' => $refType, Annotations::COL_ID => $assocResult[$refAnno[Image::COL_ID]][Annotations::COL_ID]);
         array_push($csvArray, $rowArray);
     }
     $this->configureView($csvArray, $ceId, 'annotation_training.csv');
 }
Esempio n. 3
0
 public function replicateAction()
 {
     $ceTable = new CalibrationExercise();
     $partTable = new Participant();
     $cehimTable = new CeHasImage();
     $imagesetTable = new ImagesetAttributes();
     $shownAtTable = new CeHasAttributeDescriptor();
     /**
      * calibration exercises
      */
     $ceArray = $ceTable->find($this->callingCeId)->current()->toArray();
     /**
      * participants
      */
     $partSelect = $partTable->getAdapter()->select();
     $partSelect->from(Participant::TABLE_NAME);
     $partSelect->where(Participant::COL_CE_ID . '=?', $this->callingCeId);
     $partArray = $partTable->getAdapter()->fetchAll($partSelect);
     /**
      * imageset
      */
     $cehimSelect = $cehimTable->getAdapter()->select();
     $cehimSelect->from(CeHasImage::TABLE_NAME);
     $cehimSelect->where(CeHasImage::COL_CALIBRATION_EXERCISE_ID . '=?', $this->callingCeId);
     $cehimArray = $cehimTable->getAdapter()->fetchAll($cehimSelect);
     /**
      * imageset definition
      */
     $imagesetSelect = $imagesetTable->getAdapter()->select();
     $imagesetSelect->from(ImagesetAttributes::TABLE_NAME);
     $imagesetSelect->where(ImagesetAttributes::COL_CE_ID . '=?', $this->callingCeId);
     $imagesetArray = $imagesetTable->getAdapter()->fetchAll($imagesetSelect);
     /**
      * shown attributes
      */
     $shownAtSelect = $shownAtTable->getAdapter()->select();
     $shownAtSelect->from(CeHasAttributeDescriptor::TABLE_NAME);
     $shownAtSelect->where(CeHasAttributeDescriptor::COL_CAEX_ID . '=?', $this->callingCeId);
     $shownAtArray = $shownAtTable->getAdapter()->fetchAll($shownAtSelect);
     /**
      * insert all data
      */
     $ceData = array(CalibrationExercise::COL_COMPAREABLE => $ceArray[CalibrationExercise::COL_COMPAREABLE], CalibrationExercise::COL_DESCRIPTION => $ceArray[CalibrationExercise::COL_DESCRIPTION], CalibrationExercise::COL_EXPERTISE_ID => $ceArray[CalibrationExercise::COL_EXPERTISE_ID], CalibrationExercise::COL_KEY_TABLE_ID => $ceArray[CalibrationExercise::COL_KEY_TABLE_ID], CalibrationExercise::COL_NAME => $ceArray[CalibrationExercise::COL_NAME], CalibrationExercise::COL_RANDOMIZED => $ceArray[CalibrationExercise::COL_RANDOMIZED], CalibrationExercise::COL_WORKSHOP_ID => $ceArray[CalibrationExercise::COL_WORKSHOP_ID]);
     $newCeId = $ceTable->insert($ceData);
     foreach ($partArray as $part) {
         $partData = array(Participant::COL_CE_ID => $newCeId, Participant::COL_EXPERTISE_LEVEL => $part[Participant::COL_EXPERTISE_LEVEL], Participant::COL_NUMBER => $part[Participant::COL_NUMBER], Participant::COL_ROLE => $part[Participant::COL_ROLE], Participant::COL_STOCK_ASSESSMENT => $part[Participant::COL_STOCK_ASSESSMENT], Participant::COL_USER_ID => $part[Participant::COL_USER_ID]);
         $partTable->insert($partData);
     }
     foreach ($cehimArray as $cehim) {
         $cehimData = array(CeHasImage::COL_CALIBRATION_EXERCISE_ID => $newCeId, CeHasImage::COL_IMAGE_ID => $cehim[CeHasImage::COL_IMAGE_ID]);
         $cehimTable->insert($cehimData);
     }
     foreach ($imagesetArray as $imageSet) {
         $imageSetData = array(ImagesetAttributes::COL_ATTRIBUTE_DESCRIPTOR_ID => $imageSet[ImagesetAttributes::COL_ATTRIBUTE_DESCRIPTOR_ID], ImagesetAttributes::COL_CE_ID => $newCeId, ImagesetAttributes::COL_FROM => $imageSet[ImagesetAttributes::COL_FROM], ImagesetAttributes::COL_TO => $imageSet[ImagesetAttributes::COL_TO], ImagesetAttributes::COL_VALUE => $imageSet[ImagesetAttributes::COL_VALUE]);
         $imagesetTable->insert($imageSetData);
     }
     foreach ($shownAtArray as $shownAt) {
         $shownAtData = array(CeHasAttributeDescriptor::COL_ATDE_ID => $shownAt[CeHasAttributeDescriptor::COL_ATDE_ID], CeHasAttributeDescriptor::COL_CAEX_ID => $newCeId);
         $imagesetTable->insert($imageSetData);
     }
     $this->redirectTo('index', array(CalibrationExercise::COL_ID => $newCeId));
 }