# HG changeset patch # User ymh # Date 1460130649 -7200 # Node ID 49b75287c30b59292731ac9a073b8f529b83e267 # Parent 03678acbfda3ebb5417f83564830808b0a1bc1d4 correct backoffocie with new handle if format diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Http/Controllers/Bo/DocumentListController.php --- a/server/src/app/Http/Controllers/Bo/DocumentListController.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Http/Controllers/Bo/DocumentListController.php Fri Apr 08 17:50:49 2016 +0200 @@ -65,6 +65,7 @@ */ public function show($id) { + Log::info("show: $id"); //$doc->add("<$doc_uri>"); $doc = $this->documentRepository->get($id); @@ -85,6 +86,7 @@ */ public function getClient($id) { + Log::info("getClient: $id"); return view('bo.docDetailClient', ['docid' => $id, 'boClientEnv' => json_encode(config('corpusparole.bo_client_environment'), JSON_UNESCAPED_SLASHES)]); } diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Http/routes.php --- a/server/src/app/Http/routes.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Http/routes.php Fri Apr 08 17:50:49 2016 +0200 @@ -18,10 +18,11 @@ Route::group(['middleware' => ['web']], function () { //Route::get('bo/docs/docDetailClient', 'Bo\DocumentListController@showClient'); + Route::pattern('docs', ".*"); + Route::get('bo/docs/client/{docs}', 'Bo\DocumentListController@getClient') + ->name('bo.docs.client') + ->where('docs', '.+'); Route::resource('bo/docs', 'Bo\DocumentListController'); - Route::controller('bo/docs', 'Bo\DocumentListController', [ - 'getClient' => 'bo.docs.client' - ]); Route::controllers([ @@ -39,6 +40,7 @@ */ Route::group(['prefix' => 'api/v1', 'middleware' => 'cors'] , function() { + Route::pattern('documents', ".*"); Route::resource('documents', 'Api\DocumentController', ['only' => ['index', 'show', 'update']]); Route::resource('viaf', 'Api\ViafController', diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Libraries/CocoonUtils.php --- a/server/src/app/Libraries/CocoonUtils.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Libraries/CocoonUtils.php Fri Apr 08 17:50:49 2016 +0200 @@ -70,8 +70,10 @@ } public static function isResourceCollection($res) { - return $res instanceof Resource && - (strpos(strtolower($res->getUri()), "collection", strlen(config('corpusparole.cocoon_doc_id_base_uri'))) !== FALSE); + return $res instanceof Resource && ( + (strpos(strtolower($res->getUri()), "collection", strlen(config('corpusparole.cocoon_doc_id_base_uri'))) !== FALSE) || + (strpos(strtolower($res->getUri()), "collection", strlen(config('corpusparole.corpus_doc_id_base_uri'))) !== FALSE) + ); } } diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Libraries/Mappers/CocoonAbstractRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonAbstractRdfMapper.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonAbstractRdfMapper.php Fri Apr 08 17:50:49 2016 +0200 @@ -80,6 +80,22 @@ $providedCHOResource->add($prop, trim($value)); } + protected function propertyCollectionMap($providedCHOResource, $prop, $value) { + // if this is a collection, we use the edm:isGatheredInto property + if(CocoonUtils::isResourceCollection($value)) { + $resId = CocoonUtils::getIdFromUri($value->getUri()); + $resUri = CocoonUtils::getCorpusUriFromId($resId); + $providedCHOResource->addResource('http://www.europeana.eu/schemas/edm/isGatheredInto', $resUri); + } elseif (strpos($value->getUri(), config('corpusparole.cocoon_doc_id_base_uri')) === 0 ) { + $resId = CocoonUtils::getIdFromUri($value->getUri()); + $resUri = CocoonUtils::getCorpusUriFromId($resId); + $providedCHOResource->add($prop, $resUri); + } else { + $providedCHOResource->add($prop, $value); + } + } + + protected function addSpatialProperties($destRes, $res, $outputGraph) { $spatials = $res->all($this->inputGraph->resource('http://purl.org/dc/terms/spatial')); $lats = $res->all($this->inputGraph->resource('http://www.w3.org/2003/01/geo/wgs84_pos#lat')); diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Libraries/Mappers/CocoonCollectionRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonCollectionRdfMapper.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonCollectionRdfMapper.php Fri Apr 08 17:50:49 2016 +0200 @@ -97,7 +97,7 @@ ['http://purl.org/dc/elements/1.1/language', null], ['http://purl.org/dc/terms/accessRights', 'propertyTrimMap'], ['http://purl.org/dc/terms/extent', null], - ['http://purl.org/dc/terms/isPartOf', null], + ['http://purl.org/dc/terms/isPartOf', 'propertyCollectionMap'], ['http://www.language-archives.org/OLAC/1.1/annotator', 'propertyOlacRoleMap'], ['http://www.language-archives.org/OLAC/1.1/author', 'propertyOlacRoleMap'], ['http://www.language-archives.org/OLAC/1.1/compiler', 'propertyOlacRoleMap'], diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php Fri Apr 08 17:50:49 2016 +0200 @@ -81,15 +81,6 @@ $providedCHOResource->add('http://purl.org/dc/terms/references', $value); } - protected function propertyCollectionMap($providedCHOResource, $prop, $value) { - // if this is a collection, we use the edm:isGatheredInto property - if(CocoonUtils::isResourceCollection($value)) { - $providedCHOResource->add('http://www.europeana.eu/schemas/edm/isGatheredInto', $value); - } else { - $providedCHOResource->add($prop, $value); - } - } - /** * Build the provided CHO. */ diff -r 03678acbfda3 -r 49b75287c30b server/src/app/Models/Document.php --- a/server/src/app/Models/Document.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/app/Models/Document.php Fri Apr 08 17:50:49 2016 +0200 @@ -273,8 +273,8 @@ //remove old, foreach ($this->getContributors() as $contribDef) { $value = null; - if (is_null($contribDef['url'])) { - if(is_null($contribDef['nameLiteral'])) { + if (empty($contribDef['url'])) { + if(empty($contribDef['nameLiteral'])) { $value = new Literal($contribDef['name']); } else { $value = $contribDef['nameLiteral']; @@ -289,7 +289,7 @@ //put new foreach ($contributors as $newContribDef) { $value = null; - if (is_null($newContribDef['url'])) { + if (empty($newContribDef['url'])) { $value = new Literal($newContribDef['name'], "fr", null); } else { $value = new Resource($newContribDef['url']); diff -r 03678acbfda3 -r 49b75287c30b server/src/resources/views/bo/docList.blade.php --- a/server/src/resources/views/bo/docList.blade.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/resources/views/bo/docList.blade.php Fri Apr 08 17:50:49 2016 +0200 @@ -16,7 +16,7 @@ @foreach ($docs as $doc) - {{ $doc->getId() }} + {{ $doc->getId() }} {{ $doc->getTitle() }} {{substr($doc->getLanguageValue(), 29)}} diff -r 03678acbfda3 -r 49b75287c30b server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php --- a/server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php Fri Apr 08 17:50:49 2016 +0200 @@ -178,7 +178,6 @@ 'http://purl.org/dc/terms/issued', 'http://purl.org/dc/elements/1.1/type', 'http://purl.org/dc/elements/1.1/language', - 'http://purl.org/dc/terms/isPartOf', 'http://purl.org/dc/terms/modified', ]; @@ -216,4 +215,23 @@ } + /** + * Test mapping for isPartOf + * + * @return void + */ + public function testOneToOneCollectionIsPartOf() { + $collection = $this->resGraphes['BASE']->get('edm:Collection', '^rdf:type'); + $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); + + $this->assertNotNull($collection); + $this->assertNotNull($sourceNode); + + $ispartOf = $collection->all(''); + $this->assertCount(1, $ispartOf, "Must have one collection node"); + + $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ALA", strval($collection->get('')), "the isPartOf mus equals ".config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ALA"); + } + + } diff -r 03678acbfda3 -r 49b75287c30b server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php --- a/server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php Sat Mar 26 00:24:34 2016 +0100 +++ b/server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php Fri Apr 08 17:50:49 2016 +0200 @@ -380,22 +380,22 @@ $this->assertNotNull($providedCHO); $this->assertNotNull($sourceNode); - $isGatheredInto = $providedCHO->all($this->resGraphes['BASE']->resource('http://www.europeana.eu/schemas/edm/isGatheredInto')); + $isGatheredInto = $providedCHO->all(''); $this->assertCount(2, $isGatheredInto, "Must have two collection node"); - $ispartOf = $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/isPartOf')); + $ispartOf = $providedCHO->all(''); $this->assertCount(1, $ispartOf, "Must have one collection node"); $outputValuesStr = []; - foreach($providedCHO->all($this->resGraphes['BASE']->resource('http://www.europeana.eu/schemas/edm/isGatheredInto')) as $outputValue) { + foreach($providedCHO->all('') as $outputValue) { array_push($outputValuesStr, strval($outputValue)); } $this->assertNotEmpty($outputValuesStr, "we must found some values to test isGatheredInto"); - $this->assertContains("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE", $outputValuesStr, "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE not found in output graph"); - $this->assertContains("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1", $outputValuesStr, "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1 not found in output graph"); + $this->assertContains(config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_LANGUESDEFRANCE", $outputValuesStr, config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_LANGUESDEFRANCE not found in output graph"); + $this->assertContains(config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ESLO1", $outputValuesStr, config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ESLO1 not found in output graph"); - $this->assertEquals("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_010", strval($providedCHO->get($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/isPartOf'))), "the isPartOf mus equals http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_010"); + $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ESLO1_ENT_010", strval($providedCHO->get('')), "the isPartOf mus equals ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ESLO1_ENT_010"); } /**