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);
 }
 /**
  * Constructor.
  *
  * @param array $array Array to paginate
  */
 public function __construct($query, array $parameters = array())
 {
     $this->_solr = OpenSKOS_Solr::getInstance();
     $this->_parameters = $parameters;
     $this->_query = $query;
     $response = $this->_solr->search($this->_query, $this->_parameters + array('rows' => 0));
     $this->_count = $response['response']['numFound'];
 }
Exemple #3
0
 public function delete()
 {
     $tenant = $this->code;
     $result = parent::delete();
     $solr = OpenSKOS_Solr::getInstance()->delete('tenant:' . $tenant);
     return $result;
 }
Exemple #4
0
 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;
     }
 }