Search in sources :

Example 1 with ReportQuery

use of com.ramussoft.report.ReportQuery in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method printReport.

private void printReport(final String string) throws IOException {
    final long num = Long.parseLong(string);
    Element report = null;
    report = dataPlugin.getEngine().getElement(num);
    if (report == null) {
        printError(RES.getString("reportEror"));
        return;
    }
    htmlTitle = report.getName();
    printStartD();
    Query query = null;
    Qualifier qualifier = ((ReportQuery) dataPlugin.getEngine()).getHTMLReportQuery(report);
    if (qualifier != null) {
        query = new Query(null);
        List<Element> elements = new ArrayList<Element>();
        for (Row row : getSelRows(qualifier)) {
            elements.add(row.getElement());
        }
        query.setElements(elements);
    }
    printReport(report, query);
    printEndD();
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Query(com.ramussoft.report.Query) ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) ArrayList(java.util.ArrayList) Qualifier(com.ramussoft.common.Qualifier) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow)

Example 2 with ReportQuery

use of com.ramussoft.report.ReportQuery in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method getReportHTMLText.

protected Source getReportHTMLText(Engine engine, Element report, Query query) {
    String page = null;
    try {
        HashMap<String, Object> map = new HashMap<String, Object>();
        ReportQuery impl;
        if (dataPlugin.getEngine().getDeligate() instanceof IEngineImpl)
            impl = new ReportQueryImpl(engine) {

                @Override
                protected Out createOut(OutputStream stream) {
                    try {
                        return new Out(stream) {

                            @Override
                            public void print(Object object) {
                                if (!printVersion) {
                                    if (object instanceof Qualifier) {
                                        Engine engine = dataPlugin.getEngine();
                                        Element element = StandardAttributesPlugin.getElement(engine, ((Qualifier) object).getId());
                                        if (element == null) {
                                            print(object.toString());
                                        } else {
                                            String href = "rows/index.html?id=" + element.getId();
                                            print(getStartATeg(href, false, true));
                                            print(object.toString());
                                            print(getEndATeg());
                                        }
                                    } else if (object instanceof Code) {
                                        String href = "rows/index.html?id=" + ((Code) object).getElement().getId();
                                        print(getStartATeg(href, false, true));
                                        print(object.toString());
                                        print(getEndATeg());
                                    } else if (object instanceof com.ramussoft.database.common.Row) {
                                        String href = "rows/index.html?id=" + ((com.ramussoft.database.common.Row) object).getElementId();
                                        print(getStartATeg(href, false, true));
                                        print(object.toString());
                                        print(getEndATeg());
                                    } else
                                        super.print(object);
                                } else
                                    super.print(object);
                            }
                        };
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    }
                }
            };
        else
            impl = (ReportQuery) dataPlugin.getEngine();
        if (query != null)
            map.put("query", query);
        page = impl.getHTMLReport(report, map);
    } catch (Exception e1) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        java.io.PrintStream s = null;
        try {
            s = new java.io.PrintStream(stream, true, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        if (e1 instanceof DataException)
            s.println(((DataException) e1).getMessage(new MessageFormatter() {

                @Override
                public String getString(String key, Object[] arguments) {
                    return MessageFormat.format(ReportResourceManager.getString(key), arguments);
                }
            }));
        else {
            s.println("<pre>");
            e1.printStackTrace(s);
            s.println("</pre>");
        }
        s.flush();
        try {
            page = new String(stream.toByteArray(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        htmlStream.println(page);
        return null;
    }
    if (!printVersion) {
        htmlStream.println("<H4>" + report.getName() + "</H4>");
    }
    Source source = new Source(page);
    source.fullSequentialParse();
    htmlStream.println(source);
    return source;
}
Also used : HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Element(com.ramussoft.common.Element) MessageFormatter(com.ramussoft.report.data.MessageFormatter) Source(net.htmlparser.jericho.Source) Qualifier(com.ramussoft.common.Qualifier) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine) ReportQuery(com.ramussoft.report.ReportQuery) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Code(com.ramussoft.report.Code) DataException(com.ramussoft.report.data.DataException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IOException(java.io.IOException) ReportQueryImpl(com.ramussoft.report.ReportQueryImpl) Out(com.ramussoft.report.data.Out) DataException(com.ramussoft.report.data.DataException) IEngineImpl(com.ramussoft.core.impl.IEngineImpl) Row(com.ramussoft.pb.Row) NRow(com.ramussoft.pb.data.negine.NRow)

Example 3 with ReportQuery

use of com.ramussoft.report.ReportQuery in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method printReportsQ.

private void printReportsQ() throws IOException {
    final String sNum = params.get("num");
    if (sNum == null)
        printError(RES.getString("reportEror"));
    final long num = Long.parseLong(sNum);
    Element report = null;
    if ((report = dataPlugin.getEngine().getElement(num)) == null) {
        printError(RES.getString("reportEror"));
        return;
    }
    htmlTitle = RES.getString("reportQuaryFor") + ": " + report.getName();
    printStartD();
    Qualifier qualifier = ((ReportQuery) dataPlugin.getEngine()).getHTMLReportQuery(report);
    if (qualifier == null) {
        printReport(report, null);
    } else
        printReportQuary(qualifier, Long.toString(report.getId()));
    printEndD();
}
Also used : ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) Qualifier(com.ramussoft.common.Qualifier)

Example 4 with ReportQuery

use of com.ramussoft.report.ReportQuery in project ramus by Vitaliy-Yakovchuk.

the class HTTPParser method printReportsList.

/**
 * Друкує список звітів з посиланнями на них.
 *
 * @throws IOException
 */
protected void printReportsList() throws IOException {
    Engine engine = dataPlugin.getEngine();
    Qualifier qualifier = ReportPlugin.getReportsQualifier(engine);
    Attribute name = ReportPlugin.getReportNameAttribute(engine);
    RowSet rowSet = new RowSet(engine, qualifier, new Attribute[] { name }, null, true);
    List<Element> reports = ((ReportQuery) engine).getHTMLReports();
    if (reports.size() == 0)
        return;
    printMainTableTitle(RES.getString("reportsTitle"));
    for (com.ramussoft.database.common.Row element : rowSet.getAllRows()) {
        htmlStream.println("<tr>");
        htmlStream.println("<td colspan=2>");
        printStartATeg("reportsq/index.html?num=" + element.getElementId());
        htmlStream.println(element.getCode());
        printEndATeg();
        printStartATeg("reportsq/index.html?num=" + element.getElementId());
        htmlStream.print(element.getName());
        printEndATeg();
        htmlStream.println("</td>");
        htmlStream.println("</tr>");
    }
}
Also used : Attribute(com.ramussoft.common.Attribute) ReportQuery(com.ramussoft.report.ReportQuery) Element(com.ramussoft.common.Element) RowSet(com.ramussoft.database.common.RowSet) Qualifier(com.ramussoft.common.Qualifier) IEngine(com.ramussoft.common.IEngine) Engine(com.ramussoft.common.Engine)

Example 5 with ReportQuery

use of com.ramussoft.report.ReportQuery in project ramus by Vitaliy-Yakovchuk.

the class ReportEditorView method getHTMLText.

protected String getHTMLText() {
    String page;
    try {
        HashMap<String, Object> map = new HashMap<String, Object>();
        Query query = queryView.getQuery();
        if (query != null)
            map.put("query", query);
        page = ((ReportQuery) framework.getEngine()).getHTMLReport(element, map);
    } catch (Exception e1) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        PrintStream s = new PrintStream(stream);
        e1.printStackTrace();
        if (e1 instanceof DataException)
            s.println(((DataException) e1).getMessage(new MessageFormatter() {

                @Override
                public String getString(String key, Object[] arguments) {
                    return MessageFormat.format(ReportResourceManager.getString(key), arguments);
                }
            }));
        else {
            e1.printStackTrace(s);
        }
        s.flush();
        page = new String(stream.toByteArray());
    }
    return page;
}
Also used : PrintStream(java.io.PrintStream) DataException(com.ramussoft.report.data.DataException) ReportQuery(com.ramussoft.report.ReportQuery) Query(com.ramussoft.report.Query) HashMap(java.util.HashMap) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageFormatter(com.ramussoft.report.data.MessageFormatter) DataException(com.ramussoft.report.data.DataException) PrinterException(java.awt.print.PrinterException)

Aggregations

ReportQuery (com.ramussoft.report.ReportQuery)5 Element (com.ramussoft.common.Element)4 Qualifier (com.ramussoft.common.Qualifier)4 Engine (com.ramussoft.common.Engine)2 IEngine (com.ramussoft.common.IEngine)2 Row (com.ramussoft.pb.Row)2 NRow (com.ramussoft.pb.data.negine.NRow)2 Query (com.ramussoft.report.Query)2 DataException (com.ramussoft.report.data.DataException)2 MessageFormatter (com.ramussoft.report.data.MessageFormatter)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HashMap (java.util.HashMap)2 Attribute (com.ramussoft.common.Attribute)1 IEngineImpl (com.ramussoft.core.impl.IEngineImpl)1 RowSet (com.ramussoft.database.common.RowSet)1 Code (com.ramussoft.report.Code)1 ReportQueryImpl (com.ramussoft.report.ReportQueryImpl)1 Out (com.ramussoft.report.data.Out)1 PrinterException (java.awt.print.PrinterException)1 IOException (java.io.IOException)1