Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Merging BIRT .rptdesign(Merging BIRT .rptdesign)
Merging BIRT .rptdesign [message #686276] Tue, 21 June 2011 23:49 Go to next message
thomascovenanttheunbeliever is currently offline thomascovenanttheunbelieverFriend
Messages: 2
Registered: June 2011
Junior Member
I'm a newb to BIRT and I'm goofing around with manipulating the actual .rptdesign files seeing if I can create some kind of FrankenBIRT implementation.

I am attempting to merge/append 2 .rptdesign file bodies into one, and the basic methodology is similar to this (simplified version):

SlotHandle reportSourceBodyHandle = reportHandleSource.getBody();
SlotHandle reportDestinationBodyHandle = reportHandleDestination.getBody();

Iterator iter = reportSourceBodyHandle.iterator();
while(iter.hasNext()){
   DesignElementHandle item = (DesignElementHandle)iter.next();
   reportDestinationBodyHandle.add(item);
}



It gives me an error stating:
'Element "report.Body[0]" is not allowed to be added into the (Body) of "Report Design", for it is already in the design.'

The destination doc doesn't have anything in the body, so I'm assuming it's talking about the reportDestinationBodyHandle object having that already defined, but I'm not sure how to get around this.
Re: Merging BIRT .rptdesign [message #686652 is a reply to message #686276] Wed, 22 June 2011 17:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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
Re: Merging BIRT .rptdesign [message #689557 is a reply to message #686652] Mon, 27 June 2011 20:31 Go to previous message
thomascovenanttheunbeliever is currently offline thomascovenanttheunbelieverFriend
Messages: 2
Registered: June 2011
Junior Member
Thank you. That worked for what I needed it to do.

It seems it's similar to the DOM (where you have to import nodes into a document before you can add them to other nodes) and I was actually looking for something like an import method. I guess this is ROM's process of doing so.

Your answer is greatly appreciated!
Previous Topic:Web server hostname
Next Topic:BIRT Engine cant open report after stop/start app in tomcat
Goto Forum:
  


Current Time: Fri Apr 19 22:10:02 GMT 2024

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

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

Back to the top