コード例 #1
0
 @Test
 public void testMatch() throws Exception {
   SQLQuery query =
       SQLQueryParser.parse(
           "SELECT ecm:uuid, cmp:addresses/*1/street FROM D WHERE " //
               + "cmp:addresses/*1/city = 'Paris'");
   SelectClause selectClause = query.getSelectClause();
   Expression expression = query.getWhereClause().predicate;
   OrderByClause orderByClause = query.getOrderByClause();
   DBSExpressionEvaluator evaluator =
       new DBSExpressionEvaluator(null, selectClause, expression, orderByClause, null, false);
   evaluator.parse();
   assertTrue(evaluator.hasWildcardProjection());
   State state =
       state( //
           "ecm:id",
           "id1", //
           "cmp:addresses",
           list( //
               state("city", "Paris", "street", "Champs Elysees"), //
               state("city", "Paris", "street", "Boulevard Peripherique")));
   List<Map<String, Serializable>> projections = evaluator.matches(state);
   assertEquals(
       list( //
           map("ecm:uuid", "id1", "cmp:addresses/*1/street", "Champs Elysees"), //
           map("ecm:uuid", "id1", "cmp:addresses/*1/street", "Boulevard Peripherique")), //
       projections);
 }
コード例 #2
0
 @Test
 public void testWildcardCrossProduct() throws Exception {
   SQLQuery query =
       SQLQueryParser.parse(
           "SELECT cmp:addresses/*1/city, cmp:addresses/*2/city FROM D WHERE " //
               + "ecm:uuid <> 'nothing'");
   SelectClause selectClause = query.getSelectClause();
   Expression expression = query.getWhereClause().predicate;
   OrderByClause orderByClause = query.getOrderByClause();
   DBSExpressionEvaluator evaluator =
       new DBSExpressionEvaluator(null, selectClause, expression, orderByClause, null, false);
   evaluator.parse();
   assertTrue(evaluator.hasWildcardProjection());
   State state =
       state( //
           "ecm:id",
           "id1", //
           "cmp:addresses",
           list( //
               state("city", "Paris"), //
               state("city", "London")));
   List<Map<String, Serializable>> projections = evaluator.matches(state);
   assertEquals(
       list( //
           map("cmp:addresses/*1/city", "Paris", "cmp:addresses/*2/city", "Paris"), //
           map("cmp:addresses/*1/city", "Paris", "cmp:addresses/*2/city", "London"), //
           map("cmp:addresses/*1/city", "London", "cmp:addresses/*2/city", "Paris"), //
           map("cmp:addresses/*1/city", "London", "cmp:addresses/*2/city", "London")), //
       projections);
 }