function apply_changes($storeName, $resourceUri, $before, $after) { $args = array('subjectOfChange' => $resourceUri, 'before' => $before->get_index(), 'after' => $after->get_index(), 'creatorName' => 'RDF Editor', 'changeReason' => 'user edit'); $cs = new ChangeSet($args); if ($cs->has_changes()) { $store = getStore($storeName); $cs_response = $store->get_metabox()->apply_changeset_rdfxml($cs->to_rdfxml()); if (!$cs_response->is_success()) { echo 'Failed to apply changeset : <br/><pre>' . $cs_response->to_string() . '</pre>'; return false; } } else { echo 'No changes to apply'; return false; } return true; }
function test_to_rdfxml_with_blank_subject() { $cs = new ChangeSet(array('subjectOfChange' => "_:a", 'after_rdfxml' => $this->_single_blank_subject)); $index = $cs->get_index(); $changesetResource = $this->_find_changeset_resource($index); $objects = $index[$changesetResource]["http://purl.org/vocab/changeset/schema#subjectOfChange"]; $this->assertEquals("bnode", $objects[0]["type"]); $this->assertEquals("_:a", $objects[0]['value']); $this->_parser->parse("", $cs->to_rdfxml()); $triples = $this->_parser->getTriples(); $subjectId = null; for ($i = 0, $i_max = count($triples); $i < $i_max; $i++) { if ($triples[$i]['p'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#subject') { $subjectId = $triples[$i]['o']; } } $this->assertEquals('_:a', $subjectId); }