Examples of BandData


Examples of com.haulmont.yarg.structure.BandData

        IOUtils.closeQuietly(outputStream);
    }

    @Test
    public void testHtml() throws Exception {
        BandData root = createRootBand();
        root.addData("date", null);
        root.addData("date2", new Date());
        FileOutputStream outputStream = new FileOutputStream("./result/smoke/result.pdf");
        DefaultFormatterFactory defaultFormatterFactory = new DefaultFormatterFactory();
        ReportFormatter formatter = defaultFormatterFactory.createFormatter(new FormatterFactoryInput("html", root,
                new ReportTemplateImpl("", "test.ftl", "./modules/core/test/smoketest/test.ftl", ReportOutputType.pdf), outputStream));
        formatter.renderDocument();
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

        IOUtils.closeQuietly(outputStream);
    }

    @Test
    public void testHtml2() throws Exception {
        BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);
        HashMap<String, Object> rootData = new HashMap<String, Object>();
        rootData.put("param1", "AAAAAA");
        root.setData(rootData);

        class StrangeMap implements Map {
            Random random = new Random();

            @Override
            public int size() {
                return 0;
            }

            @Override
            public boolean isEmpty() {
                return false;
            }

            @Override
            public boolean containsKey(Object key) {
                return false;
            }

            @Override
            public boolean containsValue(Object value) {
                return false;
            }

            @Override
            public Object get(Object key) {
                return random.nextInt();
            }

            @Override
            public Object put(Object key, Object value) {
                return null;
            }

            @Override
            public Object remove(Object key) {
                return null;
            }

            @Override
            public void putAll(Map m) {

            }

            @Override
            public void clear() {

            }

            @Override
            public Set keySet() {
                return null;
            }

            @Override
            public Collection values() {
                return null;
            }

            @Override
            public Set<Entry> entrySet() {
                return null;
            }
        }

        BandData band11 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
        band11.setData(new StrangeMap());

        BandData band12 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
        band12.setData(new StrangeMap());

        root.addChild(band11);
        root.addChild(band12);

        FileOutputStream outputStream = new FileOutputStream("./result/smoke/result2.html");
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

        IOUtils.closeQuietly(outputStream);
    }

    @Test
    public void testDocxWithColontitulesAndHtmlPageBreak() throws Exception {
        BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);
        HashMap<String, Object> rootData = new HashMap<String, Object>();
        rootData.put("param1", "AAAAAA");
        root.setData(rootData);
        BandData letterTable = new BandData("letterTable", root, BandOrientation.HORIZONTAL);
        BandData creatorInfo = new BandData("creatorInfo", root, BandOrientation.HORIZONTAL);
        HashMap<String, Object> letterTableData = new HashMap<String, Object>();
        String html = "<html><body>";
        html += "<table border=\"2px\">";
        for (int i = 0; i < 5; i++) {
            html += "<tr><td>1234567</td></tr>";
        }
        html += "</table>";
        html += "<br style=\"page-break-after: always\">";
        html += "<p>Second table</p>";
        html += "<table border=\"2px\">";
        for (int i = 0; i < 5; i++) {
            html += "<tr><td>1234567</td></tr>";
        }
        html += "</table>";


        html += "</body></html>";
        letterTableData.put("html", html);
        letterTable.setData(letterTableData);
        HashMap<String, Object> creatorInfoData = new HashMap<String, Object>();
        creatorInfoData.put("name", "12345");
        creatorInfoData.put("phone", "54321");
        creatorInfo.setData(creatorInfoData);
        root.addChild(letterTable);
        root.addChild(creatorInfo);
        root.getReportFieldFormats().put("letterTable.html", new ReportFieldFormatImpl("letterTable.html", "${html}"));

        FileOutputStream outputStream = new FileOutputStream("./result/smoke/colontitules.docx");
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

        IOUtils.closeQuietly(outputStream);
    }

    @Test
    public void testDocWithColontitulesAndHtmlPageBreak() throws Exception {
        BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);
        HashMap<String, Object> rootData = new HashMap<String, Object>();
        rootData.put("param1", "AAAAAA");
        root.setData(rootData);
        BandData letterTable = new BandData("letterTable", root, BandOrientation.HORIZONTAL);
        BandData creatorInfo = new BandData("creatorInfo", root, BandOrientation.HORIZONTAL);
        HashMap<String, Object> letterTableData = new HashMap<String, Object>();
        String html = "<html><body>";
        html += "<table border=\"2px\">";
        for (int i = 0; i < 5; i++) {
            html += "<tr><td>1234567</td></tr>";
        }
        html += "</table>";
        html += "<br style=\"page-break-after: always\">";
        html += "<p>Second table</p>";
        html += "<table border=\"2px\">";
        for (int i = 0; i < 5; i++) {
            html += "<tr><td>1234567</td></tr>";
        }
        html += "</table>";


        html += "</body></html>";
        letterTableData.put("html", html);
        letterTable.setData(letterTableData);
        HashMap<String, Object> creatorInfoData = new HashMap<String, Object>();
        creatorInfoData.put("name", "12345");
        creatorInfoData.put("phone", "54321");
        creatorInfo.setData(creatorInfoData);
        root.addChild(letterTable);
        root.addChild(creatorInfo);
        root.getReportFieldFormats().put("letterTable.html", new ReportFieldFormatImpl("letterTable.html", "${html}"));

        FileOutputStream outputStream = new FileOutputStream("./result/smoke/colontitules.doc");
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

    private BandData createRootBand() {
        return createRootBand(null);
    }

    private BandData createRootBand(List<BandData> bands) {
        BandData root = new BandData("Root", null, BandOrientation.HORIZONTAL);
        root.setReportFieldFormats(Arrays.<ReportFieldFormat>asList(new ReportFieldFormatImpl("Root.param1", "%16s")));
        HashMap<String, Object> rootData = new HashMap<String, Object>();
        rootData.put("param1", "AAAAAA");
        root.setData(rootData);
        BandData band1_1 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
        BandData band1_2 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
        BandData band1_3 = new BandData("Band1", root, BandOrientation.HORIZONTAL);
        BandData footer = new BandData("Footer", root, BandOrientation.HORIZONTAL);
        BandData split = new BandData("Split", root, BandOrientation.HORIZONTAL);
        split.setData(new HashMap<String, Object>());

        Map<String, Object> datamap = new HashMap<String, Object>();
        datamap.put("col1", 111);
        datamap.put("col2", 222);
        datamap.put("col3", 333);
        datamap.put("col.nestedCol", null);
        datamap.put("col.nestedBool", null);
        datamap.put("cwidth", 10000);
        band1_1.setData(datamap);

        Map<String, Object> datamap2 = new HashMap<String, Object>();
        datamap2.put("col1", 444);
        datamap2.put("col2", 555);
        datamap2.put("col3", 666);
        datamap2.put("col.nestedCol", "NESTED1");
        datamap2.put("col.nestedBool", false);
        datamap2.put("cwidth", 10000);
        band1_2.setData(datamap2);

        Map<String, Object> datamap3 = new HashMap<String, Object>();
        datamap3.put("col1", 777);
        datamap3.put("col2", 888);
        datamap3.put("col3", 999);
        datamap3.put("col.nestedCol", "NESTED2");
        datamap3.put("col.nestedBool", true);
        datamap3.put("cwidth", 10000);
        band1_3.setData(datamap3);

        BandData band2_1 = new BandData("Band2", root, BandOrientation.HORIZONTAL);
        BandData band2_2 = new BandData("Band2", root, BandOrientation.HORIZONTAL);

        Map<String, Object> datamap4 = new HashMap<String, Object>();
        datamap4.put("col1", 111);
        datamap4.put("col2", 222);
        datamap4.put("col3", 333);
        datamap4.put("col4", 444);
        band2_1.setData(datamap4);

        Map<String, Object> datamap5 = new HashMap<String, Object>();
        datamap5.put("col1", 555);
        datamap5.put("col2", 666);
        datamap5.put("col3", 777);
        datamap5.put("col4", 888);
        band2_2.setData(datamap5);

        Map<String, Object> datamap6 = new HashMap<String, Object>();
        datamap6.put("col1", 123);
        datamap6.put("col2", 456);
        datamap6.put("col3", 789);
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

                emptyMap = EMPTY_MAP;
            }
        };
        dataExtractor.setPutEmptyRowIfNoDataSelected(true);
        Report report = createReport();
        BandData rootBand = rootBand();

        dataExtractor.extractData(report, new HashMap<String, Object>(), rootBand);
        System.out.println(rootBand);
        Assert.assertEquals(1, rootBand.getChildrenList().size());

        BandData band1 = rootBand.getChildrenList().get(0);
        Assert.assertEquals(emptyMap, band1.getData());

        Assert.assertEquals(1, band1.getChildrenList().size());
        Assert.assertEquals(emptyMap, band1.getChildrenList().get(0).getData());


        dataExtractor.setPutEmptyRowIfNoDataSelected(false);
        rootBand = rootBand();
        dataExtractor.extractData(report, new HashMap<String, Object>(), rootBand);
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

        Assert.assertEquals(0, rootBand.getChildrenList().size());
    }

    private BandData rootBand() {
        BandData rootBand = new BandData(BandData.ROOT_BAND_NAME);
        rootBand.setData(new HashMap<String, Object>());
        rootBand.setFirstLevelBandDefinitionNames(new HashSet<String>());
        return rootBand;
    }
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

    @Test
    public void testReplaceSingleCondition() throws Exception {
        String query = "select id as id from user where id  =  ${param1}";
        HashMap<String, Object> params = new HashMap<String, Object>();
        AbstractDbDataLoader.QueryPack queryPack = prepareQuery(query, new BandData(""), params);
        System.out.println(queryPack.getQuery());
        Assert.assertFalse(queryPack.getQuery().contains("${"));
        writeParams(queryPack);

        params.put("param1", "param1");
        queryPack = prepareQuery(query, new BandData(""), params);
        System.out.println(queryPack.getQuery());
        Assert.assertEquals(1, StringUtils.countMatches(queryPack.getQuery(), "?"));
        writeParams(queryPack);
    }
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

    @Test
    public void testParentBandCondition() throws Exception {
        String query = "select id as id from user where id  =  ${Root.parentBandParam}";
        HashMap<String, Object> params = new HashMap<String, Object>();
        AbstractDbDataLoader.QueryPack queryPack = prepareQuery(query, new BandData(""), params);
        System.out.println(queryPack.getQuery());
        Assert.assertFalse(queryPack.getQuery().contains("${"));
        writeParams(queryPack);

        BandData parentBand = new BandData("Root");
        parentBand.setData(new HashMap<String, Object>());
        parentBand.addData("parentBandParam", "parentBandParam");
        queryPack = prepareQuery(query, parentBand, params);
        System.out.println(queryPack.getQuery());
        Assert.assertEquals(1, StringUtils.countMatches(queryPack.getQuery(), "?"));
        writeParams(queryPack);
    }
View Full Code Here

Examples of com.haulmont.yarg.structure.BandData

    @Test
    public void testParamReordering() throws Exception {
        String query = "select id as id from user where id  =  ${param1} or id = ${param2} and id > ${param1}";
        HashMap<String, Object> params = new HashMap<String, Object>();
        AbstractDbDataLoader.QueryPack queryPack = prepareQuery(query, new BandData(""), params);
        System.out.println(queryPack.getQuery());
        Assert.assertFalse(queryPack.getQuery().contains("${"));
        writeParams(queryPack);

        params.put("param1", "param1");
        params.put("param2", "param2");
        queryPack = prepareQuery(query, new BandData(""), params);
        System.out.println(queryPack.getQuery());
        Assert.assertEquals(3, StringUtils.countMatches(queryPack.getQuery(), "?"));
        writeParams(queryPack);

        Assert.assertEquals("param1", queryPack.getParams()[0].getValue());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.