CDrillPath.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** IBM Cognos Products: drill
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2011
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with
  10. ** IBM Corp.
  11. *****************************************************************/
  12. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  13. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  14. /**
  15. *
  16. * This application is used to generate the SOAP messages that are required to
  17. * send add, query, and update requests to the server and also handles the response
  18. * with proper action (e.g. error message)
  19. *
  20. * To use this javascript library following variable and resources should be initialize in hte html file
  21. * //HAL Options
  22. * G_HALOptions = { "isApplication" : false, "path" : "/cognos8/" };
  23. * G_CCHLOptions = { "path" : "/cognos8/" };
  24. * G_CCHL.M_sProductLocale ='en';
  25. * G_CCHL.M_sContentLocale ='en-us';
  26. * G_BusServer.F_SetRouterServerGroup() ;
  27. * G_BusServer.F_SetCafContextId(cafContextId);
  28. *
  29. * This file uses following HAL resources that need to be loaded in the html file
  30. *
  31. * <link type="text/css" rel="stylesheet" href="/cognos8/skins/business/hal/hal_portal_skin_business.css"/>
  32. * <script language="javascript" src="/cognos8/hal/hal.js"/>
  33. * <script language="javascript" src="/cognos8/cchl/cchl.js"/>
  34. * <script src="/cognos8/camcrypto/base64.js"></script>
  35. * <script src="/cognos8/camcrypto/camcryptoutil.js"></script>
  36. * <script src="/cognos8/camcrypto/sha1.js"></script>
  37. * <script src="/cognos8/camcrypto/authtoken1.js"></script>
  38. * G_CCHL.M_sGatewayURL ='http://localhost/cognos8/cgi-bin/cognos.cgi';
  39. * G_HAL.F_Include("hal/C_WebRequest.js");
  40. * G_HAL.F_Include("cchl/C_BusRequest.js");
  41. * G_HAL.F_Include("hal/D_Progress.js");
  42. * G_HAL.F_Include( "hal/C_Dialog.js" );
  43. * G_HAL.F_Include( "cchl/dialogs/D_DetailedMsgBox.js" );
  44. * G_HAL.F_Include( "hal/G_ResManager.js" );
  45. * G_HAL.F_Include( "hal/C_Error.js" );
  46. *
  47. * This should be added to the end of HTML file
  48. *
  49. * <script>
  50. * G_HAL.F_WriteHtml();
  51. * </script>
  52. *
  53. * @author Alireza Pourshahid
  54. */
  55. // Defines the HAL
  56. var G_DrillPath = {};
  57. // Global variables
  58. var el_oForm; // the HTML form that is passed and contains the inputs
  59. var g_sParentPath = ''; // the location that drillpath is saved
  60. var g_sDefaultName = ''; // drill path name
  61. var g_sDefaultDescription = ''; // drill path default description
  62. var g_sDefaultScreenTip = ''; // drill path default sceen tip
  63. var g_sAction = ''; // this is the run action can be either edit or run
  64. var g_bUseEditSpecification = ''; // specifies if dynamic filtering is used when we run the drill through
  65. var g_sScope = ''; // contains a model data item as the drill path scope
  66. var g_sTargetSearchPath = ''; // the search path of the target object
  67. var g_sOutputFormat = ''; // the out format of the target report (e.g. PDF, HTML, XML ...)
  68. var g_bPromptOption = ''; // Specifies whether wether we always promt the user or not
  69. var g_sBookMarkItem = ''; // contains a model data item as bookMarkItem in the target
  70. var g_sBookMarkText = ''; // contains a lable that is a bookmark in the target
  71. var g_sTargetClass = ''; // specifies the class of the target object (e.g. report, query, analysis, powerPlay8Report, package)
  72. var g_sRequestType = ''; // This is used to specify the type of the request. Can be AddDrillPath, QueryDrillPath, UpdateDrillPath
  73. // It is used by functions to act appropriatly based on the request type.
  74. var g_sDrillPathObjectSearchPath = ''; // This is the search path to the Drill path object that is used in the update method
  75. // Called during the window.onload event
  76. // This is used to load the required strings
  77. //This (G_DrillPath.F_HAL_OnLoad = function()) is the function that should be used for HAL applications
  78. // however since xts generate init() function that takes over the the load event we have renamed the function
  79. function init()
  80. {
  81. // Asynchronously load resources
  82. G_ResManager.F_SetLocale(G_CCHL.M_sProductLocale);
  83. // loads the string files that are require
  84. G_ResManager.F_LoadStrings( new Array( "cchl/res/cchl_strings",G_CCHLOptions.path+"drill/res/drill_strings"), G_DrillPath );
  85. };
  86. G_DrillPath.F_ResManager_OnStringsLoaded = function ( v_aFiles )
  87. {
  88. G_ResManager.F_LoadResources( new Array( "cchl/res/cchl_resources.xml" ), this );
  89. };
  90. G_DrillPath.F_ResManager_OnResourcesLoaded = function( v_aFiles )
  91. {
  92. };
  93. G_DrillPath.F_HAL_OnUnLoad = function()
  94. {
  95. };
  96. /**
  97. * Generates the add request and calls the adddrillPath method with a SOAP requesst
  98. * Uses C_BusRequest from CCHL
  99. * @el_oForm the HTML form object that contains the inputs
  100. * @v_sTargetClass the class of drill path target
  101. * @v_sUpdateAction This is the update action when the add request is sent
  102. if it is replace the drill path will be replaced
  103. * @author Alireza Pourshahid
  104. */
  105. G_DrillPath.F_addDrillPath = function(v_oForm,v_sTargetClass, v_sUpdateAction){
  106. // if we pass the update action it means user has been prompted to select the action (rename or replace)
  107. // this means this is the second request we are going to send after the first failure due to having an object
  108. // with the same name so we have already processed the form and
  109. // initialized the variables we need to build the request and don't need to do
  110. // the steps inside the if anymore
  111. if (v_sUpdateAction != 'rename' && v_sUpdateAction != 'replace')
  112. {
  113. // set the passed in form object into global object
  114. el_oForm = v_oForm;
  115. // set the target class
  116. g_sTargetClass = v_sTargetClass;
  117. // set the request type
  118. g_sRequestType = "addDrillPath";
  119. // get the data from HTML page;
  120. this.F_getHTMLPageData();
  121. }
  122. v_sBusRequest = " <rns1:addDrillPath xmlns:rns1=\"http://developer.cognos.com/schemas/reportService/1\">\r\n" +
  123. " <bus:parentPath xsi:type=\"bus:searchPathSingleObject\">"+g_sParentPath+"</bus:parentPath>\r\n" +
  124. " <bus:object xsi:type=\"bus:drillPath\">\r\n" +
  125. this.F_getDefaultName()+
  126. this.F_getDefaultDescription()+
  127. this.F_getDefaultScreenTip()+
  128. this.F_getAction()+
  129. this.F_getScope()+
  130. this.F_getParameterAssignments()+
  131. this.F_getDrillSpec()+
  132. " <bus:options xsi:type=\"bus:optionArrayProp\">\r\n" +
  133. " <bus:value xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:option[3]\">\r\n" +
  134. this.F_getOutputFormat()+
  135. this.F_getPrompt()+
  136. this.F_getUseEditSpecification()+
  137. " </bus:value>\r\n" +
  138. " </bus:options>\r\n" +
  139. this.F_getBookMark()+
  140. " </bus:object>\r\n";
  141. // the drill path will be replaced
  142. if (v_sUpdateAction == 'replace')
  143. {
  144. v_sBusRequest = v_sBusRequest + "<bus:options xsi:type=\"bus:addOptions\">\r\n" +
  145. " <bus:faultIfObjectReferenced xsi:type=\"xs:boolean\">false</bus:faultIfObjectReferenced>\r\n" +
  146. " <bus:ignoreInvalidObjectReference xsi:type=\"xs:boolean\">false</bus:ignoreInvalidObjectReference>\r\n" +
  147. " <bus:returnProperties xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:propEnum[0]\"/>\r\n" +
  148. " <bus:updateAction xsi:type=\"bus:updateActionEnum\">replace</bus:updateAction>\r\n" +
  149. " </bus:options>\r\n" +
  150. " </rns1:addDrillPath>" ;
  151. }
  152. else
  153. {
  154. v_sBusRequest = v_sBusRequest + "<bus:options xsi:type=\"bus:addOptions\">\r\n" +
  155. " <bus:faultIfObjectReferenced xsi:type=\"xs:boolean\">false</bus:faultIfObjectReferenced>\r\n" +
  156. " <bus:ignoreInvalidObjectReference xsi:type=\"xs:boolean\">false</bus:ignoreInvalidObjectReference>\r\n" +
  157. " <bus:returnProperties xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:propEnum[0]\"/>\r\n" +
  158. " <bus:updateAction xsi:type=\"bus:updateActionEnum\">fail</bus:updateAction>\r\n" +
  159. " </bus:options>\r\n" +
  160. " </rns1:addDrillPath>" ;
  161. }
  162. var v_oRequest = new C_BusRequest( this , C_BusRequest.K_sSOAPAction_reportService, v_sBusRequest );
  163. // This is used for debuging to dump the request to a text (requestDump)
  164. // it only works if requestDump exist in the html page
  165. if (el_oForm.requestDump){
  166. el_oForm.requestDump.value = v_sBusRequest;
  167. }
  168. this.F_sendRequest(v_oRequest);
  169. return false;
  170. };
  171. /**
  172. * Gets form variables, generate the drill specification, and update the drill spec form variable
  173. * @See this.F_getDrillSpecString()
  174. * @el_oForm the HTML form object that contains the inputs
  175. * @v_sTargetClass the class of drill path target. This is used to generate appropriate drill spec based on the target.
  176. * @author Alireza Pourshahid
  177. */
  178. G_DrillPath.F_updateDrillPath = function(v_oForm,v_sTargetClass){
  179. // set the passed in form object into global object
  180. el_oForm = v_oForm;
  181. // set the target class
  182. g_sTargetClass = v_sTargetClass;
  183. // set the request type
  184. g_sRequestType = "updateDrillPath";
  185. // get the data from HTML page;
  186. this.F_getHTMLPageData();
  187. // get a new list of parameters (defined in Specs but not visible)
  188. G_DrillPath.F_getNewParameterList();
  189. // make sure that we don't have any problem with non abacab targets
  190. if(el_oForm.m_p_target){el_oForm.removeChild(el_oForm.m_p_target);}
  191. el_oForm.m_p_specification.value = this.F_getDrillSpecString();
  192. return true;
  193. }
  194. G_DrillPath.F_D_RenameReplace_OnOK = function(v_oDialog,v_sUpdateAction, v_sDrillNewName)
  195. {
  196. // This function is defined in the xts page
  197. // It enables the select controls and change their color
  198. // This has done as a part of work around for IE 6 bug for select z-index
  199. // without this work around select controls were popping over the dialog blocker
  200. F_selectUnblocker();
  201. v_oDialog.F_Hide();
  202. if (v_sUpdateAction == "rename")
  203. {
  204. g_sDefaultName = v_sDrillNewName;
  205. }
  206. this.F_addDrillPath(null,null,v_sUpdateAction);
  207. }
  208. //G_DrillPath.F_D_Choose_OnCancel= function(v_oDialog)
  209. G_DrillPath.F_D_RenameReplace_OnCancel= function(v_oDialog)
  210. {
  211. F_selectUnblocker();
  212. v_oDialog.F_Hide();
  213. }
  214. /**
  215. * sends the SOAP request to the server
  216. * @v_oRequest the request body
  217. * @author Alireza Pourshahid
  218. */
  219. G_DrillPath.F_sendRequest = function (v_oRequest){
  220. // Send the request via a progress bar
  221. switch (g_sRequestType)
  222. {
  223. case "addDrillPath":
  224. v_sRequestMessage = G_ResManager.F_GetString("IDS_WIZARD_SAVING");
  225. break;
  226. case "updateDrillPath":
  227. v_sRequestMessage = G_ResManager.F_GetString("IDS_WIZARD_SAVING");
  228. break;
  229. case "queryDrillPath":
  230. v_sRequestMessage = G_ResManager.F_GetString("IDS_WIZARD_PLEASE_WAIT");
  231. break;
  232. }
  233. // This function is defined in the xts page
  234. // It disables the select controls and change their color to Gray
  235. // This has done as a part of work around for IE 6 bug for select z-index
  236. // without this work around select controls were popping over the dialog blocker
  237. F_selectBlocker();
  238. // Set the Title of Adding Dialog to blank
  239. C_Dialog.F_SetDefaultTitle(" ");
  240. D_Progress.F_SendRequest( v_oRequest, el_oForm, v_sRequestMessage );
  241. }
  242. G_DrillPath.F_OnCancel = function()
  243. {
  244. return false;
  245. };
  246. /**
  247. * Handles the response of the SOAP request
  248. * In case of addDrillPath request submit the form and goes to cc_drillthrough.xts
  249. * @v_oRequest the SOAP request
  250. */
  251. G_DrillPath.F_Request_OnComplete = function(v_oRequest){
  252. var v_oError = v_oRequest.F_GetError();
  253. if (v_oError)
  254. {
  255. //TODO: in IB9 the fix for HAL bug in this area is dropped
  256. // Add title and description to the message box
  257. var v_sMsg = "You Drill path cannot be saved!";
  258. var v_sTitle = "Drill Path Save result";
  259. var v_sDetails = v_oError.F_GetErrorSummary();
  260. var v_sErrorCode = v_oError.F_GetErrorCode();
  261. var v_oErrorMessage = new C_Error( v_sMsg, v_sDetails, v_sErrorCode );
  262. // check for the error number which is due to existence of an object with the same name
  263. // show the replace or rename dialog
  264. if (v_sErrorCode=='CM-REQ-4024')
  265. {
  266. // This function is defined in the xts page
  267. // It disables the select controls and change their color to Gray
  268. // This has done as a part of work around for IE 6 bug for select z-index
  269. // without this work around select controls were popping over the dialog blocker
  270. F_selectBlocker();
  271. D_RenameReplace.F_Show( el_oForm, "", this, g_sDefaultName);
  272. }
  273. else
  274. {
  275. F_ShowError(v_oError);
  276. }
  277. }
  278. else
  279. {
  280. switch (g_sRequestType)
  281. {
  282. case "addDrillPath":
  283. window.location = el_oForm.backURL.value;
  284. break;
  285. case "updateDrillPath":
  286. el_oForm.removeChild(el_oForm.m_p_target);
  287. el_oForm.ps_nav_op.value = 'submit';
  288. el_oForm.m.value = 'portal/submit.xts';
  289. el_oForm.submit();
  290. break;
  291. case "queryDrillPath":
  292. var v_docSoapResponse = v_oRequest.F_GetResponse();
  293. this.F_processQueryResponse(v_docSoapResponse);
  294. break;
  295. }
  296. }
  297. }
  298. /** Handles the response of queryDrillPath request.
  299. * Get a drill specs from the soap response and set Vars needed for property sheet.
  300. * @v_docSoapResponse : A Soap response.
  301. **/
  302. G_DrillPath.F_processQueryResponse = function(v_docSoapResponse) {
  303. var v_docDrillSpecs = v_docSoapResponse.selectSingleNode( "/SOAP-ENV:Envelope/SOAP-ENV:Body/rns1:queryDrillPathResponse/bus:result/bus:details/item/bus:drillPath/bus:specification/bus:value");
  304. if (v_docDrillSpecs){
  305. var v_docDrillSpecsDecoded = U_XML.F_LoadString(null, v_docDrillSpecs.text, false, true);
  306. v_docDrillSpecsDecoded.setProperty( "SelectionNamespaces", "xmlns:dts='http://developer.cognos.com/schemas/drillThroughSpecification/1/'" );
  307. /* comment out the call since the current RSVP queryDrillPath() function does not return the correct drill specs yet*/
  308. //this.F_setPropertiesFromDrillSpecs(v_docDrillSpecsDecoded);
  309. }
  310. }
  311. /** Set drill path Properties from the drill specs.
  312. * @v_docDrillSpecs : drill specs from the soap response
  313. **/
  314. G_DrillPath.F_setPropertiesFromDrillSpecs = function(v_docDrillSpecs) {
  315. if (v_docDrillSpecs) {
  316. /* set serach path*/
  317. var v_docSearchPath = v_docDrillSpecs.selectSingleNode("//dts:searchPath");
  318. if ( v_docSearchPath && el_oForm.m_path) {
  319. el_oForm.m_path.value = v_docSearchPath.text;
  320. }
  321. /* set target path */
  322. var v_docTargetSearchPath = v_docDrillSpecs.selectSingleNode("//dts:targetSearchPath");
  323. if (v_docTargetSearchPath && el_oForm.m_p_target) {
  324. el_oForm.m_p_target.value = v_docTargetSearchPath.text;
  325. }
  326. /* set action */
  327. var v_docAction = v_docDrillSpecs.selectSingleNode("//dts:action");
  328. if (v_docAction && el_oForm.m_p_action) {
  329. el_oForm.m_p_action.value = v_docAction.text;
  330. }
  331. }
  332. }
  333. /**
  334. * Generates the XML node required for adding parameter assignments
  335. * @return parameterAssignmentsXML XML node that contains the part of the request related to PromptOption
  336. * @author alireza pourshahid
  337. */
  338. G_DrillPath.F_getParameterAssignments = function(){
  339. var items = "";
  340. for(i=0;i < el_oForm.elements.length; i++)
  341. {
  342. if(el_oForm.elements[i].name.indexOf('drillParam_')==0)
  343. {
  344. if(el_oForm.elements[i].value != "")
  345. {
  346. items = items+"<item xsi:type=\"bus:parameterAssignmentDataItem\">\r\n" +
  347. "<bus:parameterName xsi:type=\"xs:string\">"+document.getElementsByName("name_" + el_oForm.elements[i].name)[0].value.F_XMLEncode()+"</bus:parameterName>\r\n" +
  348. "<bus:dataItemName xsi:type=\"bus:metadataModelItemName\">"+el_oForm.elements[i].value.F_XMLEncode()+"</bus:dataItemName>\r\n" +
  349. "</item>\r\n";
  350. }
  351. }
  352. }
  353. parameterAssignmentsXML = "<bus:parameterAssignments xsi:type=\"bus:baseParameterAssignmentArrayProp\">\r\n" +
  354. " <bus:value xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:baseParameterAssignment[1]\">\r\n"+
  355. items+
  356. " </bus:value>\r\n" +
  357. " </bus:parameterAssignments>\r\n";
  358. return parameterAssignmentsXML;
  359. };
  360. /**
  361. * Generates the XML node required for adding the drill spec to the SOAP request
  362. * @v_sDrillSpec the drill spec
  363. * @return m_nDrillSpecProp XML node that contains the part of drill spec
  364. * @author alireza pourshahid
  365. */
  366. G_DrillPath.F_getDrillSpec = function(){
  367. var v_sDrillSpec = "";
  368. v_sDrillSpec = this.F_getDrillSpecString();
  369. var m_nDrillSpecProp = " <bus:specification xsi:type=\"bus:reportServiceDrillThroughSpecificationProp\">\r\n" +
  370. " <bus:value xsi:type=\"bus:reportServiceDrillThroughSpecification\">\r\n" +
  371. " <bus:value xsi:type=\"bus:specification\">"+v_sDrillSpec+"</bus:value>\r\n" +
  372. " </bus:value>\r\n" +
  373. " </bus:specification>\r\n";
  374. return m_nDrillSpecProp;
  375. };
  376. /**
  377. * Method F_GetDrillSpecString generates the drill spec
  378. * TODO : This part can be moved to a another class
  379. */
  380. G_DrillPath.F_getDrillSpecString = function(){
  381. var v_sDrillSpec = "";
  382. //TODO: Add other target objects specific DrillSpec to here when we start using add method for all target objects
  383. if (g_sTargetClass == 'report' || g_sTargetClass == 'reportView' || g_sTargetClass == 'query' || g_sTargetClass == 'analysis'){
  384. v_sDrillSpec = "&lt;dts:drillThroughSpecification xmlns:dts=&quot;http://developer.cognos.com/schemas/drillThroughSpecification/1/&quot;&gt;"+
  385. "&lt;dts:modelSearchPaths&gt;"+
  386. "&lt;dts:searchPath&gt;"+g_sParentPath.F_XMLEncode()+"/model[last()]"+
  387. "&lt;/dts:searchPath&gt;"+
  388. "&lt;/dts:modelSearchPaths&gt;"+
  389. this.F_getDrillSpecParameterAssignments()+
  390. "&lt;dts:reportTarget&gt;"+
  391. "&lt;dts:action&gt;#"+g_sAction+"&lt;/dts:action&gt;"+
  392. "&lt;dts:targetSearchPath&gt;"+g_sTargetSearchPath.F_XMLEncode()+"&lt;/dts:targetSearchPath&gt;"+
  393. "&lt;/dts:reportTarget&gt;"+
  394. "&lt;/dts:drillThroughSpecification&gt;";
  395. } // if authored report
  396. if (g_sTargetClass == 'powerPlay8Report' || g_sTargetClass == 'powerPlay8ReportView')
  397. {
  398. v_sDrillSpec = "&lt;dts:drillThroughSpecification xmlns:dts=&quot;http://developer.cognos.com/schemas/drillThroughSpecification/1/&quot;&gt;"+
  399. "&lt;dts:modelSearchPaths&gt;"+
  400. "&lt;dts:searchPath&gt;"+g_sParentPath.F_XMLEncode()+"/model[last()]"+
  401. "&lt;/dts:searchPath&gt;"+
  402. "&lt;/dts:modelSearchPaths&gt;"+
  403. "&lt;dts:powerPlay8ReportTarget&gt;"+
  404. "&lt;dts:action&gt;#"+g_sAction+"&lt;/dts:action&gt;"+
  405. "&lt;dts:targetSearchPath&gt;"+g_sTargetSearchPath.F_XMLEncode()+"&lt;/dts:targetSearchPath&gt;"+
  406. "&lt;/dts:powerPlay8ReportTarget&gt;"+
  407. "&lt;/dts:drillThroughSpecification&gt;";
  408. } // if powerPlay8report
  409. if (g_sTargetClass == 'package')
  410. {
  411. v_sDrillSpec = "&lt;dts:drillThroughSpecification xmlns:dts=&quot;http://developer.cognos.com/schemas/drillThroughSpecification/1/&quot;&gt;"+
  412. "&lt;dts:modelSearchPaths&gt;"+
  413. "&lt;dts:searchPath&gt;"+g_sParentPath.F_XMLEncode()+"/model[last()]"+
  414. "&lt;/dts:searchPath&gt;"+
  415. "&lt;/dts:modelSearchPaths&gt;"+
  416. "&lt;dts:packageTarget&gt;"+
  417. "&lt;dts:action&gt;#"+g_sAction+"&lt;/dts:action&gt;"+
  418. "&lt;dts:targetSearchPath&gt;"+g_sTargetSearchPath.F_XMLEncode()+"&lt;/dts:targetSearchPath&gt;"+
  419. "&lt;/dts:packageTarget&gt;"+
  420. "&lt;/dts:drillThroughSpecification&gt;";
  421. } // if package
  422. return v_sDrillSpec;
  423. };
  424. // Get parameters defined in the drill specs but not in visible list
  425. G_DrillPath.F_getNewParameterList = function(){
  426. this.v_aVisibleList = new Array();
  427. var v_aOriList = new Array();
  428. this.v_aNewList = new Array();
  429. var v_iVisibleIndex = 0;
  430. var v_iOriIndex = 0;
  431. var v_OriListString = new String("");
  432. for (i = 0; i < el_oForm.elements.length; i++)
  433. {
  434. // set visible list for parameters.
  435. if(el_oForm.elements[i].name.indexOf('drillParam_')==0) {
  436. this.v_aVisibleList[v_iVisibleIndex++] = el_oForm.elements[i];
  437. }
  438. // set original list stored in drill specs.
  439. else if(el_oForm.elements[i].name.indexOf('drillParamInSpecs_')==0) {
  440. var objKey = el_oForm.elements[i].name;
  441. if (v_OriListString.indexOf(el_oForm.elements[i].name)==-1)
  442. {
  443. v_OriListString = v_OriListString +el_oForm.elements[i].name + ' ' ;
  444. v_aOriList[v_iOriIndex++] = el_oForm.elements[i];
  445. }
  446. }
  447. }
  448. delete v_OriListString;
  449. // Put the parameters that are in drill specs but not in visible list into a New list.
  450. if (v_aOriList.length > this.v_aVisibleList.length)
  451. {
  452. var k = 0;
  453. for (i = 0; i < v_aOriList.length; i++)
  454. {
  455. var v_bNew = true;
  456. for (j = 0; j < this.v_aVisibleList.length; j++)
  457. {
  458. if (v_aOriList[i].value == this.v_aVisibleList[j].value)
  459. v_bNew = false;
  460. }
  461. if (v_bNew)
  462. {
  463. this.v_aNewList[k++] = v_aOriList[i]
  464. }
  465. }
  466. }
  467. }
  468. /**
  469. *
  470. */
  471. G_DrillPath.F_getDrillSpecParameterAssignments = function(){
  472. var v_sDrillSpecParameterAssignment = ""
  473. // Finding all parameter assignments in the page and write them into the spec
  474. for(i=0;i < el_oForm.elements.length; i++)
  475. {
  476. if(el_oForm.elements[i].name.indexOf('drillParam_')==0)
  477. {
  478. if(el_oForm.elements[i].value != "")
  479. {
  480. var v_elSelect = document.getElementsByName("select_MappedMetaDataType_" + el_oForm.elements[i].name)[0];
  481. var v_sOriItemValue = el_oForm.elements[i].value.F_XMLEncode();
  482. if (v_sOriItemValue.match("roleValue") ){
  483. v_iStart = v_sOriItemValue.indexOf(",") + 1;
  484. v_iEnd = v_sOriItemValue.length - 1;
  485. v_sOriItemValue = v_sOriItemValue.substring(v_iStart, v_iEnd );
  486. }
  487. //if (v_elSelect) //bugfix 602394
  488. {
  489. var v_bAddShowPropertiesExtension = false;
  490. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment+
  491. "&lt;dts:parameterAssignment&gt;"+
  492. "&lt;dts:parameterName&gt;"+
  493. document.getElementsByName("name_" + el_oForm.elements[i].name)[0].value.F_XMLEncode()+
  494. "&lt;/dts:parameterName&gt;"+
  495. "&lt;dts:item&gt;";
  496. if (v_elSelect && !v_elSelect.disabled && v_elSelect.value != 'default')
  497. {
  498. // A name of source parameter needs to be encoded twice.
  499. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment + "roleValue('"+v_elSelect.value+"'," + v_sOriItemValue.F_XMLEncode() + ")";
  500. v_bAddShowPropertiesExtension = true;
  501. }
  502. else if (v_elSelect && !v_elSelect.disabled && v_elSelect.value == 'default')
  503. {
  504. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment + v_sOriItemValue.F_XMLEncode();
  505. v_bAddShowPropertiesExtension = true;
  506. }
  507. else
  508. {
  509. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment + v_sOriItemValue.F_XMLEncode();
  510. }
  511. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment + "&lt;/dts:item&gt;";
  512. if (v_bAddShowPropertiesExtension)
  513. {
  514. //This extension is used in the senario where users select default property for the parameter
  515. //when define the drill path so we don't have role value stored in the spec and
  516. //we cannot find out if we need to show the select control or not
  517. //This extension is used in target.xslt
  518. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment +
  519. "&lt;dts:extension&gt;" +
  520. "&lt;dts:showParameterProperties&gt;" +
  521. "true" +
  522. "&lt;/dts:showParameterProperties&gt;"+
  523. "&lt;/dts:extension&gt;";
  524. }
  525. v_sDrillSpecParameterAssignment += "&lt;/dts:parameterAssignment&gt;";
  526. }
  527. }
  528. }
  529. }
  530. // Add parameters in the New list to the drill specs when updating a drill through definition.
  531. if (this.v_aNewList)
  532. {
  533. for(i=0;i < this.v_aNewList.length; i++)
  534. {
  535. if(this.v_aNewList[i].value != "")
  536. {
  537. var v_bAddShowPropertiesExtension = false;
  538. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment+
  539. "&lt;dts:parameterAssignment&gt;"+
  540. "&lt;dts:parameterName&gt;"+
  541. document.getElementsByName("name_" + this.v_aNewList[i].name)[0].value.F_XMLEncode()+
  542. "&lt;/dts:parameterName&gt;"+
  543. "&lt;dts:item&gt;"+
  544. document.getElementsByName("MappedMetaDataType_" + this.v_aNewList[i].name)[0].value.F_XMLEncode().F_XMLEncode() +
  545. "&lt;/dts:item&gt;";
  546. v_sDrillSpecParameterAssignment = v_sDrillSpecParameterAssignment +
  547. "&lt;dts:extension&gt;" +
  548. "&lt;dts:showParameterProperties&gt;" +
  549. "true" +
  550. "&lt;/dts:showParameterProperties&gt;"+
  551. "&lt;/dts:extension&gt;";
  552. v_sDrillSpecParameterAssignment += "&lt;/dts:parameterAssignment&gt;";
  553. }
  554. }
  555. }
  556. if (v_sDrillSpecParameterAssignment!="")
  557. {
  558. v_sDrillSpecParameterAssignment = "&lt;dts:parameterAssignments&gt;" +
  559. v_sDrillSpecParameterAssignment +
  560. "&lt;/dts:parameterAssignments&gt;";
  561. }
  562. return v_sDrillSpecParameterAssignment;
  563. }
  564. /**
  565. * Generates the XML node required for adding the bookmark the the request
  566. * @g_sBookMarkItem string that contains the model Item for the bookmark item
  567. @g_sBookMarkText string that contains the Label
  568. * @return m_nBookmark XML node that contains the part of the request related to bookmark
  569. * @author alireza pourshahid
  570. */
  571. G_DrillPath.F_getBookMark = function(){
  572. var m_nBookmark = "";
  573. if (g_sBookMarkItem!='')
  574. {
  575. m_nBookmark = "<bookmarkItem xsi:type=\"bus:metadataModelItemNameProp\">\r\n" +
  576. "<value xsi:type=\"bus:metadataModelItemName\">"+g_sBookMarkItem+"</value>\r\n" +
  577. "</bookmarkItem>\r\n";
  578. }
  579. else if (g_sBookMarkText!='')
  580. {
  581. m_nBookmark = "<bookmarkText xsi:type=\"bus:stringProp\">\r\n" +
  582. "<value xsi:type=\"xs:string\">"+g_sBookMarkText+"</value>\r\n"+
  583. "</bookmarkText>\r\n";
  584. }
  585. return m_nBookmark;
  586. };
  587. /**
  588. * Generates the XML node required for adding the PromptOption the the request
  589. * @g_bPromptOption boolean that contains if user get prompted or not
  590. * @return m_nPromptOption XML node that contains the part of the request related to PromptOption
  591. * @author alireza pourshahid
  592. */
  593. G_DrillPath.F_getPrompt = function (){
  594. var m_nPromptOption = '';
  595. if (g_bPromptOption != '')
  596. {
  597. m_nPromptOption = " <item xsi:type=\"bus:runOptionBoolean\">\r\n" +
  598. " <name xsi:type=\"bus:runOptionEnum\">prompt</name>\r\n" +
  599. " <value xsi:type=\"xs:boolean\">\r\n" +
  600. g_bPromptOption+
  601. " </value>\r\n" +
  602. " </item>";
  603. }
  604. return m_nPromptOption;
  605. };
  606. /**
  607. Generates the XML node required for adding the scope the the request
  608. * @g_sScope string that contains the modelItem for the scope
  609. * @return m_nScope XML node that contains the part of the request related to scope
  610. * @author alireza pourshahid
  611. */
  612. G_DrillPath.F_getScope = function(){
  613. var m_nScope = "";
  614. if (g_sScope!=''){
  615. m_nScope = " <bus:scope xsi:type=\"bus:metadataModelItemNameArrayProp\">\r\n" +
  616. " <value xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:metadataModelItemName[2]\">\r\n" +
  617. " <item xsi:type=\"bus:metadataModelItemName\">"+g_sScope+"</item>\r\n" +
  618. " </value>\r\n" +
  619. " </bus:scope>\r\n";
  620. }
  621. return m_nScope;
  622. }
  623. /**
  624. Generates the XML node required for adding the action the the request
  625. * @v_sAction string that contains the action
  626. * @return m_nAction XML node that contains the part of the request related to action
  627. * @author alireza pourshahid
  628. */
  629. G_DrillPath.F_getAction = function(){
  630. var m_nAction = "";
  631. if (g_sAction!=''){
  632. m_nAction = " <bus:action xsi:type=\"bus:baseReportActionEnumProp\">\r\n" +
  633. " <bus:value xsi:type=\"bus:baseReportActionEnum\">"+g_sAction+"</bus:value>\r\n" +
  634. " </bus:action>\r\n";
  635. }
  636. return m_nAction;
  637. }
  638. /**
  639. Generates the XML node required for adding the defaultName the the request
  640. * @v_sDefaultName string that contains the defaultName
  641. * @return m_nDefaultName XML node that contains the part of the request related to defaultName
  642. * @author alireza pourshahid
  643. */
  644. G_DrillPath.F_getDefaultName = function(){
  645. var m_nDefaultName = "";
  646. if (g_sDefaultName!=''){
  647. m_nDefaultName = " <bus:defaultName xsi:type=\"bus:tokenProp\">\r\n" +
  648. " <bus:value xsi:type=\"xs:string\">"+g_sDefaultName+"</bus:value>\r\n" +
  649. " </bus:defaultName>\r\n"
  650. }
  651. return m_nDefaultName;
  652. }
  653. /**
  654. Generates the XML node required for adding the DefaultScreenTip the the request
  655. * @v_sDefaultScreenTip string that contains the DefaultScreenTip
  656. * @return m_nDefaultScreenTip XML node that contains the part of the request related to DefaultScreenTip
  657. * @author alireza pourshahid
  658. */
  659. G_DrillPath.F_getDefaultScreenTip = function(){
  660. var m_nDefaultScreenTip = "";
  661. if (g_sDefaultScreenTip!=''){
  662. m_nDefaultScreenTip = "<bus:defaultScreenTip xsi:type=\"bus:stringProp\">\r\n" +
  663. " <bus:value xsi:type=\"xs:string\">"+g_sDefaultScreenTip+"</bus:value>\r\n" +
  664. "</bus:defaultScreenTip>\r\n";
  665. }
  666. return m_nDefaultScreenTip;
  667. }
  668. /**
  669. Generates the XML node required for adding the defaultDescription the the request
  670. * @v_sDefaultName string that contains the defaultDescription
  671. * @return m_nDefaultDescription XML node that contains the part of the request related to defaultDescription
  672. * @author alireza pourshahid
  673. */
  674. G_DrillPath.F_getDefaultDescription = function(){
  675. var m_nDefaultDescription = "";
  676. if (g_sDefaultDescription!=''){
  677. m_nDefaultDescription = "<bus:defaultDescription xsi:type=\"bus:stringProp\">\r\n" +
  678. " <bus:value xsi:type=\"xs:string\">"+g_sDefaultDescription+"</bus:value>\r\n" +
  679. "</bus:defaultDescription>\r\n";
  680. }
  681. return m_nDefaultDescription;
  682. }
  683. /**
  684. Generates the XML node required for adding the contact the the request
  685. * @g_sContactDefaultName string that contains the ContactDefaultName
  686. * @return m_nDefaultDescription XML node that contains the part of the request related to ContactDefaultName
  687. * @author alireza pourshahid
  688. */
  689. G_DrillPath.F_getContact = function(){
  690. var m_nContact = "";
  691. if (g_sContactDefaultName!=''){
  692. m_nContact = "<bus:contact xsi:type=\"bus:baseClassArrayProp\">\r\n" +
  693. " <bus:value xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"bus:baseClass[1]\">\r\n" +
  694. " <item xsi:type=\"bus:account\">\r\n" +
  695. " <bus:defaultName xsi:type=\"bus:tokenProp\">\r\n" +
  696. " <bus:value xsi:type=\"xs:string\">Anonymous</bus:value>\r\n" +
  697. " </bus:defaultName>\r\n" +
  698. " <bus:searchPath xsi:type=\"bus:stringProp\">\r\n" +
  699. " <bus:value xsi:type=\"xs:string\">CAMID(&quot;::Anonymous&quot;)</bus:value>\r\n" +
  700. " </bus:searchPath>\r\n" +
  701. " </item>\r\n" +
  702. " </bus:value>\r\n" +
  703. "</bus:contact>\r\n";
  704. }
  705. return m_nContact;
  706. }
  707. /**
  708. Generates the XML node required for adding the useEditSpecification the the request
  709. * @g_bUseEditSpecification boolean that contains the value (true or false) for useEditSpecification
  710. * @return m_nUseEditSpecification XML node that contains the part of the request related to useEditSpecification
  711. * @author alireza pourshahid
  712. */
  713. G_DrillPath.F_getUseEditSpecification = function(){
  714. var m_nUseEditSpecification = "";
  715. if (g_bUseEditSpecification!='')
  716. {
  717. m_nUseEditSpecification = "<item xsi:type=\"bus:drillThroughOptionBoolean\">\r\n" +
  718. " <name xsi:type=\"bus:drillThroughOptionEnum\">useEditSpecification</name>\r\n" +
  719. " <value xsi:type=\"xs:boolean\">\r\n" +
  720. g_bUseEditSpecification+
  721. " </value>\r\n" +
  722. "</item>\r\n";
  723. }
  724. return m_nUseEditSpecification;
  725. }
  726. /**
  727. Generates the XML node required for adding the OutputFormat the the request
  728. * @g_bUseEditSpecification string that contains the OutputFormat value
  729. * @return m_nUseEditSpecification XML node that contains the part of the request related to OutputFormat
  730. * @author alireza pourshahid
  731. */
  732. G_DrillPath.F_getOutputFormat = function(){
  733. var m_nOutputFormat = "";
  734. if (g_sOutputFormat!='' && g_sOutputFormat!='default')
  735. {
  736. m_nOutputFormat = "<item xsi:type=\"bus:runOptionStringArray\">\r\n" +
  737. " <name xsi:type=\"bus:runOptionEnum\">outputFormat</name>\r\n" +
  738. " <value xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:string[1]\">\r\n" +
  739. " <item xsi:type=\"xsd:string\">"+g_sOutputFormat+"</item>\r\n" +
  740. " </value>\r\n" +
  741. "</item>\r\n";
  742. }
  743. return m_nOutputFormat;
  744. }
  745. /**
  746. * Gets the variables that are required from the the page
  747. * @el_oForm the HTML form object that contains the form fields
  748. * @author Alireza Pourshahid
  749. */
  750. G_DrillPath.F_getHTMLPageData = function(){
  751. if (g_sRequestType=='addDrillPath'){
  752. g_sParentPath = el_oForm.m_path.value.F_XMLEncode();
  753. g_sDefaultName = el_oForm.m_p_defaultName.value.F_XMLEncode();
  754. g_sDefaultDescription = el_oForm.m_p_defaultDescription.value.F_XMLEncode();
  755. g_sDefaultScreenTip = el_oForm.m_p_defaultScreenTip.value.F_XMLEncode();
  756. g_sAction = el_oForm.m_p_action.value;
  757. g_bUseEditSpecification = el_oForm.m_dt_useEditSpecification.value;
  758. g_sScope = el_oForm.m_p_scope.value.F_XMLEncode();
  759. g_sTargetSearchPath = el_oForm.m_p_target.value.F_XMLEncode();
  760. // if action is edit the format is HTML
  761. if(!el_oForm.m_ro_outputF_HTML_Type.value){
  762. g_sOutputFormat = el_oForm.tg_fmtselect.options[el_oForm.tg_fmtselect.selectedIndex].value
  763. }
  764. else{
  765. g_sOutputFormat = 'HTML';
  766. }
  767. // We don't have the following elements in case of Abacab targets so we need gard
  768. if (el_oForm.m_ro_prompt){
  769. g_bPromptOption = el_oForm.m_ro_prompt.value;
  770. }
  771. if (el_oForm.m_p_bookmarkText){
  772. g_sBookMarkItem = el_oForm.m_p_bookmarkItem.value.F_XMLEncode();
  773. g_sBookMarkText = el_oForm.m_p_bookmarkText.value.F_XMLEncode();
  774. }
  775. }
  776. if (g_sRequestType=='updateDrillPath'){
  777. g_sParentPath = el_oForm.m_path.value.F_XMLEncode();
  778. g_sDefaultName = el_oForm.pty_name.value.F_XMLEncode();
  779. g_sDefaultDescription = el_oForm.pty_desc.value.F_XMLEncode();
  780. g_sDefaultScreenTip = el_oForm.pty_scrt.value.F_XMLEncode();
  781. g_sAction = el_oForm.m_p_action.value;
  782. g_bUseEditSpecification = el_oForm.m_dt_useEditSpecification.value;
  783. g_sScope = el_oForm.m_p_scope.value.F_XMLEncode();
  784. g_sTargetSearchPath = el_oForm.m_p_target.value.F_XMLEncode();
  785. //g_sOutputFormat = el_oForm.tg_fmtselect.options[el_oForm.tg_fmtselect.selectedIndex].value
  786. g_sDrillPathObjectSearchPath = el_oForm.m_obj.value.F_XMLEncode();
  787. if (el_oForm.m_ro_prompt){
  788. g_bPromptOption = el_oForm.m_ro_prompt.value;
  789. }
  790. if (el_oForm.m_p_bookmarkText){
  791. g_sBookMarkItem = el_oForm.m_p_bookmarkItem.value.F_XMLEncode();
  792. g_sBookMarkText = el_oForm.m_p_bookmarkText.value.F_XMLEncode();
  793. }
  794. }
  795. // used for debuggin: s all the information gathered from the form.
  796. //alert("parentPath:" + g_sParentPath + " --DefaultName: " + g_sDefaultName + " --DefaultDescription: " + g_sDefaultDescription + " --DefaultScreenTip: " + g_sDefaultScreenTip + " --Action: " + g_sAction + " --UsedEditSpecification: " + g_bUseEditSpecification + " --Scope: " + g_sScope + " --TargetSearchPath: " + g_sTargetSearchPath + " --OutputFormat: " + g_sOutputFormat + " --promptOption: " + g_bPromptOption + " --BookmarkItem: " + g_sBookMarkItem + " --BookMarkText: " +g_sBookMarkText);
  797. };
  798. /**
  799. * Construct a SOAP request to call RSVP API queryDrillPath by using C_BusRequest from CCHL.
  800. * @sObjPath : string contains drill path for a drill through definition.
  801. * @parameterValues : XML node contains a list of parameter values.
  802. * @return boolean false
  803. * @author Paul Cai
  804. **/
  805. G_DrillPath.queryDrillPath = function(v_oForm, sObjPath, parameterValues) {
  806. var sRequest = G_DrillPath.sQueryRequestTemplate;
  807. sRequest = sRequest.replace("@OBJECTPATH@", sObjPath);
  808. sRequest = sRequest.replace("@PARAMETERVALUES@",parameterValues);
  809. g_sRequestType = "queryDrillPath";
  810. el_oForm = v_oForm;
  811. var v_oRequest = new C_BusRequest( this , C_BusRequest.K_sSOAPAction_reportService, sRequest );
  812. this.F_sendRequest(v_oRequest);
  813. return false;
  814. }
  815. /**
  816. Used to construct a SOAP request for queryDrillPath
  817. **/
  818. G_DrillPath.sQueryRequestTemplate =
  819. '<rns1:queryDrillPath xmlns:rns1="http://developer.cognos.com/schemas/reportService/1">' +
  820. '<bus:objectPath xsi:type="bus:searchPathSingleObject">' +
  821. '@OBJECTPATH@' +
  822. '</bus:objectPath>' +
  823. '<bus:parameterValues SOAP-ENC:arrayType="bus:parameterValue[]" xsi:type="SOAP-ENC:Array">' +
  824. '@PARAMETERVALUES@' +
  825. '</bus:parameterValues>' +
  826. '<bus:options xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[]">' +
  827. '<item xsi:type="bus:contentManagerQueryOptionPropEnumArray">' +
  828. '<bus:name xsi:type="bus:contentManagerQueryOptionEnum">properties</bus:name>' +
  829. '<bus:value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:propEnum[]">' +
  830. '<item xsi:type="bus:propEnum">defaultName</item>' +
  831. '<item xsi:type="bus:propEnum">searchPath</item>' +
  832. '<item xsi:type="bus:propEnum">specification</item>' +
  833. '</bus:value>' +
  834. '</item>' +
  835. '<item xsi:type="bus:asynchOptionInt">' +
  836. '<bus:name xsi:type="bus:asynchOptionEnum">primaryWaitThreshold</bus:name>' +
  837. '<bus:value xsi:type="xs:int">0</bus:value>' +
  838. '</item>' +
  839. '</bus:options>' +
  840. '</rns1:queryDrillPath>';