Skip to main content



      Home
Home » Archived » BIRT » Cannot add data sets (using the birt engine)
Cannot add data sets (using the birt engine) [message #511098] Fri, 29 January 2010 14:45 Go to next message
Eclipse UserFriend
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 #511510 is a reply to message #511098] Mon, 01 February 2010 14:54 Go to previous messageGo to next message
Eclipse UserFriend
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 #511512 is a reply to message #511510] Mon, 01 February 2010 10:14 Go to previous messageGo to next message
Eclipse UserFriend
"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?
>>
Re: Cannot add data sets (using the birt engine) [message #511522 is a reply to message #511512] Mon, 01 February 2010 16:24 Go to previous messageGo to next message
Eclipse UserFriend
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?
>>>
Re: Cannot add data sets (using the birt engine) [message #512527 is a reply to message #511522] Fri, 05 February 2010 06:01 Go to previous message
Eclipse UserFriend
"Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
news:hk7gks$hpn$1@build.eclipse.org...
> 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
>


I had duplicated data in the list, the original approach now works.
Previous Topic:Get rowmapping from DataSetHandle?
Next Topic:production process
Goto Forum:
  


Current Time: Sat Jul 05 01:40:34 EDT 2025

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

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

Back to the top