Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public void Add(ResourceStatement statement)
 {
     AddStatement(statement.GetSubject().GetHashCode(), statement.GetPredicate().GetHashCode(), statement.GetObject().GetHashCode());
 }