Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Read parameters (column mappings) from a dataSet using the API`??
Read parameters (column mappings) from a dataSet using the API`?? [message #555128] Wed, 25 August 2010 14:06 Go to next message
Eclipse UserFriend
Originally posted by: vm.vm.com

I have a .rptdesign with a working dataset connected to a xml datasource
containing a bunch of parameters. I would like to read those parameters
using the birt api. Here is what I do:

List<String> parameters = new ArrayList<String>();
OdaDataSetHandle de = (OdaDataSetHandle) ds;
CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
for (int i = 0; i < cols.size(); i++) {
ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
String name = rsc.getColumnName();
parameters.add(name);
}

this works fine if the .rptdesign file has already been used (eg. added some
tables and added some parameters).

But if I load a .rptdesign file which has no content on the master page the
above line:

CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();

fails with a NullPointerException. I guess this is because the data has not
been cached jet. But how do I read data set parameters from a .rptdesign
file which has no other content or has not been run jet?
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #555196 is a reply to message #555128] Wed, 25 August 2010 19:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you want the design for the dataset parameter use script similar to this:

var pl =
reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
//first ds parameter OdaDataSetParameter
var pl_1 = pl.get(0);
myparmname = pl_1.getName();
myparmdefaultvalue = pl_1.getDefaultValue();

You use the api like
PropertyHandle phl
=dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
prm1.getName();

Jason



On 8/25/2010 10:06 AM, vm wrote:
> I have a .rptdesign with a working dataset connected to a xml datasource
> containing a bunch of parameters. I would like to read those parameters
> using the birt api. Here is what I do:
>
> List<String> parameters = new ArrayList<String>();
> OdaDataSetHandle de = (OdaDataSetHandle) ds;
> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
> for (int i = 0; i < cols.size(); i++) {
> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
> String name = rsc.getColumnName();
> parameters.add(name);
> }
>
> this works fine if the .rptdesign file has already been used (eg. added
> some tables and added some parameters).
>
> But if I load a .rptdesign file which has no content on the master page
> the above line:
>
> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>
> fails with a NullPointerException. I guess this is because the data has
> not been cached jet. But how do I read data set parameters from a
> .rptdesign file which has no other content or has not been run jet?
>
>
>
>
>
>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #555319 is a reply to message #555196] Thu, 26 August 2010 09:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vm.vm.com

I now do:

public List<String> readAllParameters(DataSetHandle ds) {
System.out.println(ds.getProperty("queryText"));
PropertyHandle pp = ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
String myparmname = pl_1.getName();
String myparmdefaultvalue = pl_1.getDefaultValue();
.....
}

but the line:

String myparmdefaultvalue = pl_1.getDefaultValue();

gives a NullPointerException even though the querytext on the dataset is
valid and contains (from the above print statement):

table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}

any ideas?



"Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
news:i53p91$hi2$1@build.eclipse.org...
> If you want the design for the dataset parameter use script similar to
> this:
>
> var pl =
> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
> //first ds parameter OdaDataSetParameter
> var pl_1 = pl.get(0);
> myparmname = pl_1.getName();
> myparmdefaultvalue = pl_1.getDefaultValue();
>
> You use the api like
> PropertyHandle phl
> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
> prm1.getName();
>
> Jason
>
>
>
> On 8/25/2010 10:06 AM, vm wrote:
>> I have a .rptdesign with a working dataset connected to a xml datasource
>> containing a bunch of parameters. I would like to read those parameters
>> using the birt api. Here is what I do:
>>
>> List<String> parameters = new ArrayList<String>();
>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>> for (int i = 0; i < cols.size(); i++) {
>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>> String name = rsc.getColumnName();
>> parameters.add(name);
>> }
>>
>> this works fine if the .rptdesign file has already been used (eg. added
>> some tables and added some parameters).
>>
>> But if I load a .rptdesign file which has no content on the master page
>> the above line:
>>
>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>
>> fails with a NullPointerException. I guess this is because the data has
>> not been cached jet. But how do I read data set parameters from a
>> .rptdesign file which has no other content or has not been run jet?
>>
>>
>>
>>
>>
>>
>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #555469 is a reply to message #555319] Thu, 26 August 2010 16:58 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I do not see the dataset parmeter syntax in your table line "{?p1?}".
Take a look at the attached example:

It uses this xml:

<?xml version="1.0"?>
<BookStore xmlns="http://www.books.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<Book category="my first cat">
<Title>Illusions The Adventures of a Reluctant
Messiah</Title>
<Author>Richard Bach</Author>
<Date>1977</Date>
<ISBN>0-440-34319-4</ISBN>
<Publisher>Dell Publishing Co.</Publisher>
</Book>
<Book category="my second cat">
<Title>The First and Last Freedom</Title>
<Author>J. Krishnamurti</Author>
<Date>1954</Date>
<ISBN>0-06-064831-7</ISBN>
<Publisher>Harper &amp; Row</Publisher>
</Book>
</BookStore>

Jason


<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<method name="initialize"><![CDATA[var pl =
reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
//first ds parameter OdaDataSetParameter
var pl_1 = pl.get(0);
myparmname = pl_1.getName();
myparmdefaultvalue = pl_1.getDefaultValue();]]></method>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<oda-data-source
extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data
Source" id="7">
<text-property name="displayName"></text-property>
<property
name="FILELIST">C:\work\styles\BookStore.xml</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
name="Data Set" id="8">
<list-property name="parameters">
<structure>
<property name="name">p1</property>
<property name="nativeName">p1</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
<property name="position">1</property>
<expression name="defaultValue" type="constant">my
first cat</expression>
<property name="isOptional">false</property>
<property name="isInput">true</property>
<property name="isOutput">false</property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">Title</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Author</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">category</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">Title</property>
<property name="nativeName">Title</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Author</property>
<property name="nativeName">Author</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">category</property>
<property name="nativeName">category</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property
name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/BookStore/Book[@category= "{?p1?}" ]]#:#{Title;STRING;/Title},{Author;STRING;/Author},{category ;STRING;/@category}#:# <"","http:%%www.books.org";"xsi","http:%%www.w3.org%2001%XMLSchema-instance ">]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:DataSetParameters>
<design:parameterDefinitions>
<design:inOutMode>In</design:inOutMode>
<design:attributes>
<design:name>p1</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
</design:parameterDefinitions>
</design:DataSetParameters>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>Title</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>Title</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>Author</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>Author</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>category</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>category</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
<list-property name="privateDriverProperties">
<ex-property>
<name>MAX_ROW</name>
<value>-1</value>
</ex-property>
<ex-property>
<name>XML_FILE</name>
</ex-property>
</list-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<data id="31">
<list-property name="boundDataColumns">
<structure>
<property name="name">Column Binding</property>
<expression name="expression"
type="javascript">myparmdefaultvalue;</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="resultSetColumn">Column Binding</property>
</data>
<table id="9">
<property name="dataSet">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Title</property>
<text-property name="displayName">Title</text-property>
<expression name="expression"
type="javascript">dataSetRow["Title"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">Author</property>
<text-property
name="displayName">Author</text-property>
<expression name="expression"
type="javascript">dataSetRow["Author"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">category</property>
<text-property
name="displayName">category</text-property>
<expression name="expression"
type="javascript">dataSetRow["category"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="28"/>
<column id="29"/>
<column id="30"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property
name="text">Title</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property
name="text">Author</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property
name="text">category</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="17">
<cell id="18">
<data id="19">
<property
name="resultSetColumn">Title</property>
</data>
</cell>
<cell id="20">
<data id="21">
<property
name="resultSetColumn">Author</property>
</data>
</cell>
<cell id="22">
<data id="23">
<property
name="resultSetColumn">category</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="24">
<cell id="25"/>
<cell id="26"/>
<cell id="27"/>
</row>
</footer>
</table>
</body>
</report>


On 8/26/2010 5:33 AM, vm wrote:
> I now do:
>
> public List<String> readAllParameters(DataSetHandle ds) {
> System.out.println(ds.getProperty("queryText"));
> PropertyHandle pp = ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
> OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
> String myparmname = pl_1.getName();
> String myparmdefaultvalue = pl_1.getDefaultValue();
> .....
> }
>
> but the line:
>
> String myparmdefaultvalue = pl_1.getDefaultValue();
>
> gives a NullPointerException even though the querytext on the dataset is
> valid and contains (from the above print statement):
>
> table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}
>
>
> any ideas?
>
>
>
> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
> news:i53p91$hi2$1@build.eclipse.org...
>> If you want the design for the dataset parameter use script similar to
>> this:
>>
>> var pl =
>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>
>> //first ds parameter OdaDataSetParameter
>> var pl_1 = pl.get(0);
>> myparmname = pl_1.getName();
>> myparmdefaultvalue = pl_1.getDefaultValue();
>>
>> You use the api like
>> PropertyHandle phl
>> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
>> prm1.getName();
>>
>> Jason
>>
>>
>>
>> On 8/25/2010 10:06 AM, vm wrote:
>>> I have a .rptdesign with a working dataset connected to a xml datasource
>>> containing a bunch of parameters. I would like to read those parameters
>>> using the birt api. Here is what I do:
>>>
>>> List<String> parameters = new ArrayList<String>();
>>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>>> for (int i = 0; i < cols.size(); i++) {
>>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>>> String name = rsc.getColumnName();
>>> parameters.add(name);
>>> }
>>>
>>> this works fine if the .rptdesign file has already been used (eg. added
>>> some tables and added some parameters).
>>>
>>> But if I load a .rptdesign file which has no content on the master page
>>> the above line:
>>>
>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>
>>> fails with a NullPointerException. I guess this is because the data has
>>> not been cached jet. But how do I read data set parameters from a
>>> .rptdesign file which has no other content or has not been run jet?
>>>
>>>
>>>
>>>
>>>
>>>
>>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #555487 is a reply to message #555469] Thu, 26 August 2010 17:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vm.vm.com

I don't use that syntax or any scripts for that matter, but maybe thats
necessary to be able to read parameters from a "unused" .rptdesign file?



"Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
news:i566cf$8d9$1@build.eclipse.org...
> I do not see the dataset parmeter syntax in your table line "{?p1?}". Take
> a look at the attached example:
>
> It uses this xml:
>
> <?xml version="1.0"?>
> <BookStore xmlns="http://www.books.org"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
> <Book category="my first cat">
> <Title>Illusions The Adventures of a Reluctant
> Messiah</Title>
> <Author>Richard Bach</Author>
> <Date>1977</Date>
> <ISBN>0-440-34319-4</ISBN>
> <Publisher>Dell Publishing Co.</Publisher>
> </Book>
> <Book category="my second cat">
> <Title>The First and Last Freedom</Title>
> <Author>J. Krishnamurti</Author>
> <Date>1954</Date>
> <ISBN>0-06-064831-7</ISBN>
> <Publisher>Harper &amp; Row</Publisher>
> </Book>
> </BookStore>
>
> Jason
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
> id="1">
> <property name="createdBy">Eclipse BIRT Designer Version
> 2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
> <property name="units">in</property>
> <method name="initialize"><![CDATA[var pl =
> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
> //first ds parameter OdaDataSetParameter
> var pl_1 = pl.get(0);
> myparmname = pl_1.getName();
> myparmdefaultvalue = pl_1.getDefaultValue();]]></method>
> <property name="iconFile">/templates/blank_report.gif</property>
> <property name="bidiLayoutOrientation">ltr</property>
> <property name="imageDPI">96</property>
> <data-sources>
> <oda-data-source
> extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data Source"
> id="7">
> <text-property name="displayName"></text-property>
> <property
> name="FILELIST">C:\work\styles\BookStore.xml</property>
> </oda-data-source>
> </data-sources>
> <data-sets>
> <oda-data-set
> extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet " name="Data
> Set" id="8">
> <list-property name="parameters">
> <structure>
> <property name="name">p1</property>
> <property name="nativeName">p1</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> <property name="position">1</property>
> <expression name="defaultValue" type="constant">my
> first cat</expression>
> <property name="isOptional">false</property>
> <property name="isInput">true</property>
> <property name="isOutput">false</property>
> </structure>
> </list-property>
> <structure name="cachedMetaData">
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">Title</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">Author</property>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">category</property>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> </structure>
> <property name="dataSource">Data Source</property>
> <list-property name="resultSet">
> <structure>
> <property name="position">1</property>
> <property name="name">Title</property>
> <property name="nativeName">Title</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> </structure>
> <structure>
> <property name="position">2</property>
> <property name="name">Author</property>
> <property name="nativeName">Author</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> </structure>
> <structure>
> <property name="position">3</property>
> <property name="name">category</property>
> <property name="nativeName">category</property>
> <property name="dataType">string</property>
> <property name="nativeDataType">12</property>
> </structure>
> </list-property>
> <xml-property
> name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/BookStore/Book[@category= "{?p1?}" ]]#:#{Title;STRING;/Title},{Author;STRING;/Author},{category ;STRING;/@category}#:# <"","http:%%www.books.org";"xsi","http:%%www.w3.org%2001%XMLSchema-instance ">]]></xml-property>
> <xml-property name="designerValues"><![CDATA[<?xml
> version="1.0" encoding="UTF-8"?>
> <model:DesignValues
> xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
> xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
> <Version>1.0</Version>
> <design:DataSetParameters>
> <design:parameterDefinitions>
> <design:inOutMode>In</design:inOutMode>
> <design:attributes>
> <design:name>p1</design:name>
> <design:position>1</design:position>
> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
> <design:precision>-1</design:precision>
> <design:scale>-1</design:scale>
> <design:nullability>Unknown</design:nullability>
> </design:attributes>
> </design:parameterDefinitions>
> </design:DataSetParameters>
> <design:ResultSets derivedMetaData="true">
> <design:resultSetDefinitions>
> <design:resultSetColumns>
> <design:resultColumnDefinitions>
> <design:attributes>
> <design:name>Title</design:name>
> <design:position>1</design:position>
> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
> <design:precision>-1</design:precision>
> <design:scale>-1</design:scale>
> <design:nullability>Unknown</design:nullability>
> </design:attributes>
> <design:usageHints>
> <design:label>Title</design:label>
> <design:formattingHints/>
> </design:usageHints>
> </design:resultColumnDefinitions>
> <design:resultColumnDefinitions>
> <design:attributes>
> <design:name>Author</design:name>
> <design:position>2</design:position>
> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
> <design:precision>-1</design:precision>
> <design:scale>-1</design:scale>
> <design:nullability>Unknown</design:nullability>
> </design:attributes>
> <design:usageHints>
> <design:label>Author</design:label>
> <design:formattingHints/>
> </design:usageHints>
> </design:resultColumnDefinitions>
> <design:resultColumnDefinitions>
> <design:attributes>
> <design:name>category</design:name>
> <design:position>3</design:position>
> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
> <design:precision>-1</design:precision>
> <design:scale>-1</design:scale>
> <design:nullability>Unknown</design:nullability>
> </design:attributes>
> <design:usageHints>
> <design:label>category</design:label>
> <design:formattingHints/>
> </design:usageHints>
> </design:resultColumnDefinitions>
> </design:resultSetColumns>
> <design:criteria/>
> </design:resultSetDefinitions>
> </design:ResultSets>
> </model:DesignValues>]]></xml-property>
> <list-property name="privateDriverProperties">
> <ex-property>
> <name>MAX_ROW</name>
> <value>-1</value>
> </ex-property>
> <ex-property>
> <name>XML_FILE</name>
> </ex-property>
> </list-property>
> </oda-data-set>
> </data-sets>
> <styles>
> <style name="report" id="4">
> <property name="fontFamily">sans-serif</property>
> <property name="fontSize">10pt</property>
> </style>
> <style name="crosstab-cell" id="5">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> <style name="crosstab" id="6">
> <property name="borderBottomColor">#CCCCCC</property>
> <property name="borderBottomStyle">solid</property>
> <property name="borderBottomWidth">1pt</property>
> <property name="borderLeftColor">#CCCCCC</property>
> <property name="borderLeftStyle">solid</property>
> <property name="borderLeftWidth">1pt</property>
> <property name="borderRightColor">#CCCCCC</property>
> <property name="borderRightStyle">solid</property>
> <property name="borderRightWidth">1pt</property>
> <property name="borderTopColor">#CCCCCC</property>
> <property name="borderTopStyle">solid</property>
> <property name="borderTopWidth">1pt</property>
> </style>
> </styles>
> <page-setup>
> <simple-master-page name="Simple MasterPage" id="2">
> <page-footer>
> <text id="3">
> <property name="contentType">html</property>
> <text-property name="content"><![CDATA[<value-of>new
> Date()</value-of>]]></text-property>
> </text>
> </page-footer>
> </simple-master-page>
> </page-setup>
> <body>
> <data id="31">
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">Column Binding</property>
> <expression name="expression"
> type="javascript">myparmdefaultvalue;</expression>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <property name="resultSetColumn">Column Binding</property>
> </data>
> <table id="9">
> <property name="dataSet">Data Set</property>
> <list-property name="boundDataColumns">
> <structure>
> <property name="name">Title</property>
> <text-property
> name="displayName">Title</text-property>
> <expression name="expression"
> type="javascript">dataSetRow["Title"]</expression>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">Author</property>
> <text-property
> name="displayName">Author</text-property>
> <expression name="expression"
> type="javascript">dataSetRow["Author"]</expression>
> <property name="dataType">string</property>
> </structure>
> <structure>
> <property name="name">category</property>
> <text-property
> name="displayName">category</text-property>
> <expression name="expression"
> type="javascript">dataSetRow["category"]</expression>
> <property name="dataType">string</property>
> </structure>
> </list-property>
> <column id="28"/>
> <column id="29"/>
> <column id="30"/>
> <header>
> <row id="10">
> <cell id="11">
> <label id="12">
> <text-property
> name="text">Title</text-property>
> </label>
> </cell>
> <cell id="13">
> <label id="14">
> <text-property
> name="text">Author</text-property>
> </label>
> </cell>
> <cell id="15">
> <label id="16">
> <text-property
> name="text">category</text-property>
> </label>
> </cell>
> </row>
> </header>
> <detail>
> <row id="17">
> <cell id="18">
> <data id="19">
> <property
> name="resultSetColumn">Title</property>
> </data>
> </cell>
> <cell id="20">
> <data id="21">
> <property
> name="resultSetColumn">Author</property>
> </data>
> </cell>
> <cell id="22">
> <data id="23">
> <property
> name="resultSetColumn">category</property>
> </data>
> </cell>
> </row>
> </detail>
> <footer>
> <row id="24">
> <cell id="25"/>
> <cell id="26"/>
> <cell id="27"/>
> </row>
> </footer>
> </table>
> </body>
> </report>
>
>
> On 8/26/2010 5:33 AM, vm wrote:
>> I now do:
>>
>> public List<String> readAllParameters(DataSetHandle ds) {
>> System.out.println(ds.getProperty("queryText"));
>> PropertyHandle pp = ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
>> OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
>> String myparmname = pl_1.getName();
>> String myparmdefaultvalue = pl_1.getDefaultValue();
>> .....
>> }
>>
>> but the line:
>>
>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>
>> gives a NullPointerException even though the querytext on the dataset is
>> valid and contains (from the above print statement):
>>
>> table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}
>>
>>
>> any ideas?
>>
>>
>>
>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>> news:i53p91$hi2$1@build.eclipse.org...
>>> If you want the design for the dataset parameter use script similar to
>>> this:
>>>
>>> var pl =
>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>
>>> //first ds parameter OdaDataSetParameter
>>> var pl_1 = pl.get(0);
>>> myparmname = pl_1.getName();
>>> myparmdefaultvalue = pl_1.getDefaultValue();
>>>
>>> You use the api like
>>> PropertyHandle phl
>>> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>>> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
>>> prm1.getName();
>>>
>>> Jason
>>>
>>>
>>>
>>> On 8/25/2010 10:06 AM, vm wrote:
>>>> I have a .rptdesign with a working dataset connected to a xml
>>>> datasource
>>>> containing a bunch of parameters. I would like to read those parameters
>>>> using the birt api. Here is what I do:
>>>>
>>>> List<String> parameters = new ArrayList<String>();
>>>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>>>> for (int i = 0; i < cols.size(); i++) {
>>>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>>>> String name = rsc.getColumnName();
>>>> parameters.add(name);
>>>> }
>>>>
>>>> this works fine if the .rptdesign file has already been used (eg. added
>>>> some tables and added some parameters).
>>>>
>>>> But if I load a .rptdesign file which has no content on the master page
>>>> the above line:
>>>>
>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>
>>>> fails with a NullPointerException. I guess this is because the data has
>>>> not been cached jet. But how do I read data set parameters from a
>>>> .rptdesign file which has no other content or has not been run jet?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #555655 is a reply to message #555487] Fri, 27 August 2010 14:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

From the api try:

SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;

ReportDesignHandle design = null;
try{
design = session.openDesign("Reports/XMLParameter.rptdesign" );

OdaDataSetHandle dsh = (OdaDataSetHandle) design.getDataSets().get(0);
PropertyHandle phl
=dsh.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
OdaDataSetParameterHandle prm1 =
(OdaDataSetParameterHandle)phl.get(0);
System.out.println(prm1.getName());
System.out.println(prm1.getDefaultValue());

..
..
..


Jason


On 8/26/2010 1:51 PM, vm wrote:
> I don't use that syntax or any scripts for that matter, but maybe thats
> necessary to be able to read parameters from a "unused" .rptdesign file?
>
>
>
> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
> news:i566cf$8d9$1@build.eclipse.org...
>> I do not see the dataset parmeter syntax in your table line "{?p1?}".
>> Take a look at the attached example:
>>
>> It uses this xml:
>>
>> <?xml version="1.0"?>
>> <BookStore xmlns="http://www.books.org"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>> <Book category="my first cat">
>> <Title>Illusions The Adventures of a Reluctant Messiah</Title>
>> <Author>Richard Bach</Author>
>> <Date>1977</Date>
>> <ISBN>0-440-34319-4</ISBN>
>> <Publisher>Dell Publishing Co.</Publisher>
>> </Book>
>> <Book category="my second cat">
>> <Title>The First and Last Freedom</Title>
>> <Author>J. Krishnamurti</Author>
>> <Date>1954</Date>
>> <ISBN>0-06-064831-7</ISBN>
>> <Publisher>Harper &amp; Row</Publisher>
>> </Book>
>> </BookStore>
>>
>> Jason
>>
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <report xmlns="http://www.eclipse.org/birt/2005/design"
>> version="3.2.21" id="1">
>> <property name="createdBy">Eclipse BIRT Designer Version
>> 2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
>> <property name="units">in</property>
>> <method name="initialize"><![CDATA[var pl =
>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>
>> //first ds parameter OdaDataSetParameter
>> var pl_1 = pl.get(0);
>> myparmname = pl_1.getName();
>> myparmdefaultvalue = pl_1.getDefaultValue();]]></method>
>> <property name="iconFile">/templates/blank_report.gif</property>
>> <property name="bidiLayoutOrientation">ltr</property>
>> <property name="imageDPI">96</property>
>> <data-sources>
>> <oda-data-source
>> extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data
>> Source" id="7">
>> <text-property name="displayName"></text-property>
>> <property name="FILELIST">C:\work\styles\BookStore.xml</property>
>> </oda-data-source>
>> </data-sources>
>> <data-sets>
>> <oda-data-set
>> extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
>> name="Data Set" id="8">
>> <list-property name="parameters">
>> <structure>
>> <property name="name">p1</property>
>> <property name="nativeName">p1</property>
>> <property name="dataType">string</property>
>> <property name="nativeDataType">12</property>
>> <property name="position">1</property>
>> <expression name="defaultValue" type="constant">my first cat</expression>
>> <property name="isOptional">false</property>
>> <property name="isInput">true</property>
>> <property name="isOutput">false</property>
>> </structure>
>> </list-property>
>> <structure name="cachedMetaData">
>> <list-property name="resultSet">
>> <structure>
>> <property name="position">1</property>
>> <property name="name">Title</property>
>> <property name="dataType">string</property>
>> </structure>
>> <structure>
>> <property name="position">2</property>
>> <property name="name">Author</property>
>> <property name="dataType">string</property>
>> </structure>
>> <structure>
>> <property name="position">3</property>
>> <property name="name">category</property>
>> <property name="dataType">string</property>
>> </structure>
>> </list-property>
>> </structure>
>> <property name="dataSource">Data Source</property>
>> <list-property name="resultSet">
>> <structure>
>> <property name="position">1</property>
>> <property name="name">Title</property>
>> <property name="nativeName">Title</property>
>> <property name="dataType">string</property>
>> <property name="nativeDataType">12</property>
>> </structure>
>> <structure>
>> <property name="position">2</property>
>> <property name="name">Author</property>
>> <property name="nativeName">Author</property>
>> <property name="dataType">string</property>
>> <property name="nativeDataType">12</property>
>> </structure>
>> <structure>
>> <property name="position">3</property>
>> <property name="name">category</property>
>> <property name="nativeName">category</property>
>> <property name="dataType">string</property>
>> <property name="nativeDataType">12</property>
>> </structure>
>> </list-property>
>> <xml-property
>> name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/BookStore/Book[@category= "{?p1?}" ]]#:#{Title;STRING;/Title},{Author;STRING;/Author},{category ;STRING;/@category}#:# <"","http:%%www.books.org";"xsi","http:%%www.w3.org%2001%XMLSchema-instance ">]]></xml-property>
>>
>> <xml-property name="designerValues"><![CDATA[<?xml version="1.0"
>> encoding="UTF-8"?>
>> <model:DesignValues
>> xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design" xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
>>
>> <Version>1.0</Version>
>> <design:DataSetParameters>
>> <design:parameterDefinitions>
>> <design:inOutMode>In</design:inOutMode>
>> <design:attributes>
>> <design:name>p1</design:name>
>> <design:position>1</design:position>
>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>> <design:precision>-1</design:precision>
>> <design:scale>-1</design:scale>
>> <design:nullability>Unknown</design:nullability>
>> </design:attributes>
>> </design:parameterDefinitions>
>> </design:DataSetParameters>
>> <design:ResultSets derivedMetaData="true">
>> <design:resultSetDefinitions>
>> <design:resultSetColumns>
>> <design:resultColumnDefinitions>
>> <design:attributes>
>> <design:name>Title</design:name>
>> <design:position>1</design:position>
>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>> <design:precision>-1</design:precision>
>> <design:scale>-1</design:scale>
>> <design:nullability>Unknown</design:nullability>
>> </design:attributes>
>> <design:usageHints>
>> <design:label>Title</design:label>
>> <design:formattingHints/>
>> </design:usageHints>
>> </design:resultColumnDefinitions>
>> <design:resultColumnDefinitions>
>> <design:attributes>
>> <design:name>Author</design:name>
>> <design:position>2</design:position>
>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>> <design:precision>-1</design:precision>
>> <design:scale>-1</design:scale>
>> <design:nullability>Unknown</design:nullability>
>> </design:attributes>
>> <design:usageHints>
>> <design:label>Author</design:label>
>> <design:formattingHints/>
>> </design:usageHints>
>> </design:resultColumnDefinitions>
>> <design:resultColumnDefinitions>
>> <design:attributes>
>> <design:name>category</design:name>
>> <design:position>3</design:position>
>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>> <design:precision>-1</design:precision>
>> <design:scale>-1</design:scale>
>> <design:nullability>Unknown</design:nullability>
>> </design:attributes>
>> <design:usageHints>
>> <design:label>category</design:label>
>> <design:formattingHints/>
>> </design:usageHints>
>> </design:resultColumnDefinitions>
>> </design:resultSetColumns>
>> <design:criteria/>
>> </design:resultSetDefinitions>
>> </design:ResultSets>
>> </model:DesignValues>]]></xml-property>
>> <list-property name="privateDriverProperties">
>> <ex-property>
>> <name>MAX_ROW</name>
>> <value>-1</value>
>> </ex-property>
>> <ex-property>
>> <name>XML_FILE</name>
>> </ex-property>
>> </list-property>
>> </oda-data-set>
>> </data-sets>
>> <styles>
>> <style name="report" id="4">
>> <property name="fontFamily">sans-serif</property>
>> <property name="fontSize">10pt</property>
>> </style>
>> <style name="crosstab-cell" id="5">
>> <property name="borderBottomColor">#CCCCCC</property>
>> <property name="borderBottomStyle">solid</property>
>> <property name="borderBottomWidth">1pt</property>
>> <property name="borderLeftColor">#CCCCCC</property>
>> <property name="borderLeftStyle">solid</property>
>> <property name="borderLeftWidth">1pt</property>
>> <property name="borderRightColor">#CCCCCC</property>
>> <property name="borderRightStyle">solid</property>
>> <property name="borderRightWidth">1pt</property>
>> <property name="borderTopColor">#CCCCCC</property>
>> <property name="borderTopStyle">solid</property>
>> <property name="borderTopWidth">1pt</property>
>> </style>
>> <style name="crosstab" id="6">
>> <property name="borderBottomColor">#CCCCCC</property>
>> <property name="borderBottomStyle">solid</property>
>> <property name="borderBottomWidth">1pt</property>
>> <property name="borderLeftColor">#CCCCCC</property>
>> <property name="borderLeftStyle">solid</property>
>> <property name="borderLeftWidth">1pt</property>
>> <property name="borderRightColor">#CCCCCC</property>
>> <property name="borderRightStyle">solid</property>
>> <property name="borderRightWidth">1pt</property>
>> <property name="borderTopColor">#CCCCCC</property>
>> <property name="borderTopStyle">solid</property>
>> <property name="borderTopWidth">1pt</property>
>> </style>
>> </styles>
>> <page-setup>
>> <simple-master-page name="Simple MasterPage" id="2">
>> <page-footer>
>> <text id="3">
>> <property name="contentType">html</property>
>> <text-property name="content"><![CDATA[<value-of>new
>> Date()</value-of>]]></text-property>
>> </text>
>> </page-footer>
>> </simple-master-page>
>> </page-setup>
>> <body>
>> <data id="31">
>> <list-property name="boundDataColumns">
>> <structure>
>> <property name="name">Column Binding</property>
>> <expression name="expression"
>> type="javascript">myparmdefaultvalue;</expression>
>> <property name="dataType">string</property>
>> </structure>
>> </list-property>
>> <property name="resultSetColumn">Column Binding</property>
>> </data>
>> <table id="9">
>> <property name="dataSet">Data Set</property>
>> <list-property name="boundDataColumns">
>> <structure>
>> <property name="name">Title</property>
>> <text-property name="displayName">Title</text-property>
>> <expression name="expression"
>> type="javascript">dataSetRow["Title"]</expression>
>> <property name="dataType">string</property>
>> </structure>
>> <structure>
>> <property name="name">Author</property>
>> <text-property name="displayName">Author</text-property>
>> <expression name="expression"
>> type="javascript">dataSetRow["Author"]</expression>
>> <property name="dataType">string</property>
>> </structure>
>> <structure>
>> <property name="name">category</property>
>> <text-property name="displayName">category</text-property>
>> <expression name="expression"
>> type="javascript">dataSetRow["category"]</expression>
>> <property name="dataType">string</property>
>> </structure>
>> </list-property>
>> <column id="28"/>
>> <column id="29"/>
>> <column id="30"/>
>> <header>
>> <row id="10">
>> <cell id="11">
>> <label id="12">
>> <text-property name="text">Title</text-property>
>> </label>
>> </cell>
>> <cell id="13">
>> <label id="14">
>> <text-property name="text">Author</text-property>
>> </label>
>> </cell>
>> <cell id="15">
>> <label id="16">
>> <text-property name="text">category</text-property>
>> </label>
>> </cell>
>> </row>
>> </header>
>> <detail>
>> <row id="17">
>> <cell id="18">
>> <data id="19">
>> <property name="resultSetColumn">Title</property>
>> </data>
>> </cell>
>> <cell id="20">
>> <data id="21">
>> <property name="resultSetColumn">Author</property>
>> </data>
>> </cell>
>> <cell id="22">
>> <data id="23">
>> <property name="resultSetColumn">category</property>
>> </data>
>> </cell>
>> </row>
>> </detail>
>> <footer>
>> <row id="24">
>> <cell id="25"/>
>> <cell id="26"/>
>> <cell id="27"/>
>> </row>
>> </footer>
>> </table>
>> </body>
>> </report>
>>
>>
>> On 8/26/2010 5:33 AM, vm wrote:
>>> I now do:
>>>
>>> public List<String> readAllParameters(DataSetHandle ds) {
>>> System.out.println(ds.getProperty("queryText"));
>>> PropertyHandle pp = ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
>>> OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
>>> String myparmname = pl_1.getName();
>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>> .....
>>> }
>>>
>>> but the line:
>>>
>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>>
>>> gives a NullPointerException even though the querytext on the dataset is
>>> valid and contains (from the above print statement):
>>>
>>> table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}
>>>
>>>
>>>
>>> any ideas?
>>>
>>>
>>>
>>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>>> news:i53p91$hi2$1@build.eclipse.org...
>>>> If you want the design for the dataset parameter use script similar to
>>>> this:
>>>>
>>>> var pl =
>>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>>
>>>>
>>>> //first ds parameter OdaDataSetParameter
>>>> var pl_1 = pl.get(0);
>>>> myparmname = pl_1.getName();
>>>> myparmdefaultvalue = pl_1.getDefaultValue();
>>>>
>>>> You use the api like
>>>> PropertyHandle phl
>>>> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>>>> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
>>>> prm1.getName();
>>>>
>>>> Jason
>>>>
>>>>
>>>>
>>>> On 8/25/2010 10:06 AM, vm wrote:
>>>>> I have a .rptdesign with a working dataset connected to a xml
>>>>> datasource
>>>>> containing a bunch of parameters. I would like to read those
>>>>> parameters
>>>>> using the birt api. Here is what I do:
>>>>>
>>>>> List<String> parameters = new ArrayList<String>();
>>>>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>>>>> for (int i = 0; i < cols.size(); i++) {
>>>>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>>>>> String name = rsc.getColumnName();
>>>>> parameters.add(name);
>>>>> }
>>>>>
>>>>> this works fine if the .rptdesign file has already been used (eg.
>>>>> added
>>>>> some tables and added some parameters).
>>>>>
>>>>> But if I load a .rptdesign file which has no content on the master
>>>>> page
>>>>> the above line:
>>>>>
>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>>
>>>>> fails with a NullPointerException. I guess this is because the data
>>>>> has
>>>>> not been cached jet. But how do I read data set parameters from a
>>>>> .rptdesign file which has no other content or has not been run jet?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #556662 is a reply to message #555655] Thu, 02 September 2010 09:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vm.vm.com

Same problem. Currently its only possible to read the parameters from a data
set if they have been bound to a table in the .rptdesign file.




"Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
news:i58gah$m93$1@build.eclipse.org...
> From the api try:
>
> SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
>
> ReportDesignHandle design = null;
> try{
> design = session.openDesign("Reports/XMLParameter.rptdesign" );
>
> OdaDataSetHandle dsh = (OdaDataSetHandle) design.getDataSets().get(0);
> PropertyHandle phl
> =dsh.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
> OdaDataSetParameterHandle prm1 =
> (OdaDataSetParameterHandle)phl.get(0);
> System.out.println(prm1.getName());
> System.out.println(prm1.getDefaultValue());
>
> .
> .
> .
>
>
> Jason
>
>
> On 8/26/2010 1:51 PM, vm wrote:
>> I don't use that syntax or any scripts for that matter, but maybe thats
>> necessary to be able to read parameters from a "unused" .rptdesign file?
>>
>>
>>
>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>> news:i566cf$8d9$1@build.eclipse.org...
>>> I do not see the dataset parmeter syntax in your table line "{?p1?}".
>>> Take a look at the attached example:
>>>
>>> It uses this xml:
>>>
>>> <?xml version="1.0"?>
>>> <BookStore xmlns="http://www.books.org"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>>> <Book category="my first cat">
>>> <Title>Illusions The Adventures of a Reluctant Messiah</Title>
>>> <Author>Richard Bach</Author>
>>> <Date>1977</Date>
>>> <ISBN>0-440-34319-4</ISBN>
>>> <Publisher>Dell Publishing Co.</Publisher>
>>> </Book>
>>> <Book category="my second cat">
>>> <Title>The First and Last Freedom</Title>
>>> <Author>J. Krishnamurti</Author>
>>> <Date>1954</Date>
>>> <ISBN>0-06-064831-7</ISBN>
>>> <Publisher>Harper &amp; Row</Publisher>
>>> </Book>
>>> </BookStore>
>>>
>>> Jason
>>>
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <report xmlns="http://www.eclipse.org/birt/2005/design"
>>> version="3.2.21" id="1">
>>> <property name="createdBy">Eclipse BIRT Designer Version
>>> 2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
>>> <property name="units">in</property>
>>> <method name="initialize"><![CDATA[var pl =
>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>
>>> //first ds parameter OdaDataSetParameter
>>> var pl_1 = pl.get(0);
>>> myparmname = pl_1.getName();
>>> myparmdefaultvalue = pl_1.getDefaultValue();]]></method>
>>> <property name="iconFile">/templates/blank_report.gif</property>
>>> <property name="bidiLayoutOrientation">ltr</property>
>>> <property name="imageDPI">96</property>
>>> <data-sources>
>>> <oda-data-source
>>> extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data
>>> Source" id="7">
>>> <text-property name="displayName"></text-property>
>>> <property name="FILELIST">C:\work\styles\BookStore.xml</property>
>>> </oda-data-source>
>>> </data-sources>
>>> <data-sets>
>>> <oda-data-set
>>> extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
>>> name="Data Set" id="8">
>>> <list-property name="parameters">
>>> <structure>
>>> <property name="name">p1</property>
>>> <property name="nativeName">p1</property>
>>> <property name="dataType">string</property>
>>> <property name="nativeDataType">12</property>
>>> <property name="position">1</property>
>>> <expression name="defaultValue" type="constant">my first
>>> cat</expression>
>>> <property name="isOptional">false</property>
>>> <property name="isInput">true</property>
>>> <property name="isOutput">false</property>
>>> </structure>
>>> </list-property>
>>> <structure name="cachedMetaData">
>>> <list-property name="resultSet">
>>> <structure>
>>> <property name="position">1</property>
>>> <property name="name">Title</property>
>>> <property name="dataType">string</property>
>>> </structure>
>>> <structure>
>>> <property name="position">2</property>
>>> <property name="name">Author</property>
>>> <property name="dataType">string</property>
>>> </structure>
>>> <structure>
>>> <property name="position">3</property>
>>> <property name="name">category</property>
>>> <property name="dataType">string</property>
>>> </structure>
>>> </list-property>
>>> </structure>
>>> <property name="dataSource">Data Source</property>
>>> <list-property name="resultSet">
>>> <structure>
>>> <property name="position">1</property>
>>> <property name="name">Title</property>
>>> <property name="nativeName">Title</property>
>>> <property name="dataType">string</property>
>>> <property name="nativeDataType">12</property>
>>> </structure>
>>> <structure>
>>> <property name="position">2</property>
>>> <property name="name">Author</property>
>>> <property name="nativeName">Author</property>
>>> <property name="dataType">string</property>
>>> <property name="nativeDataType">12</property>
>>> </structure>
>>> <structure>
>>> <property name="position">3</property>
>>> <property name="name">category</property>
>>> <property name="nativeName">category</property>
>>> <property name="dataType">string</property>
>>> <property name="nativeDataType">12</property>
>>> </structure>
>>> </list-property>
>>> <xml-property
>>> name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/BookStore/Book[@category= "{?p1?}" ]]#:#{Title;STRING;/Title},{Author;STRING;/Author},{category ;STRING;/@category}#:# <"","http:%%www.books.org";"xsi","http:%%www.w3.org%2001%XMLSchema-instance ">]]></xml-property>
>>>
>>> <xml-property name="designerValues"><![CDATA[<?xml version="1.0"
>>> encoding="UTF-8"?>
>>> <model:DesignValues
>>> xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
>>> xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
>>>
>>> <Version>1.0</Version>
>>> <design:DataSetParameters>
>>> <design:parameterDefinitions>
>>> <design:inOutMode>In</design:inOutMode>
>>> <design:attributes>
>>> <design:name>p1</design:name>
>>> <design:position>1</design:position>
>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>> <design:precision>-1</design:precision>
>>> <design:scale>-1</design:scale>
>>> <design:nullability>Unknown</design:nullability>
>>> </design:attributes>
>>> </design:parameterDefinitions>
>>> </design:DataSetParameters>
>>> <design:ResultSets derivedMetaData="true">
>>> <design:resultSetDefinitions>
>>> <design:resultSetColumns>
>>> <design:resultColumnDefinitions>
>>> <design:attributes>
>>> <design:name>Title</design:name>
>>> <design:position>1</design:position>
>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>> <design:precision>-1</design:precision>
>>> <design:scale>-1</design:scale>
>>> <design:nullability>Unknown</design:nullability>
>>> </design:attributes>
>>> <design:usageHints>
>>> <design:label>Title</design:label>
>>> <design:formattingHints/>
>>> </design:usageHints>
>>> </design:resultColumnDefinitions>
>>> <design:resultColumnDefinitions>
>>> <design:attributes>
>>> <design:name>Author</design:name>
>>> <design:position>2</design:position>
>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>> <design:precision>-1</design:precision>
>>> <design:scale>-1</design:scale>
>>> <design:nullability>Unknown</design:nullability>
>>> </design:attributes>
>>> <design:usageHints>
>>> <design:label>Author</design:label>
>>> <design:formattingHints/>
>>> </design:usageHints>
>>> </design:resultColumnDefinitions>
>>> <design:resultColumnDefinitions>
>>> <design:attributes>
>>> <design:name>category</design:name>
>>> <design:position>3</design:position>
>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>> <design:precision>-1</design:precision>
>>> <design:scale>-1</design:scale>
>>> <design:nullability>Unknown</design:nullability>
>>> </design:attributes>
>>> <design:usageHints>
>>> <design:label>category</design:label>
>>> <design:formattingHints/>
>>> </design:usageHints>
>>> </design:resultColumnDefinitions>
>>> </design:resultSetColumns>
>>> <design:criteria/>
>>> </design:resultSetDefinitions>
>>> </design:ResultSets>
>>> </model:DesignValues>]]></xml-property>
>>> <list-property name="privateDriverProperties">
>>> <ex-property>
>>> <name>MAX_ROW</name>
>>> <value>-1</value>
>>> </ex-property>
>>> <ex-property>
>>> <name>XML_FILE</name>
>>> </ex-property>
>>> </list-property>
>>> </oda-data-set>
>>> </data-sets>
>>> <styles>
>>> <style name="report" id="4">
>>> <property name="fontFamily">sans-serif</property>
>>> <property name="fontSize">10pt</property>
>>> </style>
>>> <style name="crosstab-cell" id="5">
>>> <property name="borderBottomColor">#CCCCCC</property>
>>> <property name="borderBottomStyle">solid</property>
>>> <property name="borderBottomWidth">1pt</property>
>>> <property name="borderLeftColor">#CCCCCC</property>
>>> <property name="borderLeftStyle">solid</property>
>>> <property name="borderLeftWidth">1pt</property>
>>> <property name="borderRightColor">#CCCCCC</property>
>>> <property name="borderRightStyle">solid</property>
>>> <property name="borderRightWidth">1pt</property>
>>> <property name="borderTopColor">#CCCCCC</property>
>>> <property name="borderTopStyle">solid</property>
>>> <property name="borderTopWidth">1pt</property>
>>> </style>
>>> <style name="crosstab" id="6">
>>> <property name="borderBottomColor">#CCCCCC</property>
>>> <property name="borderBottomStyle">solid</property>
>>> <property name="borderBottomWidth">1pt</property>
>>> <property name="borderLeftColor">#CCCCCC</property>
>>> <property name="borderLeftStyle">solid</property>
>>> <property name="borderLeftWidth">1pt</property>
>>> <property name="borderRightColor">#CCCCCC</property>
>>> <property name="borderRightStyle">solid</property>
>>> <property name="borderRightWidth">1pt</property>
>>> <property name="borderTopColor">#CCCCCC</property>
>>> <property name="borderTopStyle">solid</property>
>>> <property name="borderTopWidth">1pt</property>
>>> </style>
>>> </styles>
>>> <page-setup>
>>> <simple-master-page name="Simple MasterPage" id="2">
>>> <page-footer>
>>> <text id="3">
>>> <property name="contentType">html</property>
>>> <text-property name="content"><![CDATA[<value-of>new
>>> Date()</value-of>]]></text-property>
>>> </text>
>>> </page-footer>
>>> </simple-master-page>
>>> </page-setup>
>>> <body>
>>> <data id="31">
>>> <list-property name="boundDataColumns">
>>> <structure>
>>> <property name="name">Column Binding</property>
>>> <expression name="expression"
>>> type="javascript">myparmdefaultvalue;</expression>
>>> <property name="dataType">string</property>
>>> </structure>
>>> </list-property>
>>> <property name="resultSetColumn">Column Binding</property>
>>> </data>
>>> <table id="9">
>>> <property name="dataSet">Data Set</property>
>>> <list-property name="boundDataColumns">
>>> <structure>
>>> <property name="name">Title</property>
>>> <text-property name="displayName">Title</text-property>
>>> <expression name="expression"
>>> type="javascript">dataSetRow["Title"]</expression>
>>> <property name="dataType">string</property>
>>> </structure>
>>> <structure>
>>> <property name="name">Author</property>
>>> <text-property name="displayName">Author</text-property>
>>> <expression name="expression"
>>> type="javascript">dataSetRow["Author"]</expression>
>>> <property name="dataType">string</property>
>>> </structure>
>>> <structure>
>>> <property name="name">category</property>
>>> <text-property name="displayName">category</text-property>
>>> <expression name="expression"
>>> type="javascript">dataSetRow["category"]</expression>
>>> <property name="dataType">string</property>
>>> </structure>
>>> </list-property>
>>> <column id="28"/>
>>> <column id="29"/>
>>> <column id="30"/>
>>> <header>
>>> <row id="10">
>>> <cell id="11">
>>> <label id="12">
>>> <text-property name="text">Title</text-property>
>>> </label>
>>> </cell>
>>> <cell id="13">
>>> <label id="14">
>>> <text-property name="text">Author</text-property>
>>> </label>
>>> </cell>
>>> <cell id="15">
>>> <label id="16">
>>> <text-property name="text">category</text-property>
>>> </label>
>>> </cell>
>>> </row>
>>> </header>
>>> <detail>
>>> <row id="17">
>>> <cell id="18">
>>> <data id="19">
>>> <property name="resultSetColumn">Title</property>
>>> </data>
>>> </cell>
>>> <cell id="20">
>>> <data id="21">
>>> <property name="resultSetColumn">Author</property>
>>> </data>
>>> </cell>
>>> <cell id="22">
>>> <data id="23">
>>> <property name="resultSetColumn">category</property>
>>> </data>
>>> </cell>
>>> </row>
>>> </detail>
>>> <footer>
>>> <row id="24">
>>> <cell id="25"/>
>>> <cell id="26"/>
>>> <cell id="27"/>
>>> </row>
>>> </footer>
>>> </table>
>>> </body>
>>> </report>
>>>
>>>
>>> On 8/26/2010 5:33 AM, vm wrote:
>>>> I now do:
>>>>
>>>> public List<String> readAllParameters(DataSetHandle ds) {
>>>> System.out.println(ds.getProperty("queryText"));
>>>> PropertyHandle pp =
>>>> ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
>>>> OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
>>>> String myparmname = pl_1.getName();
>>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>>> .....
>>>> }
>>>>
>>>> but the line:
>>>>
>>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>>>
>>>> gives a NullPointerException even though the querytext on the dataset
>>>> is
>>>> valid and contains (from the above print statement):
>>>>
>>>> table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}
>>>>
>>>>
>>>>
>>>> any ideas?
>>>>
>>>>
>>>>
>>>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>>>> news:i53p91$hi2$1@build.eclipse.org...
>>>>> If you want the design for the dataset parameter use script similar to
>>>>> this:
>>>>>
>>>>> var pl =
>>>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>>>
>>>>>
>>>>> //first ds parameter OdaDataSetParameter
>>>>> var pl_1 = pl.get(0);
>>>>> myparmname = pl_1.getName();
>>>>> myparmdefaultvalue = pl_1.getDefaultValue();
>>>>>
>>>>> You use the api like
>>>>> PropertyHandle phl
>>>>> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>>>>> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
>>>>> prm1.getName();
>>>>>
>>>>> Jason
>>>>>
>>>>>
>>>>>
>>>>> On 8/25/2010 10:06 AM, vm wrote:
>>>>>> I have a .rptdesign with a working dataset connected to a xml
>>>>>> datasource
>>>>>> containing a bunch of parameters. I would like to read those
>>>>>> parameters
>>>>>> using the birt api. Here is what I do:
>>>>>>
>>>>>> List<String> parameters = new ArrayList<String>();
>>>>>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>>>>>> for (int i = 0; i < cols.size(); i++) {
>>>>>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>>>>>> String name = rsc.getColumnName();
>>>>>> parameters.add(name);
>>>>>> }
>>>>>>
>>>>>> this works fine if the .rptdesign file has already been used (eg.
>>>>>> added
>>>>>> some tables and added some parameters).
>>>>>>
>>>>>> But if I load a .rptdesign file which has no content on the master
>>>>>> page
>>>>>> the above line:
>>>>>>
>>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>>>
>>>>>> fails with a NullPointerException. I guess this is because the data
>>>>>> has
>>>>>> not been cached jet. But how do I read data set parameters from a
>>>>>> .rptdesign file which has no other content or has not been run jet?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>
Re: Read parameters (column mappings) from a dataSet using the API`?? [message #556784 is a reply to message #556662] Thu, 02 September 2010 15:14 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Is your parameter dynamic? Can you post the snippet of xml that shows
your data parameter? I ran this test with 2.5.2 and it worked fine.

Jason

On 9/2/2010 5:12 AM, vm wrote:
> Same problem. Currently its only possible to read the parameters from a
> data set if they have been bound to a table in the .rptdesign file.
>
>
>
>
> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
> news:i58gah$m93$1@build.eclipse.org...
>> From the api try:
>>
>> SessionHandle session = engine.newSessionHandle( ULocale.ENGLISH ) ;
>>
>> ReportDesignHandle design = null;
>> try{
>> design = session.openDesign("Reports/XMLParameter.rptdesign" );
>>
>> OdaDataSetHandle dsh = (OdaDataSetHandle) design.getDataSets().get(0);
>> PropertyHandle phl
>> =dsh.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>> OdaDataSetParameterHandle prm1 = (OdaDataSetParameterHandle)phl.get(0);
>> System.out.println(prm1.getName());
>> System.out.println(prm1.getDefaultValue());
>>
>> .
>> .
>> .
>>
>>
>> Jason
>>
>>
>> On 8/26/2010 1:51 PM, vm wrote:
>>> I don't use that syntax or any scripts for that matter, but maybe thats
>>> necessary to be able to read parameters from a "unused" .rptdesign file?
>>>
>>>
>>>
>>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>>> news:i566cf$8d9$1@build.eclipse.org...
>>>> I do not see the dataset parmeter syntax in your table line "{?p1?}".
>>>> Take a look at the attached example:
>>>>
>>>> It uses this xml:
>>>>
>>>> <?xml version="1.0"?>
>>>> <BookStore xmlns="http://www.books.org"
>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>>>> <Book category="my first cat">
>>>> <Title>Illusions The Adventures of a Reluctant Messiah</Title>
>>>> <Author>Richard Bach</Author>
>>>> <Date>1977</Date>
>>>> <ISBN>0-440-34319-4</ISBN>
>>>> <Publisher>Dell Publishing Co.</Publisher>
>>>> </Book>
>>>> <Book category="my second cat">
>>>> <Title>The First and Last Freedom</Title>
>>>> <Author>J. Krishnamurti</Author>
>>>> <Date>1954</Date>
>>>> <ISBN>0-06-064831-7</ISBN>
>>>> <Publisher>Harper &amp; Row</Publisher>
>>>> </Book>
>>>> </BookStore>
>>>>
>>>> Jason
>>>>
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <report xmlns="http://www.eclipse.org/birt/2005/design"
>>>> version="3.2.21" id="1">
>>>> <property name="createdBy">Eclipse BIRT Designer Version
>>>> 2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
>>>> <property name="units">in</property>
>>>> <method name="initialize"><![CDATA[var pl =
>>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>>
>>>>
>>>> //first ds parameter OdaDataSetParameter
>>>> var pl_1 = pl.get(0);
>>>> myparmname = pl_1.getName();
>>>> myparmdefaultvalue = pl_1.getDefaultValue();]]></method>
>>>> <property name="iconFile">/templates/blank_report.gif</property>
>>>> <property name="bidiLayoutOrientation">ltr</property>
>>>> <property name="imageDPI">96</property>
>>>> <data-sources>
>>>> <oda-data-source
>>>> extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data
>>>> Source" id="7">
>>>> <text-property name="displayName"></text-property>
>>>> <property name="FILELIST">C:\work\styles\BookStore.xml</property>
>>>> </oda-data-source>
>>>> </data-sources>
>>>> <data-sets>
>>>> <oda-data-set
>>>> extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
>>>> name="Data Set" id="8">
>>>> <list-property name="parameters">
>>>> <structure>
>>>> <property name="name">p1</property>
>>>> <property name="nativeName">p1</property>
>>>> <property name="dataType">string</property>
>>>> <property name="nativeDataType">12</property>
>>>> <property name="position">1</property>
>>>> <expression name="defaultValue" type="constant">my first
>>>> cat</expression>
>>>> <property name="isOptional">false</property>
>>>> <property name="isInput">true</property>
>>>> <property name="isOutput">false</property>
>>>> </structure>
>>>> </list-property>
>>>> <structure name="cachedMetaData">
>>>> <list-property name="resultSet">
>>>> <structure>
>>>> <property name="position">1</property>
>>>> <property name="name">Title</property>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="position">2</property>
>>>> <property name="name">Author</property>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="position">3</property>
>>>> <property name="name">category</property>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> </list-property>
>>>> </structure>
>>>> <property name="dataSource">Data Source</property>
>>>> <list-property name="resultSet">
>>>> <structure>
>>>> <property name="position">1</property>
>>>> <property name="name">Title</property>
>>>> <property name="nativeName">Title</property>
>>>> <property name="dataType">string</property>
>>>> <property name="nativeDataType">12</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="position">2</property>
>>>> <property name="name">Author</property>
>>>> <property name="nativeName">Author</property>
>>>> <property name="dataType">string</property>
>>>> <property name="nativeDataType">12</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="position">3</property>
>>>> <property name="name">category</property>
>>>> <property name="nativeName">category</property>
>>>> <property name="dataType">string</property>
>>>> <property name="nativeDataType">12</property>
>>>> </structure>
>>>> </list-property>
>>>> <xml-property
>>>> name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/BookStore/Book[@category= "{?p1?}" ]]#:#{Title;STRING;/Title},{Author;STRING;/Author},{category ;STRING;/@category}#:# <"","http:%%www.books.org";"xsi","http:%%www.w3.org%2001%XMLSchema-instance ">]]></xml-property>
>>>>
>>>>
>>>> <xml-property name="designerValues"><![CDATA[<?xml version="1.0"
>>>> encoding="UTF-8"?>
>>>> <model:DesignValues
>>>> xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
>>>> xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
>>>>
>>>>
>>>> <Version>1.0</Version>
>>>> <design:DataSetParameters>
>>>> <design:parameterDefinitions>
>>>> <design:inOutMode>In</design:inOutMode>
>>>> <design:attributes>
>>>> <design:name>p1</design:name>
>>>> <design:position>1</design:position>
>>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>>> <design:precision>-1</design:precision>
>>>> <design:scale>-1</design:scale>
>>>> <design:nullability>Unknown</design:nullability>
>>>> </design:attributes>
>>>> </design:parameterDefinitions>
>>>> </design:DataSetParameters>
>>>> <design:ResultSets derivedMetaData="true">
>>>> <design:resultSetDefinitions>
>>>> <design:resultSetColumns>
>>>> <design:resultColumnDefinitions>
>>>> <design:attributes>
>>>> <design:name>Title</design:name>
>>>> <design:position>1</design:position>
>>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>>> <design:precision>-1</design:precision>
>>>> <design:scale>-1</design:scale>
>>>> <design:nullability>Unknown</design:nullability>
>>>> </design:attributes>
>>>> <design:usageHints>
>>>> <design:label>Title</design:label>
>>>> <design:formattingHints/>
>>>> </design:usageHints>
>>>> </design:resultColumnDefinitions>
>>>> <design:resultColumnDefinitions>
>>>> <design:attributes>
>>>> <design:name>Author</design:name>
>>>> <design:position>2</design:position>
>>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>>> <design:precision>-1</design:precision>
>>>> <design:scale>-1</design:scale>
>>>> <design:nullability>Unknown</design:nullability>
>>>> </design:attributes>
>>>> <design:usageHints>
>>>> <design:label>Author</design:label>
>>>> <design:formattingHints/>
>>>> </design:usageHints>
>>>> </design:resultColumnDefinitions>
>>>> <design:resultColumnDefinitions>
>>>> <design:attributes>
>>>> <design:name>category</design:name>
>>>> <design:position>3</design:position>
>>>> <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
>>>> <design:precision>-1</design:precision>
>>>> <design:scale>-1</design:scale>
>>>> <design:nullability>Unknown</design:nullability>
>>>> </design:attributes>
>>>> <design:usageHints>
>>>> <design:label>category</design:label>
>>>> <design:formattingHints/>
>>>> </design:usageHints>
>>>> </design:resultColumnDefinitions>
>>>> </design:resultSetColumns>
>>>> <design:criteria/>
>>>> </design:resultSetDefinitions>
>>>> </design:ResultSets>
>>>> </model:DesignValues>]]></xml-property>
>>>> <list-property name="privateDriverProperties">
>>>> <ex-property>
>>>> <name>MAX_ROW</name>
>>>> <value>-1</value>
>>>> </ex-property>
>>>> <ex-property>
>>>> <name>XML_FILE</name>
>>>> </ex-property>
>>>> </list-property>
>>>> </oda-data-set>
>>>> </data-sets>
>>>> <styles>
>>>> <style name="report" id="4">
>>>> <property name="fontFamily">sans-serif</property>
>>>> <property name="fontSize">10pt</property>
>>>> </style>
>>>> <style name="crosstab-cell" id="5">
>>>> <property name="borderBottomColor">#CCCCCC</property>
>>>> <property name="borderBottomStyle">solid</property>
>>>> <property name="borderBottomWidth">1pt</property>
>>>> <property name="borderLeftColor">#CCCCCC</property>
>>>> <property name="borderLeftStyle">solid</property>
>>>> <property name="borderLeftWidth">1pt</property>
>>>> <property name="borderRightColor">#CCCCCC</property>
>>>> <property name="borderRightStyle">solid</property>
>>>> <property name="borderRightWidth">1pt</property>
>>>> <property name="borderTopColor">#CCCCCC</property>
>>>> <property name="borderTopStyle">solid</property>
>>>> <property name="borderTopWidth">1pt</property>
>>>> </style>
>>>> <style name="crosstab" id="6">
>>>> <property name="borderBottomColor">#CCCCCC</property>
>>>> <property name="borderBottomStyle">solid</property>
>>>> <property name="borderBottomWidth">1pt</property>
>>>> <property name="borderLeftColor">#CCCCCC</property>
>>>> <property name="borderLeftStyle">solid</property>
>>>> <property name="borderLeftWidth">1pt</property>
>>>> <property name="borderRightColor">#CCCCCC</property>
>>>> <property name="borderRightStyle">solid</property>
>>>> <property name="borderRightWidth">1pt</property>
>>>> <property name="borderTopColor">#CCCCCC</property>
>>>> <property name="borderTopStyle">solid</property>
>>>> <property name="borderTopWidth">1pt</property>
>>>> </style>
>>>> </styles>
>>>> <page-setup>
>>>> <simple-master-page name="Simple MasterPage" id="2">
>>>> <page-footer>
>>>> <text id="3">
>>>> <property name="contentType">html</property>
>>>> <text-property name="content"><![CDATA[<value-of>new
>>>> Date()</value-of>]]></text-property>
>>>> </text>
>>>> </page-footer>
>>>> </simple-master-page>
>>>> </page-setup>
>>>> <body>
>>>> <data id="31">
>>>> <list-property name="boundDataColumns">
>>>> <structure>
>>>> <property name="name">Column Binding</property>
>>>> <expression name="expression"
>>>> type="javascript">myparmdefaultvalue;</expression>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> </list-property>
>>>> <property name="resultSetColumn">Column Binding</property>
>>>> </data>
>>>> <table id="9">
>>>> <property name="dataSet">Data Set</property>
>>>> <list-property name="boundDataColumns">
>>>> <structure>
>>>> <property name="name">Title</property>
>>>> <text-property name="displayName">Title</text-property>
>>>> <expression name="expression"
>>>> type="javascript">dataSetRow["Title"]</expression>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="name">Author</property>
>>>> <text-property name="displayName">Author</text-property>
>>>> <expression name="expression"
>>>> type="javascript">dataSetRow["Author"]</expression>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="name">category</property>
>>>> <text-property name="displayName">category</text-property>
>>>> <expression name="expression"
>>>> type="javascript">dataSetRow["category"]</expression>
>>>> <property name="dataType">string</property>
>>>> </structure>
>>>> </list-property>
>>>> <column id="28"/>
>>>> <column id="29"/>
>>>> <column id="30"/>
>>>> <header>
>>>> <row id="10">
>>>> <cell id="11">
>>>> <label id="12">
>>>> <text-property name="text">Title</text-property>
>>>> </label>
>>>> </cell>
>>>> <cell id="13">
>>>> <label id="14">
>>>> <text-property name="text">Author</text-property>
>>>> </label>
>>>> </cell>
>>>> <cell id="15">
>>>> <label id="16">
>>>> <text-property name="text">category</text-property>
>>>> </label>
>>>> </cell>
>>>> </row>
>>>> </header>
>>>> <detail>
>>>> <row id="17">
>>>> <cell id="18">
>>>> <data id="19">
>>>> <property name="resultSetColumn">Title</property>
>>>> </data>
>>>> </cell>
>>>> <cell id="20">
>>>> <data id="21">
>>>> <property name="resultSetColumn">Author</property>
>>>> </data>
>>>> </cell>
>>>> <cell id="22">
>>>> <data id="23">
>>>> <property name="resultSetColumn">category</property>
>>>> </data>
>>>> </cell>
>>>> </row>
>>>> </detail>
>>>> <footer>
>>>> <row id="24">
>>>> <cell id="25"/>
>>>> <cell id="26"/>
>>>> <cell id="27"/>
>>>> </row>
>>>> </footer>
>>>> </table>
>>>> </body>
>>>> </report>
>>>>
>>>>
>>>> On 8/26/2010 5:33 AM, vm wrote:
>>>>> I now do:
>>>>>
>>>>> public List<String> readAllParameters(DataSetHandle ds) {
>>>>> System.out.println(ds.getProperty("queryText"));
>>>>> PropertyHandle pp =
>>>>> ds.getPropertyHandle(DataSetHandle.PARAMETERS_PROP);
>>>>> OdaDataSetParameter pl_1 = (OdaDataSetParameter) pp.get(0);
>>>>> String myparmname = pl_1.getName();
>>>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>>>> .....
>>>>> }
>>>>>
>>>>> but the line:
>>>>>
>>>>> String myparmdefaultvalue = pl_1.getDefaultValue();
>>>>>
>>>>> gives a NullPointerException even though the querytext on the
>>>>> dataset is
>>>>> valid and contains (from the above print statement):
>>>>>
>>>>> table0#-TNAME-#table0#:#[/root/parameters]#:#{box;STRING;/pa rameter[@id= "box"]/@value},{length;STRING;/parameter[@id="length"]/@value}
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> any ideas?
>>>>>
>>>>>
>>>>>
>>>>> "Jason Weathersby" <jasonweathersby@windstream.net> wrote in message
>>>>> news:i53p91$hi2$1@build.eclipse.org...
>>>>>> If you want the design for the dataset parameter use script
>>>>>> similar to
>>>>>> this:
>>>>>>
>>>>>> var pl =
>>>>>> reportContext.getDesignHandle().getDataSets().get(0).getProp ertyHandle( "parameters");
>>>>>>
>>>>>>
>>>>>>
>>>>>> //first ds parameter OdaDataSetParameter
>>>>>> var pl_1 = pl.get(0);
>>>>>> myparmname = pl_1.getName();
>>>>>> myparmdefaultvalue = pl_1.getDefaultValue();
>>>>>>
>>>>>> You use the api like
>>>>>> PropertyHandle phl
>>>>>> =dsHandle.getPropertyHandle(DataSetHandle.PARAMETERS_PROP );
>>>>>> OdaDataSetParameter prm1 = (OdaDataSetParameter)phl.get(0);
>>>>>> prm1.getName();
>>>>>>
>>>>>> Jason
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 8/25/2010 10:06 AM, vm wrote:
>>>>>>> I have a .rptdesign with a working dataset connected to a xml
>>>>>>> datasource
>>>>>>> containing a bunch of parameters. I would like to read those
>>>>>>> parameters
>>>>>>> using the birt api. Here is what I do:
>>>>>>>
>>>>>>> List<String> parameters = new ArrayList<String>();
>>>>>>> OdaDataSetHandle de = (OdaDataSetHandle) ds;
>>>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>>>> List<?> cols = (List<?>) cachedMeta.getResultSet().getValue();
>>>>>>> for (int i = 0; i < cols.size(); i++) {
>>>>>>> ResultSetColumn rsc = (ResultSetColumn) cols.get(i);
>>>>>>> String name = rsc.getColumnName();
>>>>>>> parameters.add(name);
>>>>>>> }
>>>>>>>
>>>>>>> this works fine if the .rptdesign file has already been used (eg.
>>>>>>> added
>>>>>>> some tables and added some parameters).
>>>>>>>
>>>>>>> But if I load a .rptdesign file which has no content on the master
>>>>>>> page
>>>>>>> the above line:
>>>>>>>
>>>>>>> CachedMetaDataHandle cachedMeta = de.getCachedMetaDataHandle();
>>>>>>>
>>>>>>> fails with a NullPointerException. I guess this is because the data
>>>>>>> has
>>>>>>> not been cached jet. But how do I read data set parameters from a
>>>>>>> .rptdesign file which has no other content or has not been run jet?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>
>>
Previous Topic:Where is the beforeOpen script?
Next Topic:BIRT Training Classes - Oct.
Goto Forum:
  


Current Time: Tue Mar 19 05:28:12 GMT 2024

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

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

Back to the top