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)); }
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); } }
public function searchAction() { $request = $this->getRequest(); $formValues = $this->namespace->formValues; $this->view->callingAction = $this->defaultNamespace->callingAction; // get meta data select for image and fish descriptors $metaData = new Default_MetaData(); $metaData->getSelectForGroups(TRUE); $select = $metaData->addWhereToSelect($formValues); if ($this->defaultNamespace->callingAction == 'annotation/browse/byimage') { unset($this->namespace->ceArray); $select->joinLeft(array('vaa' => 'v_all_annotations'), 'vaa.' . CeHasImage::COL_IMAGE_ID . ' = ' . 'image.' . Image::COL_ID, array()); //auf cehas_image damit die ausgefiltert werden die keine annotationen haben $select->where(Annotations::COL_WS_REF . "=? ", 1); $select->orWhere(Annotations::COL_FINAL . " = ? ", 1); $select->orWhere(Annotations::COL_GROUP . "=? ", 1); $select->orWhere(Annotations::COL_WEBGR_REF . "=? ", 1); $select->group('image.' . Image::COL_ID); $resultArray = Zend_Registry::get('DB_CONNECTION1')->fetchAll($select); if ($resultArray != array()) { $resultKey = new Ble422_Guid(); $this->defaultNamespace->{$resultKey} = $resultArray; $redirect = new Zend_Controller_Action_Helper_Redirector(); $redirect->setGotoSimple('start', 'browse', 'annotation', array('resultKey' => $resultKey)); } } else { //select only own images if ($this->defaultNamespace->callingAction == 'user/edit/myimages') { $select->where('image.' . Image::COL_USER_ID . ' = ?', $this->defaultNamespace->callingActionId); } //filter double datasets caused by multiple meta data //$select->group('image.'.Image::COL_ID); //get already assigned datasets for setting disabled in view if ($this->defaultNamespace->callingAction == '/ce/edit/addimages') { $ceId = $this->defaultNamespace->callingActionId; $ceHasIm = new CeHasImage(); $rowSet = $ceHasIm->fetchAll(CeHasImage::COL_CALIBRATION_EXERCISE_ID . '=' . $ceId); if (count($rowSet) > 0) { $assignedImages = array(); foreach ($rowSet as $row) { $assignedImages[$row[CeHasImage::COL_IMAGE_ID]] = TRUE; } $this->view->assignedImages = $assignedImages; } } //echo $select; /** * Pagination control */ $paginator = new Ble422_Paginator_Extended($select, $this->getRequest()); // echo $select->__toString(); // die(); //static + dynamic header array $statArray = array(array('raw' => Image::COL_ORIGINAL_FILENAME, 'name' => 'Original file name'), array('raw' => Fish::COL_SAMPLE_CODE, 'name' => 'Fish sample code'), array('raw' => Image::COL_DIM_X, 'name' => 'Width'), array('raw' => Image::COL_DIM_Y, 'name' => 'Height')); $dynArray = array(); $i = 0; foreach ($metaData->fishRowSetArray as $fishAttr) { $dynInnerArray = array('raw' => 'ATDE_' . $fishAttr[AttributeDescriptor::COL_ID], 'name' => $fishAttr[AttributeDescriptor::COL_NAME] . '<br>' . $fishAttr['UNIT']); $dynArray[$i] = $dynInnerArray; $i++; } $headerArray = array_merge($statArray, $dynArray); unset($i); unset($dynArray); unset($dynInnerArray); $i = 0; foreach ($metaData->imageRowSetArray as $imAttr) { $dynInnerArray = array('raw' => 'ATDE_' . $imAttr[AttributeDescriptor::COL_ID], 'name' => $imAttr[AttributeDescriptor::COL_NAME] . '<br>' . $imAttr['UNIT']); $dynArray[$i] = $dynInnerArray; $i++; } $headerArray = array_merge($headerArray, $dynArray); unset($i); unset($dynArray); unset($dynInnerArray); $paginator->setHeader($headerArray); $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(1000)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy')); //$this->_getParam('pageRange')); Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml'); $this->view->paginator = $paginator; } }