//This is a code to get Web Intelligence Reports Dump in a text file -List Objects used in WebI reports import com.crystaldecisions.sdk.occa.infostore.*; import com.crystaldecisions.sdk.plugin.desktop.folder.*; import com.crystaldecisions.sdk.framework.*; import com.crystaldecisions.sdk.exception.SDKException; import com.businessobjects.rebean.wi.*; import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class ListObjectsUsedWebi { public static void main(String args[])throws Exception { //Environment and BO Credentials to Login String boUser = "BO User Name"; String boPassword = "BO Password"; String boCmsName = "CMS:Port Number"; String boAuthType = "secEnterprise"; Date today = Calendar.getInstance().getTime(); DateFormat df = new SimpleDateFormat("yyyyMMdd"); //Location to save the report dump in text file at a location with the current date as the file name File theDir = new File("C:\\repdump\\"); System.out.println("Today. toString "+df.format(today)); File f = new File("C:\\repdump\\"+df.format(today)+ ".txt"); if(theDir.exists()) { } else { System.out.print("Making Directory"); theDir.mkdir(); } FileOutputStream fs = new FileOutputStream(f); PrintStream p= new PrintStream( fs ); //Declaring Objects for IInfoStore ,IInfoObjects,IInfoObject,IEnterpriseSession and to intialize them with Null IInfoStore boInfoStore=null; IInfoObjects boInfoObjects=null; IInfoObject infoObject = null; IEnterpriseSession boEnterpriseSession = null; ReportEngines reportEngines = null; try { // Creating Login Session StringBuffer buf = new StringBuffer(); boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( boUser, boPassword, boCmsName, boAuthType); boInfoStore = (IInfoStore) boEnterpriseSession.getService("", "InfoStore"); System.out.println("Logged in....!"); reportEngines = (ReportEngines) boEnterpriseSession.getService("ReportEngines"); ReportEngine wiRepEngine = (ReportEngine) reportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE); /*select SI_NAME, SI_ID from CI_INFOOBJECTS Where SI_Kind='Webi' would retrieve all the Webi reports present in the repository. We can have some extra condition in the query if required. For eg: SI_NAME */ boInfoObjects = boInfoStore.query("select SI_NAME, SI_ID from CI_INFOOBJECTS Where SI_Kind='Webi'"); // To Create Headings in the file and # is used as a delimiter buf.append("***"+"Report Name#Folder Full Path#Report ID#DP Name#Universe/Source#Has Combined Queries#No.of Result Objects/Condition objects in DP#Class Name#Object Name#Operands#"); // To open each report and retrieve the objects, classes, DataProvider information in the text file for(int i=0;i < boInfoObjects.size(); i++) { infoObject = (IInfoObject) boInfoObjects.get(i); String repname=infoObject.getTitle(); // Report Name int repid=infoObject.getID(); // Report ID DocumentInstance widoc = wiRepEngine.openDocument(infoObject.getID()); //Opening the report DataProviders dataProviders = widoc.getDataProviders(); // Fetches the DataProvider IFolder rfolder=(IFolder) infoObject.getParent(); // Folder information in which the report is present String repfold=rfolder.getTitle(); // Folder Name int parentFolderId=rfolder.getID(); // Folder ID IInfoStore tboinfostore=(IInfoStore) boEnterpriseSession.getService("", "InfoStore"); IInfoObjects tboInfoObjects=null; String temp=""; // To get Folder Full Path while(parentFolderId>0) { String query1= "select SI_ID,SI_NAME,SI_PARENTID from CI_INFOOBJECTS where SI_ID="+parentFolderId ; tboInfoObjects = tboinfostore.query(query1); IInfoObject folder = (IInfoObject)tboInfoObjects.get(0); String folderName = folder.getTitle(); temp=folderName+"\\"+temp; parentFolderId = folder.getParentID(); } // Adding Public Folders as prefix if it is a corporate document if(temp.length()>=12) { String subtemp=temp.substring(0,12); // Substring to get 1-12 characters to know whether the report is from User Folders String tye="User Folders"; if(subtemp.equals(tye)) { repfold=temp; } else { repfold="Public Folders\\"+temp; } } else { repfold="Public Folders\\"+temp; } int dpcount=dataProviders.getCount(); // Number of DataProvider in the report // To retrieve the information of each DataProvider for(int te=0;te