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))); }
/// <summary> /// Converts a Sesame Value to a dotNetRDF Node /// </summary> /// <param name="value">Value</param> /// <param name="mapping">Blank Node Mapping</param> /// <returns></returns> internal static INode FromSesameValue(dotSesame.Value value, SesameMapping mapping) { if (value is dotSesame.URI) { return(mapping.Graph.CreateUriNode(new Uri(((dotSesame.URI)value).stringValue()))); } else if (value is dotSesame.Literal) { dotSesame.Literal lit = (dotSesame.Literal)value; if (lit.getDatatype() != null) { return(mapping.Graph.CreateLiteralNode(lit.stringValue(), FromSesameUri(lit.getDatatype()))); } else if (lit.getLanguage() != null) { return(mapping.Graph.CreateLiteralNode(lit.stringValue(), lit.getLanguage())); } else { return(mapping.Graph.CreateLiteralNode(lit.stringValue())); } } else if (value is dotSesame.BNode) { dotSesame.BNode bnode = (dotSesame.BNode)value; if (mapping.InputMapping.ContainsKey(bnode)) { return(mapping.InputMapping[bnode]); } else { INode n = mapping.Graph.CreateBlankNode(); lock (mapping) { if (!mapping.InputMapping.ContainsKey(bnode)) { mapping.InputMapping.Add(bnode, n); } else { n = mapping.InputMapping[bnode]; } if (!mapping.OutputMapping.ContainsKey(n)) { mapping.OutputMapping.Add(n, bnode); } } return(n); } } else { throw new RdfException("Unable to convert unexpected Sesame Value Type to a dotNetRDF INode"); } }
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); } }
public void setBinding(string str, org.openrdf.model.Value v) { this._queryString.SetVariable(str, SesameConverter.FromSesameValue(v, this._mapping)); }
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); }
public dotSesame.Statement createStatement(dotSesame.Resource r, dotSesame.URI uri, dotSesame.Value v) { return(this._mapping.ValueFactory.createStatement(r, uri, v)); }
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)))); }
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); }
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(); }
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())); }
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)); }
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(); }