public void Remove(ResourceStatement resourceStatement) { MySqlCommand cmd = new MySqlCommand("DELETE FROM Statements WHERE " + "subjectHash = " + resourceStatement.GetSubject().GetHashCode() + " AND " + "predicateHash = " + resourceStatement.GetPredicate().GetHashCode() + " AND " + "objectHash = " + resourceStatement.GetObject().GetHashCode() + " AND " + "graphId = " + itsHashCode, itsConn); cmd.ExecuteNonQuery(); }
public void Add(ResourceStatement resourceStatement) { if (!itsResourceStatements.ContainsKey(resourceStatement)) { if (!HasNodeDenoting(resourceStatement.GetSubject())) { AddDenotation(MakeNameForResource(resourceStatement.GetSubject()), resourceStatement.GetSubject()); } if (!HasNodeDenoting(resourceStatement.GetPredicate())) { AddDenotation(MakeNameForResource(resourceStatement.GetPredicate()), resourceStatement.GetPredicate()); } if (!HasNodeDenoting(resourceStatement.GetObject())) { AddDenotation(MakeNameForResource(resourceStatement.GetObject()), resourceStatement.GetObject()); } itsResourceStatements[resourceStatement] = resourceStatement; } }
public void Merge(ResourceStatementCollection statements, ResourceMap map) { IEnumerator statementEnumerator = statements.GetStatementEnumerator(); while (statementEnumerator.MoveNext()) { ResourceStatement resStatement = (ResourceStatement)statementEnumerator.Current; Node theSubject = (Node)map.GetBestDenotingNode(resStatement.GetSubject()); Arc thePredicate = (Arc)map.GetBestDenotingNode(resStatement.GetPredicate()); Node theObject = (Node)map.GetBestDenotingNode(resStatement.GetObject()); Statement statement = new Statement(theSubject, thePredicate, theObject); Add(statement); } }
public void Write(RdfWriter writer) { writer.StartOutput(); IEnumerator statementEnum = GetStatementEnumerator(); while (statementEnum.MoveNext()) { ResourceStatement statement = (ResourceStatement)statementEnum.Current; writer.StartSubject(); GetBestDenotingNode(statement.GetSubject()).Write(writer); writer.StartPredicate(); GetBestDenotingNode(statement.GetPredicate()).Write(writer); writer.StartObject(); GetBestDenotingNode(statement.GetObject()).Write(writer); writer.EndObject(); writer.EndPredicate(); writer.EndSubject(); } writer.EndOutput(); }
public virtual void Replace(ConciseBoundedDescription description) { Resource internalSubjectResource = GetResourceDescribedBy(description); ArrayList statementsToRemove = new ArrayList(); IEnumerator statementEnumerator = itsAssertions.GetStatementEnumerator(); while (statementEnumerator.MoveNext()) { ResourceStatement statement = (ResourceStatement)statementEnumerator.Current; if (statement.GetSubject().Equals(internalSubjectResource)) { statementsToRemove.Add(statement); } } foreach (ResourceStatement statement in statementsToRemove) { itsAssertions.Remove(statement); } Add(description); }
public void Merge(ResourceStatementCollection statements, ResourceMap map) { if (this == statements) { return; } Hashtable equivalentResources = new Hashtable(); foreach (Resource resource in statements.ReferencedResources) { Resource internalResource = resource; foreach (GraphMember member in map.GetNodesDenoting(resource)) { if (HasResourceDenotedBy(member)) { internalResource = GetResourceDenotedBy(member); equivalentResources[resource] = internalResource; break; } // Must be a new resource // Remember this for when we're Adding statements // TODO: move this outside the loop equivalentResources[resource] = resource; } foreach (GraphMember member in map.GetNodesDenoting(resource)) { AddDenotation(member, internalResource); } } IEnumerator statementEnumerator = statements.GetStatementEnumerator(); while (statementEnumerator.MoveNext()) { ResourceStatement statement = (ResourceStatement)statementEnumerator.Current; ResourceStatement internalStatement = new ResourceStatement((Resource)equivalentResources[statement.GetSubject()], (Resource)equivalentResources[statement.GetPredicate()], (Resource)equivalentResources[statement.GetObject()]); Add(internalStatement); } }
public bool Contains(ResourceStatement statement) { MySqlCommand cmd = new MySqlCommand("SELECT EXISTS (SELECT * FROM Statements s " + "WHERE s.graphId = " + itsHashCode + " AND s.subjectHash = " + statement.GetSubject().GetHashCode() + " AND s.predicateHash = " + statement.GetPredicate().GetHashCode() + " AND s.objectHash = " + statement.GetObject().GetHashCode() + ")", itsConn); return(Convert.ToInt32(cmd.ExecuteScalar()) > 0); }
public void Add(ResourceStatement statement) { AddStatement(statement.GetSubject().GetHashCode(), statement.GetPredicate().GetHashCode(), statement.GetObject().GetHashCode()); }