Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 19:45 Go to next message
bob is currently offline bobFriend
Messages: 60
Registered: July 2009
Member
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 19:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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 15:14 Go to previous messageGo to next message
bob is currently offline bobFriend
Messages: 60
Registered: July 2009
Member
"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 21:24 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

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 11:01 Go to previous message
bob is currently offline bobFriend
Messages: 60
Registered: July 2009
Member
"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: Fri Apr 26 19:40:16 GMT 2024

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

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

Back to the top