Exemple #1
0
        public override IEnumerable <Triple> WithPredicate(INode pred)
        {
            dotSesame.URI u = SesameConverter.ToSesameUri(pred, this._mapping);
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(this._g.match(null, u, null, null));

            return(stmtIter.Select(s => SesameConverter.FromSesame(s, this._mapping)));
        }
Exemple #2
0
        public bool hasStatement(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, bool b, params org.openrdf.model.Resource[] rarr)
        {
            SparqlParameterizedString queryString = new SparqlParameterizedString();

            queryString.CommandText = "ASK";
            foreach (Uri u in rarr.ToContexts(this._mapping))
            {
                queryString.CommandText += "\nFROM <" + this._formatter.FormatUri(u) + ">";
            }
            queryString.CommandText += "\nWHERE { ?subject ?predicate ?object}";
            if (r != null)
            {
                queryString.SetVariable("subject", SesameConverter.FromSesameResource(r, this._mapping));
            }
            if (uri != null)
            {
                queryString.SetVariable("predicate", SesameConverter.FromSesameUri(uri, this._mapping));
            }
            if (v != null)
            {
                queryString.SetVariable("object", SesameConverter.FromSesameValue(v, this._mapping));
            }

            return(this.HasTriplesInternal(queryString.ToString()));
        }
Exemple #3
0
        public virtual void add(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, params org.openrdf.model.Resource[] rarr)
        {
            IEnumerable <Uri> contexts = rarr.ToContexts(this._mapping);
            Graph             g        = new Graph();

            g.Assert(SesameConverter.FromSesameResource(r, this._mapping), SesameConverter.FromSesameUri(uri, this._mapping), SesameConverter.FromSesameValue(v, this._mapping));
            this.AddInternal(g, contexts);
        }
Exemple #4
0
        public override void remove(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, params org.openrdf.model.Resource[] rarr)
        {
            if (this._manager.IsReadOnly)
            {
                throw NotWritableError("remove");
            }

            base.remove(r, uri, v, rarr);
        }
Exemple #5
0
 public void exportStatements(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, bool b, org.openrdf.rio.RDFHandler rdfh, params org.openrdf.model.Resource[] rarr)
 {
     dotSesameRepo.RepositoryResult results = this.getStatements(r, uri, v, b, rarr);
     rdfh.startRDF();
     while (results.hasNext())
     {
         rdfh.handleStatement((dotSesame.Statement)results.next());
     }
     rdfh.endRDF();
 }
Exemple #6
0
        public bool add(dotSesame.Resource r, dotSesame.URI uri, dotSesame.Value v, params dotSesame.Resource[] rarr)
        {
            Triple t = new Triple(SesameConverter.FromSesameResource(r, this._mapping), SesameConverter.FromSesameUri(uri, this._mapping), SesameConverter.FromSesameValue(v, this._mapping));

            if (this._g.ContainsTriple(t))
            {
                return(false);
            }
            else
            {
                this._g.Assert(t);
                return(true);
            }
        }
Exemple #7
0
 /// <summary>
 /// Converts a Sesame URI to a URI
 /// </summary>
 /// <param name="uri">URI</param>
 /// <returns></returns>
 internal static Uri FromSesameUri(dotSesame.URI uri)
 {
     return(new Uri(uri.stringValue()));
 }
Exemple #8
0
 /// <summary>
 /// Converts a Sesame URI to a dotNetRDF Node
 /// </summary>
 /// <param name="uri">URI</param>
 /// <param name="mapping">Blank Node Mapping</param>
 /// <returns></returns>
 internal static INode FromSesameUri(dotSesame.URI uri, SesameMapping mapping)
 {
     return(mapping.Graph.CreateUriNode(new Uri(uri.stringValue())));
 }
Exemple #9
0
 public dotSesame.Statement createStatement(dotSesame.Resource r, dotSesame.URI uri, dotSesame.Value v)
 {
     return(this._mapping.ValueFactory.createStatement(r, uri, v));
 }
Exemple #10
0
 public dotSesame.Literal createLiteral(string str, dotSesame.URI uri)
 {
     return(this._mapping.ValueFactory.createLiteral(str, uri));
 }
Exemple #11
0
        public java.util.Iterator match(dotSesame.Resource r, dotSesame.URI uri, dotSesame.Value v, params dotSesame.Resource[] rarr)
        {
            INode s = (r != null) ? SesameConverter.FromSesameResource(r, this._mapping) : null;
            INode p = (uri != null) ? SesameConverter.FromSesameUri(uri, this._mapping) : null;
            INode o = (v != null) ? SesameConverter.FromSesameValue(v, this._mapping) : null;
            //Contexts are Ignored for matches on a single Graph

            IEnumerable <Triple> ts;

            if (s != null)
            {
                if (p != null)
                {
                    if (o != null)
                    {
                        //Matching on Subject Predicate and Object
                        Triple t = new Triple(s, p, o);
                        if (this._g.ContainsTriple(t))
                        {
                            ts = t.AsEnumerable();
                        }
                        else
                        {
                            ts = Enumerable.Empty <Triple>();
                        }
                    }
                    else
                    {
                        //Just matching on Subject Predicate
                        ts = this._g.GetTriplesWithSubjectPredicate(s, p);
                    }
                }
                else
                {
                    if (o != null)
                    {
                        //Matching on Subject Object
                        ts = this._g.GetTriplesWithSubjectObject(s, o);
                    }
                    else
                    {
                        //Just Matching on Subject
                        ts = this._g.GetTriplesWithSubject(s);
                    }
                }
            }
            else if (p != null)
            {
                if (o != null)
                {
                    //Matching on Predicate Object
                    ts = this._g.GetTriplesWithPredicateObject(p, o);
                }
                else
                {
                    //Just Matching on Predicate
                    ts = this._g.GetTriplesWithPredicate(p);
                }
            }
            else if (o != null)
            {
                //Matching on Object only
                ts = this._g.GetTriplesWithObject(o);
            }
            else
            {
                //Matching anything
                ts = this._g.Triples;
            }

            return(new DotNetEnumerableWrapper(ts.Select(t => SesameConverter.ToSesame(t, this._mapping))));
        }
Exemple #12
0
 public virtual void remove(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, params org.openrdf.model.Resource[] rarr)
 {
     throw new NotImplementedException();
 }
Exemple #13
0
        public org.openrdf.repository.RepositoryResult getStatements(org.openrdf.model.Resource r, org.openrdf.model.URI uri, org.openrdf.model.Value v, bool b, params org.openrdf.model.Resource[] rarr)
        {
            SparqlParameterizedString queryString = new SparqlParameterizedString();
            IEnumerable <Uri>         contexts    = rarr.ToContexts(this._mapping);

            if (contexts.Any())
            {
                queryString.CommandText = "SELECT (?s AS ?subj) (?p AS ?pred) (?o AS ?obj)\n";
                foreach (Uri u in contexts)
                {
                    queryString.CommandText += "FROM <" + this._formatter.FormatUri(u) + ">\n";
                }
                queryString.CommandText += "WHERE { ?s ?p ?o }";
            }
            else
            {
                queryString.CommandText = "SELECT (?s AS ?subj) (?p AS ?pred) (?o AS ?obj) WHERE { ?s ?p ?o }";
            }
            if (r != null)
            {
                queryString.SetVariable("s", SesameConverter.FromSesameResource(r, this._mapping));
            }
            if (uri != null)
            {
                queryString.SetVariable("p", SesameConverter.FromSesameUri(uri, this._mapping));
            }
            if (v != null)
            {
                queryString.SetVariable("o", SesameConverter.FromSesameValue(v, this._mapping));
            }

            return(this.GetStatementsInternal(queryString.ToString(), this._mapping));
        }