Java Code Examples for org.apache.jena.sparql.syntax.ElementTriplesBlock#addTriple()
The following examples show how to use
org.apache.jena.sparql.syntax.ElementTriplesBlock#addTriple() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OWLQLCompiler.java From quetzal with Eclipse Public License 2.0 | 6 votes |
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; }
Example 2
Source File: ConjunctiveQuery.java From quetzal with Eclipse Public License 2.0 | 6 votes |
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; }
Example 3
Source File: labelSearch.java From xcurator with Apache License 2.0 | 6 votes |
private QueryIterator buildSyntax(QueryIterator input, Node nodeVar, String pattern, ExecutionContext execCxt) { Var var2 = createNewVar() ; // Triple patterns for ?x rdfs:label ?hiddenVar ElementTriplesBlock elementBGP = new ElementTriplesBlock(); Triple t = new Triple(nodeVar, RDFS.label.asNode(), var2) ; elementBGP.addTriple(t) ; // Regular expression for regex(?hiddenVar, "pattern", "i") Expr regex = new E_Regex(new ExprVar(var2.getName()), pattern, "i") ; ElementGroup elementGroup = new ElementGroup() ; elementGroup.addElement(elementBGP) ; elementGroup.addElement(new ElementFilter(regex)) ; // Compile it. // The better design is to build the Op structure programmatically, Op op = Algebra.compile(elementGroup) ; op = Algebra.optimize(op, execCxt.getContext()) ; return QC.execute(op, input, execCxt) ; }
Example 4
Source File: RuleSystemToUnionQuery.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(ElementTriplesBlock tb) { ElementTriplesBlock ret = new ElementTriplesBlock(); for (Triple t:tb.getPattern().getList()) { ret.addTriple(copySubstitute(t)); } result = ret; }
Example 5
Source File: NormalizedOWLQLTbox.java From quetzal with Eclipse Public License 2.0 | 5 votes |
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); }
Example 6
Source File: OCUtils.java From quetzal with Eclipse Public License 2.0 | 5 votes |
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; }
Example 7
Source File: PropertyPathRewrite.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(P_Link p) { Triple t = new Triple(subject, p.getNode(), object); ElementTriplesBlock e = new ElementTriplesBlock(); e.addTriple(t); result = e; }
Example 8
Source File: PropertyPathRewrite.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override public void visit(P_ReverseLink p) { Triple t = new Triple(object, p.getNode(), subject); ElementTriplesBlock e = new ElementTriplesBlock(); e.addTriple(t); result = e; }