Exemple #1
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 #2
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));
        }
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 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 #5
0
 internal static IEnumerable <Uri> ToContexts(this dotSesame.Resource[] contexts, SesameMapping mapping)
 {
     if (contexts == null)
     {
         return(Enumerable.Empty <Uri>());
     }
     else if (contexts.Length == 0)
     {
         return(Enumerable.Empty <Uri>());
     }
     else
     {
         List <Uri> results = new List <Uri>();
         foreach (dotSesame.Resource r in contexts)
         {
             if (r != null && r is dotSesame.URI)
             {
                 results.Add(((IUriNode)SesameConverter.FromSesameResource(r, mapping)).Uri);
             }
         }
         return(results);
     }
 }
Exemple #6
0
        public void parse(org.openrdf.model.Graph g, org.openrdf.model.Resource r)
        {
            Graph         config  = new Graph();
            SesameMapping mapping = new SesameMapping(config, g);

            SesameConverter.FromSesame(g, config);

            this._name = r.stringValue().Substring(r.stringValue().LastIndexOf(":") + 1);

            Object temp = ConfigurationLoader.LoadObject(config, SesameConverter.FromSesameResource(r, mapping));

            if (temp is IInMemoryQueryableStore)
            {
                this._repo = new DotNetRdfInMemoryRepository((IInMemoryQueryableStore)temp);
            }
            else if (temp is IGenericIOManager)
            {
                this._repo = new DotNetRdfGenericRepository((IGenericIOManager)temp);
            }
            else
            {
                throw new dotSesameRepo.config.RepositoryConfigException("Unable to load Configuration for the Repository as the loaded Object was not an IInMemoryQueryableStore or an IGenericIOManager implementation");
            }
        }
Exemple #7
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))));
        }