diff -r 01a844d292ac -r 00e2916104fe server/src/app/Console/Commands/ImportCocoonRDF.php --- a/server/src/app/Console/Commands/ImportCocoonRDF.php Mon Jun 15 19:30:32 2015 +0200 +++ b/server/src/app/Console/Commands/ImportCocoonRDF.php Tue Jun 23 17:01:39 2015 +0200 @@ -1,73 +1,96 @@ -load(); - /** - * Execute the console command. - * - * @return mixed - */ - public function fire() - { - echo("hello\n"); - $doc = new \EasyRdf_Graph("http://cocoon.huma-num.fr/exist/crdo/rdf/crdo-ESLO1_ENTCONT_203"); - $doc->load(); + $client = new Client(Config::get('corpusparole.cocoon_oaipmh_url')); + //$client = new Client('http://memory.loc.gov/cgi-bin/oai2_0'); + $endpoint = new Endpoint($client); + + $recs = $endpoint->listRecords('olac', null, null, 'LanguesDeFrance'); + //$recs = $endpoint->listRecords('oai_dc', null, null, 'mussm'); - echo $doc->dump('text'); - - echo(join(', ', $doc->allOfType('foaf:Agent'))); - } + foreach ($recs as $item) { + if ($recs->getNumRequests() > 1) { + break; + } + $identifier = (string) $item->xpath('/record/header/identifier')[0]; + $docRdfUrl = Config::get('corpusparole.cocoon_rdf_base_uri').substr($identifier, strlen(Config::get('corpusparole.cocoon_doc_id_base'))); + print("Processing $identifier : $docRdfUrl\n"); + $doc = new \EasyRdf_Graph($docRdfUrl); + $doc->load(); + $subjects = $doc->resourcesMatching('foaf:primaryTopic'); + $subject = reset($subjects)->getUri(); + $gs->insert($doc, $subject); + } + } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['example', InputArgument::REQUIRED, 'An example argument.'], - ]; - } + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['example', InputArgument::REQUIRED, 'An example argument.'], + ]; + } - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - //['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], - ]; - } - + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + //['example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null], + ]; + } }