Package com.haulmont.yarg.structure.impl

Examples of com.haulmont.yarg.structure.impl.ReportQueryImpl


            SqlDataLoader sqlDataLoader = new SqlDataLoader(testDatabase.getDs());
            BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
            rootBand.setData(Collections.<String, Object>emptyMap());

            List<Map<String, Object>> result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login, password from user where login in ${login}", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertEquals(2, result.size());
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
View Full Code Here


            SqlDataLoader sqlDataLoader = new SqlDataLoader(testDatabase.getDs());
            BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
            rootBand.setData(Collections.<String, Object>emptyMap());

            List<Map<String, Object>> result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login, password from user where login in ${login}", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertEquals(2, result.size());
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
View Full Code Here

            SqlDataLoader sqlDataLoader = new SqlDataLoader(testDatabase.getDs());
            BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
            rootBand.setData(Collections.<String, Object>emptyMap());

            List<Map<String, Object>> result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login, password from user where login = CONCAT(${login}, '1')", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertEquals(1, result.size());

            params.put("login", null);
            result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login, password from user [[where login = CONCAT(${login}, '1')]]", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertEquals(3, result.size());

            params.put("login", "ABCD");
            result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login, password from user [[where login = CONCAT(${login}, '1')]]", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertEquals(0, result.size());
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
View Full Code Here

            SqlDataLoader sqlDataLoader = new SqlDataLoader(testDatabase.getDs());
            BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
            rootBand.setData(Collections.<String, Object>emptyMap());

            List<Map<String, Object>> result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login as \"Login\", password as \"Password\" from user where create_ts > ${startDate} and login like ${start} limit 10", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertNotNull(result.get(0).get("Login"));
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
View Full Code Here

            SqlDataLoader sqlDataLoader = new SqlDataLoader(testDatabase.getDs());
            BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
            rootBand.setData(Collections.<String, Object>emptyMap());

            List<Map<String, Object>> result = sqlDataLoader.loadData(
                    new ReportQueryImpl("", "select login as Login, password as Password from user where create_ts > ${startDate} and login like ${start} limit 10", "sql", null, null), rootBand, params);
            printResult(result);
            Assert.assertNotNull(result.get(0).get("Login"));
        } catch (Exception e) {
            e.printStackTrace();
            Assert.fail();
View Full Code Here

        GroovyDataLoader groovyDataLoader = new GroovyDataLoader(new DefaultScriptingImpl());
        BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
        rootBand.setData(Collections.<String, Object>emptyMap());

        List<Map<String, Object>> result = groovyDataLoader.loadData(
                new ReportQueryImpl("", "return [['a':123, 'b':321], ['a':456, 'b':654]]", "groovy", null, null)
                , rootBand, Collections.<String, Object>emptyMap());
        printResult(result);
    }
View Full Code Here

    @Test
    public void testJson() throws Exception {
        JsonDataLoader jsonDataLoader = new JsonDataLoader();
        BandData rootBand = new BandData("band1", null, BandOrientation.HORIZONTAL);
        rootBand.setData(Collections.<String, Object>emptyMap());
        ReportQueryImpl reportQuery = new ReportQueryImpl("", "parameter=param1 $.store.book[*]", "json", null, null);

        String json = "{ \"store\": {\n" +
                "    \"book\": [ \n" +
                "      { \"category\": \"reference\",\n" +
                "        \"author\": \"Nigel Rees\",\n" +
                "        \"title\": \"Sayings of the Century\",\n" +
                "        \"price\": 8.95\n" +
                "      },\n" +
                "      { \"category\": \"fiction\",\n" +
                "        \"author\": \"Evelyn Waugh\",\n" +
                "        \"title\": \"Sword of Honour\",\n" +
                "        \"price\": 12.99,\n" +
                "        \"isbn\": \"0-553-21311-3\"\n" +
                "      }\n" +
                "    ],\n" +
                "    \"bicycle\": {\n" +
                "      \"color\": \"red\",\n" +
                "      \"price\": 19.95\n" +
                "    }\n" +
                "  }\n" +
                "}";

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("param1", json);

        List<Map<String, Object>> maps = jsonDataLoader.loadData(reportQuery, rootBand, params);
        Assert.assertEquals(2, maps.size());

        Map<String, Object> book1 = maps.get(0);
        Assert.assertEquals("Sayings of the Century", book1.get("title"));

        reportQuery = new ReportQueryImpl("", "parameter=param1 $", "json", null, null);
        maps = jsonDataLoader.loadData(reportQuery, rootBand, params);

        Map<String, Object> map = maps.get(0);

        Assert.assertEquals("red", map.get("store.bicycle.color"));

        reportQuery = new ReportQueryImpl("", "parameter=param1 $some.not.existing", "json", null, null);
        maps = jsonDataLoader.loadData(reportQuery, rootBand, params);
        Assert.assertEquals(0, maps.size());

    }
View Full Code Here

TOP

Related Classes of com.haulmont.yarg.structure.impl.ReportQueryImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.