When merging ore:aggregation, process the license correctly, if different or null, the default is use, if the same, this is the value used
--- 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();
--- 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 <http://cocoon.huma-num.fr/exist/crdo/meta/crdo-UVE_MOCIKA_SOUND> ;
edm:isShownBy <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
- edm:rights <http://creativecommons.org/licenses/by-nc-nd/4.0/> ;
+ edm:rights <http://creativecommons.org/licenses/by-nc-sa/4.0/> ;
edm:hasView <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav>, <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3> .
<http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND>
@@ -423,6 +423,30 @@
}
}
+ public function testRightDifferent() {
+ $resGraph = $this->resGraph["SOUND_TEXT"];
+
+ $aggregationRes = $resGraph->get('ore:Aggregation', '^rdf:type');
+
+ $license = $aggregationRes->get('<http://www.europeana.eu/schemas/edm/rights>');
+
+ $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('<http://www.europeana.eu/schemas/edm/rights>');
+
+ $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");
+ }
+
}