|
Re: Cannot add data sets (using the birt engine) [message #511510 is a reply to message #511098] |
Mon, 01 February 2010 19:54 |
|
Bob,
Are the columns for the new dataset the same as the old? Remember
column names are stored in bindings on report elements that use them, so
if you change the structure of the columns returned you will have to
updated the bindings on all report items that use the dataset.
Jason
bob wrote:
> I have the following scenario:
>
> 1) Read an already existing .rptdesign file.
>
> 2) Create NEW data sets.
>
> 3) Remove the OLD data sets.
>
> 4) Add the NEW data sets to the existing .rptdesign file
>
> 5) Save the updated .rptdesign file.
>
>
> But when I add the NEW data sets I cannot reuse the names from the old
> data sets even though the current data sets have been removed.
>
> Here is what I do:
>
> step 3)
>
> List<DataSetHandle> dataSetHandles =
> reportDesignHandle.getAllDataSets();
> for (DataSetHandle dataSetHandle : dataSetHandles) {
> try {
> dataSetHandle.dropAndClear();
> } catch (SemanticException e) {
> e.printStackTrace();
> }
> }
>
> step 4)
>
> ...
> OdaDataSetHandle dataSetHandle = elementFactory.newOdaDataSet(name,
> "org.eclipse.birt.report.data.oda.xml.dataSet" );
>
> try {
> dataSetHandle.setDataSource(dataSourceName);
> dataSetHandle.setQueryText(query);
> dataSetHandle.setName(name);
> reportDesignHandle.getDataSets().add(dsh);
> } catch (ContentException e) {
> e.printStackTrace();
> } catch (NameException e) {
> e.printStackTrace();
> } catch (SemanticException e) {
> e.printStackTrace();
> }
>
> But the above throws:
>
> org.eclipse.birt.report.model.api.command.NameException: The name
> "ds0" duplicates an existing name. Please choose a different name.
>
>
> But in step 3) I have already removed that data set so why is it not
> possible to reuse that name - is it stored somewhere else?
>
>
|
|
|
|
Re: Cannot add data sets (using the birt engine) [message #511522 is a reply to message #511512] |
Mon, 01 February 2010 21:24 |
|
Bob,
Can you try code similar to the following:
IReportRunnable design = null;
//Open the report design
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
ReportDesignHandle report = (ReportDesignHandle)
design.getDesignHandle( );
OdaDataSet dscopy = (OdaDataSet)report.findDataSet("Customer
Sales").copy();
List<DataSetHandle> dataSetHandles = report.getAllDataSets();
for (DataSetHandle dataSetHandle : dataSetHandles) {
try {
dataSetHandle.dropAndClear();
} catch (SemanticException e) {
e.printStackTrace();
}
}
dscopy.setName("Customer Sales");
report.getDataSets().add(dscopy.getHandle(dscopy.getRoot()), 0);
report.findElement("mychart").setProperty("dataSet", "Customer Sales");
report.findElement("mytable").setProperty("dataSet", "Customer Sales");
report.saveAs("Reports/topnewds.rptdesign");
Jason
bob wrote:
>
> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
> news:hk7bbv$qjt$1@build.eclipse.org...
>> Bob,
>>
>> Are the columns for the new dataset the same as the old?
>
> Yes the new data set is basically just a copy of the old one but with a
> few new parameters (column-mappings).
>
>
>> Remember column names are stored in bindings on report elements that
>> use them, so if you change the structure of the columns returned you
>> will have to updated the bindings on all report items that use the
>> dataset.
>
>
> But why is it illegal to add a dataset with name "ds0" after calling
> "drop()" on the old dataset with the same name? Especially when the new
> data set only contains additional column mappings and leaves the old
> bindings unchanged.
>
>
>
>
>
>>
>> Jason
>>
>> bob wrote:
>>> I have the following scenario:
>>>
>>> 1) Read an already existing .rptdesign file.
>>>
>>> 2) Create NEW data sets.
>>>
>>> 3) Remove the OLD data sets.
>>>
>>> 4) Add the NEW data sets to the existing .rptdesign file
>>>
>>> 5) Save the updated .rptdesign file.
>>>
>>>
>>> But when I add the NEW data sets I cannot reuse the names from the
>>> old data sets even though the current data sets have been removed.
>>>
>>> Here is what I do:
>>>
>>> step 3)
>>>
>>> List<DataSetHandle> dataSetHandles =
>>> reportDesignHandle.getAllDataSets();
>>> for (DataSetHandle dataSetHandle : dataSetHandles) {
>>> try {
>>> dataSetHandle.dropAndClear();
>>> } catch (SemanticException e) {
>>> e.printStackTrace();
>>> }
>>> }
>>>
>>> step 4)
>>>
>>> ...
>>> OdaDataSetHandle dataSetHandle =
>>> elementFactory.newOdaDataSet(name,
>>> "org.eclipse.birt.report.data.oda.xml.dataSet" );
>>>
>>> try {
>>> dataSetHandle.setDataSource(dataSourceName);
>>> dataSetHandle.setQueryText(query);
>>> dataSetHandle.setName(name);
>>> reportDesignHandle.getDataSets().add(dsh);
>>> } catch (ContentException e) {
>>> e.printStackTrace();
>>> } catch (NameException e) {
>>> e.printStackTrace();
>>> } catch (SemanticException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> But the above throws:
>>>
>>> org.eclipse.birt.report.model.api.command.NameException: The name
>>> "ds0" duplicates an existing name. Please choose a different name.
>>>
>>>
>>> But in step 3) I have already removed that data set so why is it not
>>> possible to reuse that name - is it stored somewhere else?
>>>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04225 seconds