Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Copy Elements from source report to target report
bemar
Hello,
I have the following problem:
I want to copy elements from a source report to a target report to reuse elements for a mini report.
I'm using the "findElement()" function.
If I copy a whole grid X with elements on the root level it will work fine. If I want to copy grid Y inside the grid X I will get a exception. In this special case in grid Y is a chart and I get the exception "The byte array is not a recognized imageformat".
Does anyone knows the problem?
Thx in advance
Regards
Ben
Find more posts tagged with
Comments
bemar
Additionaly I can say, that it doesn't work for every item. No matter if its a grid, a chart or anything else.
With "findElement()" I will get the item and I can put it to the targetReport, but if the item is not from the root level of the body, the targetReport is empty after rendering.
Could this be a bug?
Regards
Ben
bemar
This is the code to copy a table from report1 to report2:
ReportComponent is a own class with the element IDs and Names.
ReportDesignHandle sourceReportHandle = (ReportDesignHandle)sourceReport.getDesignHandle();
ReportDesignHandle targetReportHandle = (ReportDesignHandle)targetReport.getDesignHandle();
SlotHandle masterSlot = (SlotHandle)((CellHandle)((GridHandle)targetReportHandle.findElement("MASTER_GRID")).getCell(0, 0)).getContent();
/** Concatenate the different component in the target report. */
Iterator<ReportComponent> itComponents = components.iterator();
while(itComponents.hasNext()){
ReportComponent component = itComponents.next();
TableHandle handle = null;
//handle = sourceReportHandle.findElement(component.getCode());
handle = (TableHandle)sourceReportHandle.findElement(component.getCode());
//DesignElementHandle handle2 = handle.get
//handle.getElement();
System.out.println("Taking Element "+handle+" with Code "+component.getCode());
masterSlot.add(handle);
handle = (TableHandle)targetReportHandle.findElement(component.getCode());
if (handle!=null){
handle.setValid(true);
System.out.println("Element "+component.getCode()+" found." );
}else{
System.out.println("Element "+component.getCode()+" in targetReport not found!!!");
}
}
zqian
bemar,
I think you need use Model Copy/Paste API to do this instead of just operating on the element references. You can check out this class from Model API: org.eclipse.birt.report.model.api.util.CopyUtil.
bemar
Thank you for your answer.
In which version I can find the copyUtil?
In 2.3.0 there is no class named "CopyUtil" in the package "org.eclipse.birt.report.model.api.util"
bemar
Found it. I had the 2.2.2 version in classpath instead of 2.3.0. I found the class.
I will have a try.
bemar
Looks good. It seems that is what I need.
Have you worked with that Util already?
I have a grid in the target report in which the source element should be inserted but the paste command throws the following error: The Chart("MyFirstChart") is not allowed in the slot (columns) of Grid("MASTER_GRID").
What should be the Target "container" ?
zqian
I think in this case, you actually want to paste the item into the grid cell, so the target container should be the cell, not the grid.
bemar
Thank you, thats it. It works. All things I want to copy (tables, charts) are working.
Thank very much.
Ben