server/src/app/Libraries/Mergers/CocoonSoundRdfMerger.php
changeset 504 4ab820b387da
parent 170 31bee084df32
child 526 cdaf9dfb5dfd
equal deleted inserted replaced
503:bd2701bd8142 504:4ab820b387da
   157             "http://purl.org/dc/terms/available",
   157             "http://purl.org/dc/terms/available",
   158             "http://purl.org/dc/terms/created",
   158             "http://purl.org/dc/terms/created",
   159             "http://purl.org/dc/terms/issued",
   159             "http://purl.org/dc/terms/issued",
   160         ], $targetArray, $baseRes, $srcRes);
   160         ], $targetArray, $baseRes, $srcRes);
   161 
   161 
   162         // Must handle modified
   162         // Must handle modified and created
   163         $isBaseText = false;
   163         $isBaseText = false;
   164         foreach ($baseRes->all("dc11:type","resource") as $resType) {
   164         foreach ($baseRes->all("dc11:type","resource") as $resType) {
   165             $type = $resType->getUri();
   165             $type = $resType->getUri();
   166             if($type === 'http://purl.org/dc/dcmitype/Text') {
   166             if($type === 'http://purl.org/dc/dcmitype/Text') {
   167                 $isBaseText = true;
   167                 $isBaseText = true;
   169             }
   169             }
   170         }
   170         }
   171         if($isBaseText) {
   171         if($isBaseText) {
   172             // The base is Text. In this case for http://purl.org/dc/terms/mofified,
   172             // The base is Text. In this case for http://purl.org/dc/terms/mofified,
   173             // the sound takes over. So we switch baseRes with srcRes in the arguments
   173             // the sound takes over. So we switch baseRes with srcRes in the arguments
       
   174             //print_r($targetArray);
       
   175             //print_r($srcRes->get("<http://purl.org/dc/terms/created>"));
   174             $this->mergeProperties([], ["http://purl.org/dc/terms/mofified"], $targetArray, $srcRes, $baseRes);
   176             $this->mergeProperties([], ["http://purl.org/dc/terms/mofified"], $targetArray, $srcRes, $baseRes);
       
   177             // created must be handled separately
       
   178             $srcCreated = $srcRes->get("<http://purl.org/dc/terms/created>");
       
   179             $baseCreated = $baseRes->get("<http://purl.org/dc/terms/created>");
       
   180 
       
   181             if(is_null($srcCreated) && !is_null($baseCreated)) {
       
   182                 // There is no created in sound. Remove created info from targetArray
       
   183                 unset($targetArray['http://purl.org/dc/terms/created']);
       
   184             } elseif (!is_null($srcCreated) && !is_null($baseCreated)) {
       
   185                 // Force Sound value into target array
       
   186                 $targetArray['http://purl.org/dc/terms/created'] = [
       
   187                     $srcCreated->toRdfPhp()
       
   188                 ];
       
   189             }
   175         }
   190         }
   176 
   191 
   177     }
   192     }
   178 
   193 
   179     protected function mergeEdmWebResources($baseRes, $srcRes, $uri=null) {
   194     protected function mergeEdmWebResources($baseRes, $srcRes, $uri=null) {