protected void add(ElementPathBlock targetPathBlock, ElementPathBlock newPaths) { for (TriplePath tp:newPaths.getPattern().getList()) { targetPathBlock.addTriple(tp); } } protected void add(ElementPathBlock targetPathBlock, ElementTriplesBlock newTriples) {
@Override public void visit(ElementPathBlock e) { for (TriplePath t:e.getPattern().getList()) { addVars(t); } } @Override
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) {
public void setQueryPattern(Element graphPattern) { if (graphPattern instanceof ElementTriplesBlock) { query.setQueryPattern((ElementTriplesBlock)graphPattern); } else if (graphPattern instanceof ElementGroup) { ElementGroup group = (ElementGroup) graphPattern; for (Element e: flatten(group)) { if (e instanceof ElementPathBlock) { ElementPathBlock epb = (ElementPathBlock) e; for (TriplePath p:epb.getPattern().getList()) { if (!p.isTriple()) { throw new IllegalArgumentException("Conjunctive query only accepts a basic graph patterns. No triple path: "+ p+"\n"+graphPattern ); } } } else if (!(e instanceof ElementTriplesBlock) && !(e instanceof ElementFilter)) { throw new IllegalArgumentException("Conjunctive query only accepts a basic graph patterns: "+ e+"\n"+graphPattern ); } } query.setQueryPattern(graphPattern); } else { throw new IllegalArgumentException("Conjunctive query only accepts a basic graph patterns: "+ graphPattern); } } public void addTriple(Triple t) {
protected void insert(TripleCollector target, ElementPathBlock source) { for (TriplePath path : source.getPattern()) { if (path.isTriple()) { target.addTriple(path.asTriple()); } else { target.addTriplePath(path); } } }
currentPathBlock = etb2.getPattern() ; groupElts.add(etb2) ; currentPathBlock = etb2.getPattern() ; groupElts.add(etb2) ; currentPathBlock.addAll(epb.getPattern()) ; continue ;
if ( prev2 != null ) prev2.addAll(epb.getPattern()) ; continue ; epb2.getPattern().addAll(epb.getPattern()) ; prev2 = epb2.getPattern() ; groupElts.add(epb2) ; continue ;
public List<Triple> getTriples() { if (query.getQueryPattern() instanceof ElementTriplesBlock) { ElementTriplesBlock sp = (ElementTriplesBlock) query.getQueryPattern(); return sp.getPattern().getList(); } else { assert query.getQueryPattern() instanceof ElementGroup : query.getQueryPattern() ; List<Element> es = flatten(query.getQueryPattern()); List<Triple> ret = new ArrayList<Triple>(); for (Element e: es) { if (e instanceof ElementTriplesBlock) { ret.addAll(((ElementTriplesBlock) e).getPattern().getList()); } else if (e instanceof ElementPathBlock ) { ElementPathBlock epb = (ElementPathBlock) e; for (TriplePath tp: epb.getPattern().getList()) { assert tp.isTriple() : tp; ret.add(tp.asTriple()); } } } return ret; } }
if (first instanceof ElementPathBlock) { triples = new ArrayList<Triple>(); for (TriplePath path : ((ElementPathBlock) first).getPattern()) { if (!path.isTriple()) { throw new UnsupportedQueryException("Path expressions are not supported yet.");
ElementTriplesBlock etb = null; ElementGroup g = new ElementGroup(); for (TriplePath tp : e.getPattern().getList()) { boolean[] hasPropPaths = new boolean[]{false}; Element tpres =transform(tp, bestEffort, vargen, hasPropPaths); for (TriplePath t: ((ElementPathBlock) tpres).getPattern().getList()) { if (epb == null) { epb = new ElementPathBlock();
ElementGroup group = (ElementGroup) query.getQueryPattern(); ElementPathBlock p = (ElementPathBlock) group.getElements().get(0); for (TriplePath path : p.getPattern().getList()) { System.out.println("Path: "+path); RuleSystem rs = toRules.toRules(path, true, "Triple", "NegatedPropertySetTriple");
return compilePathBlock(((ElementPathBlock)elt).getPattern()) ;
return compilePathBlock(((ElementPathBlock)elt).getPattern()) ;
public void visit(ElementPathBlock arg0) { log(arg0); List<TriplePath> list = arg0.getPattern().getList(); ind.increase(); for(TriplePath path:list) {
PathBlock pBlk = el.getPattern() ; for ( TriplePath tp : pBlk )
PathBlock pBlk = el.getPattern() ; for ( TriplePath tp : pBlk )
Op op = compilePathBlock(epb.getPattern()) ; return join(current, op) ;