Java Code Examples for org.eclipse.rdf4j.query.algebra.BindingSetAssignment#getBindingSets()
The following examples show how to use
org.eclipse.rdf4j.query.algebra.BindingSetAssignment#getBindingSets() .
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: AbstractSearchQueryEvaluator.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void replaceQueryPatternsWithResults(final BindingSetAssignment bsa) { final QueryModelNode placeholder = removeQueryPatterns(); if (bsa != null && bsa.getBindingSets() != null && bsa.getBindingSets().iterator().hasNext()) { placeholder.replaceWith(bsa); } else { placeholder.replaceWith(new EmptySet()); } }
Example 2
Source File: OneOfVisitorTest.java From rya with Apache License 2.0 | 5 votes |
@Test public void testOneOf() throws Exception { // Configure a mock instance engine with an ontology: final InferenceEngine inferenceEngine = mock(InferenceEngine.class); when(inferenceEngine.isEnumeratedType(SUITS)).thenReturn(true); when(inferenceEngine.getEnumeration(SUITS)).thenReturn(CARD_SUIT_ENUMERATION); when(inferenceEngine.isEnumeratedType(RANKS)).thenReturn(true); when(inferenceEngine.getEnumeration(RANKS)).thenReturn(CARD_RANK_ENUMERATION); // Query for a Suits and rewrite using the visitor: final Projection query = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", SUITS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); query.visit(new OneOfVisitor(conf, inferenceEngine)); // Expected structure: BindingSetAssignment containing the enumeration: // BindingSetAssignment(CLUBS, DIAMONDS, HEARTS, SPADES) // Collect the arguments to the BindingSetAssignment: assertTrue(query.getArg() instanceof BindingSetAssignment); final BindingSetAssignment bsa = (BindingSetAssignment) query.getArg(); final Iterable<BindingSet> iterable = bsa.getBindingSets(); final Iterator<BindingSet> iter = iterable.iterator(); assertBindingSet(iter, CARD_SUIT_ENUMERATION.iterator()); // Query for a Ranks and rewrite using the visitor: final Projection query2 = new Projection( new StatementPattern(new Var("s"), new Var("p", RDF.TYPE), new Var("o", RANKS)), new ProjectionElemList(new ProjectionElem("s", "subject"))); query2.visit(new OneOfVisitor(conf, inferenceEngine)); // Expected structure: BindingSetAssignment containing the enumeration: // BindingSetAssignment(ACE, 2, 3, 4, 5, 6, 7, 8, 9, 10, JACK, QUEEN, KING) // Collect the arguments to the BindingSetAssignment: assertTrue(query2.getArg() instanceof BindingSetAssignment); final BindingSetAssignment bsa2 = (BindingSetAssignment) query2.getArg(); final Iterable<BindingSet> iterable2 = bsa2.getBindingSets(); final Iterator<BindingSet> iter2 = iterable2.iterator(); assertBindingSet(iter2, CARD_RANK_ENUMERATION.iterator()); }