//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 int xc=0; public static ArrayList al=new ArrayList(); public static StringBuffer buf = new StringBuffer(); public static void main(String args[])throws Exception { //Environment and BO Credentials to Login String boUser = "bouser"; String boPassword = "passowrd"; String boCmsName = "cms name"; 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 buf1 = 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_id,si_name from ci_infoobjects where si_kind='webi'and si_id in (give sid's in the list)"); System.out.println("Test..!!") ; // To Create Headings in the file and # is used as a delimiter buf1.append("***"+"Report Name#Folder Full Path#Report ID#DP Name#Universe/Source#Has Combined Queries#Class Name#Object Name#Result Object/Condition Object#Operands#Sub Queries#Combined Queries"); p.println(buf1); // To write the data into the text file from StringBuffer // To open each report and retrieve the objects, classes, DataProvider information in the text file for(int i=0;i < boInfoObjects.size(); i++) { buf.delete(0, buf.length()); 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 System.out.println(repname); 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(); for(int te=0;te=0) { TreeNode tnc=tn.getChildAt(loop); int cnodecount1=tnc.getChildCount(); CombinedQueriesNode(cnodecount1,tnc,repdet); loop--; } } } public static void CombinedQueryResultCondition(Query query,String repdet,String cq) { int RCount=query.getResultObjectCount(); QueryResultObjects(RCount,query,repdet,cq); if(query.hasCondition()) { QueryCondtionObjects(query,repdet,cq); } } public static void QueryResultObjects(int Rcount,Query query,String repdet,String cq) { for(int rc=0;rc0) { loop=ndcount-1; } //System.out.println(ndcount+" Sub-Nodes"); while(loop>=0) { if(fc1.getChildCount()==0) { ConditionObject conobj1=(ConditionObject)fc1; if(conobj1.isPreCondition()) { precon="Pre-Condition"; opvalue=""; }else { precon="Condition Obj"; FilterConditionOperand fco=conobj1.getOperand(); opvalue=fco.toString(); } DataSourceObject sp1=conobj1.getDataSourceObject(); TreeNode cidcon=sp1.getParent(); String cnamecon=cidcon.toString(); al.add(cnamecon+"#"+sp1.getName()+"#"+precon+"#"+opvalue+"#"); xc++; } else { int cksubq=fc1.toString().indexOf("Subquery"); if(cksubq>1 || ind==-1) { Node(ind,fc1.getFilterConditionNode(loop)); } else { al.add("####"+fc1.toString()); xc++; } } loop--; } } }