Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Automatically create daily reports by using a Java Application
Automatically create daily reports by using a Java Application [message #670265] Fri, 13 May 2011 10:13 Go to next message
Jochen v. B. is currently offline Jochen v. B.Friend
Messages: 7
Registered: May 2011
Location: Germany
Junior Member
Hi everybody,

currently I am using the Birt Designer to manually create daily reports out of .csv Flat Files. Therefore I change the Flat-File name in the Query of the Data Set which can be found in the Properties of the Data Set. I cannot change the Flat-File name in the "Edit Data Set"-Window at the tab "Select Columns", because Birt will delete all existing columns from the old file but I want to keep these columns due to their name change and further use in the report.

My aim is to automatically create daily reports by using a Java Application that initiates that process. The short graphic of how the process should look is available in the file attachments.

Is there a possibility in Java to automatically change the Flat-File name in the Query and save the new report with a report name that includes the date used in the Flat-File name (or the current date)?
Or is there another solution?

Thank you,
Jochen

Re: Automatically create daily reports by using a Java Application [message #671497 is a reply to message #670265] Wed, 18 May 2011 06:42 Go to previous messageGo to next message
Jochen v. B. is currently offline Jochen v. B.Friend
Messages: 7
Registered: May 2011
Location: Germany
Junior Member
Hi again,

is there no way to solve my problem?
Would appreciate every kind of help.

Thanks,
Jochen
Re: Automatically create daily reports by using a Java Application [message #671635 is a reply to message #671497] Wed, 18 May 2011 14:22 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You can change the csv file with a little de api. take a look at the
attached.

Jason



import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.model.api.DataSetHandle;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.IDesignEngine;
import org.eclipse.birt.report.model.api.IDesignEngineFactory;
import org.eclipse.birt.report.model.api.ReportDesignHandle;
import org.eclipse.birt.report.model.api.SessionHandle;

import com.ibm.icu.util.ULocale;



public class ChangeFlatFile {

public void runReport() throws EngineException
{

IDesignEngine dengine=null;


try{

DesignConfig dconfig = new DesignConfig( );

dconfig.setBIRTHome("C:/birt/birt-runtime-2_6_1/birt-runtime-2_6_1/ReportEngine ");
Platform.startup( dconfig );
IDesignEngineFactory dfactory = (IDesignEngineFactory) Platform
.createFactoryObject(
IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
dengine = dfactory.createDesignEngine( dconfig );



IReportRunnable design = null;
//Open the report design

SessionHandle session = dengine.newSessionHandle( ULocale.ENGLISH );

ReportDesignHandle report =
session.openDesign("Reports/FlatFile.rptdesign");
DataSetHandle dsh = report.findDataSet("Data Set");

String currentquery = (String) dsh.getProperty("queryText");
currentquery.replaceFirst("chart1.csv", "chart2.csv");

report.saveAs("output/desample/FlatFile2.rptdesign" );
report.close( );
session.closeAll(false);
Platform.shutdown();
System.out.println("Finished");


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


}


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

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

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


}

On 5/18/2011 2:42 AM, Jochen v. B. wrote:
> Hi again,
>
> is there no way to solve my problem?
> Would appreciate every kind of help.
>
> Thanks,
> Jochen
Re: Automatically create daily reports by using a Java Application [message #671904 is a reply to message #671635] Thu, 19 May 2011 10:10 Go to previous messageGo to next message
Jochen v. B. is currently offline Jochen v. B.Friend
Messages: 7
Registered: May 2011
Location: Germany
Junior Member
Thank you, Jason.

I used the attached and changed the directory, rptdesgin name, data set name and source-flat-file names.
In debug mode, everything is working fine (queryText is changed correctly) until the report.saveAs("..") line.

I get the following Exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at org.eclipse.birt.report.model.writer.ModuleWriterImpl.<clinit>(ModuleWriterImpl.java:241)
at org.eclipse.birt.report.model.elements.ReportDesign.getWriter(ReportDesign.java:90)
at org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHandle.java:1440)
at org.eclipse.birt.report.model.api.ModuleHandle.saveAs(ModuleHandle.java:1460)
at testsection.ChangeFlatFile.runReport(ChangeFlatFile.java:48)
at testsection.ChangeFlatFile.main(ChangeFlatFile.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.binary.Base64
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 6 more


Any idea how to solve this?

Best regards,
Jochen

[Updated on: Thu, 19 May 2011 10:11]

Report message to a moderator

Re: Automatically create daily reports by using a Java Application [message #671979 is a reply to message #671904] Thu, 19 May 2011 13:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Do you have all the jars from the runtime download:
birt-runtime-2_6_2\ReportEngine\lib in your classpath?

Jason

On 5/19/2011 6:10 AM, Jochen v. B. wrote:
> Thank you, Jason.
>
> I used the attached and changed the directory, rptdesgin name, data set
> name and source-flat-file names.
> In debug mode, everything is working fine (queryText is changed
> correctly) until the report.saveAs("..") line.
>
> I get the following Exception:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/commons/codec/binary/Base64
> at
> org.eclipse.birt.report.model.writer.ModuleWriterImpl.<clinit>(ModuleWriterImpl.java:241)
>
> at
> org.eclipse.birt.report.model.elements.ReportDesign.getWriter(ReportDesign.java:90)
>
> at
> org.eclipse.birt.report.model.api.ModuleHandle.save(ModuleHandle.java:1440)
> at
> org.eclipse.birt.report.model.api.ModuleHandle.saveAs(ModuleHandle.java:1460)
>
> at testsection.ChangeFlatFile.runReport(ChangeFlatFile.java:48)
> at testsection.ChangeFlatFile.main(ChangeFlatFile.java:64)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.codec.binary.Base64
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> ... 6 more
>
> Best regards,
> Jochen
Re: Automatically create daily reports by using a Java Application [message #671993 is a reply to message #671979] Thu, 19 May 2011 14:21 Go to previous message
Jochen v. B. is currently offline Jochen v. B.Friend
Messages: 7
Registered: May 2011
Location: Germany
Junior Member
Ah, I accidently just had the modelapi.jar, coreapi.jar and engineapi.jar in my classpath.
Problem and request solved!

Thank you very much.
Jochen
Previous Topic:True subreport?
Next Topic:Server Side 'Connection Profile' Usage
Goto Forum:
  


Current Time: Sat Apr 20 04:31:27 GMT 2024

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

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

Back to the top