本文整理汇总了Java中org.eclipse.birt.report.engine.api.IRunAndRenderTask类的典型用法代码示例。如果您正苦于以下问题:Java IRunAndRenderTask类的具体用法?Java IRunAndRenderTask怎么用?Java IRunAndRenderTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRunAndRenderTask类属于org.eclipse.birt.report.engine.api包,在下文中一共展示了IRunAndRenderTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderPDFReport
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
@Override
public void renderPDFReport(String reportName,
Map<String, Object> parameters, OutputStream out)
throws BirtReportException {
try {
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask(
reportName);
injectParameters(parameters, runAndRenderTask);
PDFRenderOption pdfOptions = new PDFRenderOption();
pdfOptions.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF);
pdfOptions.setOutputStream(out);
pdfOptions.setEmbededFont(true); // TODO idueppe - should be
// configurable from cockpit
pdfOptions.setImageHandler(new HTMLServerImageHandler());
runAndRenderTask(runAndRenderTask, pdfOptions);
} catch (EngineException | IOException e) {
throw new RenderReportException("pdf", reportName, e);
}
}
示例2: renderExcelReport
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
@Override
public void renderExcelReport(String reportName,
Map<String, Object> parameters, OutputStream out)
throws BirtReportException {
try {
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask(
reportName);
injectParameters(parameters, runAndRenderTask);
EXCELRenderOption excelRenderOptions = new EXCELRenderOption();
excelRenderOptions.setOutputFormat("xlsx");
excelRenderOptions.setOutputStream(out);
excelRenderOptions.setEnableMultipleSheet(true);
// TODO idueppe - should be configurable from cockpit
excelRenderOptions.setHideGridlines(true);
// TODO idueppe - should be configurable from cockpit
// excelRenderOptions.setOfficeVersion();
// TODO idueppe - should be configurable from cockpit
excelRenderOptions.setImageHandler(new HTMLServerImageHandler());
runAndRenderTask(runAndRenderTask, excelRenderOptions);
} catch (EngineException | IOException e) {
throw new RenderReportException("excel", reportName, e);
}
}
示例3: setRunAndRenderOption
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
public void setRunAndRenderOption( String inputFile, String inputName,
String boolVar1, String boolVar2 ) throws Exception
{
copyResource_INPUT( inputName + ".rptdesign", inputName + ".rptdesign" );
IReportRunnable runnable = engine
.openReportDesign( new FileInputStream( new File( inputFile ) ) );
IRunAndRenderTask task = engine.createRunAndRenderTask( runnable );
IPDFRenderOption option = new PDFRenderOption( );
option.setOutputFileName( outputPath + inputName + "_" + boolVar1 + "_"
+ boolVar2 + ".pdf" );
option.setOutputFormat( "pdf" );
option.setOption( option.FIT_TO_PAGE, new Boolean( boolVar1 ) );
option.setOption( option.PAGEBREAK_PAGINATION_ONLY, new Boolean(
boolVar2 ) );
task.setRenderOption( option );
task.run( );
task.close( );
}
示例4: runandrender_emitter
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* @param format
* render format
* @param pagination
* For html output only, decide whether generate report with page
* break or not.
* @throws EngineException
*/
protected ArrayList runandrender_emitter( String format, boolean pagination )
throws EngineException
{
IReportRunnable reportRunnable = engine.openReportDesign( inPath
+ getReportName( ) );
IRunAndRenderTask task = engine.createRunAndRenderTask( reportRunnable );
RenderOption options = new HTMLRenderOption( );
options.setOutputFormat( format );
if ( format.equals( EMITTER_HTML ) )
{
( (HTMLRenderOption) options ).setHtmlPagination( pagination );
}
HashMap appContext = new HashMap( );
appContext.put( "emitter_class", this );
task.setAppContext( appContext );
task.setRenderOption( options );
task.run( );
ArrayList errors = (ArrayList) task.getErrors( );
task.close( );
return errors;
}
示例5: runAndRender
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* Run and render the report, and return the render result.
*
* @param designFile
* @return render result.
* @throws EngineException
* @throws IOException
*/
protected String runAndRender( String designFile ) throws EngineException,
IOException
{
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( designFile );
HTMLRenderOption options = new HTMLRenderOption( );
ByteArrayOutputStream out = new ByteArrayOutputStream( );
options.setOutputStream( out );
options.setOutputFormat( "html" );
options.setHtmlPagination( true );
runAndRenderTask.setRenderOption( options );
runAndRenderTask.run( );
runAndRenderTask.close( );
String result = new String( out.toByteArray( ) );
out.close( );
return result;
}
示例6: testHyphenation
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* Test case for bugzilla bug <a
* href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=181578">181578</a> :
* Exception is thrown when preview attached report in PDF[1102]
*
* @throws EngineException
*/
public void testHyphenation() throws EngineException
{
String designFile = "org/eclipse/birt/report/engine/layout/pdf/181578.xml";
try
{
IReportRunnable report = openReportDesign( designFile );
List pageAreas = new ArrayList();
IEmitterMonitor monitor = new PageMonitor(pageAreas);
IRunAndRenderTask runAndRenderTask = new TestRunAndRenderTask( engine,
report, monitor );
runAndRenderTask.setLocale( Locale.CHINA );
runAndRenderTask.setRenderOption( createRenderOption() );
runAndRenderTask.run( );
runAndRenderTask.close( );
}
catch(Throwable t)
{
System.out.println(t);
assertTrue(false);
}
assertTrue(true);
}
示例7: setParameter
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
private void setParameter(IRunAndRenderTask task, String name, String fieldType, JsonValue val) {
Class<?> clz = lookupParameterType(fieldType);
Object value = extractJsonValue(val, clz);
if(value instanceof Object[]){
Object[] values = (Object[]) value;
String[] displayText = new String[values.length];
for(int i = 0; i < displayText.length; i++){
displayText[i] = String.valueOf(values[i]);
}
task.setParameter(name, values, displayText);
}
else {
task.setParameter(name, value, String.valueOf(value));
}
}
示例8: createRunAndRenderTask
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
private IRunAndRenderTask createRunAndRenderTask(String reportName)
throws EngineException, IOException {
String reportFileName = absolutePathOf(reportFileName(reportName));
IReportRunnable iReportRunnable = reportEngine
.openReportDesign(reportFileName);
IRunAndRenderTask task = reportEngine
.createRunAndRenderTask(iReportRunnable);
injectLocale(task);
return task;
}
示例9: renderMergedOutputModel
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
InputStream reportPath = null;
try {
reportPath = getServletContext()
.getResourceAsStream(getUrl());
if (reportPath == null) {
reportPath = new ClassPathResource(getUrl()).getInputStream();
}
IReportRunnable report = reportEngine.openReportDesign(getUrl(), reportPath);
IRunAndRenderTask task = reportEngine.createRunAndRenderTask(report);
task.setLocale(request.getLocale());
for (Map.Entry<String, Object> e : model.entrySet()) {
task.setParameterValue(e.getKey(), e.getValue());
}
RenderOption opts = buildRenderOptions(request, response);
response.setContentType(getContentType());
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
task.setRenderOption(opts);
task.run();
task.close();
} finally {
if (reportPath != null) {
reportPath.close();
}
}
}
示例10: testIEmitterServices
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* Test IEmitterServices methods.
*
* @throws BirtException
*/
public void testIEmitterServices( ) throws BirtException
{
EngineConfig config = new EngineConfig( );
emitterConfig = new HTMLEmitterConfig( );
config.setEmitterConfiguration( EMITTER_HTML, emitterConfig );
emitterConfig = config.getEmitterConfigs( ).get( EMITTER_HTML );
Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
IReportEngine reportEngine = factory.createReportEngine( config );
IReportRunnable reportRunnable = engine.openReportDesign( this
.genInputFile( report ) );
IRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( EMITTER_HTML );
options.setOutputFileName( this.genOutputFile( "myService.html" ) );
HTMLRenderContext renderContext = new HTMLRenderContext( );
renderContext.setImageDirectory( "myImage" ); //$NON-NLS-1$
HashMap appContext = new HashMap( );
appContext.put(
EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext );
appContext.put( "emitter_class", this );
IRunAndRenderTask rrTask = reportEngine
.createRunAndRenderTask( reportRunnable );
rrTask.setRenderOption( options );
rrTask.setAppContext( appContext );
rrTask.run( );
rrTask.close( );
}
示例11: testRunAndRenderTask
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* Test methods in RunAndRenderTask class
*/
public void testRunAndRenderTask( ) throws EngineException
{
String input = this.genInputFile( "report_engine.rptdesign" );
try
{
IReportRunnable runnable = engine
.openReportDesign( new FileInputStream( new File( input ) ) );
IRunAndRenderTask task = engine.createRunAndRenderTask( runnable );
// validateParameters
assertTrue( task.validateParameters( ) );
// set/getRenderOption
RenderOptionBase option = new RenderOptionBase( ), optionGet;
task.setRenderOption( option );
optionGet = (RenderOptionBase) task.getRenderOption( );
assertEquals( "set/getRenderOption fail", option, optionGet );
// parameters
HashMap hm = new HashMap( ), hmGet;
task.setParameterValues( hm );
hmGet = task.getParameterValues( );
assertEquals( "set/getParameterValues(hashmap) fail", hm, hmGet );
task.setParameterValue( "p1", "p1value" );
assertEquals( "Set/getParameterValues fail", task
.getParameterValues( )
.get( "p1" ), "p1value" );
}
catch ( FileNotFoundException e )
{
e.printStackTrace( );
}
}
示例12: runAndRender_WithPagination
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
private List runAndRender_WithPagination( String inputFile, String outputFile )
throws EngineException
{
IReportRunnable runnable = engine.openReportDesign( inputFile );
IRunAndRenderTask task = engine.createRunAndRenderTask( runnable );
task.setLocale( Locale.ENGLISH );
IRenderOption options = new HTMLRenderOption( );
options.setOutputFileName( outputFile );
( (HTMLRenderOption) options ).setHtmlPagination( true );
HTMLRenderContext renderContext = new HTMLRenderContext( );
renderContext.setImageDirectory( "image" ); //$NON-NLS-1$
HashMap appContext = new HashMap( );
appContext.put( EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext );
task.setAppContext( appContext );
options.setOutputFormat( "html" ); //$NON-NLS-1$
options.getOutputSetting( )
.put( HTMLRenderOption.URL_ENCODING, "UTF-8" ); //$NON-NLS-1$
task.setRenderOption( options );
task.run( );
List errors = task.getErrors( );
task.close( );
return errors;
}
示例13: createRunAndRenderTask
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
protected IRunAndRenderTask createRunAndRenderTask( String designFileName )
throws EngineException
{
useDesignFile( designFileName );
IReportRunnable reportRunnable = engine
.openReportDesign( REPORT_DESIGN );
return engine.createRunAndRenderTask( reportRunnable );
}
示例14: runAndRender
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
public void runAndRender( String design, IRenderOption options )
throws EngineException
{
IReportRunnable reportRunnable = engine.openReportDesign( design );
IRunAndRenderTask runAndRenderTask = engine
.createRunAndRenderTask( reportRunnable );
runAndRenderTask.setRenderOption( options );
runAndRenderTask.run( );
runAndRenderTask.close( );
}
示例15: testRenderReport
import org.eclipse.birt.report.engine.api.IRunAndRenderTask; //导入依赖的package包/类
/**
* Test if text with underline, line-through or overline, uri
* images(bmp,gif,jpg,png,tif),url images(gif), embeded
* images(bmp,gif,jpg,png,tif), and report design with page breaks can be
* correctly rendered. <br>
* <br>
* The result PS files have same names as the respective report design, and
* are put in folder named "testresult" under current working folder. For
* Eclipse, the current working folder is normally the folder where Eclipse
* is installed. <br>
* <b>To check the results, every result files should be checked manually.</b>
* @throws Exception
*/
public void testRenderReport( ) throws Exception
{
if ( isOnWindows( ) )
{
String thePackage = "org/eclipse/birt/report/engine/emitter/postscript/";
String[] designs = new String[]{"underline", "uriImages",
"urlImages", "pageBreak", "embededImages", "svgImages",
"pageBackgroundColor", "lableWithBorder",
"pageBackgroundImage", "gridBackgroundImage",
"pageBackgroundImageNoRepeat",
"pageBackgroundImageRepeatX", "pageBackgroundImageRepeatY"};
String suffix = ".rptdesign";
HTMLRenderOption options = new HTMLRenderOption( );
options.setOutputFormat( "postscript" );
String resultFolder = "testresult/";
for ( int i = 0; i < designs.length; i++ )
{
options.setOutputFileName( resultFolder + designs[i] + ".ps" );
String design = thePackage + designs[i] + suffix;
IRunAndRenderTask runAndRenderTask = createRunAndRenderTask( design );
runAndRenderTask.setRenderOption( options );
runAndRenderTask.run( );
runAndRenderTask.close( );
}
System.out.println( "please check result manually in folder : "
+ new File( resultFolder ).getAbsolutePath( ) );
}
}