/** * @return Zend_Db_Table_Rowset */ public function getJobs($task = null) { //new records do not have jobs: if (null === $this->id) { return array(); } $model = new OpenSKOS_Db_Table_Jobs(); $select = $model->select()->where('collection=?', $this->id)->where('finished IS NULL')->order('created desc')->order('started asc'); if (null !== $task) { $select->where('task = ?', $task); } return $model->fetchAll($select); }
/** * Gets an array map for all concept schemes which has a delet job started (and not completed yet) for them. * @return array array(conceptSchemeUuid => deleteJobUuid) */ protected function _getConceptSchemesWithDeleteJob() { $model = new OpenSKOS_Db_Table_Jobs(); $conceptDeleteJobs = $model->fetchAll($model->select()->where('task = ?', OpenSKOS_Db_Table_Row_Job::JOB_TASK_DELETE_CONCEPT_SCHEME)->where('status IS NULL')->where('finished IS NULL')); $conceptSchemesDeleteJobsMap = array(); foreach ($conceptDeleteJobs as $conceptDeleteJob) { $params = $conceptDeleteJob->getParams(); if (!isset($conceptSchemesDeleteJobsMap[$params['uuid']])) { $conceptSchemesDeleteJobsMap[$params['uuid']] = $conceptDeleteJob->id; } } return $conceptSchemesDeleteJobsMap; }
break; case 'delete': case 'process': if ($OPTS->tenant) { fwrite(STDERR, "`tenant` option not allowed with delete and process actions\n"); exit(1); } $model = new OpenSKOS_Db_Table_Jobs(); if ($OPTS->job) { $jobs = $model->find($OPTS->job); if (!count($jobs)) { fwrite(STDERR, "Job `{$OPTS->job}` not found\n"); exit(1); } } else { $select = $model->select()->where('finished IS NULL')->order('created asc')->where('started IS NULL'); if ($OPTS->task && $OPTS->task != 'all') { if ($OPTS->task == 'noExport') { $select->where('job.task!=?', OpenSKOS_Db_Table_Row_Job::JOB_TASK_EXPORT); } else { $select->where('job.task=?', $OPTS->task); } } $jobs = $model->fetchAll($select); } if (!count($jobs)) { exit(0); } if ($action === 'delete') { foreach ($jobs as $job) { try {