Search in sources :

Example 1 with HtmlRenderCallback

use of org.pivot4j.ui.html.HtmlRenderCallback in project bamboobsc by billchen198318.

the class Pivot4JUtils method rendererHtml.

public static String rendererHtml(String mondrianUrl, String mdx, boolean showDimensionTitle, boolean showParentMembers) throws Exception {
    if (StringUtils.isBlank(mondrianUrl) || StringUtils.isBlank(mdx)) {
        throw new java.lang.IllegalArgumentException("mondrian url and MDX cannot blank.");
    }
    String body = "";
    OlapConnection connection = OlapUtils.getConnection(mondrianUrl);
    OlapDataSource dataSource = new SingleConnectionOlapDataSource(connection);
    try {
        PivotModel model = getPivotModel(dataSource, mdx);
        TableRenderer renderer = getTableRenderer(showDimensionTitle, showParentMembers);
        StringWriter writer = new StringWriter();
        renderer.render(model, new HtmlRenderCallback(writer));
        //writer.write(body);
        body = writer.toString();
        writer.flush();
        writer.close();
    } catch (Exception e) {
        throw e;
    } finally {
        OlapUtils.nullConnection(connection);
        connection = null;
        dataSource = null;
    }
    return body;
}
Also used : TableRenderer(org.pivot4j.ui.table.TableRenderer) SingleConnectionOlapDataSource(org.pivot4j.datasource.SingleConnectionOlapDataSource) OlapDataSource(org.olap4j.OlapDataSource) PivotModel(org.pivot4j.PivotModel) StringWriter(java.io.StringWriter) OlapConnection(org.olap4j.OlapConnection) SingleConnectionOlapDataSource(org.pivot4j.datasource.SingleConnectionOlapDataSource) HtmlRenderCallback(org.pivot4j.ui.html.HtmlRenderCallback) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 OlapConnection (org.olap4j.OlapConnection)1 OlapDataSource (org.olap4j.OlapDataSource)1 PivotModel (org.pivot4j.PivotModel)1 SingleConnectionOlapDataSource (org.pivot4j.datasource.SingleConnectionOlapDataSource)1 HtmlRenderCallback (org.pivot4j.ui.html.HtmlRenderCallback)1 TableRenderer (org.pivot4j.ui.table.TableRenderer)1