# HG changeset patch # User ymh # Date 1454681326 -3600 # Node ID e60c55988ed48b8d226364c1a83780cddef4fea9 # Parent 34ffc04cef6283777afafabd0b22e109935d51d4 put right, access and licence info on webresource diff -r 34ffc04cef62 -r e60c55988ed4 server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonContentRdfMapper.php Fri Feb 05 15:08:46 2016 +0100 @@ -108,19 +108,24 @@ } + protected function addResourceRightProperties($resource, $res) { + $this->applyPropertiesToRes($res, $resource, [ + ['http://purl.org/dc/elements/1.1/rights', null], + ['http://purl.org/dc/terms/license', null], + ['http://purl.org/dc/terms/accessRights', 'propertyTrimMap'], + ]); + } + protected function addCHOResourceProperties($providedCHOResource, $res, $outputGraph) { $this->applyPropertiesToRes($res, $providedCHOResource, [ ['http://purl.org/dc/terms/tableOfContents', null], ['http://purl.org/dc/elements/1.1/description', null], ['http://purl.org/dc/elements/1.1/language', null], ['http://purl.org/dc/elements/1.1/publisher', null], - ['http://purl.org/dc/elements/1.1/rights', null], ['http://purl.org/dc/elements/1.1/type', 'propertyTypeMap'], - ['http://purl.org/dc/terms/license', null], ['http://purl.org/dc/elements/1.1/subject', null], ['http://purl.org/dc/elements/1.1/title', null], ['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', 'propertyCollectionMap'], ['http://purl.org/dc/terms/abstract', null], @@ -160,9 +165,11 @@ ['http://www.language-archives.org/OLAC/1.1/translator', 'propertyOlacRoleMap'], ]); + $this->addResourceRightProperties($providedCHOResource, $res); + } - protected function addDateToWebResource($sourceRes, $targetRes) { + protected function addDateToWebResource($targetRes, $sourceRes) { $this->applyPropertiesToRes($sourceRes, $targetRes, [ ['http://purl.org/dc/terms/created', null], diff -r 34ffc04cef62 -r e60c55988ed4 server/src/app/Libraries/Mappers/CocoonSoundRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonSoundRdfMapper.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonSoundRdfMapper.php Fri Feb 05 15:08:46 2016 +0100 @@ -119,7 +119,9 @@ $masterWebResource->addLiteral('http://purl.org/dc/elements/1.1/format', Literal::create($mimetype, null, $outputGraph->resource('http://purl.org/dc/terms/IMT'))); } - $this->addDateToWebResource($res, $masterWebResource); + $this->addResourceRightProperties($masterWebResource, $res); + + $this->addDateToWebResource($masterWebResource, $res); } @@ -135,7 +137,11 @@ if(!is_null($masterReprUrl)) { $webResource->addResource('edm:isDerivativeOf', $masterReprUrl); } - $this->addDateToWebResource($res, $webResource); + + $this->addResourceRightProperties($webResource, $res); + + $this->addDateToWebResource($webResource, $res); + $aggregationNode->addResource('edm:hasView', $reprUrl); } } diff -r 34ffc04cef62 -r e60c55988ed4 server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php --- a/server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php Fri Feb 05 15:08:46 2016 +0100 @@ -155,7 +155,8 @@ $webResource->addLiteral('http://purl.org/dc/elements/1.1/format', Literal::create($mimetype, null, $outputGraph->resource('http://purl.org/dc/terms/IMT'))); - $this->addDateToWebResource($res, $webResource); + $this->addResourceRightProperties($webResource, $res); + $this->addDateToWebResource($webResource, $res); $aggregationNode->addResource('edm:hasView', $reprUrl); } diff -r 34ffc04cef62 -r e60c55988ed4 server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php --- a/server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php Fri Feb 05 15:08:46 2016 +0100 @@ -268,6 +268,51 @@ } + public function testRightsWebResourceIdentity() { + $properties = [ + "http://purl.org/dc/elements/1.1/rights", + 'http://purl.org/dc/terms/license', + ]; + + $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); + $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); + + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { + $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph"); + } + } + } + } + + public function testRightsWebResourceTrim() { + $properties = [ + 'http://purl.org/dc/terms/accessRights', + ]; + + $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); + $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); + + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { + $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph"); + } + } + } + } + /** * Test one to one mapping * diff -r 34ffc04cef62 -r e60c55988ed4 server/src/tests/libraries/Mappers/CocoonTextRdfMapperTest.php --- a/server/src/tests/libraries/Mappers/CocoonTextRdfMapperTest.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/tests/libraries/Mappers/CocoonTextRdfMapperTest.php Fri Feb 05 15:08:46 2016 +0100 @@ -133,6 +133,52 @@ } + public function testRightsWebResourceIdentity() { + $properties = [ + "http://purl.org/dc/elements/1.1/rights", + 'http://purl.org/dc/terms/license', + ]; + + $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); + $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); + + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { + $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph"); + } + } + } + } + + public function testRightsWebResourceTrim() { + $properties = [ + 'http://purl.org/dc/terms/accessRights', + ]; + + $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); + $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); + + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { + $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph"); + } + } + } + } + + /** * Test providedCHO uri. * diff -r 34ffc04cef62 -r e60c55988ed4 server/src/tests/libraries/Mergers/CocoonSoundRdfMergerTest.php --- a/server/src/tests/libraries/Mergers/CocoonSoundRdfMergerTest.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/tests/libraries/Mergers/CocoonSoundRdfMergerTest.php Fri Feb 05 15:08:46 2016 +0100 @@ -43,6 +43,7 @@ dc11:language ; dc11:publisher ; dc11:type , "primary_text"^^olac:linguistic-type, "narrative"^^olac:discourse-type, "report"^^olac:discourse-type, "unintelligible_speech"^^olac:discourse-type ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; dc:license ; dc11:subject "lexicography"^^olac:linguistic-field, "phonetics"^^olac:linguistic-field, "anthropological_linguistics"^^olac:linguistic-field, "general_linguistics"^^olac:linguistic-field, , "text_and_corpus_linguistics"^^olac:linguistic-field, "phonology"^^olac:linguistic-field, "semantics"^^olac:linguistic-field, "sociolinguistics"^^olac:linguistic-field, "syntax"^^olac:linguistic-field, "typology"^^olac:linguistic-field, "discourse_analysis"^^olac:linguistic-field, "historical_linguistics"^^olac:linguistic-field, "language_documentation"^^olac:linguistic-field, "mathematical_linguistics"^^olac:linguistic-field ; dc11:title "CFPP2000 [03-01] Ozgur_Kilic_H_32_alii_3e Entretien de Ozgur KILIÇ 2"@fr ; @@ -72,6 +73,9 @@ dc:extent "PT48M26S" ; dc11:format "audio/x-wav"^^dc:IMT ; dc:created "2010-11-17"^^dc:W3CDTF ; + dc:accessRights "Freely available for non-commercial use" ; + dc:license ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; dc:issued "2013-10-12T14:35:57+02:00"^^dc:W3CDTF . @@ -80,7 +84,11 @@ dc11:format "audio/x-wav"^^dc:IMT ; edm:isDerivativeOf ; dc:created "2010-11-17"^^dc:W3CDTF ; - dc:issued "2013-10-12T14:35:57+02:00"^^dc:W3CDTF . + dc:issued "2013-10-12T14:35:57+02:00"^^dc:W3CDTF ; + dc:accessRights "Freely available for non-commercial use" ; + dc:license ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResource ; @@ -88,7 +96,11 @@ dc11:format "audio/mpeg"^^dc:IMT ; edm:isDerivativeOf ; dc:created "2010-11-17"^^dc:W3CDTF ; - dc:issued "2013-10-12T14:35:57+02:00"^^dc:W3CDTF . + dc:issued "2013-10-12T14:35:57+02:00"^^dc:W3CDTF ; + dc:accessRights "Freely available for non-commercial use" ; + dc:license ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + EOT , 'SOURCE' => <<, "text_and_corpus_linguistics"^^olac:linguistic-field, "phonology"^^olac:linguistic-field, "semantics"^^olac:linguistic-field, "sociolinguistics"^^olac:linguistic-field, "syntax"^^olac:linguistic-field, "typology"^^olac:linguistic-field, "discourse_analysis"^^olac:linguistic-field, "historical_linguistics"^^olac:linguistic-field, "language_documentation"^^olac:linguistic-field, "mathematical_linguistics"^^olac:linguistic-field ; dc11:title "CFPP2000 [03-01] Ozgur_Kilic_H_32_alii_3e Entretien de Ozgur KILIÇ 2 (annotations)"@fr ; dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; dc:isPartOf , ; dc11:source "CFPP2000"@fr ; dc11:coverage "Quartier concerné : 3e"@fr ; @@ -146,13 +159,20 @@ a edm:WebResource ; dc11:format "application/xml"^^dc:IMT ; dc:created "2010-11-17"^^dc:W3CDTF ; - dc:issued "2013-11-04T22:20:07+01:00"^^dc:W3CDTF . + dc:issued "2013-11-04T22:20:07+01:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . a edm:WebResource ; dc11:format "application/xhtml+xml"^^dc:IMT ; dc:created "2010-11-17"^^dc:W3CDTF ; - dc:issued "2013-11-04T22:20:07+01:00"^^dc:W3CDTF . + dc:issued "2013-11-04T22:20:07+01:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + EOT ]; @@ -333,5 +353,26 @@ } + public function testRightsWebResource() { + $properties = [ + "http://purl.org/dc/elements/1.1/rights", + 'http://purl.org/dc/terms/license', + 'http://purl.org/dc/terms/accessRights', + ]; + + $webResourceList = $this->resGraph->all('edm:WebResource', '^rdf:type'); + + //just check that they have all these resources. + //TODO: check that the same rights are kept (difficult) + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($this->resGraph->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + } + } + } } diff -r 34ffc04cef62 -r e60c55988ed4 server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php --- a/server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php Wed Feb 03 18:34:44 2016 +0100 +++ b/server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php Fri Feb 05 15:08:46 2016 +0100 @@ -49,6 +49,7 @@ dc11:subject , , ; dc11:title "The two hermit crabs and the coconut crab"@en ; dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; dc:extent "PT2M35S" ; edm:isGatheredInto , ; olac:depositor ; @@ -72,7 +73,11 @@ dc:extent "PT2M35S" ; dc11:format "audio/x-wav"^^dc:IMT ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResources ; @@ -80,7 +85,11 @@ dc11:format "audio/x-wav"^^dc:IMT ; edm:isDerivativeOf ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResources ; @@ -88,7 +97,11 @@ dc11:format "audio/mpeg"^^dc:IMT ; edm:isDerivativeOf ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + EOT , 'SOUND_NO_MOD' => <<, , ; dc11:title "The two hermit crabs and the coconut crab"@en ; dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; dc:extent "PT2M35S" ; edm:isGatheredInto , ; olac:depositor ; @@ -146,7 +160,11 @@ dc:extent "PT2M35S" ; dc11:format "audio/x-wav"^^dc:IMT ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResources ; @@ -154,7 +172,11 @@ dc11:format "audio/x-wav"^^dc:IMT ; edm:isDerivativeOf ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResources ; @@ -162,7 +184,11 @@ dc11:format "audio/mpeg"^^dc:IMT ; edm:isDerivativeOf ; dc:created "1997-08-29"^^dc:W3CDTF ; - dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF . + dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + EOT , 'TEXT' => << ; dc11:title "The two hermit crabs and the coconut crab"@en ; dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ; edm:isGatheredInto , ; dc:alternative "Les deux bernard-l'hermite et le crabe de cocotier"@fr ; olac:depositor ; @@ -212,12 +239,20 @@ a edm:WebResources ; dc11:format "application/xml"^^dc:IMT ; - dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF . + dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + a edm:WebResources ; dc11:format "application/xhtml+xml"^^dc:IMT ; - dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF . + dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF ; + dc:license ; + dc:accessRights "Freely available for non-commercial use" ; + dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" . + EOT ]; @@ -365,4 +400,29 @@ } + public function testRightsWebResource() { + $properties = [ + "http://purl.org/dc/elements/1.1/rights", + 'http://purl.org/dc/terms/license', + 'http://purl.org/dc/terms/accessRights', + ]; + + $resGraph = $this->resGraph["SOUND_TEXT"]; + $webResourceList = $resGraph->all('edm:WebResource', '^rdf:type'); + + //just check that they have all these resources. + //TODO: check that the same rights are kept (difficult) + foreach ($webResourceList as $webResource) { + foreach ($properties as $prop) { + $outputValuesStr = []; + foreach($webResource->all($resGraph->resource($prop)) as $outputValue) { + array_push($outputValuesStr, strval($outputValue)); + } + $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); + } + } + } + + + }