server/src/app/Libraries/Mappers/CocoonTextRdfMapper.php
changeset 18 f2a40bbc27f6
child 19 eadaf0b8f02e
equal deleted inserted replaced
17:ac3dc090e987 18:f2a40bbc27f6
       
     1 <?php
       
     2 namespace CorpusParole\Libraries\Mappers;
       
     3 
       
     4 use Config;
       
     5 
       
     6 use CorpusParole\Libraries\Utils;
       
     7 use CorpusParole\Libraries\CocoonUtils;
       
     8 
       
     9 use EasyRdf\RdfNamespace;
       
    10 use EasyRdf\Graph;
       
    11 use EasyRdf\Literal;
       
    12 use EasyRdf\Resource;
       
    13 
       
    14 /**
       
    15  * <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA> a <http://crdo.risc.cnrs.fr/schemas/Resource> ;
       
    16  * 	<http://purl.org/dc/elements/1.1/description> "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 ;
       
    17  * 	<http://purl.org/dc/elements/1.1/format> "text/xml"^^<http://purl.org/dc/terms/IMT> ;
       
    18  * 	<http://purl.org/dc/elements/1.1/type> "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , <http://purl.org/dc/dcmitype/Text> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
       
    19  * 	<http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/uve> ;
       
    20  * 	<http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/uve> ;
       
    21  * 	<http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/56614135> ;
       
    22  * 	<http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/154919513> ;
       
    23  * 	<http://purl.org/dc/elements/1.1/rights> "Copyright (c) Moyse-Faurie, Claire" ;
       
    24  * 	<http://purl.org/dc/elements/1.1/title> "The two hermit crabs and the coconut crab"@en ;
       
    25  * 	<http://purl.org/dc/terms/isFormatOf> <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xml> , <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xhtml> ;
       
    26  * 	<http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
       
    27  * 	<http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/2.5/> ;
       
    28  * 	<http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LACITO> ;
       
    29  * 	<http://purl.org/dc/terms/spatial> "NC"^^<http://purl.org/dc/terms/ISO3166> , "New Caledonia, Ohnyat (Ouvéa)" ;
       
    30  * 	<http://purl.org/dc/terms/available> "2011-02-05"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    31  * 	<http://purl.org/dc/terms/issued> "2011-02-05T23:22:23+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    32  * 	<http://www.language-archives.org/OLAC/1.1/speaker> "Idakote, Félicien" ;
       
    33  * 	<http://purl.org/dc/terms/requires> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND> ;
       
    34  * 	<http://purl.org/dc/terms/alternative> "Les deux bernard-l'hermite et le crabe de cocotier"@fr ;
       
    35  * 	<http://www.language-archives.org/OLAC/1.1/researcher> "Moyse-Faurie, Claire" ;
       
    36  * 	<http://purl.org/dc/terms/modified> "2002-02-20"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    37  * 	<http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_archive> .
       
    38  *
       
    39  * <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND> a <http://crdo.risc.cnrs.fr/schemas/Resource> ;
       
    40  * 	<http://purl.org/dc/elements/1.1/format> "audio/x-wav"^^<http://purl.org/dc/terms/IMT> ;
       
    41  * 	<http://purl.org/dc/elements/1.1/type> <http://purl.org/dc/dcmitype/Sound> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , "narrative"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
       
    42  * 	<http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/uve> ;
       
    43  * 	<http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/uve> ;
       
    44  * 	<http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/56614135> ;
       
    45  * 	<http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/154919513> ;
       
    46  * 	<http://purl.org/dc/elements/1.1/rights> "Copyright (c) Moyse-Faurie, Claire" ;
       
    47  * 	<http://purl.org/dc/elements/1.1/title> "The two hermit crabs and the coconut crab"@en ;
       
    48  * 	<http://purl.org/dc/terms/isFormatOf> <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav> , <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3> ;
       
    49  * 	<http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
       
    50  * 	<http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-nd/2.5/> ;
       
    51  * 	<http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LACITO> ;
       
    52  * 	<http://purl.org/dc/terms/extent> "PT2M35S" ;
       
    53  * 	<http://purl.org/dc/terms/created> "1997-08-29"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    54  * 	<http://purl.org/dc/terms/spatial> "NC"^^<http://purl.org/dc/terms/ISO3166> , "New Caledonia, Ohnyat (Ouvéa)" ;
       
    55  * 	<http://crdo.risc.cnrs.fr/schemas/master> <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
    56  * 	<http://purl.org/dc/terms/available> "2010-10-23"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    57  * 	<http://purl.org/dc/terms/issued> "2010-10-23T00:08:27+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    58  * 	<http://www.language-archives.org/OLAC/1.1/speaker> "Idakote, Félicien" ;
       
    59  * 	<http://www.w3.org/2003/01/geo/wgs84_pos#long> "166.6526"^^xsd:float ;
       
    60  * 	<http://www.w3.org/2003/01/geo/wgs84_pos#lat> "-20.4765"^^xsd:float ;
       
    61  * 	<http://purl.org/dc/terms/isRequiredBy> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA> ;
       
    62  * 	<http://www.language-archives.org/OLAC/1.1/researcher> "Moyse-Faurie, Claire" .
       
    63  *
       
    64  *  http://purl.org/dc/elements/1.1/description
       
    65  *  http://purl.org/dc/elements/1.1/format
       
    66  *  http://purl.org/dc/elements/1.1/language
       
    67  *  http://purl.org/dc/elements/1.1/publisher
       
    68  *  http://purl.org/dc/elements/1.1/rights
       
    69  *  http://purl.org/dc/elements/1.1/subject
       
    70  *  http://purl.org/dc/elements/1.1/title
       
    71  *  http://purl.org/dc/elements/1.1/type
       
    72  *  http://purl.org/dc/terms/accessRights
       
    73  *  http://purl.org/dc/terms/available
       
    74  *  http://purl.org/dc/terms/conformsTo
       
    75  *  http://purl.org/dc/terms/created
       
    76  *  http://purl.org/dc/terms/isFormatOf
       
    77  *  http://purl.org/dc/terms/isPartOf
       
    78  *  http://purl.org/dc/terms/issued
       
    79  *  http://purl.org/dc/terms/license
       
    80  *  http://purl.org/dc/terms/requires
       
    81  *  http://www.language-archives.org/OLAC/1.1/data_inputter
       
    82  *  http://www.language-archives.org/OLAC/1.1/depositor
       
    83  *  http://www.language-archives.org/OLAC/1.1/editor
       
    84  *  http://www.language-archives.org/OLAC/1.1/interviewer
       
    85  *  http://www.language-archives.org/OLAC/1.1/researcher
       
    86  *  http://www.language-archives.org/OLAC/1.1/speaker
       
    87  *  http://www.language-archives.org/OLAC/1.1/transcriber
       
    88  *  http://www.language-archives.org/OLAC/1.1/author
       
    89  *  http://www.language-archives.org/OLAC/1.1/recorder
       
    90  *  http://www.language-archives.org/OLAC/1.1/translator
       
    91  *  http://www.language-archives.org/OLAC/1.1/responder
       
    92  *  http://www.language-archives.org/OLAC/1.1/sponsor
       
    93  *  http://www.language-archives.org/OLAC/1.1/annotator
       
    94  *  http://www.language-archives.org/OLAC/1.1/participant
       
    95  *  http://www.language-archives.org/OLAC/1.1/compiler
       
    96  *  http://www.language-archives.org/OLAC/1.1/developer
       
    97  *  http://www.language-archives.org/OLAC/1.1/consultant
       
    98  *  http://www.language-archives.org/OLAC/1.1/research_participant
       
    99  *  http://purl.org/dc/terms/spatial
       
   100  *  http://purl.org/dc/terms/tableOfContents
       
   101  *  http://www.w3.org/2003/01/geo/wgs84_pos#lat
       
   102  *  http://www.w3.org/2003/01/geo/wgs84_pos#long
       
   103  *  http://purl.org/dc/terms/alternative
       
   104  *  http://purl.org/dc/terms/modified
       
   105  *  http://purl.org/dc/elements/1.1/identifier
       
   106  *  http://purl.org/dc/terms/extent
       
   107  *  http://purl.org/dc/terms/medium
       
   108  *  http://purl.org/dc/elements/1.1/source
       
   109  *  http://purl.org/dc/elements/1.1/coverage
       
   110  *  http://crdo.risc.cnrs.fr/schemas/master
       
   111  *  http://purl.org/dc/elements/1.1/creator
       
   112  *  http://purl.org/dc/elements/1.1/reference
       
   113  *  http://purl.org/dc/terms/references
       
   114  *  http://purl.org/dc/terms/abstract
       
   115  *  http://purl.org/dc/elements/1.1/relation
       
   116  */
       
   117 class CocoonTextRdfMapper extends CocoonContentRdfMapper {
       
   118 
       
   119 
       
   120     protected function getResourceBaseId($res=null) {
       
   121 
       
   122         if(is_null($res)) {
       
   123             $res = $this->inputGraph->resource($this->uri);
       
   124         }
       
   125         $soundRes = $res->get('dc:requires');
       
   126 
       
   127         if(! $soundRes instanceof Resource) {
       
   128             throw new \Exception("Input graph for text not correct, can not find sound resource", 1);
       
   129         }
       
   130 
       
   131         return $soundRes->getUri();
       
   132     }
       
   133 
       
   134     protected function addCHOResourceDateProperties($providedCHOResource, $res, $outputGraph) {
       
   135         // We do not add date to the providedCHO for Text resource
       
   136     }
       
   137 
       
   138     protected function propertyTypeMap($providedCHOResource, $prop, $value) {
       
   139         if((!$value instanceof Resource) || $value->getUri() !== "http://purl.org/dc/dcmitype/Text") {
       
   140             $providedCHOResource->add($prop, $value);
       
   141         }
       
   142     }
       
   143 
       
   144     protected function mapWebResources($res, $outputGraph) {
       
   145         $resId = CocoonUtils::getIdFromUri($this->getResourceBaseId($res));
       
   146         $resUri = CocoonUtils::getCorpusUriFromId($resId);
       
   147 
       
   148 
       
   149         $aggregationNode = $outputGraph->resource($resUri, 'ore:Aggregation');
       
   150 
       
   151         // build others
       
   152         foreach($res->all($this->inputGraph->resource('http://purl.org/dc/terms/isFormatOf')) as $reprUrl) {
       
   153             $webResource = $outputGraph->resource($reprUrl, 'edm:WebResources');
       
   154             $mimetype = Utils::getMimetype($reprUrl);
       
   155 
       
   156             $webResource->addLiteral('http://purl.org/dc/elements/1.1/format', Literal::create($mimetype, null, $outputGraph->resource('http://purl.org/dc/terms/IMT')));
       
   157 
       
   158             $this->addDateToWebResource($res, $webResource);
       
   159             $aggregationNode->addResource('edm:hasView', $reprUrl);
       
   160 
       
   161         }
       
   162 
       
   163     }
       
   164 
       
   165 }