コード例 #1
0
 public function getAction()
 {
     $model = new OpenSKOS_Db_Table_Tenants();
     $code = $this->getRequest()->getParam('id');
     $tenant = $model->find($code)->current();
     if (null === $tenant) {
         throw new Zend_Controller_Action_Exception('Insitution `' . $code . '` not found', 404);
     }
     $context = $this->_helper->contextSwitch()->getCurrentContext();
     if ($context == 'json' || $context == 'jsonp') {
         foreach ($tenant as $key => $val) {
             $this->view->assign($key, $val);
         }
         $this->view->assign('collections', $tenant->findDependentRowset('OpenSKOS_Db_Table_Collections')->toArray());
     } else {
         $this->view->assign('tenant', $tenant);
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 public function getInstitution()
 {
     $model = new OpenSKOS_Db_Table_Tenants();
     return $model->find($this->data['tenant'])->current();
 }
コード例 #4
0
 /**
  * @return OpenSKOS_Db_Table_Row_Tenant
  */
 protected function _getTenant()
 {
     static $tenant;
     if (null === $tenant) {
         //need a tenant and a collection:
         $tenantCode = $this->getRequest()->getParam('tenant');
         if (!$tenantCode) {
             throw new Zend_Controller_Action_Exception('No tenant specified', 412);
         }
         $model = new OpenSKOS_Db_Table_Tenants();
         $tenant = $model->find($tenantCode)->current();
         if (null === $tenant) {
             throw new Zend_Controller_Action_Exception('No such tenant: `' . $tenantCode . '`', 404);
         }
     }
     return $tenant;
 }
コード例 #5
0
ファイル: Parser.php プロジェクト: rubensworks/OpenSKOS
 /**
  * 
  * @param Zend_Console_Getopt $opts
  * @return OpenSKOS_Rdf_Parser
  */
 public function setOpts(Zend_Console_Getopt $opts)
 {
     try {
         $opts->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         echo str_replace('[ options ]', '[ options ] file', $e->getUsageMessage());
         throw new OpenSKOS_Rdf_Parser_Exception($e->getMessage());
     }
     if (null !== $opts->help) {
         echo str_replace('[ options ]', '[ options ] file', $opts->getUsageMessage());
         throw new OpenSKOS_Rdf_Parser_Exception('', 0);
     }
     if ($opts->status) {
         if (!in_array($opts->status, self::$statuses)) {
             throw new OpenSKOS_Rdf_Parser_Exception('Illegal `status` value, must be one of `' . implode('|', self::$statuses) . '`', 0);
         }
     }
     foreach (self::$required as $opt) {
         if (null === $this->_opts->{$opt}) {
             throw new OpenSKOS_Rdf_Parser_Exception("missing required parameter `{$opt}`");
         }
     }
     $this->_opts = $opts;
     if (null !== $this->_opts->help) {
         $this->printUsageMessageAndExit();
     }
     if (null !== $opts->limit) {
         $this->setLimit((int) $opts->limit);
     }
     if (null !== $opts->from) {
         $this->setFrom((int) $opts->from);
     }
     $this->_bootstrap();
     $files = $this->_opts->getRemainingArgs();
     if (count($files) !== 1) {
         throw new OpenSKOS_Rdf_Parser_Exception(str_replace('[ options ]', '[ options ] file', $this->_opts->getUsageMessage()));
     }
     $this->setFiles($files);
     $model = new OpenSKOS_Db_Table_Tenants();
     $tenant = $model->find($opts->tenant)->current();
     if (null === $tenant) {
         throw new OpenSKOS_Rdf_Parser_Exception("No such tenant: `{$opts->tenant}`");
     }
     $model = new OpenSKOS_Db_Table_Collections();
     if (preg_match('/^\\d+$/', $opts->collection)) {
         $collection = $model->find($opts->collection)->current();
     } else {
         $collection = $model->findByCode($opts->collection, $opts->tenant);
     }
     if (null === $collection) {
         throw new OpenSKOS_Rdf_Parser_Exception("No such collection: `{$opts->collection}`");
     } else {
         $this->_collection = $collection;
     }
     return $this;
 }
コード例 #6
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;
     }
 }