/** * Construct a non-optional join group having the specified child as its * initial member. */ public JoinGroupNode(final IGroupMemberNode child) { super(); addChild(child); }
/** * Construct a non-optional join group having the specified child as its * initial member. */ public JoinGroupNode(final IGroupMemberNode child) { super(); addChild(child); }
/** * Construct a GRAPH group having the specified child as its initial member. * * @param context * The variable or constant for the GRAPH group. * @param child * The initial child. */ public JoinGroupNode(final TermNode context, final IGroupMemberNode child) { super(); setContext(context); addChild(child); }
/** * Construct a GRAPH group having the specified child as its initial member. * * @param context * The variable or constant for the GRAPH group. * @param child * The initial child. */ public JoinGroupNode(final TermNode context, final IGroupMemberNode child) { super(); setContext(context); addChild(child); }
/** * Construct a possibly optional group having the specified child as its * initial member. * * @param optional * <code>true</code> iff the group is optional. * @param child * The initial child. */ public JoinGroupNode(final boolean optional, final IGroupMemberNode child) { super(); setOptional(optional); addChild(child); }
/** * Construct a possibly optional group having the specified child as its * initial member. * * @param optional * <code>true</code> iff the group is optional. * @param child * The initial child. */ public JoinGroupNode(final boolean optional, final IGroupMemberNode child) { super(); setOptional(optional); addChild(child); }
/** * @param queryBase * @param group * @param searchVar * @param statementPatterns * @return */ private ServiceNode createServiceNode(final AST2BOpContext ctx, final QueryBase queryBase, final GroupNodeBase<IGroupMemberNode> group, IVariable<?> searchVar, final Map<URI, StatementPatternNode> statementPatterns) { final JoinGroupNode groupNode = new JoinGroupNode(); for(StatementPatternNode sp : statementPatterns.values()) { groupNode.addChild(sp); } @SuppressWarnings("unchecked") final TermId<BigdataURI> iv = (TermId<BigdataURI>) TermId .mockIV(VTE.URI); iv.setValue(ctx.db.getValueFactory().asValue(searchPredicate)); return new ServiceNode(new ConstantNode(iv), groupNode); }
/** * @param queryBase * @param group * @param searchVar * @param statementPatterns * @return */ private ServiceNode createServiceNode(final AST2BOpContext ctx, final QueryBase queryBase, final GroupNodeBase<IGroupMemberNode> group, IVariable<?> searchVar, final Map<URI, StatementPatternNode> statementPatterns) { final JoinGroupNode groupNode = new JoinGroupNode(); for(StatementPatternNode sp : statementPatterns.values()) { groupNode.addChild(sp); } @SuppressWarnings("unchecked") final TermId<BigdataURI> iv = (TermId<BigdataURI>) TermId .mockIV(VTE.URI); iv.setValue(ctx.db.getValueFactory().asValue(searchPredicate)); return new ServiceNode(new ConstantNode(iv), groupNode); }
/** * Unit test for simple SELECT query * * <pre> * SELECT ?s where {?s ?p ?o} * </pre> */ public void test_select_s_where_s_p_o() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select ?s where {?s ?p ?o}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("s")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); expected.setWhereClause(whereClause); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
/** * Unit test for SELECT query with a wildcard (<code>*</code>). * * <pre> * SELECT * where {?s ?p ?o} * </pre> */ public void test_select_star() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select * where {?s ?p ?o}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("*")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); expected.setWhereClause(whereClause); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS));
whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS));
/** * A unit test for the DELETE WHERE "shortcut" form. * <pre> * DELETE WHERE {?x foaf:name ?y } * </pre> */ public void test_delete_where_01() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "DELETE WHERE {?x <http://xmlns.com/foaf/0.1/name> ?y }"; @SuppressWarnings("rawtypes") final IV foafName = makeIV(valueFactory .createURI("http://xmlns.com/foaf/0.1/name")); final UpdateRoot expected = new UpdateRoot(); { final DeleteInsertGraph op = new DeleteInsertGraph(); expected.addChild(op); { final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("x"), new ConstantNode(foafName), new VarNode("y"))); op.setWhereClause(whereClause); } } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }
/** * Unit test for simple SELECT query * * <pre> * SELECT ?s where {?s ?p ?o} * </pre> */ public void test_select_s_where_s_p_o() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select ?s where {?s ?p ?o}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("s")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); expected.setWhereClause(whereClause); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
/** * Unit test for SELECT query with a wildcard (<code>*</code>). * * <pre> * SELECT * where {?s ?p ?o} * </pre> */ public void test_select_star() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select * where {?s ?p ?o}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("*")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); expected.setWhereClause(whereClause); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
/** * Unit test for simple triple pattern in the default context consisting of * three variables. * * <pre> * SELECT ?s where {?s ?p ?o} * </pre> */ public void test_triple_pattern_var_var_var() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select ?s where {?s ?p ?o}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("s")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS)); expected.setWhereClause(whereClause); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
/** * Unit test with BNode. Should be rewritten as an anonymous variable. * <p> * Note: a bare blank node may not appear in the SELECT expression with * (bnode as ?x) so we have to test this somewhere else in the syntax of the * query. */ public void test_select_bnode() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "select ?s where {?s ?p _:a1}"; final QueryRoot expected = new QueryRoot(QueryType.SELECT); { { final Map<String, String> prefixDecls = new LinkedHashMap<String, String>(PrefixDeclProcessor.defaultDecls); expected.setPrefixDecls(prefixDecls); } final ProjectionNode projection = new ProjectionNode(); projection.addProjectionVar(new VarNode("s")); expected.setProjection(projection); final JoinGroupNode whereClause = new JoinGroupNode(); expected.setWhereClause(whereClause); final VarNode blankNodeVar = new VarNode("-anon-1"); blankNodeVar.setAnonymous(true); whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), blankNodeVar, null/* c */, Scope.DEFAULT_CONTEXTS)); } final QueryRoot actual = parse(sparql, baseURI); assertSameAST(sparql, expected, actual); }
whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS));
whereClause.addChild(new StatementPatternNode(new VarNode("s"), new VarNode("p"), new VarNode("o"), null/* c */, Scope.DEFAULT_CONTEXTS));
/** * A unit test for the DELETE WHERE "shortcut" form. * <pre> * DELETE WHERE {?x foaf:name ?y } * </pre> */ public void test_delete_where_01() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "DELETE WHERE {?x <http://xmlns.com/foaf/0.1/name> ?y }"; @SuppressWarnings("rawtypes") final IV foafName = makeIV(valueFactory .createURI("http://xmlns.com/foaf/0.1/name")); final UpdateRoot expected = new UpdateRoot(); { final DeleteInsertGraph op = new DeleteInsertGraph(); expected.addChild(op); { final JoinGroupNode whereClause = new JoinGroupNode(); whereClause.addChild(new StatementPatternNode(new VarNode("x"), new ConstantNode(foafName), new VarNode("y"))); op.setWhereClause(whereClause); } } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }