/// <summary>
 /// Clears the triples and metadata of the graph
 /// </summary>
 public void ClearTriples()
 {
     //Clear triples
     this.Triples.Clear();
     //Clear index
     this.GraphIndex.ClearIndex();
     //Raise event
     RDFModelEvents.RaiseOnGraphCleared(String.Format("Graph '{0}' has been cleared.", this));
 }
 /// <summary>
 /// Removes the given triple from the graph
 /// </summary>
 public RDFGraph RemoveTriple(RDFTriple triple)
 {
     if (this.ContainsTriple(triple))
     {
         //Remove triple
         this.Triples.Remove(triple.TripleID);
         //Remove index
         this.GraphIndex.RemoveIndex(triple);
         //Raise event
         RDFModelEvents.RaiseOnTripleRemoved(String.Format("Triple '{0}' has been removed from the Graph '{1}'.", triple, this));
     }
     return(this);
 }
 /// <summary>
 /// Removes the triples with the given literal as object
 /// </summary>
 public RDFGraph RemoveTriplesByLiteral(RDFLiteral objectLiteral)
 {
     if (objectLiteral != null)
     {
         foreach (var triple in this.SelectTriplesByLiteral(objectLiteral))
         {
             //Remove triple
             this.Triples.Remove(triple.TripleID);
             //Remove index
             this.GraphIndex.RemoveIndex(triple);
             //Raise event
             RDFModelEvents.RaiseOnTripleRemoved(String.Format("Triple '{0}' has been removed from the Graph '{1}'.", triple, this));
         }
     }
     return(this);
 }
 /// <summary>
 /// Removes the triples with the given (non-blank) predicate
 /// </summary>
 public RDFGraph RemoveTriplesByPredicate(RDFResource predicateResource)
 {
     if (predicateResource != null && !predicateResource.IsBlank)
     {
         foreach (var triple in this.SelectTriplesByPredicate(predicateResource))
         {
             //Remove triple
             this.Triples.Remove(triple.TripleID);
             //Remove index
             this.GraphIndex.RemoveIndex(triple);
             //Raise event
             RDFModelEvents.RaiseOnTripleRemoved(String.Format("Triple '{0}' has been removed from the Graph '{1}'.", triple, this));
         }
     }
     return(this);
 }
 /// <summary>
 /// Adds the given triple to the graph, avoiding duplicate insertions
 /// </summary>
 public RDFGraph AddTriple(RDFTriple triple)
 {
     if (triple != null)
     {
         if (!this.Triples.ContainsKey(triple.TripleID))
         {
             //Add triple
             this.Triples.Add(triple.TripleID, triple);
             //Add index
             this.GraphIndex.AddIndex(triple);
             //Raise event
             RDFModelEvents.RaiseOnTripleAdded(String.Format("Triple '{0}' has been added to the Graph '{1}'.", triple, this));
         }
     }
     return(this);
 }
Exemple #6
0
 /// <summary>
 /// Removes the triples with the given subject
 /// </summary>
 public RDFGraph RemoveTriplesBySubject(RDFResource subjectResource)
 {
     if (subjectResource != null)
     {
         foreach (RDFTriple triple in this.SelectTriplesBySubject(subjectResource))
         {
             //Remove triple
             this.Triples.Remove(triple.TripleID);
             //Remove index
             this.GraphIndex.RemoveIndex(triple);
             //Raise event
             RDFModelEvents.RaiseOnTripleRemoved(String.Format("Triple '{0}' has been removed from the Graph '{1}'.", triple, this));
         }
     }
     return(this);
 }