# HG changeset patch # User ymh # Date 1454688069 -3600 # Node ID 7abc74acf392ce4af9bfc5b1e75590f382f88165 # Parent e60c55988ed48b8d226364c1a83780cddef4fea9 When merging ore:aggregation, process the license correctly, if different or null, the default is use, if the same, this is the value used diff -r e60c55988ed4 -r 7abc74acf392 server/src/app/Libraries/Mergers/CocoonSoundRdfMerger.php --- a/server/src/app/Libraries/Mergers/CocoonSoundRdfMerger.php Fri Feb 05 15:08:46 2016 +0100 +++ b/server/src/app/Libraries/Mergers/CocoonSoundRdfMerger.php Fri Feb 05 17:01:09 2016 +0100 @@ -111,8 +111,38 @@ "http://www.europeana.eu/schemas/edm/isShownBy" ], $targetArray, $baseRes, $srcRes); + $this->mergeEdmRight($targetArray, $baseRes, $srcRes); + } + protected function mergeEdmRight(&$targetArray, $baseRes, $srcRes) { + $srcRdfPhp = $this->srcGraph->toRdfPhp(); + $srcArray = array_key_exists($srcRes->getUri(), $srcRdfPhp)?$srcRdfPhp[$srcRes->getUri()]:[]; + $baseRdfPhp = $this->baseGraph->toRdfPhp(); + $baseArray = array_key_exists($baseRes->getUri(), $baseRdfPhp)?$baseRdfPhp[$baseRes->getUri()]:[]; + + $prop = "http://www.europeana.eu/schemas/edm/rights"; + + $baseRight = null; + if(isset($baseArray[$prop]) && count($baseArray[$prop]) > 0) { + $baseRight = $baseArray[$prop][0]; + } + $srcRight = null; + if(isset($srcArray[$prop]) && count($srcArray[$prop]) > 0) { + $srcRight = $srcArray[$prop][0]; + } + + $license = [ 'type' => 'uri', 'value' => config('corpusparole.corpus_doc_default_cc_rights') ]; + + if($baseRight != null && $baseRight == $srcRight ) { + $license = $baseRight; + } + + $targetArray[$prop] = [$license,]; + } + + + protected function mergeEdmProvidedCHO($baseRes, $srcRes, $uri=null) { if(is_null($uri)) { $uri = $baseRes->getUri(); diff -r e60c55988ed4 -r 7abc74acf392 server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php --- a/server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php Fri Feb 05 15:08:46 2016 +0100 +++ b/server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php Fri Feb 05 17:01:09 2016 +0100 @@ -122,7 +122,7 @@ edm:dataProvider "Laboratoire de langues et civilisations à tradition orale" ; edm:isShownAt ; edm:isShownBy ; - edm:rights ; + edm:rights ; edm:hasView , . @@ -423,6 +423,30 @@ } } + public function testRightDifferent() { + $resGraph = $this->resGraph["SOUND_TEXT"]; + + $aggregationRes = $resGraph->get('ore:Aggregation', '^rdf:type'); + + $license = $aggregationRes->get(''); + + $this->assertNotNull($license, "The licence must not be null"); + $this->assertInstanceOf("EasyRdf\Resource", $license, "Licence must be a resource"); + $this->assertEquals(config('corpusparole.corpus_doc_default_cc_rights'), $license->getUri(), "License must be default licence"); + } + + public function testRightSame() { + $resGraph = $this->resGraph["SOUND_NO_MOD_TEXT"]; + + $aggregationRes = $resGraph->get('ore:Aggregation', '^rdf:type'); + + $license = $aggregationRes->get(''); + + $this->assertNotNull($license, "The licence must not be null"); + $this->assertInstanceOf("EasyRdf\Resource", $license, "Licence must be a resource"); + $this->assertEquals('http://creativecommons.org/licenses/by-nc-sa/4.0/', $license->getUri(), "License must be default licence"); + } + }