Cognos SDK - 运行 报告的连接参数

Cognos SDK - Connection parameter to run a report

我正在使用 Cognos SDK 运行 一份报告。我可以传递标准参数,但在某些情况下,我必须在执行报表之前选择数据源连接。我知道可以将数据源连接保存为 ParameterValue。

在我们的单一数据源环境中,我们有多个 DS 连接。每个 DS 连接只有一个登录,用于登录到数据库。所以我尝试通过以下方式设置 ParameterValue 以执行报告:

  try {
    bc = cognosSDK.getCMservice().query(new SearchPathMultipleObject("CAMID(\":\")/dataSource[@name='DataSourceA']/dataSourceConnection[@name='ConnectionA']/dataSourceSignon[@name='SignonConA']"), props, new Sort[]{}, new QueryOptions());
       
   }catch (RemoteException ex) {
      ex.printStackTrace();
   }

    //set information for Connection and SignOn
    SimpleParmValueItem spv = new SimpleParmValueItem();
    spv.setDisplay("CAMID(\":\")/dataSource[@name='DataSourceA']/dataSourceConnection[@name='ConnectionA']");
    spv.setUse(((DataSourceSignon)bc[0]).getCredentials().getValue());
    spv.setInclusive(true);


    //Assign DataSource Info
    ParmValueItem[] con = new ParmValueItem[]{spv};
    ParameterValue ds = new ParameterValue();
    ds.setName("credential:DataSourceA");
    ds.setValue(con);

很遗憾,我无法通过这种方式运行报告。我想对 SimpleParmValueItem 中的定义 use 存在误解。您是否有任何想法如何在报表执行之前传递 DS 连接参数来处理数据源连接提示页面?如果有任何帮助,我将不胜感激。

谢谢!

我终于为我们的用例找到了解决方案。必须通过以下方式更改它:

    //set information for Connection and SignOn
SimpleParmValueItem spv = new SimpleParmValueItem();
spv.setDisplay("CAMID(\":\")/dataSource[@name='DataSourceA']/dataSourceConnection[@name='ConnectionA']");
spv.setUse("<credential><dataSourceConnection>CAMID(\":\")/dataSource[@name='DataSourceA']/dataSourceConnection[@name='ConnectionA']</dataSourceConnection><dataSourceSignon/><username/><password/></credential>");
spv.setInclusive(true);


//Assign DataSource Info
ParmValueItem[] con = new ParmValueItem[]{spv};
ParameterValue ds = new ParameterValue();
ds.setName("credential:DataSourceA:password");
ds.setValue(con);