|
Re: Merging BIRT .rptdesign [message #686652 is a reply to message #686276] |
Wed, 22 June 2011 17:00 |
|
Make a copy of the item.
package DEAPI;
import java.io.IOException;
import java.util.Iterator;
import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.model.api.DesignConfig;
import org.eclipse.birt.report.model.api.DesignElementHandle;
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 org.eclipse.birt.report.model.api.SlotHandle;
import org.eclipse.birt.report.model.api.activity.SemanticException;
import com.ibm.icu.util.ULocale;
/**
* Simple BIRT Design Engine API (DEAPI) demo.
*/
public class MergeReports
{
public static void main( String[] args )
{
try
{
buildReport( );
}
catch ( IOException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( SemanticException e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
static void buildReport( ) throws IOException, SemanticException
{
// Create a session handle. This is used to manage all open designs.
// Your app need create the session only once.
DesignConfig config = new DesignConfig( );
config.setBIRTHome("C:/birt/birt-runtime-2_6_1/birt-runtime-2_6_1/ReportEngine");
IDesignEngine engine = null;
try{
Platform.startup( config );
IDesignEngineFactory factory = (IDesignEngineFactory) Platform
.createFactoryObject( IDesignEngineFactory.EXTENSION_DESIGN_ENGINE_FACTORY );
engine = factory.createDesignEngine( config );
}catch( Exception ex){
ex.printStackTrace();
}
SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
ReportDesignHandle design1 = null;
ReportDesignHandle design2 = null;
try{
design1 = session.openDesign("Reports/customers.rptdesign" );
design2 = session.openDesign("Reports/empty.rptdesign" );
SlotHandle reportSourceBodyHandle = design1.getBody();
SlotHandle reportDestinationBodyHandle = design2.getBody();
Iterator iter = reportSourceBodyHandle.iterator();
while(iter.hasNext()){
DesignElementHandle item = (DesignElementHandle)iter.next();
DesignElementHandle cpy = item.copy().getHandle(null);
reportDestinationBodyHandle.add(cpy);
}
design2.saveAs("Reports/merged.rptdesign");
design2.close();
design1.close( );
Platform.shutdown();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("Finished");
// We're done!
}
}
This code does not handle parameters, styles, cubes etc.
Jason
|
|
|
|
Powered by
FUDForum. Page generated in 0.02668 seconds