--- a/server/src/app/Libraries/Mergers/CocoonAbstractRdfMerger.php Tue Nov 17 13:11:55 2015 +0100
+++ b/server/src/app/Libraries/Mergers/CocoonAbstractRdfMerger.php Fri Nov 27 17:59:36 2015 +0100
@@ -26,10 +26,11 @@
*
* @return EasyRdf\Graph The new merged graph
*/
- function mergeGraph($baseGraph, $srcGraph) {
+ function mergeGraph($baseGraph, $srcGraph, $uri = null) {
+ $uri = is_null($uri)?$baseGraph->getUri():$uri;
$this->mergedArray = [];
- $this->resGraph = new Graph($baseGraph->getUri());
+ $this->resGraph = new Graph($uri);
$this->bnodeMerge = [];
$this->baseGraph = $baseGraph;
$this->srcGraph = $srcGraph;
@@ -78,11 +79,13 @@
$baseResource = $baseGraph->resource($baseUrl);
$srcResource = $srcGraph->resource($srcUrl);
- $mergeMethod = $typeMergeMethodMap[$baseResource->typeAsResource()->getUri()];
- $this->mergedArray[$bnodeId] = [];
+ if(!is_null($baseResource->typeAsResource()) && array_key_exists($baseResource->typeAsResource()->getUri(), $typeMergeMethodMap)) {
- call_user_func(array($this, $mergeMethod), $baseResource, $srcResource, $bnodeId);
+ $mergeMethod = $typeMergeMethodMap[$baseResource->typeAsResource()->getUri()];
+ $this->mergedArray[$bnodeId] = [];
+ call_user_func(array($this, $mergeMethod), $baseResource, $srcResource, $bnodeId);
+ }
}
}
@@ -183,8 +186,10 @@
protected function mergeProperties($singleBNodeProperties, $singleProperties, &$targetArray, $baseRes, $srcRes) {
- $srcArray = $this->srcGraph->toRdfPhp()[$srcRes->getUri()];
- $baseArray = $this->baseGraph->toRdfPhp()[$baseRes->getUri()];
+ $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()]:[];
foreach($srcRes->propertyUris() as $prop) {
if(in_array($prop, $singleBNodeProperties)) {
$this->mergePropertySingleBNode($prop, $targetArray, $baseArray, $srcArray);