The community of Analytics developers are invited to follow and participate in the developer network.
OpenText technical experts collaborate with supported customers and partners in the Magellan product area.

Dynamicaly Add New dataset

edited December 31, 1969 in Designing reports
Hi All,

First of all i would like to know is it possible to add new dataset Dynamically in the report and insert new graph to show values coming from the dataset ?

Thanks

lrnit

Comments

  • edited October 5, 2011
    Hi ,


    I have one table which has three columns and n no of rows.

    1 column is ID (to identify particular row )
    2 column contains Select Statement
    3 column contains Where clause


    Now what i require is call these Select and where fields make a query and run it using the id as parameter to identify row.

    After that i have to show this value in any chart.

    i have been able to do so for predefined no of arguments X.

    By defining X dummy dataset and writing script on open before

    this.queryString = queryN;


    How this could be done dynamically or is it Possible or not?


    Any help will be appreciated.

    Thanks

    lrnit
  • mwilliamsmwilliams BIRT Guru
    edited December 31, 1969
    Sorry for the delay. I was at JavaOne this week. Take a look at this post by John Ward:

    http://www.birt-exchange.org/org/devshare/interactive-reporting/1317-using-the-deapi-to-dynamically-add-a-data-set/

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog
    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited October 10, 2011
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="83846" data-time="1318008948" data-date="07 October 2011 - 10:35 AM"><p>
    Sorry for the delay. I was at JavaOne this week. Take a look at this post by John Ward:<br />
    <br />
    <a class='bbc_url' href='http://www.birt-exchange.org/org/devshare/interactive-reporting/1317-using-the-deapi-to-dynamically-add-a-data-set/'>http://www.birt-exchange.org/org/devshare/interactive-reporting/1317-using-the-deapi-to-dynamically-add-a-data-set/</a><br /></p></blockquote>
    <br />
    <br />
    Hi I have added this in my report design beforFactory / Initalize event But it gives error on fist line it self. Am i missing something here ?<br />
    <br />
    public class ReportEventHandler extends ReportEventAdapter {<br />
    <br />
    @Override&lt;br />
    public void beforeFactory(IReportDesign report, IReportContext reportContext) {<br />
    super.beforeFactory(report, reportContext);<br />
    <br />
    try {<br />
    ReportDesignHandle reportDesign = reportContext.getDesignHandle();<br />
    OdaDataSetHandle dataSet = reportDesign.getElementFactory().newOdaDataSet("Data Set", "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet");<br />
    <br />
    dataSet.setDataSource("Data Source");<br />
    dataSet.setQueryText("select employeenumber from employees where employeenumber = ?");<br />
    <br />
    OdaDataSetParameter param = new OdaDataSetParameter();<br />
    <br />
    param.setName("param_1");<br />
    param.setParamName("empNo");<br />
    param.setNativeName("");<br />
    param.setDataType("integer");<br />
    param.setNativeDataType(4);<br />
    param.setPosition(1);<br />
    param.setIsInput(true);<br />
    param.setIsOutput(false);<br />
    <br />
    dataSet.getPropertyHandle(DataSetHandle.PARAMETERS_PROP).addItem(param);<br />
    <br />
    OdaResultSetColumn result = new OdaResultSetColumn();<br />
    result.setColumnName("EMPLOYEENUMBER");<br />
    result.setNativeName("EMPLOYEENUMBER");<br />
    result.setDataType("integer");<br />
    result.setPosition(1);<br />
    result.setNativeDataType(4);<br />
    dataSet.getPropertyHandle(DataSetHandle.RESULT_SET_PROP).addItem(result);<br />
    <br />
    ColumnHint resultHint = new ColumnHint();<br />
    resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, "EMPLOYEENUMBER");<br />
    resultHint.setProperty(ColumnHint.COLUMN_NAME_MEMBER, "integer");<br />
    <br />
    dataSet.getPropertyHandle(DataSet.COLUMN_HINTS_PROP).addItem(resultHint);<br />
    <br />
    //this works<br />
    reportDesign.getDataSets().add(dataSet);<br />
    <br />
    //and so does this<br />
    //reportDesign.getSlot(ReportDesignHandle.DATA_SET_SLOT).add(dataSet);<br />
    <br />
    //just saving for debug purposes, you can ignore this<br />
    reportDesign.saveAs("C:/TEMP/MyTestDesign.rptdesign");<br />
    } catch (ContentException e) {<br />
    e.printStackTrace();<br />
    } catch (NameException e) {<br />
    e.printStackTrace();<br />
    } catch (SemanticException e) {<br />
    e.printStackTrace();<br />
    } catch (IOException e) {<br />
    e.printStackTrace();<br />
    }<br />
    }<br />
    }
  • edited December 31, 1969
    Hi ,


    Pls reply. i am still looking for answer.


    thanx

    lrnit
  • How I can execute dynamic query which is set on DataSet inside rptdesign file?
    stageDataSet.setQueryText(dynQuery);

    expected column is not binding on chart/cube , meaning, query on dataSet is set but not executed?

  • yes, its working
    var dataSets = reportContext.getReportRunnable().designHandle.getDesignHandle().getDataSets()
    ....
    newDataSet = reportContext.getReportRunnable().designHandle.getElementFactory().newOdaDataSet("something" + uaIndex)
    newDataSet.setDataSource("JDBC_DataSource");
    newDataSet.setQueryText("select stage_id," + stage.userSpecifiedAnalysis[uaIndex].columnNames.toString() + " from " + stage.userSpecifiedAnalysis[uaIndex].tableName + " where stage_id='" + stage.stageId + "' and journey_id='" + json_param.journeyId + "'")

            dataSets.add(newDataSet);
    
Sign In or Register to comment.