private ElementTriplesBlock pushBGP() { ElementTriplesBlock bgp = new ElementTriplesBlock() ; elements.add(bgp) ; return bgp ; }
private ElementTriplesBlock pushBGP() { ElementTriplesBlock bgp = new ElementTriplesBlock() ; elements.add(bgp) ; return bgp ; }
private ElementTriplesBlock process(Triple triple) { // Unsubtle ElementTriplesBlock e = new ElementTriplesBlock() ; e.addTriple(triple) ; return e ; }
private ElementTriplesBlock process(Triple triple) { // Unsubtle ElementTriplesBlock e = new ElementTriplesBlock() ; e.addTriple(triple) ; return e ; }
@Override public void visit(P_Link p) { Triple t = new Triple(subject, p.getNode(), object); ElementTriplesBlock e = new ElementTriplesBlock(); e.addTriple(t); result = e; }
@Override public void visit(P_ReverseLink p) { Triple t = new Triple(object, p.getNode(), subject); ElementTriplesBlock e = new ElementTriplesBlock(); e.addTriple(t); result = e; }
protected void addOnlyAboxTriples(ElementUnion patterns, List<Triple> triples){ boolean isAbsentFromAbox = false; ElementTriplesBlock sp = new ElementTriplesBlock(); for (Triple t : triples) { if (isTripleAbsentFromAbox(t)) { isAbsentFromAbox = true; break; } sp.addTriple(t); } if (!isAbsentFromAbox) patterns.addElement(sp); }
public static ElementTriplesBlock toTriples(ElementPathBlock pb) { ElementTriplesBlock ret = new ElementTriplesBlock(); for (TriplePath tp :pb.getPattern().getList()) { if (tp.isTriple()) { ret.addTriple(tp.asTriple()); } else { throw new RuntimeException("Path query not supported"); } } return ret; } public static Set<String> getVars(Set<Var> vars) {
@Override public void visit(ElementTriplesBlock tb) { ElementTriplesBlock ret = new ElementTriplesBlock(); for (Triple t:tb.getPattern().getList()) { ret.addTriple(copySubstitute(t)); } result = ret; }
protected Element elementFromQuads(List<Quad> quads) { ElementGroup el = new ElementGroup() ; ElementTriplesBlock x = new ElementTriplesBlock() ; // Maybe empty?? el.addElement(x) ; Node g = Quad.defaultGraphNodeGenerated ; for ( Quad q : quads ) { if ( q.getGraph() != g ) { g = q.getGraph() ; x = new ElementTriplesBlock() ; if ( g == null || g == Quad.defaultGraphNodeGenerated ) el.addElement(x) ; else { ElementNamedGraph eng = new ElementNamedGraph(g, x) ; el.addElement(eng) ; } } x.addTriple(q.asTriple()) ; } return el ; }
protected Element elementFromQuads(List<Quad> quads) { ElementGroup el = new ElementGroup() ; ElementTriplesBlock x = new ElementTriplesBlock() ; // Maybe empty?? el.addElement(x) ; Node g = Quad.defaultGraphNodeGenerated ; for ( Quad q : quads ) { if ( q.getGraph() != g ) { g = q.getGraph() ; x = new ElementTriplesBlock() ; if ( g == null || g == Quad.defaultGraphNodeGenerated ) el.addElement(x) ; else { ElementNamedGraph eng = new ElementNamedGraph(g, x) ; el.addElement(eng) ; } } x.addTriple(q.asTriple()) ; } return el ; }
public static Set<ConjunctiveQuery> getMembershipQuery(OWLOntology ont) { Set<ConjunctiveQuery> ret = new HashSet<ConjunctiveQuery>(); for (OWLClass owlclass: ont.getClassesInSignature(true)) { ElementTriplesBlock p = new ElementTriplesBlock(); String x = "x"; Node sub = Node.createVariable(x); Node pred = Node.createURI(RDFConstants.RDF_TYPE); Node obj = Node.createURI(owlclass.getIRI().toString()); Triple qt = new Triple(sub, pred, obj); p.getPattern().add(qt); ConjunctiveQuery cq = new ConjunctiveQuery(); cq.setQueryPattern(p); cq.addResultVar(x); cq.setDistinct(true); ret.add(cq); } return ret; } public static List<File> getAllFiles(File inFileOrDir, boolean recurseDir) {
Expr o = args.get(2); Triple triple = toTriple(s, p, o); ElementTriplesBlock ret = new ElementTriplesBlock(); ret.addTriple(triple); return ret;
protected ConjunctiveQuery replace(ConjunctiveQuery q, Triple oldT, Triple newT) { ElementTriplesBlock newPattern = new ElementTriplesBlock(); for (Triple t:q.getTriples()) { if (t.equals(oldT)) { newPattern.addTriple(newT); } else { newPattern.addTriple(t); } } ConjunctiveQuery ret = q.cloneConjQuery(); ret.setQueryPattern(newPattern); for (ElementFilter ef: q.getFilters()) { ret.addFilter(ef.getExpr()); } return ret; }
protected static Set<ConjunctiveQuery> ruleToConjunctiveQueries(RuleSystem rules, Rule rule, Map<Predicate, Set<ConjunctiveQuery>> headPred2ConjQueries, NewVariableGenerator varGen) { Set<ConjunctiveQuery> ret = new HashSet<ConjunctiveQuery>(); ConjunctiveQuery cq = new ConjunctiveQuery(); for (Expr e: rule.getHead().getArguments()) { assert e.isVariable() : e; cq.addResultVar(((VariableExpr)e).getName()); } cq.setQueryPattern(new ElementTriplesBlock()); ret.add(cq); Set<VariableExpr> unboundVars = new HashSet<VariableExpr>(rule.getUnboundVariables()); for (AtomicFormula af : rule.getBody()) { af = renameUnboundVariables(af, unboundVars, varGen); Predicate pred = af.getPredicate(); if (rules.isIDB(pred)) { Set<ConjunctiveQuery> subcqs = getConjunctiveQueries(rules,pred, headPred2ConjQueries, varGen); ret = expand(ret, subcqs, af.getArguments()); } else { ret = expand(ret, af, af.getArguments()); } } return ret; }
private Element process(BasicPattern pattern) { // The different SPARQL versions use different internal structures for BGPs. if ( query.getSyntax() == Syntax.syntaxSPARQL_10 ) { ElementTriplesBlock e = new ElementTriplesBlock() ; for (Triple t : pattern) // Leave bNode variables as they are // Query serialization will deal with them. e.addTriple(t) ; return e ; } if ( query.getSyntax() == Syntax.syntaxSPARQL_11 || query.getSyntax() == Syntax.syntaxARQ ) { ElementPathBlock e = new ElementPathBlock() ; for (Triple t : pattern) // Leave bNode variables as they are // Query serialization will deal with them. e.addTriple(t) ; return e ; } throw new ARQInternalErrorException("Unrecognized syntax: "+query.getSyntax()) ; }
private Element process(BasicPattern pattern) { // The different SPARQL versions use different internal structures for BGPs. if ( query.getSyntax() == Syntax.syntaxSPARQL_10 ) { ElementTriplesBlock e = new ElementTriplesBlock() ; for (Triple t : pattern) // Leave bNode variables as they are // Query serialization will deal with them. e.addTriple(t) ; return e ; } if ( query.getSyntax() == Syntax.syntaxSPARQL_11 || query.getSyntax() == Syntax.syntaxARQ ) { ElementPathBlock e = new ElementPathBlock() ; for (Triple t : pattern) // Leave bNode variables as they are // Query serialization will deal with them. e.addTriple(t) ; return e ; } throw new ARQInternalErrorException("Unrecognized syntax: "+query.getSyntax()) ; }
public Element transform(TriplePath tp,boolean bestEffort, NewVariableGenerator vargen, boolean[] resultHasPropertyPaths) { Triple t = tp.asTriple(); if (t!=null) { // this is a simple triple ElementTriplesBlock ret =new ElementTriplesBlock(); ret.addTriple(t); return ret; } assert !tp.isTriple(); assert tp.getPredicate()==null: tp; JenaPathRewrite pr = new JenaPathRewrite(tp.getSubject(), tp.getObject(), bestEffort, vargen); tp.getPath().visit(pr); if (resultHasPropertyPaths!=null) { resultHasPropertyPaths[0] = pr.resultWithPropertyPaths(); } return pr.getResult(); }
public ConjunctiveQuery cloneConjQuery(boolean copyResultVars) { //return new ConjunctiveQuery(query.cloneQuery()); ConjunctiveQuery ret = new ConjunctiveQuery(); ElementTriplesBlock pattern = new ElementTriplesBlock(); for (Triple t: getTriples()) { pattern.addTriple(new Triple(t.getSubject(), t.getPredicate(), t.getObject())); } ret.setQueryPattern(pattern); for (ElementFilter f: getFilters()) { ret.addFilter(f.getExpr()); } if (copyResultVars) { for (String v: getResultVars()) { ret.query.addResultVar(v); } } return ret; } public Set<String> getAllVariables() {