$info .= '<span class="errors">' . _('Tried to import the fallowing already existing concept schemes:') . '"' . implode('", "', $duplicateConceptSchemes) . '"</span><br /><br />'; } if (!empty($notImportedNotations)) { // If there are thousands of not imported notations - show only first 100 if (count($notImportedNotations) > 100) { $notImportedNotations = array_slice($notImportedNotations, 0, 100); $notImportedNotations[] = '...'; } $info .= _('The documents with the fallowing notations were not imported because already exist:') . '"' . implode('", "', $notImportedNotations) . '"'; } $job->setInfo($info); $job->finish()->save(); break; case OpenSKOS_Db_Table_Row_Job::JOB_TASK_HARVEST: $job->start()->save(); $harvester = OpenSKOS_Oai_Pmh_Harvester::factory($collection)->setFrom($job->getParam('from'))->setUntil($job->getParam('until'))->setOption('set', $job->getParam('set')); try { foreach ($harvester as $page => $records) { echo "page " . ($page + 1) . ":\n"; foreach ($records as $r => $record) { echo " record " . ($r + 1) . ": {$record->identifier}\n"; } } $job->finish()->save(); } catch (OpenSKOS_Oai_Pmh_Harvester_Exception $e) { fwrite(STDERR, $job->id . ': ' . $e->getMessage() . "\n"); $job->error($e->getMessage())->finish()->save(); } break; case OpenSKOS_Db_Table_Row_Job::JOB_TASK_EXPORT: $job->start()->save();
exit(3); } } } $from = $ts; $until = $OPTS->until; if (null !== $until) { $ts = strtotime($until); if (false === $ts) { fwrite(STDERR, "unrecognized date format: `{$until}`\n"); exit(3); } $until = $ts; } $params = array(); $harvester = OpenSKOS_Oai_Pmh_Harvester::factory($collection)->setFrom($from)->setUntil($until); foreach (array('set', 'q', 'row') as $opt) { if (null !== $OPTS->{$opt}) { $harvester->setOption($opt, $OPTS->{$opt}); } } $data = array('tenant' => $collection->tenant, 'collection' => $collection->id); try { foreach ($harvester as $page => $records) { if (null !== $OPTS->verbose) { fwrite(STDOUT, sprintf("fetching page %d (%d records):\n", $page + 1, count($harvester))); } foreach ($records as $r => $record) { if (null !== $OPTS->verbose) { fwrite(STDOUT, " processing record {$record->identifier}: "); }
public function getOaiJobForm() { static $form; if (null === $form) { $form = new Zend_Form(); $form->addElement('text', 'from', array('label' => 'Index records modified since', 'style' => 'width: 250px;'))->addElement('text', 'until', array('label' => 'Index records modified until', 'style' => 'width: 250px;'))->addElement('select', 'set', array('label' => 'OAI setSpec', 'style' => 'width: 250px;'))->addElement('select', 'metadataPrefix', array('label' => 'OAI metadataPrefix', 'style' => 'width: 250px;'))->addElement('checkbox', 'delete-before-import', array('label' => _('delete concepts in this collection before import')))->addElement('submit', 'submit', array('label' => 'Submit')); $form->getElement('delete-before-import')->setValue(1); } $form->getElement('from')->addValidator(new OpenSKOS_Validate_Datestring()); $form->getElement('until')->addValidator(new OpenSKOS_Validate_Datestring()); $harvester = new OpenSKOS_Oai_Pmh_Harvester($this); try { $sets = array('' => _('choose optional set:')) + $harvester->listSets()->toArray(); $form->getElement('set')->setMultiOptions($sets); } catch (OpenSKOS_Oai_Pmh_Harvester_Exception $e) { $form->getElement('set')->setMultiOptions(array('[' . _('Failed to load sets from OAI!') . ']')); } return $form; }