Search in sources :

Example 1 with ReportProcessor

use of net.sf.compilo.report.ReportProcessor in project adempiere by adempiere.

the class Process method getJasperReportPrint.

//	fillParameter
/*
	static ReportServer server = null;
	
	private void jasperReport(HttpServletRequest request, HttpServletResponse response, Properties ctx, int AD_Process_ID, int AD_Instance_ID) throws Exception
	{
	
		MProcess process = MProcess.get (ctx, AD_Process_ID);
		//	need to check if Role can access
		if (process == null)
			throw new Exception( "Brak procesu" );
		
		MPInstance pInstance = new MPInstance( ctx, AD_Instance_ID, null );
		if (pInstance == null)
			throw new Exception( "Brak intancji procesu" );
		
		ProcessInfo pi = new ProcessInfo (process.getName(), process.getAD_Process_ID());
		pi.setAD_User_ID(pInstance.getAD_User_ID());
		pi.setAD_Client_ID(pInstance.getAD_Client_ID());
		pi.setAD_PInstance_ID(pInstance.getAD_PInstance_ID());
		pi.setRecord_ID( pInstance.getRecord_ID()  );
		
		jasperReport( request, response, ctx, pi);
	}
	*/
/**
	 * Procedura obsluguje raporty jasper - przekazuje wynik raportu w postaci PDF
	 * @param request
	 * @param response
	 * @param ctx
	 * @param pi
	 */
/*
	private void jasperReport(HttpServletRequest request, HttpServletResponse response, Properties ctx, ProcessInfo pi)
	{
		try
		{
				JasperPrint jasperPrint = getJasperReportPrint( ctx, pi );
	        	
	        	ServletOutputStream output = response.getOutputStream();
	        	net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(jasperPrint, output);
	        	
	        	int bufferSize = 2048; //	2k Buffer
	        	
	        	//response.setContentType(mimeType.getMimeType());
				response.setBufferSize(bufferSize);
				
	        	response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
	        	response.setHeader("Pragma","no-cache"); //HTTP 1.0
	        	response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
				
				response.setContentType( "application/pdf" );
				
				//response.setHeader("Content-disposition","inline;filename=generated.pdf");		
				//	response.setHeader("Pragma","no-cache");	
				//	response.setHeader("Cache-Control", "no-cache");
				//	response.setHeader("Cache-Control","no-store" );
				//	response.setDateHeader("Expires", -1);
				//	response.setHeader("Content-Type","application/pdf" );
				//response.setContentType( "application/pdf" );
				//response.setHeader("Content-Type","application/pdf" );
								
								
	        	output.flush();
	        	output.close();

	        	
	        }        
	        catch (JRException e)
	        {
	            log.saveError("ReportStarter.startProcess: Can not run report - ", e);
	            return;
	            //return e.getMessage();
	        }
	        catch (Exception ex)
			{
	        	log.saveError("ReportStarter.startProcess: Can not run report - ", ex);
	        	return;
	        	// return ex.getMessage();
			}
		
		
	}
	
	*/
private static JasperPrint getJasperReportPrint(Properties ctx, ProcessInfo pi) {
    // lokalnie czy zdalnie
    boolean local = true;
    try {
        Env.setContext(ctx, "#AD_Language", "pl_PL");
        Env.setContext(Env.getCtx(), "#AD_Language", "pl_PL");
        JasperPrint jasperPrint;
        ReportProcessor rp = new ReportProcessor(ctx, pi);
        jasperPrint = rp.runReport();
        if (jasperPrint == null) {
            log.finer("ReportStarter.startProcess Cannot process JasperPrint Object");
            return null;
        } else
            return jasperPrint;
    } catch (Exception ex) {
        log.saveError("ReportStarter.startProcess: Can not run report - ", ex);
        return null;
    // return ex.getMessage();
    }
}
Also used : JasperPrint(net.sf.jasperreports.engine.JasperPrint) ReportProcessor(net.sf.compilo.report.ReportProcessor) SQLException(java.sql.SQLException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ReportProcessor (net.sf.compilo.report.ReportProcessor)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1