Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » org.eclipse.birt.core.archive.FolderArchive Example?
org.eclipse.birt.core.archive.FolderArchive Example? [message #870450] Tue, 08 May 2012 09:54 Go to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello,

I'm trieing to use the FolderArchive to manage my ReportDocuments.
Example:
FolderArchive archive = new FolderArchive("c:\\temp\\Documents");
// IRunTask
runTask.run((IDocArchiveWriter) archive);
IReportDocument rptdoc = getReportEngine().openReportDocument(null, archive, null);


This never returns a document able to render. The render result is always a blank PDF (when rendering PDF).

Is there a example how the FolderArchive should work? Do I have to use one for each executed task? Or is it meant to work as a container for more then one job?

Thanks!
Jan
Re: org.eclipse.birt.core.archive.FolderArchive Example? [message #870584 is a reply to message #870450] Tue, 08 May 2012 20:37 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Jan

Try something like the following:

package REAPI;



import java.util.HashMap;
import java.util.Locale;

import org.eclipse.birt.core.archive.FolderArchiveReader;
import org.eclipse.birt.core.archive.FolderArchiveWriter;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IRenderTask;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.birt.report.engine.api.PDFRenderOption;

import com.lowagie.text.pdf.PdfReader;


public class RunThenRenderFolderArchive {

public void runReport() throws EngineException
{

IReportEngine engine=null;
EngineConfig config = null;
IReportDocument document = null;
try{
config = new EngineConfig( );

config.setBIRTHome("C:\\birt\\birt-runtime-2_6_1\\birt-runtime-2_6_1\\reportEngine");
Platform.startup( config );

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(
IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );



FolderArchiveWriter faw = new
FolderArchiveWriter("c:/test/myfolderarchive");
FolderArchiveReader far = new
FolderArchiveReader("c:/test/myfolderarchive");

IReportRunnable design = null;
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
IRunTask task = engine.createRunTask(design);
task.setLocale(new Locale("en", "US"));
task.run(faw);
task.close();

document = engine.openReportDocument(far.getName(), far, new HashMap(
));



//HTMLRenderOption options = new HTMLRenderOption();
//options.setOutputFormat("ppt");
//options.setOutputFileName("output/resample/topnpercent.ppt");
//options.setSupportedImageFormats("PNG;GIF;JPG;BMP;SWF;SVG");

PDFRenderOption options = new PDFRenderOption();
options.setOutputFileName("output/resample/topnpercentFA.pdf");
options.setOutputFormat("pdf");




IRenderTask rtask = engine.createRenderTask(document);
rtask.setLocale(new Locale("en", "US"));
rtask.setRenderOption(options);
rtask.render();
rtask.close();
document.close();
engine.destroy();

System.out.println("Finished");
}catch( Exception ex){
ex.printStackTrace();
}
finally
{
Platform.shutdown( );
System.out.println("Finished");
}

}


/**
* @param args
*/
public static void main(String[] args) {
try
{

RunThenRenderFolderArchive ex = new RunThenRenderFolderArchive( );
ex.runReport();

}
catch ( Exception e )
{
e.printStackTrace();
}
}

}


On 5/8/2012 5:54 AM, Jan Kohnert wrote:
> Hello,
>
> I'm trieing to use the FolderArchive to manage my ReportDocuments.
> Example:
>
> FolderArchive archive = new FolderArchive("c:\\temp\\Documents");
> // IRunTask
> runTask.run((IDocArchiveWriter) archive);
> IReportDocument rptdoc = getReportEngine().openReportDocument(null,
> archive, null);
>
>
> This never returns a document able to render. The render result is
> always a blank PDF (when rendering PDF).
>
> Is there a example how the FolderArchive should work? Do I have to use
> one for each executed task? Or is it meant to work as a container for
> more then one job?
>
> Thanks!
> Jan
Re: org.eclipse.birt.core.archive.FolderArchive Example? [message #870702 is a reply to message #870584] Wed, 09 May 2012 11:57 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Thank you Jason.

I there a way to get a IReportDocument without using files but the memory instead?

Do I have to create one folder writer / reader for each document or can it be used as a container?

Jan
Re: org.eclipse.birt.core.archive.FolderArchive Example? [message #870814 is a reply to message #870702] Wed, 09 May 2012 18:49 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Jan,

I do not know of a way to write the rptdoc in memory unless you wanted
to use something like a MappedByteBuffer.

The folder writer is writing the contents of the rptdocument, so you
will probably need to do a dropStream first.

Jason

On 5/9/2012 7:58 AM, Jan Kohnert wrote:
> Thank you Jason.
>
> I there a way to get a IReportDocument without using files but the
> memory instead?
>
> Do I have to create one folder writer / reader for each document or can
> it be used as a container?
>
> Jan
Re: org.eclipse.birt.core.archive.FolderArchive Example? [message #884990 is a reply to message #870814] Tue, 12 June 2012 08:25 Go to previous messageGo to next message
Jan Kohnert is currently offline Jan KohnertFriend
Messages: 196
Registered: July 2009
Senior Member
Hello,

I wrote an IDocArchiveReader and IDocArchiveWriter implementation that uses memory byte fields only to create a document. It passed all my tests. However, I cannot assure that everything works with it! Especially the listStreams:relativePath. String method remains untested since all my tests return an empty list here (also when using FolderArchive). So I only return any stream that contains the relativePath String at this point without knowing if this is a correct behavior.
The call is done like this:
MemoryArchive memoryArchive = new MemoryArchive();
runTask.run(memoryArchive);
Map<?, ?> properties = new HashMap<Object, Object>();
IReportDocument reportDocument = getReportEngine().openReportDocument(memoryArchive.getName(), memoryArchive, properties);

With this message attached the source code. Do with it whatever you like. If you run into problems using it, or if it is just running fine, I would appreciate you feedback. Thank you!
Re: org.eclipse.birt.core.archive.FolderArchive Example? [message #885181 is a reply to message #884990] Tue, 12 June 2012 14:55 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Jan,

Cool example. You should put this on the dev share at birt-exchange.org
to get feedback.

Jason

On 6/12/2012 4:25 AM, Jan Kohnert wrote:
> Hello,
>
> I wrote an IDocArchiveReader and IDocArchiveWriter implementation that uses memory byte fields only to create a document. It passed all my tests. However, I cannot assure that everything works with it! Especially the listStreams:relativePath. String method remains untested since all my tests return an empty list here (also when using FolderArchive). So I only return any stream that contains the relativePath String at this point without knowing if this is a correct behavior.
> The call is done like this:
>
> MemoryArchive memoryArchive = new MemoryArchive();
> runTask.run(memoryArchive);
> Map<?, ?> properties = new HashMap<Object, Object>();
> IReportDocument reportDocument = getReportEngine().openReportDocument(memoryArchive.getName(), memoryArchive, properties);
>
> With this message attached the source code. Do with it whatever you like. If you run into problems using it, or if it is just running fine, I would appreciate you feedback. Thank you!
>
Previous Topic:API: setProperty() with Type
Next Topic:Decreasing image quality in PDF-Export
Goto Forum:
  


Current Time: Thu Apr 25 23:09:56 GMT 2024

Powered by FUDForum. Page generated in 0.02756 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top