use of com.netsteadfast.greenstep.po.hbm.TbSysJreport in project bamboobsc by billchen198318.
the class JReportUtils method fillReportToResponse.
public static void fillReportToResponse(String reportId, Map<String, Object> paramMap, HttpServletResponse response) throws ServiceException, Exception {
if (StringUtils.isBlank(reportId)) {
throw new java.lang.IllegalArgumentException("error, reportId is blank");
}
TbSysJreport sysJreport = new TbSysJreport();
sysJreport.setReportId(reportId);
DefaultResult<TbSysJreport> result = sysJreportService.findEntityByUK(sysJreport);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
sysJreport = result.getValue();
String jasperFileFullPath = Constants.getDeployJasperReportDir() + "/" + sysJreport.getReportId() + "/" + sysJreport.getReportId() + ".jasper";
File jasperFile = new File(jasperFileFullPath);
if (!jasperFile.exists()) {
jasperFile = null;
throw new Exception("error, Files are missing : " + jasperFileFullPath);
}
InputStream reportSource = new FileInputStream(jasperFile);
Connection conn = null;
try {
conn = DataUtils.getConnection();
ServletOutputStream ouputStream = response.getOutputStream();
JasperPrint jasperPrint = JasperFillManager.fillReport(reportSource, paramMap, conn);
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "inline; filename=" + sysJreport.getReportId() + ".pdf");
JRPdfExporter jrPdfExporter = new JRPdfExporter();
jrPdfExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
jrPdfExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(ouputStream));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
jrPdfExporter.setConfiguration(configuration);
configuration.setOwnerPassword(Constants.getEncryptorKey1());
jrPdfExporter.exportReport();
ouputStream.flush();
ouputStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
DataUtils.doReleaseConnection(conn);
if (null != reportSource) {
try {
reportSource.close();
} catch (IOException e) {
e.printStackTrace();
}
}
reportSource = null;
jasperFile = null;
}
}
use of com.netsteadfast.greenstep.po.hbm.TbSysJreport in project bamboobsc by billchen198318.
the class JReportUtils method deployReport.
public static void deployReport(SysJreportVO report) throws Exception {
TbSysJreport destReportObj = new TbSysJreport();
BeanUtils.copyProperties(destReportObj, report);
deployReport(destReportObj);
}
use of com.netsteadfast.greenstep.po.hbm.TbSysJreport in project bamboobsc by billchen198318.
the class JReportUtils method deploy.
public static void deploy() throws ServiceException, Exception {
logger.info("begin deploy...");
List<TbSysJreport> reports = sysJreportService.findListByParams(null);
String reportDeployDirName = Constants.getDeployJasperReportDir() + "/";
File reportDeployDir = new File(reportDeployDirName);
try {
if (reportDeployDir.exists()) {
logger.warn("delete " + reportDeployDirName);
FileUtils.forceDelete(reportDeployDir);
}
logger.warn("mkdir " + reportDeployDirName);
FileUtils.forceMkdir(reportDeployDir);
for (TbSysJreport report : reports) {
deployReport(report);
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage().toString());
}
reportDeployDir = null;
logger.info("end deploy...");
}
Aggregations