/** * Clear the old associated graphs with the given EML sequence based on the graph name. */ private function deleteOldGraphs() { $graph_name = $this->graph->graph_name; $this->log("Before attaching the new graph, detaching and removing the old one, and possible zombie graphs"); // List of graph names we have to delete in the triple store $graphs = $this->fetchGraphs($graph_name); if ($graphs) { foreach ($graphs as $graph_name) { if ($graph_name != $this->graph->graph_id) { $query = "CLEAR GRAPH <{$graph_name}>"; $result = $this->performQuery($query); // If all went ok, delete the graph entry if ($result !== false) { $this->log("The old version of the graph with id {$graph_name} has been deleted in the triple store."); } else { $this->log("The old version of the graph with id {$graph_name} was not deleted in the triple store.", "error"); } } } } // Delete the graph objects in our back-end $query_graph_name = "'" . str_replace('/', '\\/', $this->graph->graph_name) . "'"; $graphs = \Graph::whereRaw("graph_name like {$query_graph_name}")->get(); foreach ($graphs as $graph) { if ($graph->graph_id != $this->graph->graph_id) { $graph->delete(); $this->log("The old version of the graph with id {$graph->graph_id} has been deleted in the back-end."); } } $this->log("--------------------------------------------------------------------------------------------------"); $this->log("The new graph is identified by " . $this->graph->graph_id); }