/// <summary> /// Saves a Graph to the Store. /// </summary> /// <param name="g">Graph.</param> public override void SaveGraph(IGraph g) { if (_dataset.HasGraph(g.BaseUri)) { _dataset.RemoveGraph(g.BaseUri); } _dataset.AddGraph(g); _dataset.Flush(); }
/// <summary> /// Adds a Graph to the Collection. /// </summary> /// <param name="g">Graph to add.</param> /// <param name="mergeIfExists">Whether to merge the given Graph with any existing Graph with the same URI.</param> /// <exception cref="RdfException">Thrown if a Graph with the given URI already exists and the <paramref name="mergeIfExists">mergeIfExists</paramref> is set to false.</exception> protected internal override bool Add(IGraph g, bool mergeIfExists) { if (Contains(g.BaseUri)) { if (mergeIfExists) { IGraph temp = _dataset.GetModifiableGraph(g.BaseUri); temp.Merge(g); temp.Dispose(); _dataset.Flush(); return(true); } else { throw new RdfException("Cannot add this Graph as a Graph with the URI '" + g.BaseUri.ToSafeString() + "' already exists in the Collection and mergeIfExists was set to false"); } } else { // Safe to add a new Graph if (_dataset.AddGraph(g)) { _dataset.Flush(); RaiseGraphAdded(g); return(true); } return(false); } }
/// <summary> /// Creates a new Leviathan Update Processor. /// </summary> /// <param name="data">SPARQL Dataset.</param> public LeviathanUpdateProcessor(ISparqlDataset data) { _dataset = data; if (!_dataset.HasGraph(null)) { // Create the Default unnamed Graph if it doesn't exist and then Flush() the change _dataset.AddGraph(new Graph()); _dataset.Flush(); } }
/// <summary> /// Adds a Graph to the dataset. /// </summary> /// <param name="g">Graph.</param> public virtual bool AddGraph(IGraph g) { return(_dataset.AddGraph(g)); }