function delete($doc, $g = 'http://localhost/') { $index = $this->v($g, array(), $this->data); $this->data[$g] = ARC2::getCleanedIndex($index, $this->toIndex($doc)); }
function getUpdatedIndex($old_index, $q) { if (!preg_match('/^\\s*(INSERT|DELETE)\\s*(INTO|FROM)?\\s*(.*)$/is', $q, $m)) { return 0; } $qt = strtolower($m[1]); $g = $this->getTargetGraph(); /* inject a target graph, if necessary */ if (!$m[2]) { $q = strtoupper($qt) . ($qt == 'insert' ? ' INTO ' : ' FROM') . ' <' . $g . '> ' . $m[3]; } /* parse the query */ $this->writeLog($q); ARC2::inc('SPARQLPlusParser'); $p =& new ARC2_SPARQLPlusParser($this->a, $this); $p->parse($q); $infos = $p->getQueryInfos(); /* errors? */ if ($errors = $this->getErrors()) { $this->setHeader('http', 'HTTP/1.1 400 Bad Request'); $this->setHeader('content-type', 'Content-type: text/plain; charset=utf-8'); $this->result = join("\n", $errors); return 0; } $q_index = ARC2::getSimpleIndex($infos['query']['construct_triples'], 0); if ($qt == 'insert') { return ARC2::getMergedIndex($old_index, $q_index); } elseif ($qt == 'delete') { return ARC2::getCleanedIndex($old_index, $q_index); } }