/// <summary> /// Processes a DROP command /// </summary> /// <param name="cmd">Drop Command</param> public void ProcessDropCommand(DropCommand cmd) { if (this._manager is IUpdateableGenericIOManager) { ((IUpdateableGenericIOManager)this._manager).Update(cmd.ToString()); } else { try { Graph g; switch (cmd.Mode) { case ClearMode.Graph: case ClearMode.Default: if (this._manager.DeleteSupported) { //If available use DeleteGraph() this._manager.DeleteGraph(cmd.TargetUri); } else if ((cmd.TargetUri == null && (this._manager.IOBehaviour & IOBehaviour.OverwriteDefault) != 0) || (cmd.TargetUri != null && (this._manager.IOBehaviour & IOBehaviour.OverwriteNamed) != 0)) { //Can approximate by saving an empty Graph over the existing Graph g = new Graph(); g.BaseUri = cmd.TargetUri; this._manager.SaveGraph(g); } else if (this._manager.UpdateSupported && (this._manager.IOBehaviour & IOBehaviour.CanUpdateDeleteTriples) != 0) { //Can approximate by loading the Graph and then deleting all Triples from it g = new NonIndexedGraph(); this._manager.LoadGraph(g, cmd.TargetUri); this._manager.UpdateGraph(cmd.TargetUri, null, g.Triples); } else { throw new SparqlUpdateException("Unable to evaluate a DROP command as the underlying store does not provide appropriate IO Behaviour to approximate this command"); } break; case ClearMode.All: case ClearMode.Named: if (this._manager.ListGraphsSupported) { List<Uri> graphs = this._manager.ListGraphs().ToList(); foreach (Uri u in graphs) { if (this._manager.DeleteSupported) { //If available use DeleteGraph() this._manager.DeleteGraph(u); } else if ((u == null && (this._manager.IOBehaviour & IOBehaviour.OverwriteDefault) != 0) || (u != null && (this._manager.IOBehaviour & IOBehaviour.OverwriteNamed) != 0)) { //Can approximate by saving an empty Graph over the existing Graph g = new Graph(); g.BaseUri = u; this._manager.SaveGraph(g); } else if (this._manager.UpdateSupported && (this._manager.IOBehaviour & IOBehaviour.CanUpdateDeleteTriples) != 0) { //Can approximate by loading the Graph and then deleting all Triples from it g = new NonIndexedGraph(); this._manager.LoadGraph(g, u); this._manager.UpdateGraph(u, null, g.Triples); } else { throw new SparqlUpdateException("Unable to evaluate a DROP command as the underlying store does not provide appropriate IO Behaviour to approximate this command"); } } } else { throw new NotSupportedException("The Generic Update processor does not support this form of the DROP command"); } break; } } catch { if (!cmd.Silent) throw; } } }
/// <summary> /// Processes a DROP command /// </summary> /// <param name="cmd">Drop Command</param> public void ProcessDropCommand(DropCommand cmd) { if (this._manager is IUpdateableGenericIOManager) { ((IUpdateableGenericIOManager)this._manager).Update(cmd.ToString()); } else { try { Graph g; switch (cmd.Mode) { case ClearMode.Graph: case ClearMode.Default: g = new Graph(); g.BaseUri = cmd.TargetUri; this._manager.SaveGraph(g); break; case ClearMode.All: case ClearMode.Named: if (this._manager.ListGraphsSupported) { List<Uri> graphs = this._manager.ListGraphs().ToList(); foreach (Uri u in graphs) { g = new Graph(); g.BaseUri = u; this._manager.SaveGraph(g); } } else { throw new NotSupportedException("The Generic Update processor does not support this form of the DROP command"); } break; } } catch { if (!cmd.Silent) throw; } } }