public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { res.setContentType("text/xml"); res.setHeader("Content-Disposition", "inline; filename=\"file.jrpxml\""); JRXmlExporter exporter = new JRXmlExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); //exporter.setParameter(JRExporterParameter.START_PAGE_INDEX, Integer.valueOf(1)); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".rtf"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRRtfExporter exporter = new JRRtfExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { res.setContentType("text/html;charset=UTF-8"); JRHtmlExporter exporter=new JRHtmlExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); req.getSession().setAttribute(BaseHttpServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); String path=req.getContextPath(); if(path.endsWith("/")){ path+="dorado/bdf2/jasperreports/html.image"; }else{ path+="/dorado/bdf2/jasperreports/html.image"; } exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,path+"?image="); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".pptx"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRPptxExporter exporter = new JRPptxExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".pdf"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRPdfExporter exporter = new JRPdfExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".csv"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRCsvExporter exporter = new JRCsvExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".docx"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRDocxExporter exporter = new JRDocxExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
public void export(HttpServletRequest req, HttpServletResponse res) throws Exception { String fileName=this.getExportFileName(req); fileName+=".xls"; res.setContentType("application/octet-stream"); res.setHeader("Connection", "close"); res.setHeader("Content-Disposition", "attachment;filename=\"" + new String(fileName.getBytes("utf-8"),"ISO-8859-1") + "\""); JRXlsExporter exporter = new JRXlsExporter(DefaultJasperReportsContext.getInstance()); JasperPrint jasperPrint=this.getJasperPrint(req); exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint); OutputStream ouputStream = res.getOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); try { exporter.exportReport(); } catch (JRException e) { throw new ServletException(e); } finally { if (ouputStream != null) { ouputStream.flush(); ouputStream.close(); } } }
/** * @see #viewReport(JasperReportsContext, InputStream, boolean, boolean, Locale, ResourceBundle) */ public static void viewReport( InputStream is, boolean isXMLFile, boolean isExitOnClose, Locale locale ) throws JRException { viewReport( DefaultJasperReportsContext.getInstance(), is, isXMLFile, isExitOnClose, locale, null ); }
public JRBasePart(JRPart part, JRBaseObjectFactory factory) { factory.put(part, this); this.uuid = part.getUUID(); this.propertiesMap = JRPropertiesMap.getPropertiesClone(part); this.printWhenExpression = factory.getExpression(part.getPrintWhenExpression()); this.partNameExpression = factory.getExpression(part.getPartNameExpression()); this.evaluationTime = part.getEvaluationTime(); componentKey = part.getComponentKey(); PartComponentManager manager = PartComponentsEnvironment.getInstance(DefaultJasperReportsContext.getInstance()).getManager(componentKey); component = manager.getComponentCompiler(DefaultJasperReportsContext.getInstance()).toCompiledComponent( part.getComponent(), factory); if (component instanceof JRVisitable) { ((JRVisitable) component).visit(factory); } }
private void initExcludeProperties() { JasperReportsContext context = jasperReportsContext == null ? DefaultJasperReportsContext.getInstance() : jasperReportsContext; List<PropertySuffix> excludeProperties = JRPropertiesUtil.getInstance(context).getProperties( PREFIX_EXCLUDE_PROPERTIES); excludePropertiesPattern = new ArrayList<Pattern>(excludeProperties.size()); for (PropertySuffix propertySuffix : excludeProperties) { String regex = propertySuffix.getValue(); Pattern pattern = Pattern.compile(regex); excludePropertiesPattern.add(pattern); } excludeUuids = JRPropertiesUtil.getInstance(context).getBooleanProperty(PROPERTY_EXCLUDE_UUIDS); }
/** * */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); if (sortFieldsMap == null) { sortFieldsMap = new HashMap<String, JRSortField>(); } if (sortFieldsList == null) { sortFieldsList = new ArrayList<JRSortField>(); } if (propertyExpressions == null) { propertyExpressions = new ArrayList<DatasetPropertyExpression>(); } @SuppressWarnings("resource") ContextClassLoaderObjectInputStream cclois = in instanceof ContextClassLoaderObjectInputStream ? (ContextClassLoaderObjectInputStream)in : null; if (cclois == null) { jasperReportsContext = DefaultJasperReportsContext.getInstance(); } else { jasperReportsContext = cclois.getJasperReportsContext(); } //the listener is serialized, but not added to the query. //serializing the listener does not make much sense, it could have been easily recreated. addQueryLanguageListener(); }
/** * */ public void fill() throws JRException { long start = System.currentTimeMillis(); JRDataSource datasource = createDataSource(DefaultJasperReportsContext.getInstance(), Locale.US); JasperFillManager.fillReportToFile("build/reports/FunctionsReport.jasper", null, datasource); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); }
/** * Return an {@link HtmlPrintElementFactory factory} instance. * * @return a HtmlPrintElementFactory instance * @throws JRException if the {@link #PROPERTY_HTML_PRINTELEMENT_FACTORY factory property} is not defined * or the factory cannot be instantiated. */ public static HtmlPrintElementFactory getHtmlPrintElementFactory() throws JRException { String factoryClassName = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(PROPERTY_HTML_PRINTELEMENT_FACTORY); if (factoryClassName == null) { factoryClassName = DefaultHtmlPrintElementFactory.class.getName(); } return cache.getCachedInstance(factoryClassName); }
/** * */ private static ChartUtil getDefaultInstance()//FIXMECONTEXT check this use of this { return new ChartUtil(DefaultJasperReportsContext.getInstance()); }
@Override public void contextInitialized(ServletContextEvent ce) { LocalJasperReportsContext localJasperReportsContext = new LocalJasperReportsContext(DefaultJasperReportsContext.getInstance()); SimpleFileResolver fileResolver = new SimpleFileResolver( new File( new File(ce.getServletContext().getRealPath("/")), ce.getServletContext().getInitParameter("net.sf.jasperreports.web.file.repository.root") ) ); localJasperReportsContext.setFileResolver(fileResolver); AbstractServlet.setJasperReportsContext(localJasperReportsContext); }
private static ExtensionsRegistry createDefaultRegistry() { String registryClass = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(PROPERTY_EXTENSIONS_REGISTRY_CLASS); if (log.isDebugEnabled()) { log.debug("Instantiating extensions registry class " + registryClass); } ExtensionsRegistry registry = (ExtensionsRegistry) ClassUtils. instantiateClass(registryClass, ExtensionsRegistry.class); return registry; }
/** * @see #createHandle(JasperReportsContext, JasperReport, Map) */ public static AsynchronousFillHandle createHandle( JasperReport jasperReport, Map<String,Object> parameters ) throws JRException { return createHandle(DefaultJasperReportsContext.getInstance(), jasperReport, parameters); }
@BeforeClass public void readJson() throws JRException { JsonNode tree = JsonUtil.parseJson(DefaultJasperReportsContext.getInstance(), "net/sf/jasperreports/jsonql/orders.json"); jrJsonNode = new JRJsonNode(null, tree); jsonQLExecuter = new DefaultJsonQLExecuter(); }
public JRBaseComponentElement(JRComponentElement element, JRBaseObjectFactory factory) { super(element, factory); componentKey = element.getComponentKey(); ComponentManager manager = ComponentsEnvironment.getInstance(DefaultJasperReportsContext.getInstance()).getManager(componentKey); component = manager.getComponentCompiler(DefaultJasperReportsContext.getInstance()).toCompiledComponent( element.getComponent(), factory); }
/** * Creates a fill dataset object. * @param filler the filler * @param dataset the template dataset * @param factory the fill object factory */ public JRFillDataset(BaseReportFiller filler, JRDataset dataset, JRFillObjectFactory factory) { factory.put(dataset, this); this.filler = filler; this.propertiesUtil = filler == null ? JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()) : filler.getPropertiesUtil(); this.parent = dataset; this.isMain = dataset.isMainDataset(); scriptletClassName = dataset.getScriptletClass(); resourceBundleBaseName = dataset.getResourceBundle(); whenResourceMissingType = dataset.getWhenResourceMissingTypeValue(); query = dataset.getQuery(); setParameters(dataset, factory); setFields(dataset, factory); setVariables(dataset, factory); setGroups(dataset, factory); staticProperties = dataset.hasProperties() ? dataset.getPropertiesMap().cloneProperties() : null; mergedProperties = staticProperties; DatasetPropertyExpression[] datasetPropertyExpressions = dataset.getPropertyExpressions(); propertyExpressions = datasetPropertyExpressions == null ? new ArrayList<DatasetPropertyExpression>(0) : new ArrayList<DatasetPropertyExpression>(Arrays.asList(datasetPropertyExpressions)); }
@Override public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties) { String root = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperty(properties, PROPERTY_FILE_REPOSITORY_ROOT); boolean resolveAbsolutePath = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBooleanProperty(properties, PROPERTY_FILE_REPOSITORY_RESOLVE_ABSOLUTE_PATH, false); return new SingletonExtensionRegistry<RepositoryService>(RepositoryService.class, new FileRepositoryService(DefaultJasperReportsContext.getInstance(), root, resolveAbsolutePath)); }
/** * @deprecated Replaced by {@link #createQueryExecuter(JasperReportsContext, JRDataset, Map)}. */ @Override public final JRQueryExecuter createQueryExecuter( JRDataset dataset, Map<String, ? extends JRValueParameter> parameters ) throws JRException { return createQueryExecuter(DefaultJasperReportsContext.getInstance(), dataset, parameters); }
public RenderableTypeEnum getRenderableType() { try { updateCache(DefaultJasperReportsContext.getInstance()); } catch (JRException e) { //ignore return RenderableTypeEnum.IMAGE; // arbitrary default; should not get here in normal cases } return renderableType; }
@Override public <T> List<T> getExtensions(Class<T> extensionType) { if (RepositoryService.class.equals(extensionType)) { return (List<T>) Collections.singletonList(new DefaultRepositoryService(DefaultJasperReportsContext.getInstance()));//FIXMEREPO check if this can be singleton } else if (PersistenceServiceFactory.class.equals(extensionType)) { return (List<T>) Collections.singletonList(DefaultRepositoryPersistenceServiceFactory.getInstance()); } return null; }
/** * @see #JRViewer(JasperReportsContext, JasperPrint, Locale, ResourceBundle) */ public JRViewer(JasperPrint jrPrint, Locale locale, ResourceBundle resBundle) { this( DefaultJasperReportsContext.getInstance(), jrPrint, locale, resBundle ); }
/** * @deprecated Replaced by {@link #setComponentsInternalEntityResources(JasperReportsContext, JRXmlDigester)}. */ public static void setComponentsInternalEntityResources( JRXmlDigester digester ) { setComponentsInternalEntityResources(DefaultJasperReportsContext.getInstance(), digester); }
private void initInternalResources() { internalEntityResources = new HashMap<String, URL>(); entityURLs = new HashSet<String>(); //FIXME only add entities relevant to the current document type (report, print, template) addEntityResource(JRXmlConstants.JASPERREPORT_SYSTEM_ID, JRXmlConstants.JASPERREPORT_DTD); addEntityResource(JRXmlConstants.JASPERPRINT_SYSTEM_ID, JRXmlConstants.JASPERPRINT_DTD); addEntityResource(JRXmlConstants.JASPERTEMPLATE_SYSTEM_ID, JRXmlConstants.JASPERTEMPLATE_DTD); addEntityResource(JRXmlConstants.JASPERREPORT_XSD_SYSTEM_ID, JRXmlConstants.JASPERREPORT_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERREPORT_XSD_DTD_COMPAT_RESOURCE); addEntityResource(JRXmlConstants.JASPERPRINT_XSD_SYSTEM_ID, JRXmlConstants.JASPERPRINT_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERPRINT_XSD_DTD_COMPAT_RESOURCE); addEntityResource(JRXmlConstants.JASPERTEMPLATE_XSD_SYSTEM_ID, JRXmlConstants.JASPERTEMPLATE_XSD_RESOURCE); addEntityResource(null, JRXmlConstants.JASPERTEMPLATE_XSD_DTD_COMPAT_RESOURCE); loadUnknownEntities = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getBooleanProperty( PROPERTY_LOAD_UNKNOWN_ENTITIES, false); }
private PhantomJS() { INSTANTIATED = true; this.jasperReportsContext = DefaultJasperReportsContext.getInstance(); this.scriptManager = new ScriptManager(jasperReportsContext); this.processDirector = new ProcessDirector(jasperReportsContext, this.scriptManager); }
/** * @see #write(JRReport, String) */ public static void writeReport( JRReport report, String destFileName ) throws JRException { new JRApiWriter(DefaultJasperReportsContext.getInstance()).write(report, destFileName); }
/** * @see #write(JRReport, OutputStream) */ public static void writeReport( JRReport report, OutputStream outputStream ) throws JRException { new JRApiWriter(DefaultJasperReportsContext.getInstance()).write(report, outputStream); }
/** * */ public static void main(String[] args) { if(args.length < 2) { System.out.println( "JRApiWriter usage:" ); System.out.println( "\tjava JRApiWriter reportCreatorClassName file" ); return; } String reportCreatorClassName = args[0]; String destFileName = args[1]; try { Class<?> reportCreatorClass = Class.forName(reportCreatorClassName); ReportCreator reportCreator = (ReportCreator)reportCreatorClass.newInstance(); JasperDesign jasperDesign = reportCreator.create(); new JRXmlWriter(DefaultJasperReportsContext.getInstance()).write(jasperDesign, destFileName, "UTF-8"); } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Error running report creator class : " + reportCreatorClassName, e); } } }
/** * @see #JRViewer(InputStream, boolean, Locale, ResourceBundle) */ public JRViewer(InputStream is, boolean isXML, Locale locale, ResourceBundle resBundle) throws JRException { this( DefaultJasperReportsContext.getInstance(), is, isXML, locale, resBundle ); }
protected static synchronized void registerFonts () { if (!fontsRegistered) { List<PropertySuffix> fontFiles = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperties(PDF_FONT_FILES_PREFIX);//FIXMECONTEXT no default here and below if (!fontFiles.isEmpty()) { for (Iterator<PropertySuffix> i = fontFiles.iterator(); i.hasNext();) { JRPropertiesUtil.PropertySuffix font = i.next(); String file = font.getValue(); if (file.toLowerCase().endsWith(".ttc")) { FontFactory.register(file); } else { String alias = font.getSuffix(); FontFactory.register(file, alias); } } } List<PropertySuffix> fontDirs = JRPropertiesUtil.getInstance(DefaultJasperReportsContext.getInstance()).getProperties(PDF_FONT_DIRS_PREFIX); if (!fontDirs.isEmpty()) { for (Iterator<PropertySuffix> i = fontDirs.iterator(); i.hasNext();) { JRPropertiesUtil.PropertySuffix dir = i.next(); FontFactory.registerDirectory(dir.getValue()); } } fontsRegistered = true; } }
@Override public void render( Graphics2D grx, Rectangle2D rectangle ) throws JRException { render(DefaultJasperReportsContext.getInstance(), grx, rectangle); }
@Override public Dimension2D getDimension() throws JRException { return getDimension(DefaultJasperReportsContext.getInstance()); }
/** * @see #JRCsvExporter(JasperReportsContext) */ public JRCsvExporter() { this(DefaultJasperReportsContext.getInstance()); }
/** * @deprecated Replaced by {@link PieChartXmlWriter#PieChartXmlWriter(JasperReportsContext)}. */ public PieChartXmlWriter() { super(DefaultJasperReportsContext.getInstance()); }
protected JRVirtualizationContext createVirtualizationContext() { return new JRVirtualizationContext(DefaultJasperReportsContext.getInstance()); }
/** * @deprecated Replaced by {@link HtmlComponentXmlWriter#HtmlComponentXmlWriter(JasperReportsContext)}. */ public HtmlComponentXmlWriter() { super(DefaultJasperReportsContext.getInstance()); }