コード例 #1
0
ファイル: harvest.php プロジェクト: rubensworks/OpenSKOS
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) {
コード例 #2
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;
     }
 }