public function get()
    {
        try {
            if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) {
                throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI());
            }

            $taskId = $this->getRequestParameter(self::TASK_ID_PARAM);

            /** @var TaskLogInterface $taskLog */
            $taskLog = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID);

            $filter = (new TaskLogFilter())
                ->eq(TaskLogBrokerInterface::COLUMN_ID, $taskId);

            // trying to get data from the new task queue first
            $collection = $taskLog->search($filter);

            if ($collection->isEmpty()) {
                // if we don't have the task in the new queue,
                // loading the data from the old one
                $data = $this->getTaskData($taskId);
            } else {
                // we have the task in the new queue
                $entity = $collection->first();
                $status = (string) $entity->getStatus();

                if ($entity->getStatus()->isInProgress()) {
                    $status = \oat\oatbox\task\Task::STATUS_RUNNING;
                } elseif ($entity->getStatus()->isCompleted() || $entity->getStatus()->isFailed()) {
                    $status = \oat\oatbox\task\Task::STATUS_FINISHED;
                }

                $data['id'] = $entity->getId();
                $data['status'] = $status;
                //convert to array for xml response.
                $data['report'] = json_decode(json_encode($entity->getReport()));
            }

            $this->returnSuccess($data);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function get()
    {
        try {
            if (!$this->hasRequestParameter(self::TASK_ID_PARAM)) {
                throw new \common_exception_MissingParameter(self::TASK_ID_PARAM, $this->getRequestURI());
            }

            $taskId = $this->getRequestParameter(self::TASK_ID_PARAM);

            /** @var TaskLogInterface $taskLog */
            $taskLog = $this->getServiceLocator()->get(TaskLogInterface::SERVICE_ID);

            $filter = (new TaskLogFilter())
                ->eq(TaskLogBrokerInterface::COLUMN_ID, $taskId);

            // trying to get data from the new task queue first
            $collection = $taskLog->search($filter);

            if ($collection->isEmpty()) {
                // if we don't have the task in the new queue,
                // loading the data from the old one
                $data = $this->getTaskData($taskId);
            } else {
                // we have the task in the new queue
                $entity = $collection->first();
                $status = (string) $entity->getStatus();

                if ($entity->getStatus()->isInProgress()) {
                    $status = \oat\oatbox\task\Task::STATUS_RUNNING;
                } elseif ($entity->getStatus()->isCompleted() || $entity->getStatus()->isFailed()) {
                    $status = \oat\oatbox\task\Task::STATUS_FINISHED;
                }

                $data['id'] = $entity->getId();
                $data['status'] = $status;
                //convert to array for xml response.
                $data['report'] = json_decode(json_encode($entity->getReport()));
            }

            $this->returnSuccess($data);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function get ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: TASK_ID_PARAM ) ) { throw new \ common_exception_MissingParameter ( self :: TASK_ID_PARAM , $ this -> getRequestURI ( ) ) ; } $ taskId = $ this -> getRequestParameter ( self :: TASK_ID_PARAM ) ; /** @var TaskLogInterface $taskLog */ $ taskLog = $ this -> getServiceLocator ( ) -> get ( TaskLogInterface :: SERVICE_ID ) ; $ filter = ( new TaskLogFilter ( ) ) -> eq ( TaskLogBrokerInterface :: COLUMN_ID , $ taskId ) ; // trying to get data from the new task queue first $ collection = $ taskLog -> search ( $ filter ) ; if ( $ collection -> isEmpty ( ) ) { // if we don't have the task in the new queue, // loading the data from the old one $ data = $ this -> getTaskData ( $ taskId ) ; } else { // we have the task in the new queue $ entity = $ collection -> first ( ) ; $ status = ( string ) $ entity -> getStatus ( ) ; if ( $ entity -> getStatus ( ) -> isInProgress ( ) ) { $ status = \ oat \ oatbox \ task \ Task :: STATUS_RUNNING ; } elseif ( $ entity -> getStatus ( ) -> isCompleted ( ) || $ entity -> getStatus ( ) -> isFailed ( ) ) { $ status = \ oat \ oatbox \ task \ Task :: STATUS_FINISHED ; } $ data [ 'id' ] = $ entity -> getId ( ) ; $ data [ 'status' ] = $ status ; //convert to array for xml response. $ data [ 'report' ] = json_decode ( json_encode ( $ entity -> getReport ( ) ) ) ; } $ this -> returnSuccess ( $ data ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } }
Get task data by identifier
Get task data by identifier