Exemplo n.º 1
0
 public function indexAction()
 {
     $namespace = new Zend_Session_Namespace('ce');
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($this->getRequest()->getParams())) {
             if ($this->form->getValue('Token') == $namespace->Token) {
                 $ceTable = new CalibrationExercise();
                 $data = array(CalibrationExercise::COL_NAME => $this->form->getValue(CalibrationExercise::COL_NAME), CalibrationExercise::COL_DESCRIPTION => $this->form->getValue(CalibrationExercise::COL_DESCRIPTION), CalibrationExercise::COL_WORKSHOP_ID => $this->callingWorkshopId);
                 $ceId = $ceTable->insert($data);
                 $namespace->Token = '';
                 $this->_forward("index", "edit", "ce", array("CAEX_ID" => $ceId));
             } else {
                 //form token is not equal session token
                 $this->form->reset();
                 $this->redirectTo('index');
             }
         } else {
             //not valid
         }
     } else {
         //not post
         if ($this->form->getValue('Token') == null) {
             $guid = new Ble422_Guid();
             $namespace->Token = $guid->__toString();
             $this->form->getElement('Token')->setValue($guid->__toString());
             $this->view->form = $this->form;
         }
     }
 }
Exemplo n.º 2
0
 public function createAction()
 {
     $expId = intval($this->getRequest()->getParam(Expertise::COL_ID));
     $keyId = intval($this->getRequest()->getParam(KeyTable::COL_ID));
     $expTable = new Expertise();
     $expRow = $expTable->find($expId);
     $keyTable = new KeyTable();
     $keyRow = $keyTable->find($keyId);
     if ($keyRow->count() != 0 || $expRow->count() != 0) {
         $keyArray = $keyRow->toArray();
         $expArray = $expRow->toArray();
         // create CE row
         $ceTable = new CalibrationExercise();
         $ceName = $expArray[0][Expertise::COL_SPECIES] . ' / ' . AuthQuery::getUserName();
         //TODO \r in der Datenbank
         $ceDescription = 'Area: ' . $expArray[0][Expertise::COL_AREA] . '\\r' . 'Subject: ' . $expArray[0][Expertise::COL_SUBJECT] . '\\r' . 'KeyName: ' . $keyArray[0][KeyTable::COL_NAME];
         $ceData = array(CalibrationExercise::COL_NAME => $ceName, CalibrationExercise::COL_DESCRIPTION => $ceDescription, CalibrationExercise::COL_KEY_TABLE_ID => $keyArray[0][KeyTable::COL_ID], CalibrationExercise::COL_EXPERTISE_ID => $expArray[0][Expertise::COL_ID], CalibrationExercise::COL_COMPAREABLE => 1, CalibrationExercise::COL_IS_STOPPED => 0, CalibrationExercise::COL_TRAINING => 1);
         $ceId = $ceTable->insert($ceData);
         // create participant row
         $partTable = new Participant();
         $partData = array(Participant::COL_CE_ID => $ceId, Participant::COL_USER_ID => AuthQuery::getUserId(), Participant::COL_NUMBER => 1);
         $partId = $partTable->insert($partData);
         // add all possible shown attributes
         $dbAdapter = $ceTable->getAdapter();
         $selectAttr = $dbAdapter->select();
         $selectAttr->from(AttributeDescriptor::TABLE_NAME);
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'fish');
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'image');
         $attrArray = $dbAdapter->fetchAll($selectAttr);
         $ceHasAttrTable = new CeHasAttributeDescriptor();
         foreach ($attrArray as $attr) {
             $attrData = array(CeHasAttributeDescriptor::COL_ATDE_ID => $attr[AttributeDescriptor::COL_ID], CeHasAttributeDescriptor::COL_CAEX_ID => $ceId);
             $ceHasAttrTable->insert($attrData);
         }
         //get images for exp/key
         $refQuery = new Default_ReferenceQuery();
         $images = $refQuery->getImages($expId, $keyId);
         // create imageset
         //			$selectImages = $dbAdapter->select();
         //			$imagesArray = $dbAdapter->fetchAll($selectImages);
         $imageSetTable = new CeHasImage();
         foreach ($images as $image) {
             $data = array(CeHasImage::COL_IMAGE_ID => $image, CeHasImage::COL_CALIBRATION_EXERCISE_ID => $ceId);
             $imageSetTable->insert($data);
         }
         //$this->render('form');
         $Redirect = new Zend_Controller_Action_Helper_Redirector();
         $Redirect->setGotoSimple('index', 'make', 'annotation', array(CalibrationExercise::COL_ID => $ceId));
     } else {
         throw new Zend_Controller_Exception('Error at craeting a new training Calibration Exercise.', 505);
     }
 }
Exemplo n.º 3
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');
 }
Exemplo n.º 4
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();
     }
 }
Exemplo n.º 5
0
 public function stopceAction()
 {
     $ceTable = new CalibrationExercise();
     $data = array(CalibrationExercise::COL_IS_STOPPED => 1);
     $ceTable->update($data, $ceTable->getAdapter()->quoteInto(CalibrationExercise::COL_ID . '=?', $this->callingCeId));
     $this->redirectTo('index', array(CalibrationExercise::COL_ID => $this->callingCeId));
 }