Exemple #1
0
        public void evaluate(org.openrdf.query.TupleQueryResultHandler tqrh)
        {
            SparqlResultSet rset = this.EvaluateQuery();

            java.util.ArrayList vars = new java.util.ArrayList();
            foreach (String var in rset.Variables)
            {
                vars.add(var);
            }

            tqrh.startQueryResult(vars);
            SesameMapping mapping = new SesameMapping(new Graph(), new dotSesame.impl.GraphImpl());

            foreach (SparqlResult r in rset)
            {
                dotSesameQuery.impl.MapBindingSet binding = new org.openrdf.query.impl.MapBindingSet();
                foreach (String var in r.Variables)
                {
                    binding.addBinding(var, SesameConverter.ToSesameValue(r[var], mapping));
                }
                tqrh.handleSolution(binding);
            }

            tqrh.endQueryResult();
        }
Exemple #2
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)));
        }
Exemple #3
0
        public org.openrdf.query.BindingSet getBindings()
        {
            dotSesameQuery.impl.MapBindingSet s = new org.openrdf.query.impl.MapBindingSet();

            foreach (KeyValuePair <String, INode> kvp in this._queryString.Variables)
            {
                s.addBinding(kvp.Key, SesameConverter.ToSesameValue(kvp.Value, this._mapping));
            }

            return(s);
        }
Exemple #4
0
        protected override org.openrdf.repository.RepositoryResult GetStatementsInternal(string sparqlQuery, SesameMapping mapping)
        {
            if (this._manager is IQueryableGenericIOManager)
            {
                try
                {
                    Object results = ((IQueryableGenericIOManager)this._manager).Query(sparqlQuery);
                    if (results is SparqlResultSet)
                    {
                        IEnumerable <dotSesame.Statement> stmts = from result in (SparqlResultSet)results
                                                                  select this._factory.createStatement(SesameConverter.ToSesameResource(result["subj"], mapping), SesameConverter.ToSesameUri(result["pred"], mapping), SesameConverter.ToSesameValue(result["obj"], mapping));

                        return(new dotSesameRepo.RepositoryResult(new DotNetAdunaIterationWrapper(stmts)));
                    }
                    else
                    {
                        throw new dotSesameRepo.RepositoryException("Unable to return Statements from this repository as the repository returned an unexpected result");
                    }
                }
                catch (Exception ex)
                {
                    throw new dotSesameRepo.RepositoryException("Unable to return Statements from this repository due to the following error: " + ex.Message);
                }
            }
            else
            {
                throw new dotSesameRepo.RepositoryException("This dotNetRDF Generic Repository does not support returning specific Statements");
            }
        }