Esempio n. 1
0
        public override IEnumerable <Triple> WithSubject(INode subj)
        {
            dotSesame.Resource r = SesameConverter.ToSesameResource(subj, this._mapping);
            JavaIteratorWrapper <dotSesame.Statement> stmtIter = new JavaIteratorWrapper <org.openrdf.model.Statement>(this._g.match(r, null, null, null));

            return(stmtIter.Select(s => SesameConverter.FromSesame(s, this._mapping)));
        }
Esempio n. 2
0
        public override org.openrdf.repository.RepositoryResult getContextIDs()
        {
            try
            {
                Object results = this._store.ExecuteQuery("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o }}");
                if (results is SparqlResultSet)
                {
                    IEnumerable <dotSesame.Resource> resIter = from result in (SparqlResultSet)results
                                                               where result.HasValue("g") && result["g"] != null
                                                               select SesameConverter.ToSesameResource(result["g"], this._mapping);

                    return(new org.openrdf.repository.RepositoryResult(new DotNetAdunaIterationWrapper(resIter)));
                }
                else
                {
                    throw new dotSesameRepo.RepositoryException("Unable to return the Context IDs from this repository as the repository returned an unexpected result");
                }
            }
            catch (Exception ex)
            {
                throw new dotSesameRepo.RepositoryException("Unable to return the Context IDs from this repository due to the following error: " + ex.Message);
            }
        }
Esempio n. 3
0
        public override org.openrdf.repository.RepositoryResult getContextIDs()
        {
            if (this._manager.ListGraphsSupported)
            {
                IEnumerable <dotSesame.Resource> resIter = from u in this._manager.ListGraphs()
                                                           select(dotSesame.Resource) this._mapping.ValueFactory.createURI(u.ToString());

                return(new org.openrdf.repository.RepositoryResult(new DotNetAdunaIterationWrapper(resIter)));
            }
            else if (this._manager is IQueryableGenericIOManager)
            {
                try
                {
                    Object results = ((IQueryableGenericIOManager)this._manager).Query("SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o }}");
                    if (results is SparqlResultSet)
                    {
                        IEnumerable <dotSesame.Resource> resIter = from result in (SparqlResultSet)results
                                                                   where result.HasValue("g") && result["g"] != null
                                                                   select SesameConverter.ToSesameResource(result["g"], this._mapping);

                        return(new org.openrdf.repository.RepositoryResult(new DotNetAdunaIterationWrapper(resIter)));
                    }
                    else
                    {
                        throw new dotSesameRepo.RepositoryException("Unable to return the Context IDs from this repository as the repository returned an unexpected result");
                    }
                }
                catch (Exception ex)
                {
                    throw new dotSesameRepo.RepositoryException("Unable to return the Context IDs from this repository due to the following error: " + ex.Message);
                }
            }
            else
            {
                throw new dotSesameRepo.RepositoryException("This dotNetRDF Generic Repository does not support returning the Context IDs");
            }
        }
Esempio n. 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");
            }
        }