process_mobile_entries.xslt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2015
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  15. xmlns:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/"
  16. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  17. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  18. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  19. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  20. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  21. exclude-result-prefixes="xsl dlgctrl xtsext pf send">
  22. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  23. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  24. <xsl:template match="/">
  25. <xsl:variable name="passport" select="/root/credential/param[@name='CAM']/*[local-name() ='CAM']/*[local-name() = 'CAMPassport']/*[local-name() = 'id']"/>
  26. <xts:sequence>
  27. <xsl:choose>
  28. <!-- construct the new mobileDescription parameter -->
  29. <!-- this is also processed when the page first loads to process the mobile options -->
  30. <xsl:when test="((/root/*[local-name()='morphletResponse']/*[local-name()='selectedEntries'] or /root/*[local-name()='selectedEntries'] ) and (not(key('env-param','m_ro_burst')) or key('env-param','m_ro_burst')='false' or key('env-param','run_options_visited')='true' or key('env-param','visited_run_with_options')='true' or key('env-param','visited_schedule_properties')='true'))">
  31. <xsl:variable name="mobileRecipients" select="/root/*[local-name()='selectedEntries']/*[local-name()='account' or local-name()='group' or local-name()='role' or local-name()='contact' or local-name()='distributionList']"/>
  32. <xsl:variable name="mobileRecipientCount" select="count($mobileRecipients)"/>
  33. <!-- delete the old mobileSummary and mobileDescription and create new ones with the reponse received from the add entries -->
  34. <xts:delete select="/root/env/param[@name='mobileRecipientsCount' or @name='mobileDescription' or @name='mobileSummary' or @name='hasMobileRecipients']"/>
  35. <xsl:choose>
  36. <!-- recipient count of 0 -->
  37. <xsl:when test="$mobileRecipientCount='0'">
  38. <xts:delete select="/root/env/param[@name='m_ro_mobile']"/>
  39. <xts:append select="/root/env">
  40. <param name="mobileDescription"><xts:string id="IDS_OTHERRUN_MOBILE_NO_RECIPIENTS"/></param>
  41. <param name="hasMobileRecipients">false</param>
  42. <param name="m_ro_mobile">false</param>
  43. </xts:append>
  44. </xsl:when>
  45. <!-- more then 1 recipient -->
  46. <xsl:when test="$mobileRecipientCount &gt; 1">
  47. <xts:append select="/root/env">
  48. <param name="mobileDescription"><xts:string id="IDS_OTHERRUN_MOBILE_RECIPIENT_COUNT"><xts:param name="numPeople"><xsl:value-of select="$mobileRecipientCount"/></xts:param>
  49. </xts:string>
  50. </param>
  51. <param name="hasMobileRecipients">true</param>
  52. <param name="mobileRecipientsCount">
  53. <xsl:value-of select="$mobileRecipientCount"/>
  54. </param>
  55. </xts:append>
  56. </xsl:when>
  57. <!-- only one recipient -->
  58. <xsl:otherwise>
  59. <xsl:choose>
  60. <!-- select only 1 recipient, so we must query CM for the information on the recipient -->
  61. <xsl:when test="$mobileRecipientCount = '1'">
  62. <xts:append select="/root/env">
  63. <param name="mobileDescription">
  64. <xsl:choose>
  65. <xsl:when test="/root/*[local-name()='selectedEntries']/*/*[local-name()='userName'] != ''">
  66. <xts:string id="IDS_OTHERRUN_DISPLAY_MOBILE_USER">
  67. <xts:param name="defaultName">
  68. <xsl:value-of select="/root/*[local-name()='selectedEntries']/*/*[local-name()='defaultName']"/>
  69. </xts:param>
  70. <xts:param name="userName">
  71. <xsl:value-of select="/root/*[local-name()='selectedEntries']/*/*[local-name()='userName']"/>
  72. </xts:param>
  73. </xts:string>
  74. </xsl:when>
  75. <xsl:when test="/root/*[local-name()='selectedEntries']/*/*[local-name()='defaultName'] != ''">
  76. <xsl:value-of select="/root/*[local-name()='selectedEntries']/*/*[local-name()='defaultName']"/>
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <xts:string id="IDS_OTHERRUN_UNKNOWN_MOBILE_RECIPIENT"/>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </param>
  83. <param name="hasMobileRecipients">true</param>
  84. <param name="mobileRecipientsCount"><xsl:value-of select="$mobileRecipientCount"/></param>
  85. </xts:append>
  86. </xsl:when>
  87. </xsl:choose>
  88. </xsl:otherwise>
  89. </xsl:choose>
  90. <!-- handle the addresses that were added via the add entries dialog -->
  91. <xsl:if test="$mobileRecipientCount &gt; 0">
  92. <xts:delete select="/root/env/param[@name='mobileOptions']"/>
  93. <xts:append select="/root/env">
  94. <xts:transform src="portal/controls/create_web64_param.xslt" processor="XSLT">
  95. <param name="mobileOptions">
  96. <passport><xsl:value-of select="$passport"/></passport>
  97. <markup>
  98. <xts:transform name="XMLEncode">
  99. <options xsi:type="bus:optionArrayProp">
  100. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[1]">
  101. <item xsi:type="bus:mobileOptionSearchPathMultipleObjectArray">
  102. <name xsi:type="bus:mobileOptionEnum">to</name>
  103. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:searchPathMultipleObject[{$mobileRecipientCount}]">
  104. <xsl:for-each select="$mobileRecipients">
  105. <item xsi:type="bus:searchPathMultipleObject">
  106. <xsl:value-of select="./*[local-name()='searchPath']"/>
  107. </item>
  108. </xsl:for-each>
  109. </value>
  110. </item>
  111. </value>
  112. </options>
  113. </xts:transform>
  114. </markup>
  115. </param>
  116. </xts:transform>
  117. </xts:append>
  118. </xsl:if>
  119. </xsl:when>
  120. <xsl:when test="/root/*[local-name()='morphletResponse']/*[local-name()='mobileOptions'] != '' and (key('env-param','run_options_visited')='true' or key('env-param','visited_schedule_properties')='true')">
  121. <xsl:variable name="mobileRecipients" select="/root/*[local-name()='morphletResponse']/*[local-name()='mobileOptions']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and (.='to' or .='cc' or .='bcc')]]/*[local-name()='value']/*[local-name()='item']"/>
  122. <xsl:variable name="mobileRecipientCount" select="count($mobileRecipients)"/>
  123. <!-- delete the old mobileSummary and mobileDescription and create new ones with the reponse received from the add entries -->
  124. <xts:delete select="/root/env/param[@name='mobileRecipientsCount' or @name='mobileDescription' or @name='mobileSummary' or @name='hasMobileRecipients']"/>
  125. <xsl:choose>
  126. <!-- recipient count of 0 -->
  127. <xsl:when test="$mobileRecipientCount='0'">
  128. <xts:append select="/root/env">
  129. <param name="mobileDescription"><xts:string id="IDS_OTHERRUN_MOBILE_NO_RECIPIENTS"/></param>
  130. <param name="hasMobileRecipients">false</param>
  131. </xts:append>
  132. </xsl:when>
  133. <!-- more then 1 recipient -->
  134. <xsl:when test="$mobileRecipientCount &gt; 1">
  135. <xts:append select="/root/env">
  136. <param name="mobileDescription"><xts:string id="IDS_OTHERRUN_MOBILE_RECIPIENT_COUNT"><xts:param name="numPeople"><xsl:value-of select="$mobileRecipientCount"/></xts:param>
  137. </xts:string>
  138. </param>
  139. <param name="hasMobileRecipients">true</param>
  140. <param name="mobileRecipientsCount">
  141. <xsl:value-of select="$mobileRecipientCount"/>
  142. </param>
  143. </xts:append>
  144. </xsl:when>
  145. <!-- only one recipient -->
  146. <xsl:otherwise>
  147. <xsl:choose>
  148. <!-- select only 1 recipient, so we must query CM for the information on the recipient -->
  149. <xsl:when test="$mobileRecipientCount = '1'">
  150. <xts:append select="/root/env">
  151. <xts:transform src="transforms/portal/mobileOptions/generateRecipientsSummary.xslt" processor="XSLT">
  152. <xts:param name="messageBase">/messages/portal.xml</xts:param>
  153. <xts:param name="messageBase">/messages/portalRL.xml</xts:param>
  154. <root>
  155. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  156. <send:request provider="cm">
  157. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  158. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  159. <cm:requests>
  160. <cm:query>
  161. <cm:search><xsl:value-of select="$mobileRecipients"/></cm:search>
  162. <cm:properties>
  163. <cm:property name="searchPath"/>
  164. <cm:property name="defaultName"/>
  165. <cm:property name="userName"/>
  166. <cm:property name="email"/>
  167. </cm:properties>
  168. </cm:query>
  169. </cm:requests>
  170. </cm:query>
  171. </xts:transform>
  172. </send:request>
  173. </xts:transform>
  174. <asParam>true</asParam>
  175. </root>
  176. </xts:transform>
  177. <param name="hasMobileRecipients">true</param>
  178. <param name="mobileRecipientsCount"><xsl:value-of select="$mobileRecipientCount"/></param>
  179. </xts:append>
  180. </xsl:when>
  181. </xsl:choose>
  182. </xsl:otherwise>
  183. </xsl:choose>
  184. <!-- also have to build the selectedEntries blob -->
  185. <xts:append select="/root/env">
  186. <xts:transform src="portal/controls/create_web64_param.xslt" processor="XSLT">
  187. <param name="selectedEntries">
  188. <passport><xsl:value-of select="$passport"/></passport>
  189. <markup>
  190. <xts:transform name="XMLEncode">
  191. <xts:transform src="ags/transforms/updateSelectedEntries.xslt" processor="XSLT">
  192. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  193. <send:request provider="cm">
  194. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  195. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  196. <cm:requests>
  197. <!-- get info on all the mobile recipients -->
  198. <xsl:for-each select="$mobileRecipients">
  199. <cm:query>
  200. <cm:search><xsl:value-of select="."/></cm:search>
  201. <cm:properties>
  202. <cm:property name="defaultName"/>
  203. <cm:property name="hidden"/>
  204. <cm:property name="searchPath"/>
  205. <cm:property name="permissions"/>
  206. <cm:property name="position"/>
  207. <cm:property name="searchPathForURL"/>
  208. <cm:property name="storeID"/>
  209. <cm:property name="ancestors"/>
  210. <cm:property name="hasChildren"/>
  211. <cm:property name="base"/>
  212. <cm:property name="userName"/>
  213. </cm:properties>
  214. </cm:query>
  215. </xsl:for-each>
  216. </cm:requests>
  217. </cm:query>
  218. </xts:transform>
  219. </send:request>
  220. </xts:transform>
  221. </xts:transform>
  222. </xts:transform>
  223. </markup>
  224. </param>
  225. </xts:transform>
  226. </xts:append>
  227. </xsl:when>
  228. <xsl:otherwise/>
  229. </xsl:choose>
  230. <!-- construct the mobile summary -->
  231. <xts:append select="/root/env">
  232. <param name="mobileSummary"><xts:string id="IDS_OTHERRUN_DELIVERY_MOBILE_REPORT"/></param>
  233. </xts:append>
  234. </xts:sequence>
  235. </xsl:template>
  236. </xsl:stylesheet>