Purging data provider queries using BO RE Java SDK

Before copying webi documents from test to production environment it might be useful to clean up document queries.

The following function

  • purges data providers queries,
  • removes saved prompt values, and
  • regenerates queries.
public static void purgeQueries(DocumentInstance widoc) {
   DataProviders dps = widoc.getDataProviders();
   for (int i = 0; i < dps.getCount(); ++i) {
      DataProvider dp = (DataProvider)dps.getItem(i);
      if (dp instanceof SQLDataProvider) {
         System.out.println("Data provider: " + dp.getName());
         SQLDataProvider sdp = (SQLDataProvider)dp;
         sdp.purge(true); // true means purge prompt values
         sdp.generateQuery();
         sdp.resetSQL();
      }
   }
}

The code is very simple but I use this functionality most often.

More Information

Getting started with BO RE Java SDK
Package com.businessobjects.rebean.wi.*