Search in sources :

Example 1 with NoRowsException

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

the class XMLReportEngine method execute.

@Override
public void execute(String path, OutputStream stream, Map<String, Object> parameters) throws IOException {
    createOut(stream);
    Query query = (Query) parameters.get("query");
    this.data = new Data(engine, query);
    try {
        final SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser parser;
        parser = factory.newSAXParser();
        byte[] bs = engine.getStream(path);
        if (bs == null)
            throw new DataException("Error.reportEmpty", "Report's form is empty");
        do {
            try {
                parser.parse(new ByteArrayInputStream(bs), new ReportHandler());
            } catch (NoRowsException e) {
                break;
            }
            if (null == data.getBaseRows())
                break;
            connectedLabels.clear();
            if (data.isSameBaseQualifier())
                break;
        } while (data.getBaseRows().next() != null);
    } catch (ParserConfigurationException e) {
        throw new DataException(e);
    } catch (SAXException e) {
        throw new DataException(e);
    }
    if (out.checkError())
        throw new IOException();
    out.flush();
    out.realWrite();
}
Also used : DataException(com.ramussoft.report.data.DataException) ByteArrayInputStream(java.io.ByteArrayInputStream) NoRowsException(com.ramussoft.report.xml.NoRowsException) SAXParser(javax.xml.parsers.SAXParser) Data(com.ramussoft.report.data.Data) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) SAXParserFactory(javax.xml.parsers.SAXParserFactory) SAXException(org.xml.sax.SAXException)

Example 2 with NoRowsException

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

the class Data method getBaseRowByQualifier.

public Row getBaseRowByQualifier(String baseQualifierName) {
    if (baseRows == null) {
        baseRows = getRows(baseQualifierName);
        if (query != null) {
            List<Element> elements = query.getElements();
            if (elements != null) {
                for (int i = baseRows.size() - 1; i >= 0; i--) {
                    Row row = baseRows.get(i);
                    if (elements.indexOf(row.getElement()) < 0)
                        baseRows.remove(i);
                }
            }
        }
        if (baseRows.size() == 0)
            throw new NoRowsException();
        baseRows.next();
    } else {
        if (!baseQualifierName.equals(baseRows.getQualifierName())) {
            throw new DataException("Error.differentBaseQualifiers", "Report contains diffetents base qualifiers in queries", baseQualifierName, baseRows.getQualifierName());
        }
    }
    return baseRows.getCurrent();
}
Also used : Element(com.ramussoft.common.Element) NoRowsException(com.ramussoft.report.xml.NoRowsException)

Aggregations

NoRowsException (com.ramussoft.report.xml.NoRowsException)2 Element (com.ramussoft.common.Element)1 Data (com.ramussoft.report.data.Data)1 DataException (com.ramussoft.report.data.DataException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 SAXException (org.xml.sax.SAXException)1