diff -r ac3dc090e987 -r f2a40bbc27f6 server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php Tue Nov 17 13:11:55 2015 +0100 @@ -0,0 +1,165 @@ + a ; + * "Voilà pourquoi le bernard-l'hermite, aujourd'hui, se cache dans les coquilles vides qu'il trouve, alors que le crabe de cocotier n'a pas honte de se promener tout nu."@fr ; + * "text/xml"^^ ; + * "primary_text"^^ , , "narrative"^^ ; + * ; + * ; + * ; + * ; + * "Copyright (c) Moyse-Faurie, Claire" ; + * "The two hermit crabs and the coconut crab"@en ; + * , ; + * "Freely available for non-commercial use" ; + * ; + * , ; + * "NC"^^ , "New Caledonia, Ohnyat (Ouvéa)" ; + * "2011-02-05"^^ ; + * "2011-02-05T23:22:23+01:00"^^ ; + * "Idakote, Félicien" ; + * ; + * "Les deux bernard-l'hermite et le crabe de cocotier"@fr ; + * "Moyse-Faurie, Claire" ; + * "2002-02-20"^^ ; + * . + * + * a ; + * "audio/x-wav"^^ ; + * , "primary_text"^^ , "narrative"^^ ; + * ; + * ; + * ; + * ; + * "Copyright (c) Moyse-Faurie, Claire" ; + * "The two hermit crabs and the coconut crab"@en ; + * , ; + * "Freely available for non-commercial use" ; + * ; + * , ; + * "PT2M35S" ; + * "1997-08-29"^^ ; + * "NC"^^ , "New Caledonia, Ohnyat (Ouvéa)" ; + * ; + * "2010-10-23"^^ ; + * "2010-10-23T00:08:27+02:00"^^ ; + * "Idakote, Félicien" ; + * "166.6526"^^xsd:float ; + * "-20.4765"^^xsd:float ; + * ; + * "Moyse-Faurie, Claire" . + * + * http://purl.org/dc/elements/1.1/description + * http://purl.org/dc/elements/1.1/format + * http://purl.org/dc/elements/1.1/language + * http://purl.org/dc/elements/1.1/publisher + * http://purl.org/dc/elements/1.1/rights + * http://purl.org/dc/elements/1.1/subject + * http://purl.org/dc/elements/1.1/title + * http://purl.org/dc/elements/1.1/type + * http://purl.org/dc/terms/accessRights + * http://purl.org/dc/terms/available + * http://purl.org/dc/terms/conformsTo + * http://purl.org/dc/terms/created + * http://purl.org/dc/terms/isFormatOf + * http://purl.org/dc/terms/isPartOf + * http://purl.org/dc/terms/issued + * http://purl.org/dc/terms/license + * http://purl.org/dc/terms/requires + * http://www.language-archives.org/OLAC/1.1/data_inputter + * http://www.language-archives.org/OLAC/1.1/depositor + * http://www.language-archives.org/OLAC/1.1/editor + * http://www.language-archives.org/OLAC/1.1/interviewer + * http://www.language-archives.org/OLAC/1.1/researcher + * http://www.language-archives.org/OLAC/1.1/speaker + * http://www.language-archives.org/OLAC/1.1/transcriber + * http://www.language-archives.org/OLAC/1.1/author + * http://www.language-archives.org/OLAC/1.1/recorder + * http://www.language-archives.org/OLAC/1.1/translator + * http://www.language-archives.org/OLAC/1.1/responder + * http://www.language-archives.org/OLAC/1.1/sponsor + * http://www.language-archives.org/OLAC/1.1/annotator + * http://www.language-archives.org/OLAC/1.1/participant + * http://www.language-archives.org/OLAC/1.1/compiler + * http://www.language-archives.org/OLAC/1.1/developer + * http://www.language-archives.org/OLAC/1.1/consultant + * http://www.language-archives.org/OLAC/1.1/research_participant + * http://purl.org/dc/terms/spatial + * http://purl.org/dc/terms/tableOfContents + * http://www.w3.org/2003/01/geo/wgs84_pos#lat + * http://www.w3.org/2003/01/geo/wgs84_pos#long + * http://purl.org/dc/terms/alternative + * http://purl.org/dc/terms/modified + * http://purl.org/dc/elements/1.1/identifier + * http://purl.org/dc/terms/extent + * http://purl.org/dc/terms/medium + * http://purl.org/dc/elements/1.1/source + * http://purl.org/dc/elements/1.1/coverage + * http://crdo.risc.cnrs.fr/schemas/master + * http://purl.org/dc/elements/1.1/creator + * http://purl.org/dc/elements/1.1/reference + * http://purl.org/dc/terms/references + * http://purl.org/dc/terms/abstract + * http://purl.org/dc/elements/1.1/relation + */ +class CocoonTextRdfMapper extends CocoonContentRdfMapper { + + + protected function getResourceBaseId($res=null) { + + if(is_null($res)) { + $res = $this->inputGraph->resource($this->uri); + } + $soundRes = $res->get('dc:requires'); + + if(! $soundRes instanceof Resource) { + throw new \Exception("Input graph for text not correct, can not find sound resource", 1); + } + + return $soundRes->getUri(); + } + + protected function addCHOResourceDateProperties($providedCHOResource, $res, $outputGraph) { + // We do not add date to the providedCHO for Text resource + } + + protected function propertyTypeMap($providedCHOResource, $prop, $value) { + if((!$value instanceof Resource) || $value->getUri() !== "http://purl.org/dc/dcmitype/Text") { + $providedCHOResource->add($prop, $value); + } + } + + protected function mapWebResources($res, $outputGraph) { + $resId = CocoonUtils::getIdFromUri($this->getResourceBaseId($res)); + $resUri = CocoonUtils::getCorpusUriFromId($resId); + + + $aggregationNode = $outputGraph->resource($resUri, 'ore:Aggregation'); + + // build others + foreach($res->all($this->inputGraph->resource('http://purl.org/dc/terms/isFormatOf')) as $reprUrl) { + $webResource = $outputGraph->resource($reprUrl, 'edm:WebResources'); + $mimetype = Utils::getMimetype($reprUrl); + + $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); + $aggregationNode->addResource('edm:hasView', $reprUrl); + + } + + } + +}