$cobj = json_decode($cjson); if ($cobj == null) { echo 'fail context'; echo $cjson; die; } $cURIs = array(); $newContextsGraph = ARC2::getComponent('PMJ_ResourceGraphPlugin', $config); foreach ($cobj as $key => $newContextObj) { $newContext = new Context($newContextObj); $newContext->buildPrivateGraph(); $newCURI = $newContext->uri; $newContextsGraph->mergeResourceGraph($newContext->graph); if (in_array($key, $robj->rubricMeta[4]->rContexts)) { $cURIs[] = urldecode($newCURI); } } foreach ($robj->rubricMeta[4]->rContexts as $val) { if (substr($val, 0, 3) != 'new') { $cURIs[] = urldecode($val); } } $robj->rubricMeta[4]->rContexts = $cURIs; //build contexts if needed, and get an array of the context URIs to pass to Rubric $newRubric = new Rubric($robj, $cURIs); $newRubric->buildGraph(); //echo $newRubric->graph->toNTriples(); $q = 'INSERT INTO <> { ' . $newRubric->graph->toNTriples() . ' } '; $rs = $store->query($q); $q = 'INSERT INTO <> { ' . $newContextsGraph->toNTriples() . ' } '; $rs = $store->query($q);