Search code examples
javacognos

Cognos SDK - Connection parameter to run a report


I am using Cognos SDK to run a report. I am able to pass standard parameters, but in some cases I have to choose Data Source Connection before the report is executed. I know there is a possibility to save Data Source Connection as a ParameterValue.

In our environment for a one data source we have multiple DS connections. Each DS connection have just one signon which is used to sign to the database. So I tried to set up ParameterValue for report execution in following way:

  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);

Unfortunately, I am not able to run the report by this way. I suppose there is a misunderstanding of definition use in SimpleParmValueItem. Do you have any ideas how to pass DS connection parameter to deal with Data Source Connection Prompt page before report execution? I would appreciate any help.

Thank you!


Solution

  • I finally found a solution for our usecase. It had to be changed by following way:

        //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);