public function getAction()
 {
     $modelTenant = new OpenSKOS_Db_Table_Tenants();
     $id = $this->getRequest()->getParam('id');
     list($tenantCode, $collectionCode) = explode(':', $id);
     $tenant = $modelTenant->find($tenantCode)->current();
     if (null === $tenant) {
         throw new Zend_Controller_Action_Exception('Insitution `' . $tenantCode . '` not found', 404);
     }
     $modelCollections = new OpenSKOS_Db_Table_Collections();
     $collection = $tenant->findDependentRowset('OpenSKOS_Db_Table_Collections', null, $modelCollections->select()->where('code=?', $collectionCode))->current();
     if (null === $collection) {
         throw new Zend_Controller_Action_Exception('Collection `' . $id . '` not found', 404);
     }
     $context = $this->_helper->contextSwitch()->getCurrentContext();
     if ($context == 'json' || $context == 'jsonp') {
         foreach ($collection as $key => $val) {
             $this->view->assign($key, $val);
         }
     } else {
         $this->view->assign('tenant', $tenant);
         $this->view->assign('collection', $collection);
     }
 }
 /**
  * @return Editor_Forms_SearchOptions
  */
 protected function buildCollections()
 {
     $modelCollections = new OpenSKOS_Db_Table_Collections();
     $collections = $modelCollections->fetchAll($modelCollections->select()->where('tenant = ?', $this->_getCurrentTenant()->code));
     $collectionsOptions = array();
     foreach ($collections as $collection) {
         $collectionsOptions[$collection->id] = $collection->dc_title;
     }
     $this->addElement('multiselect', 'collections', array('label' => _('Collections'), 'multiOptions' => $collectionsOptions));
     return $this;
 }
Esempio n. 3
0
if ($OPTS->help) {
    echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
    exit(0);
}
include 'bootstrap.inc.php';
$model = new OpenSKOS_Db_Table_Collections();
if (null !== $OPTS->collection) {
    if (preg_match('/^\\d+$/', $OPTS->collection)) {
        $collection = $model->find($OPTS->collection)->current();
    } else {
        $tenant = $OPTS->tenant;
        if (null === $tenant) {
            fwrite(STDERR, "if you want to select a collection by it's code, a tenant code is required\n");
            exit(1);
        }
        $collection = $model->fetchRow($model->select()->where('code=?', $OPTS->collection)->where('tenant=?', $tenant));
        if (null === $collection) {
            fwrite(STDERR, "collection `{$OPTS->collection}` not found\n");
            exit(2);
        }
        if (!$collection->OAI_baseURL) {
            fwrite(STDERR, "collection `{$OPTS->collection}` has no OAI base URL\n");
            exit(3);
        }
        $collections = array($collection);
    }
} else {
    $collections = $model->fetchAll($model->select()->where('OAI_baseURL<>?', ''));
}
foreach ($collections as $collection) {
    if (null !== $OPTS->verbose) {
Esempio n. 4
0
 /**
  * Parses the part of the query for searching for specified collections.
  * By default the search is performed for all collections.
  *
  * @return OpenSKOS_Solr_Queryparser_Editor
  */
 protected function _parseSearchForCollections()
 {
     $modelCollections = new OpenSKOS_Db_Table_Collections();
     $allCollections = $modelCollections->fetchAll($modelCollections->select()->where('tenant = ?', $this->_tenant->code));
     $searchInCollections = array();
     if (isset($this->_searchOptions['collections'])) {
         $searchInCollections = $this->_searchOptions['collections'];
     }
     if (!empty($searchInCollections) && count($searchInCollections) != count($allCollections)) {
         $query = '';
         foreach ($searchInCollections as $collectionId) {
             $query .= !empty($query) ? ' OR ' : '';
             $query .= 'collection:' . $collectionId;
         }
         if (!empty($query) && count($searchInCollections) > 1) {
             $query = '(' . $query . ')';
         }
         if (!empty($query)) {
             $this->_addDefaultQuerySeparator();
             $this->_query .= $query;
         }
     }
     return $this;
 }
Esempio n. 5
0
 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;
     }
 }