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();
}
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;
}
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();
}
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>");
}
}
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;
}
Aggregations