buildApproval.xslt 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ASV
  5. (C) Copyright IBM Corp. 2005, 2010
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0"
  9. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  10. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  11. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  12. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  13. xmlns:impl="http://www.ibm.com/xmlns/prod/cognos/internal/hts/_1"
  14. xmlns:hta="http://www.example.org/WS-HT/api"
  15. xmlns:ht="http://www.example.org/WS-HT"
  16. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  17. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  18. exclude-result-prefixes="xsl xsi SOAP-ENC xtsext bus xsd">
  19. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  20. <xsl:key name="param" match="/root/*[local-name()='param']" use="@name"/>
  21. <xsl:template match="/root">
  22. <xsl:choose>
  23. <xsl:when test="key('param','m_ro_owner_action')='approve' ">
  24. <impl:createApproveManualTask xmlns:impl="http://www.ibm.com/xmlns/prod/cognos/internal/hts/_1" xmlns:hta="http://www.example.org/WS-HT/api" xmlns:ht="http://www.example.org/WS-HT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  25. <xsl:call-template name="buildBpelManualTask"/>
  26. </impl:createApproveManualTask>
  27. </xsl:when>
  28. <xsl:when test="key('param','m_ro_owner_action')='agent' ">
  29. <impl:createAgentUserTask xmlns:impl="http://www.ibm.com/xmlns/prod/cognos/internal/hts/_1" xmlns:hta="http://www.example.org/WS-HT/api" xmlns:ht="http://www.example.org/WS-HT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  30. <xsl:call-template name="buildBpelManualTask"/>
  31. </impl:createAgentUserTask>
  32. </xsl:when>
  33. </xsl:choose>
  34. </xsl:template>
  35. <xsl:template name="buildBpelManualTask">
  36. <impl:beplTask name="Approval_instance_name" xmlns:impl="http://www.ibm.com/xmlns/prod/cognos/internal/hts/_1" xmlns:hta="http://www.example.org/WS-HT/api" xmlns:ht="http://www.example.org/WS-HT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:choose>
  37. <xsl:when test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='agentStudio'] = 'true'">
  38. <xsl:choose>
  39. <xsl:when test="/root/param[@name='m_ro_priority_radio']='priority'">
  40. <xsl:if test="/root/param[@name='m_ro_priority']">
  41. <impl:priority>
  42. <xsl:value-of select="/root/param[@name='m_ro_priority']"/>
  43. </impl:priority>
  44. </xsl:if>
  45. </xsl:when>
  46. <xsl:when test="/root/param[@name='m_ro_priority_radio']='item'">
  47. <xsl:if test="/root/param[@name='m_ro_priority_item']">
  48. <impl:priority>
  49. <xsl:value-of select="/root/param[@name='m_ro_priority_item']"/>
  50. </impl:priority>
  51. </xsl:if>
  52. </xsl:when>
  53. </xsl:choose>
  54. </xsl:when>
  55. <xsl:otherwise>
  56. <xsl:if test="/root/param[@name='m_ro_priority']">
  57. <impl:priority>
  58. <xsl:value-of select="/root/param[@name='m_ro_priority']"/>
  59. </impl:priority>
  60. </xsl:if>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. <impl:peopleAssignments>
  64. <xsl:if test="/root/param[@name='to']/param[@name='to' or @name='toGroup' or @name='toAddress']">
  65. <ht:potentialOwners>
  66. <ht:from logicalPeopleGroup="CAM">
  67. <ht:literal>
  68. <ht:organizationalEntity>
  69. <xsl:if test="/root/param[@name='to']/param[@name='to']">
  70. <ht:users>
  71. <xsl:for-each select="/root/param[@name='to']/param[@name='to']">
  72. <ht:user>
  73. <xsl:value-of select="."/>
  74. </ht:user>
  75. </xsl:for-each>
  76. </ht:users>
  77. </xsl:if>
  78. <xsl:if test="/root/param[@name='to']/param[@name='toGroup' or @name='toAddress']">
  79. <ht:groups>
  80. <xsl:for-each select="/root/param[@name='to']/param[@name='toGroup' or @name='toAddress']">
  81. <ht:group>
  82. <xsl:value-of select="."/>
  83. </ht:group>
  84. </xsl:for-each>
  85. </ht:groups>
  86. </xsl:if>
  87. </ht:organizationalEntity>
  88. </ht:literal>
  89. </ht:from>
  90. </ht:potentialOwners>
  91. </xsl:if>
  92. <xsl:if test="/root/param[@name='cc']/param[@name='cc' or @name='ccGroup' or @name='ccAddress']">
  93. <ht:taskStakeholders>
  94. <ht:from logicalPeopleGroup="CAM">
  95. <ht:literal>
  96. <ht:organizationalEntity>
  97. <xsl:if test="/root/param[@name='cc']/param[@name='cc'] ">
  98. <ht:users>
  99. <xsl:for-each select="/root/param[@name='cc']/param[@name='cc']">
  100. <ht:user>
  101. <xsl:value-of select="."/>
  102. </ht:user>
  103. </xsl:for-each>
  104. </ht:users>
  105. </xsl:if>
  106. <xsl:if test="/root/param[@name='cc']/param[@name='ccGroup' or @name='ccAddress']">
  107. <ht:groups>
  108. <xsl:for-each select="/root/param[@name='cc']/param[@name='ccGroup' or @name='ccAddress']">
  109. <ht:group>
  110. <xsl:value-of select="."/>
  111. </ht:group>
  112. </xsl:for-each>
  113. </ht:groups>
  114. </xsl:if>
  115. </ht:organizationalEntity>
  116. </ht:literal>
  117. </ht:from>
  118. </ht:taskStakeholders>
  119. </xsl:if>
  120. <ht:businessAdministrators>
  121. <ht:from logicalPeopleGroup="CAM">
  122. <ht:literal>
  123. <ht:organizationalEntity>
  124. <ht:groups>
  125. <ht:group>CAMID(":Server Administrators")</ht:group>
  126. </ht:groups>
  127. </ht:organizationalEntity>
  128. </ht:literal>
  129. </ht:from>
  130. </ht:businessAdministrators>
  131. </impl:peopleAssignments>
  132. </impl:beplTask>
  133. <impl:manualTask xmlns:impl="http://www.ibm.com/xmlns/prod/cognos/internal/hts/_1" xmlns:hta="http://www.example.org/WS-HT/api" xmlns:ht="http://www.example.org/WS-HT" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  134. <!-- placeholder for the preview -->
  135. <impl:preview/>
  136. <!-- placeholder for the eventID's - though not sure these are needed -->
  137. <impl:parentEventId/>
  138. <impl:eventId/>
  139. <!-- add the task icon path in -->
  140. <xsl:choose>
  141. <xsl:when test="key('param', 'm_ro_icon_radio')='default' ">
  142. <impl:taskIconPath/>
  143. </xsl:when>
  144. <xsl:when test="key('param', 'm_ro_icon_radio')='item' ">
  145. <impl:taskIconPath>
  146. <xsl:value-of select="key('param', 'm_ro_icon_item')"/>
  147. </impl:taskIconPath>
  148. </xsl:when>
  149. </xsl:choose>
  150. <xsl:if test="key('param','m_ro_owner_action')='approve'">
  151. <impl:approveText>
  152. <xsl:value-of select="key('param','m_ro_approveValue')"/>
  153. </impl:approveText>
  154. <impl:rejectText>
  155. <xsl:value-of select="key('param','m_ro_rejectValue')"/>
  156. </impl:rejectText>
  157. </xsl:if>
  158. <xsl:if test="key('param','m_ro_owner_action')='agent' ">
  159. <impl:submitText>
  160. <xsl:value-of select="key('param','m_ro_submitValue')"/>
  161. </impl:submitText>
  162. </xsl:if>
  163. <!-- need to set the link in ASV - when we know the searchPAth to the report output to set -->
  164. <xsl:if test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='agentStudio'] = 'true'">
  165. <xsl:if test="/root/*[local-name()='attachments']/*[local-name()='item']">
  166. <!-- attachments -->
  167. <impl:taskLinksList>
  168. <xsl:for-each select="/root/*[local-name()='attachments']/*[local-name()='item']">
  169. <impl:taskLink>
  170. <!-- if we have a locale then append to the attachment name -->
  171. <xsl:choose>
  172. <xsl:when test="*[local-name()='locale'] != ''">
  173. <impl:display>
  174. <xsl:value-of select="concat(*[local-name()='defaultName'],'_',*[local-name()='locale'])"/>
  175. </impl:display>
  176. </xsl:when>
  177. <xsl:otherwise>
  178. <impl:display>
  179. <xsl:value-of select="*[local-name()='defaultName']"/>
  180. </impl:display>
  181. </xsl:otherwise>
  182. </xsl:choose>
  183. <impl:id>
  184. <xsl:value-of select="*[local-name()='searchPath']"/>
  185. </impl:id>
  186. <impl:format>
  187. <xsl:value-of select="*[local-name()='format']"/>
  188. </impl:format>
  189. <impl:locale>
  190. <xsl:value-of select="*[local-name()='locale']"/>
  191. </impl:locale>
  192. </impl:taskLink>
  193. </xsl:for-each>
  194. </impl:taskLinksList>
  195. </xsl:if>
  196. <xsl:variable name="links" select="/root/*[local-name()='links']/*[local-name()='item']"/>
  197. <!-- links -->
  198. <xsl:if test="$links">
  199. <impl:linksList>
  200. <xsl:for-each select="$links">
  201. <impl:link>
  202. <impl:display>
  203. <xsl:value-of select="*[local-name()='displayName']"/>
  204. </impl:display>
  205. <impl:objectClass>
  206. <xsl:choose>
  207. <xsl:when test="*[local-name()='objectClass'] != ''">
  208. <xsl:value-of select="*[local-name()='objectClass']"/>
  209. </xsl:when>
  210. <xsl:otherwise>
  211. <xsl:text>nil</xsl:text>
  212. </xsl:otherwise>
  213. </xsl:choose>
  214. </impl:objectClass>
  215. <impl:id>
  216. <xsl:value-of select="*[local-name()='searchPath']"/>
  217. </impl:id>
  218. </impl:link>
  219. </xsl:for-each>
  220. </impl:linksList>
  221. </xsl:if>
  222. <xsl:variable name="futureTasks" select="/root/*[local-name()='futureTasks']/*[local-name()='futureTask']"/>
  223. <!-- future tasks -->
  224. <xsl:if test="$futureTasks and key('param','m_ro_owner_action')='agent' ">
  225. <impl:futureTaskList>
  226. <xsl:for-each select="$futureTasks">
  227. <impl:futureTask>
  228. <impl:display>
  229. <xsl:value-of select="*[local-name()='display']"/>
  230. </impl:display>
  231. <impl:id>
  232. <xsl:value-of select="*[local-name()='id']"/>
  233. </impl:id>
  234. <impl:taskType>
  235. <xsl:value-of select="*[local-name()='taskType']"/>
  236. </impl:taskType>
  237. </impl:futureTask>
  238. </xsl:for-each>
  239. </impl:futureTaskList>
  240. </xsl:if>
  241. </xsl:if>
  242. <xsl:if test="key('param','m_ro_readExpiry_start')='true'">
  243. <impl:startFor>
  244. <xsl:text>P</xsl:text>
  245. <!-- need to add the 'T' designator if specifying a time. In our case we need to resolve minutes or hours-->
  246. <xsl:if test="key('param','m_ro_readExpireUnit_start')='H' or key('param','m_ro_readExpireUnit_start')='M'">
  247. <xsl:text>T</xsl:text>
  248. </xsl:if>
  249. <xsl:value-of select="key('param','m_ro_readExpireUnitCount_start')"/>
  250. <xsl:value-of select="key('param','m_ro_readExpireUnit_start')"/>
  251. </impl:startFor>
  252. </xsl:if>
  253. <xsl:if test="key('param','m_ro_readExpiry_due')='true'">
  254. <impl:completeFor>
  255. <xsl:text>P</xsl:text>
  256. <!-- need to add the 'T' designator if specifying a time. In our case we need to resolve minutes or hours-->
  257. <xsl:if test="key('param','m_ro_readExpireUnit_due')='H' or key('param','m_ro_readExpireUnit_due')='M'">
  258. <xsl:text>T</xsl:text>
  259. </xsl:if>
  260. <xsl:value-of select="key('param','m_ro_readExpireUnitCount_due')"/>
  261. <xsl:value-of select="key('param','m_ro_readExpireUnit_due')"/>
  262. </impl:completeFor>
  263. </xsl:if>
  264. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnCreation']">
  265. <impl:notifyOnCreation>
  266. <xsl:call-template name="makeSubscriptionParam">
  267. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnCreation']"/>
  268. </xsl:call-template>
  269. </impl:notifyOnCreation>
  270. </xsl:if>
  271. <xsl:if test="/root/param[@name='m_ro_sub_notifyNotCompleted']">
  272. <impl:notifyNotCompleted>
  273. <xsl:call-template name="makeSubscriptionParam">
  274. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyNotCompleted']"/>
  275. </xsl:call-template>
  276. </impl:notifyNotCompleted>
  277. </xsl:if>
  278. <xsl:if test="/root/param[@name='m_ro_sub_notifyNotStarted']">
  279. <impl:notifyNotStarted>
  280. <xsl:call-template name="makeSubscriptionParam">
  281. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyNotStarted']"/>
  282. </xsl:call-template>
  283. </impl:notifyNotStarted>
  284. </xsl:if>
  285. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnStateChange_started']">
  286. <impl:stateChangeStarted>
  287. <xsl:call-template name="makeSubscriptionParam">
  288. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnStateChange_started']"/>
  289. </xsl:call-template>
  290. </impl:stateChangeStarted>
  291. </xsl:if>
  292. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnStateChange_owner']">
  293. <impl:stateChangeOwner>
  294. <xsl:call-template name="makeSubscriptionParam">
  295. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnStateChange_owner']"/>
  296. </xsl:call-template>
  297. </impl:stateChangeOwner>
  298. </xsl:if>
  299. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnStateChange_completed']">
  300. <impl:stateChangeCompleted>
  301. <xsl:call-template name="makeSubscriptionParam">
  302. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnStateChange_completed']"/>
  303. </xsl:call-template>
  304. </impl:stateChangeCompleted>
  305. </xsl:if>
  306. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnStateChange_comment']">
  307. <impl:stateChangeFailed>
  308. GLOBAL_SUBSCRIBE
  309. </impl:stateChangeFailed>
  310. <impl:comments>
  311. <xsl:call-template name="makeSubscriptionParam">
  312. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnStateChange_comment']"/>
  313. </xsl:call-template>
  314. </impl:comments>
  315. </xsl:if>
  316. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnStateChange_cancelled']">
  317. <impl:stateChangeCancelled>
  318. <xsl:call-template name="makeSubscriptionParam">
  319. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnStateChange_cancelled']"/>
  320. </xsl:call-template>
  321. </impl:stateChangeCancelled>
  322. </xsl:if>
  323. <xsl:if test="/root/param[@name='email_subject']">
  324. <impl:subject xml:lang="en-us">
  325. <xsl:value-of select="/root/param[@name='email_subject']"/>
  326. </impl:subject>
  327. </xsl:if>
  328. <!-- sort out the body -->
  329. <xsl:if test="key('param','email_body')!='' ">
  330. <xsl:call-template name="htmlBody"/>
  331. </xsl:if>
  332. </impl:manualTask>
  333. </xsl:template>
  334. <xsl:template name="makeSubscriptionParam">
  335. <xsl:param name="selected"/>
  336. <xsl:param name="global" select="'true'"/>
  337. <xsl:choose>
  338. <xsl:when test="$selected = 'true' or $selected = 'checked'">
  339. <xsl:choose>
  340. <xsl:when test="$global = 'true'">
  341. <xsl:text>GLOBAL_SUBSCRIBE</xsl:text>
  342. </xsl:when>
  343. <xsl:otherwise>
  344. <xsl:text>INDIVIDUAL_SUBSCRIBE</xsl:text>
  345. </xsl:otherwise>
  346. </xsl:choose>
  347. </xsl:when>
  348. <xsl:otherwise>
  349. <xsl:choose>
  350. <xsl:when test="$global = 'true'">
  351. <xsl:text>GLOBAL_UNSUBSCRIBE</xsl:text>
  352. </xsl:when>
  353. <xsl:otherwise>
  354. <xsl:text>INDIVIDUAL_UNSUBSCRIBE</xsl:text>
  355. </xsl:otherwise>
  356. </xsl:choose>
  357. </xsl:otherwise>
  358. </xsl:choose>
  359. </xsl:template>
  360. <xsl:template name="htmlBody">
  361. <impl:description xml:lang="en-us" contentType="text/plain">
  362. <xsl:value-of select="key('param','email_body')"/>
  363. </impl:description>
  364. <xsl:variable name="body">
  365. <xsl:choose>
  366. <xsl:when test="key('param','hidden_richEditBody') != ''">
  367. <xsl:value-of select="key('param','hidden_richEditBody')"/>
  368. </xsl:when>
  369. <xsl:otherwise>
  370. <xsl:value-of select="key('param','email_body')"/>
  371. </xsl:otherwise>
  372. </xsl:choose>
  373. </xsl:variable>
  374. <!-- build up a head and meta element to palce in the HTML email. -->
  375. <xsl:variable name="head">
  376. <xsl:if test="key('param','richEditMode') = 'true'">
  377. <xsl:value-of select="'&lt;HEAD&gt;&lt;META name=&quot;user-entered-html-email-body&quot;&gt;&lt;/META&gt;&lt;/HEAD&gt;'"/>
  378. </xsl:if>
  379. </xsl:variable>
  380. <!-- make sure the body has openning and closing BODY and HTML tags -->
  381. <xsl:variable name="htmlBody">
  382. <xsl:choose>
  383. <xsl:when test="starts-with($body,'&lt;HTML')">
  384. <xsl:value-of select="$body"/>
  385. </xsl:when>
  386. <xsl:when test="starts-with($body,'&lt;BODY')">
  387. <xsl:value-of select="concat('&lt;HTML&gt;',$head, $body,'&lt;/HTML&gt;')"/>
  388. </xsl:when>
  389. <xsl:otherwise>
  390. <xsl:value-of select="concat('&lt;HTML&gt;', $head, '&lt;BODY&gt;',$body,'&lt;/BODY&gt;&lt;/HTML&gt;')"/>
  391. </xsl:otherwise>
  392. </xsl:choose>
  393. </xsl:variable>
  394. <!-- if we need to add a link in the body -->
  395. <xsl:variable name="completeBody">
  396. <xsl:choose>
  397. <xsl:when test="key('param','m_ro_emailAsURL')='true' and /root/*[local-name()='requestParams']/*[local-name()='param' and @name='linkToReport']!= ''">
  398. <xsl:value-of select="substring-before($htmlBody, '&lt;/BODY&gt;&lt;/HTML&gt;')"/>
  399. <xsl:value-of select="'&lt;BR/&gt;'"/>
  400. <xsl:value-of select="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='linkToReport']"/>
  401. <xsl:value-of select="'&lt;/BODY&gt;&lt;/HTML&gt;'"/>
  402. </xsl:when>
  403. <xsl:otherwise>
  404. <xsl:value-of select="$htmlBody"/>
  405. </xsl:otherwise>
  406. </xsl:choose>
  407. </xsl:variable>
  408. <impl:description xml:lang="en-us" contentType="text/html">
  409. <xsl:value-of select="$completeBody" disable-output-escaping="yes"/>
  410. </impl:description>
  411. </xsl:template>
  412. </xsl:stylesheet>