public function getConceptSchemes(OpenSKOS_Db_Table_Row_Collection $collection = null) { $solr = OpenSKOS_Solr::getInstance(); $q = 'class:ConceptScheme collection:' . $collection->id . ' AND tenant:' . $collection->tenant . ' AND deleted:false'; $result = $solr->search($q, array('rows' => 1000)); return new OpenSKOS_SKOS_ConceptSchemes($result); }
/** * @return Api_Models_Concept */ protected function _fetchConcept() { $id = $this->getRequest()->getParam('id'); if (null === $id) { throw new Zend_Controller_Exception('No id `' . $id . '` provided', 400); } /* * this is for clients that need special routes like "http://data.beeldenegluid.nl/gtaa/123456" * with this we can create a route in the config ini like this: * * resources.router.routes.route_id.type = "Zend_Controller_Router_Route_Regex" * resources.router.routes.route_id.route = "gtaa\/(\d+)" * resources.router.routes.route_id.defaults.module = "api" * resources.router.routes.route_id.defaults.controller = "concept" * resources.router.routes.route_id.defaults.action = "get" * resources.router.routes.route_id.defaults.id_prefix = "http://data.beeldengeluid.nl/gtaa/" * resources.router.routes.route_id.defaults.format = "html" * resources.router.routes.route_id.map.1 = "id" * resources.router.routes.route_id.reverse = "gtaa/%d" */ $id_prefix = $this->getRequest()->getParam('id_prefix'); if (null !== $id_prefix && !OpenSKOS_Solr::isValidUuid($id)) { $id_prefix = str_replace('%tenant%', $this->getRequest()->getParam('tenant'), $id_prefix); $id = $id_prefix . $id; } // Tries to find any not deleted concept. $concept = $this->model->getConcept($id); // If not deleted concept was not found - tries to find deleted one. if (null === $concept) { $concept = $this->model->getConcept($id, array(), true); } if (null === $concept) { throw new Zend_Controller_Exception('Concept `' . $id . '` not found', 404); } if ($concept->isDeleted()) { throw new Zend_Controller_Exception('Concept `' . $id . '` is deleted since ' . $concept['timestamp'], 410); } return $concept; }
public function delete() { $tenant = $this->code; $result = parent::delete(); $solr = OpenSKOS_Solr::getInstance()->delete('tenant:' . $tenant); return $result; }
/** * Returns the total number of rows in the array. * * @return integer */ public function count() { $response = $this->_solr->search($this->_query, $this->_parameters + array('rows' => 0)); $this->_count = $response['response']['numFound']; return $this->_count; }
public function delete() { $collection_id = $this->id; $result = parent::delete(); $solr = OpenSKOS_Solr::getInstance()->delete('collection:' . $collection_id); return $result; }
/** * @return OpenSKOS_Solr */ protected function solr() { if (null === $this->_solr) { $this->_solr = OpenSKOS_Solr::getInstance()->cleanCopy(); } return $this->_solr; }
include dirname(__FILE__) . '/../bootstrap.inc.php'; // Allow loading of application module classes. $autoloader = new OpenSKOS_Autoloader(); $mainAutoloader = Zend_Loader_Autoloader::getInstance(); $mainAutoloader->pushAutoloader($autoloader, array('Editor_', 'Api_')); Zend_Session::start(true); // Concepts $deletedConceptsCounter = 0; $notationsCounter = 0; $apiModel = Api_Models_Concepts::factory(); $solrTenant = OpenSKOS_Solr::getInstance()->cleanCopy(); $facetsResponseTenant = $solrTenant->limit(0, 0)->search('*:*', ['facet' => 'true', 'facet.field' => 'tenant']); $facetFieldsTenant = $facetsResponseTenant['facet_counts']['facet_fields']; foreach ($facetFieldsTenant['tenant'] as $tenant => $countsTenant) { echo 'Processing tenant ' . $tenant . '.' . "\n"; $solrNotation = OpenSKOS_Solr::getInstance()->cleanCopy(); do { $facetsResponseNotation = $solrNotation->limit(0, 0)->search('deleted:false AND tenant:' . $tenant, ['facet' => 'true', 'facet.field' => 'notation', 'facet.mincount' => 2]); $facetFieldsNotation = $facetsResponseNotation['facet_counts']['facet_fields']; if (!empty($facetFieldsNotation['notation'])) { foreach ($facetFieldsNotation['notation'] as $notation => $countsNotation) { $notationsCounter++; echo 'Process: ' . $notation . ' with "' . $countsNotation . '" duplicates' . "\n"; $apiModel->setQueryParam('sort', 'modified_timestamp desc, status asc'); $response = $apiModel->getConcepts('notation:"' . $notation . '" AND tenant:"' . $tenant . '"'); // We pick the first concept with schema. If non of them has one - we pick the first concept. $keepKey = 0; foreach ($response['response']['docs'] as $docKey => $doc) { if (!empty($doc['inScheme'])) { $keepKey = $docKey; break;
fwrite(STDERR, $e->getMessage() . "\n"); echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage()); exit(1); } include dirname(__FILE__) . '/../bootstrap.inc.php'; // Allow loading of application module classes. $autoloader = new OpenSKOS_Autoloader(); $mainAutoloader = Zend_Loader_Autoloader::getInstance(); $mainAutoloader->pushAutoloader($autoloader, array('Editor_', 'Api_')); Zend_Session::start(true); // Concepts $fixedConceptsCounter = 0; $notationsCounter = 0; $docsToRestore = []; $apiModel = Api_Models_Concepts::factory(); $solr = OpenSKOS_Solr::getInstance()->cleanCopy(); $limit = 100; $offset = 0; do { $facetsResponse = $solr->limit(0, 0)->search('timestamp:[2015-04-24T00:00:00Z TO 2015-04-25T06:00:00Z] AND deleted:true', ['facet' => 'true', 'facet.field' => 'notation', 'facet.mincount' => 1, 'facet.limit' => $limit, 'facet.offset' => $offset]); $facetFields = $facetsResponse['facet_counts']['facet_fields']; if (!empty($facetFields['notation'])) { foreach ($facetFields['notation'] as $notation => $counts) { $notationsCounter++; echo 'Check notation "' . $notation . '"' . "\n"; $apiModel->setQueryParam('sort', 'modified_timestamp asc'); $response = $apiModel->getConcepts('notation:"' . $notation . '"', true); $perTenant = []; foreach ($response['response']['docs'] as $doc) { if (!isset($perTenant[$doc['tenant']])) { $perTenant[$doc['tenant']] = [];
public function getSet($set) { @(list($tenantCode, $collectionCode, $conceptSchemaUuid) = explode(':', $set)); if (null === $tenantCode) { return; } $model = new OpenSKOS_Db_Table_Tenants(); if (null === ($tenant = $model->find($tenantCode)->current())) { return; } if (null !== $collectionCode) { $model = new OpenSKOS_Db_Table_Collections(); $collection = $model->fetchRow($model->select()->where('code=?', $collectionCode)->where('tenant=?', $tenantCode)); if (null === $collection) { return; } if (null !== $conceptSchemaUuid) { $params = array('limit' => 1, 'fl' => 'uuid'); $response = new OpenSKOS_SKOS_ConceptSchemes(OpenSKOS_Solr::getInstance()->search("class:ConceptScheme AND tenant:{$tenant->code} AND collection:{$collection->id} AND uuid:{$conceptSchemaUuid}")); if (count($response) == 0) { return; } else { return $response->current(); } } else { return $collection; } } else { return $tenant; } }