private void getSubreport() { JRSubreport sr = (JRSubreport) dto.getProp1(); if (sr.getExpression() != null) { String path = sr.getExpression().getText(); path = path.replace("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$ JRBaseReport jd = getFromJRXML(path.replaceAll(".jasper", ".jrxml")); if (jd == null) jd = getFromJasper(path); if (jd != null) { JRParameter[] prms = jd.getParameters(); for (JRParameter p : prms) srcParamNames.add(p.getName()); } } }
private JRBaseReport getFromJasper(String path) { InputStream in = null; JRBaseReport jd = null; try { in = RepositoryUtil.getInstance(dto.getjConfig()).getInputStreamFromLocation(path); if (in != null) { Object obj = JRLoader.loadObject(in); if (obj instanceof JasperReport) jd = (JasperReport) obj; } } catch (Exception e) { // e.printStackTrace(); } finally { FileUtils.closeStream(in); } return jd; }
private JRBaseReport getFromJRXML(String path) { InputStream in = null; JRBaseReport jd = null; try { in = RepositoryUtil.getInstance(dto.getjConfig()).getInputStreamFromLocation(path); if (in != null) { InputSource is = new InputSource(new InputStreamReader(in, "UTF-8")); jd = new JRXmlLoader(dto.getjConfig(), JasperReportsConfiguration.getJRXMLDigester()).loadXML(is); } } catch (Exception e) { // e.printStackTrace(); } finally { FileUtils.closeStream(in); } return jd; }
/** * Instantiates a new page figure. * * @param jd the jasper design * @param viewMargins if the margins are visible * @param page the parent page */ public ReportPageFigure(JRBaseReport jd, boolean viewMargins, PageEditPart page) { super(viewMargins, page); this.jrDesign = jd; }