Ejemplo n.º 1
0
 internal static IEnumerable <Triple> ToTriples(this info.aduna.iteration.Iteration iter, SesameMapping mapping)
 {
     while (iter.hasNext())
     {
         yield return(SesameConverter.FromSesame((dotSesame.Statement)iter.next(), mapping));
     }
 }
Ejemplo n.º 2
0
 public bool add(object obj)
 {
     if (obj is dotSesame.Statement)
     {
         dotSesame.Statement stmt = (dotSesame.Statement)obj;
         Triple t = SesameConverter.FromSesame(stmt, this._mapping);
         if (this._g.ContainsTriple(t))
         {
             return(false);
         }
         else
         {
             this._g.Assert(t);
             return(true);
         }
     }
     else if (obj is Triple)
     {
         Triple t = (Triple)obj;
         if (this._g.ContainsTriple(t))
         {
             return(false);
         }
         else
         {
             this._g.Assert(t);
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public override IEnumerable <Triple> WithObject(INode obj)
        {
            dotSesame.Value v = SesameConverter.ToSesameValue(obj, this._mapping);
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(this._g.match(null, null, v, null));

            return(stmtIter.Select(s => SesameConverter.FromSesame(s, this._mapping)));
        }
Ejemplo n.º 4
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)));
        }
Ejemplo n.º 5
0
        public virtual void add(org.openrdf.model.Statement s, params org.openrdf.model.Resource[] rarr)
        {
            IEnumerable <Uri> contexts = rarr.ToContexts(this._mapping);
            Graph             g        = new Graph();

            g.Assert(SesameConverter.FromSesame(s, this._mapping));
            this.AddInternal(g, contexts);
        }
Ejemplo n.º 6
0
 public bool contains(object obj)
 {
     if (obj is dotSesame.Statement)
     {
         Triple t = SesameConverter.FromSesame((dotSesame.Statement)obj, this._mapping);
         return(this._g.ContainsTriple(t));
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 7
0
        public bool equals(object obj)
        {
            if (obj is dotSesame.Graph)
            {
                Graph h = new Graph();
                SesameConverter.FromSesame((dotSesame.Graph)obj, h);

                return(this._g.Equals(h));
            }
            else
            {
                return(this._g.Equals(obj));
            }
        }
Ejemplo n.º 8
0
        public bool addAll(java.util.Collection c)
        {
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <dotSesame.Statement>(c.iterator());
            bool added = false;

            foreach (dotSesame.Statement stmt in stmtIter)
            {
                Triple t = SesameConverter.FromSesame(stmt, this._mapping);
                if (!this._g.ContainsTriple(t))
                {
                    this._g.Assert(t);
                    added = added || true;
                }
            }
            return(added);
        }
Ejemplo n.º 9
0
        public bool removeAll(java.util.Collection c)
        {
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(c.iterator());
            bool removed = false;

            foreach (dotSesame.Statement stmt in stmtIter)
            {
                Triple t = SesameConverter.FromSesame(stmt, this._mapping);
                if (this._g.ContainsTriple(t))
                {
                    this._g.Retract(t);
                    removed = removed || true;
                }
            }

            return(removed);
        }
Ejemplo n.º 10
0
        public bool containsAll(java.util.Collection c)
        {
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(c.iterator());
            bool contains = true;

            foreach (dotSesame.Statement stmt in stmtIter)
            {
                Triple t = SesameConverter.FromSesame(stmt, this._mapping);
                if (!this._g.ContainsTriple(t))
                {
                    contains = false;
                    break;
                }
            }

            return(contains);
        }
Ejemplo n.º 11
0
        public bool retainAll(java.util.Collection c)
        {
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(c.iterator());
            HashSet <Triple> retained = new HashSet <Triple>();
            bool             changed  = false;

            foreach (dotSesame.Statement stmt in stmtIter)
            {
                retained.Add(SesameConverter.FromSesame(stmt, this._mapping));
            }
            foreach (Triple t in this._g.Triples.ToList())
            {
                if (!retained.Contains(t))
                {
                    changed = true;
                    this._g.Retract(t);
                }
            }
            return(changed);
        }
Ejemplo n.º 12
0
 public bool remove(object obj)
 {
     if (obj is dotSesame.Statement)
     {
         Triple t = SesameConverter.FromSesame((dotSesame.Statement)obj, this._mapping);
         if (this._g.ContainsTriple(t))
         {
             this._g.Retract(t);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 13
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");
            }
        }
Ejemplo n.º 14
0
        public override IEnumerator <Triple> GetEnumerator()
        {
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(this._g.iterator());

            return(stmtIter.Select(s => SesameConverter.FromSesame(s, this._mapping)).GetEnumerator());
        }
Ejemplo n.º 15
0
        public virtual void add(java.lang.Iterable i, params org.openrdf.model.Resource[] rarr)
        {
            IEnumerable <Uri> contexts = rarr.ToContexts(this._mapping);
            Graph             g        = new Graph();

            g.Assert(new JavaIteratorWrapper <dotSesame.Statement>(i.iterator()).Select(s => SesameConverter.FromSesame(s, this._mapping)));
            this.AddInternal(g, contexts);
        }
Ejemplo n.º 16
0
        public bool hasStatement(org.openrdf.model.Statement s, bool b, params org.openrdf.model.Resource[] rarr)
        {
            Triple t = SesameConverter.FromSesame(s, this._mapping);

            return(HasTripleInternal(t));
        }