Beispiel #1
0
try {
    $OPTS = new Zend_Console_Getopt($opts);
} catch (Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n");
    echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
    exit(1);
}
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);
        }
 public function getCollection()
 {
     $model = new OpenSKOS_Db_Table_Collections();
     return $model->find($this->data['collection'])->current();
 }
 public function getConceptsBaseUrlAction()
 {
     $model = new OpenSKOS_Db_Table_Collections();
     $collection = $model->find($this->getRequest()->getParam('id'))->current();
     $conceptsBaseUrl = $collection->getConceptsBaseUri();
     $this->getHelper('json')->sendJson(array('status' => 'ok', 'result' => $conceptsBaseUrl));
 }
Beispiel #4
0
 /**
  * 
  * @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;
 }