// 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; case OpenSKOS_Db_Table_Row_Job::JOB_TASK_DELETE_CONCEPT_SCHEME: $job->start()->save(); try { $response = Api_Models_Concepts::factory()->getConcepts('uuid:' . $job->getParam('uuid')); 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(); }
/** * Validate if the scheme is unique in the given tenant. * If not - checks if it should be perged. If not adds it to the _duplicateConceptSchemes and return false. * * @param OpenSKOS_Solr_Document $schemeDoc * @param int $byUserId, optional * @return bool If the document can be inserted */ protected function handleUniqueConceptScheme(OpenSKOS_Solr_Document $schemeDoc, $byUserId = null) { $canInsertDocument = true; $schemeUri = $schemeDoc->offsetGet('uri'); $schemesCheck = $this->_solr()->limit(1)->search('uri:"' . $schemeUri[0] . '" ' . 'AND tenant:"' . $this->getOpt('tenant') . '" ' . 'AND deleted:false ' . 'AND collection:' . $this->getCollection()->id); if ($schemesCheck['response']['numFound'] > 0) { if (!$this->getOpt('purge')) { $this->_duplicateConceptSchemes[] = $schemeUri[0]; $canInsertDocument = false; } else { $conceptScheme = new Editor_Models_ConceptScheme(new Api_Models_Concept(array_shift($schemesCheck['response']['docs']))); $conceptScheme->delete(true, $byUserId); } } return $canInsertDocument; }