diff -r 01a844d292ac -r 00e2916104fe server/src/app/Repositories/RdfDocumentRepository.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Repositories/RdfDocumentRepository.php Tue Jun 23 17:01:39 2015 +0200 @@ -0,0 +1,64 @@ +sparqlClient = new \EasyRdf_Sparql_Client(Config::get('corpusparole.sesame_query_url')); + } + + public function all() { + + $docs = $this->sparqlClient->query( + 'SELECT * WHERE {'. + ' ?uri ?b;'. + '} ORDER BY ?uri' + ); + + $data = []; + + foreach ($docs as $doc) { + array_push($data, new Document($doc->uri->getUri())); + } + + return $data; + } + + public function get($id) { + + $doc_uri = Config::get('corpusparole.cocoon_doc_id_base_uri').$id; + + //$doc = $sparql->query( + // "CONSTRUCT {". + // " ?doc ?p ?v.". + // "}". + // "WHERE {". + // " <$doc_uri> ?doc.". + // " ?doc ?p ?v;". + // "}" + //); + + // We want the CBD (Concise Bounded Description, cf. http://www.w3.org/Submission/CBD/) + // WARNING: This seems to work in sesame for our dataset. + $doc = $this->sparqlClient->query( + 'DESCRIBE ?doc '. + 'WHERE {'. + " <$doc_uri> ?doc;". + '}' + ); + + return new Document($doc_uri, $doc); + + } + +}