コード例 #1
0
ファイル: jobs.php プロジェクト: olhsha/OpenSKOS2tempMeertens
                         if (!isset($response['response']['docs']) || 1 !== count($response['response']['docs'])) {
                             throw new Zend_Exception('The requested concept scheme was not found');
                         }
                         $conceptScheme = new Editor_Models_ConceptScheme(new Api_Models_Concept(array_shift($response['response']['docs'])));
                         $conceptScheme->delete(true, $job['user']);
                         // Clears the schemes cache after the scheme is removed.
                         OpenSKOS_Cache::getCache()->remove(Editor_Models_ApiClient::CONCEPT_SCHEMES_CACHE_KEY);
                         $model = new OpenSKOS_Db_Table_Jobs();
                         // Gets new DB object to prevent connection time out.
                         $job = $model->find($job->id)->current();
                         // Gets new DB object to prevent connection time out.
                         $job->finish()->save();
                     } catch (Zend_Exception $e) {
                         $model = new OpenSKOS_Db_Table_Jobs();
                         // Gets new DB object to prevent connection time out.
                         $job = $model->find($job->id)->current();
                         // Gets new DB object to prevent connection time out.
                         fwrite(STDERR, $job->id . ': ' . $e->getMessage() . "\n");
                         $job->error($e->getMessage())->finish()->save();
                     }
                     break;
                 default:
                     fwrite(STDERR, '@TODO: write handler for task=' . $job->task . "\n");
                     $job->error('No handler for this task')->finish()->save();
                     break;
             }
         }
     }
     break;
 default:
     fwrite(STDERR, "Invalid action `{$action}`, allowed action: " . implode('|', $actions) . "\n");
コード例 #2
0
 /**
  * @return OpenSKOS_Db_Table_Row_Job
  */
 protected function _getJob($id = null)
 {
     if (null === $id) {
         if (null === ($id = $this->getRequest()->getParam('job'))) {
             $this->getHelper('FlashMessenger')->setNamespace('error')->addMessage(_('No job defined'));
             $this->_helper->redirector('index');
         }
     }
     $model = new OpenSKOS_Db_Table_Jobs();
     $job = $model->find($id)->current();
     if (null === $job) {
         $this->getHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Job not found'));
         $this->_helper->redirector('index');
     }
     $collection = $job->getCollection();
     if (null === $collection) {
         $this->getHelper('FlashMessenger')->setNamespace('error')->addMessage(_('Collection not found'));
         $this->_helper->redirector('index');
     }
     if ($collection->tenant != $this->_tenant->code) {
         $this->getHelper('FlashMessenger')->setNamespace('error')->addMessage(_('You are not allowed to edit this job.'));
         $this->_helper->redirector('index');
     }
     return $job;
 }