function batchStatusAction() { $this->_helper->viewRenderer->setNoRender(); Zend_Loader::loadClass('Batch'); Zend_Loader::loadClass('Document'); Zend_Loader::loadClass('Geoparser_Edina'); Zend_Loader::loadClass('Geoparser_EdinaBatch'); $batchObj = new Batch(); if (isset($_GET["batchID"])) { $batchID = $_GET["batchID"]; $batch = $batchObj->getByID($batchID); } elseif (isset($_GET["parserID"])) { $parserID = $_GET["parserID"]; $batch = $batchObj->getByParserID($parserID); $batchID = $batchObj->id; } if (!$batch) { //$this->view->requestURI = $this->_request->getRequestUri(); //return $this->render('404error'); throw new Zend_Controller_Action_Exception('Cannnot find this page: ' . $this->_request->getRequestUri(), 404); } $edinaObj = new Geoparser_EdinaBatch(); $edinaObj->prepSettings(); $edinaObj->batchName = $batchObj->parserID; //name of the batch $responseJSON = $edinaObj->cacheGetBatch(); //get the status, but use the cache if (!$edinaObj->HTTPstatusOK) { $status = "error"; } else { $status = "ok"; $respObj = Zend_Json::decode($responseJSON); if (!$edinaObj->cacheUsed) { //cache was not used to generate the resulse, so we can update the status of the batch and its documents $batchObj->updateStatus("pending"); if (isset($respObj["Texts"])) { if (is_array($respObj["Texts"])) { $docObj = new Document(); $docObj->batchID = $batchID; foreach ($respObj["Texts"] as $text) { $resourceID = $text["resource-id"]; $docStatus = $text["status"]; $data = array("parserID" => $resourceID, "status" => $docStatus); if ($docStatus == "complete") { $data["pLinks"] = Zend_Json::encode($text["output"]); } $docObj->url = $text["src"]; $docObj->updateDataByBatchURL($data); } } } } unset($batchObj); unset($docObj); $batchObj = new Batch(); $batch = $batchObj->getByID($batchID); $batch["documents"] = $batchObj->documents; $batch["edina-resp"] = $respObj; header('Content-Type: application/json; charset=utf8'); echo Zend_Json::encode($batch); } }