buildNotification.xslt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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. <impl:createNotificationManualTask 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">
  23. <impl:beplNotification name="Notification_instance_name">
  24. <xsl:choose>
  25. <xsl:when test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='agentStudio'] = 'true'">
  26. <xsl:choose>
  27. <xsl:when test="/root/param[@name='m_ro_priority_radio']='priority'">
  28. <xsl:if test="/root/param[@name='m_ro_priority']">
  29. <impl:priority>
  30. <xsl:value-of select="/root/param[@name='m_ro_priority']"/>
  31. </impl:priority>
  32. </xsl:if>
  33. </xsl:when>
  34. <xsl:when test="/root/param[@name='m_ro_priority_radio']='item'">
  35. <xsl:if test="/root/param[@name='m_ro_priority_item']">
  36. <impl:priority>
  37. <xsl:value-of select="/root/param[@name='m_ro_priority_item']"/>
  38. </impl:priority>
  39. </xsl:if>
  40. </xsl:when>
  41. </xsl:choose>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:if test="/root/param[@name='m_ro_priority']">
  45. <impl:priority>
  46. <xsl:value-of select="/root/param[@name='m_ro_priority']"/>
  47. </impl:priority>
  48. </xsl:if>
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. <impl:peopleAssignments>
  52. <xsl:if test="/root/param[@name='to']/param[@name='to' or @name='toGroup' or @name='toAddress']">
  53. <ht:recipients>
  54. <ht:from logicalPeopleGroup="CAM">
  55. <ht:literal>
  56. <ht:organizationalEntity>
  57. <xsl:if test="/root/param[@name='to']/param[@name='to']">
  58. <ht:users>
  59. <xsl:for-each select="/root/param[@name='to']/param[@name='to']">
  60. <ht:user>
  61. <xsl:value-of select="."/>
  62. </ht:user>
  63. </xsl:for-each>
  64. </ht:users>
  65. </xsl:if>
  66. <xsl:if test="/root/param[@name='to']/param[@name='toGroup' or @name='toAddress']">
  67. <ht:groups>
  68. <xsl:for-each select="/root/param[@name='to']/param[@name='toGroup' or @name='toAddress']">
  69. <ht:group>
  70. <xsl:value-of select="."/>
  71. </ht:group>
  72. </xsl:for-each>
  73. </ht:groups>
  74. </xsl:if>
  75. </ht:organizationalEntity>
  76. </ht:literal>
  77. </ht:from>
  78. </ht:recipients>
  79. </xsl:if>
  80. <xsl:if test="/root/param[@name='cc']/param[@name='cc' or @name='ccGroup' or @name='ccAddress']">
  81. <ht:taskStakeholders>
  82. <ht:from logicalPeopleGroup="CAM">
  83. <ht:literal>
  84. <ht:organizationalEntity>
  85. <xsl:if test="/root/param[@name='cc']/param[@name='cc'] ">
  86. <ht:users>
  87. <xsl:for-each select="/root/param[@name='cc']/param[@name='cc']">
  88. <ht:user>
  89. <xsl:value-of select="."/>
  90. </ht:user>
  91. </xsl:for-each>
  92. </ht:users>
  93. </xsl:if>
  94. <xsl:if test="/root/param[@name='cc']/param[@name='ccGroup' or @name='ccAddress']">
  95. <ht:groups>
  96. <xsl:for-each select="/root/param[@name='cc']/param[@name='ccGroup' or @name='ccAddress']">
  97. <ht:group>
  98. <xsl:value-of select="."/>
  99. </ht:group>
  100. </xsl:for-each>
  101. </ht:groups>
  102. </xsl:if>
  103. </ht:organizationalEntity>
  104. </ht:literal>
  105. </ht:from>
  106. </ht:taskStakeholders>
  107. </xsl:if>
  108. <ht:businessAdministrators>
  109. <ht:from logicalPeopleGroup="CAM">
  110. <ht:literal>
  111. <ht:organizationalEntity>
  112. <ht:groups>
  113. <ht:group>CAMID(":Server Administrators")</ht:group>
  114. </ht:groups>
  115. </ht:organizationalEntity>
  116. </ht:literal>
  117. </ht:from>
  118. </ht:businessAdministrators>
  119. </impl:peopleAssignments>
  120. </impl:beplNotification>
  121. <impl:manualTask>
  122. <!-- placeholder for the preview -->
  123. <impl:preview/>
  124. <!-- placeholder for the eventID's - though not sure these are needed -->
  125. <impl:parentEventId/>
  126. <impl:eventId/>
  127. <!-- add the task icon path in - this is filled server side -->
  128. <impl:taskIconPath/>
  129. <!-- need to set the link in ASV - when we know the searchPAth to the report output to set -->
  130. <xsl:if test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='agentStudio'] = 'true'">
  131. <xsl:if test="/root/*[local-name()='attachments']/*[local-name()='item']">
  132. <!-- attachments -->
  133. <impl:taskLinksList>
  134. <xsl:for-each select="/root/*[local-name()='attachments']/*[local-name()='item']">
  135. <impl:taskLink>
  136. <!-- if we have a locale then append to the attachment name -->
  137. <xsl:choose>
  138. <xsl:when test="*[local-name()='locale'] != ''">
  139. <impl:display>
  140. <xsl:value-of select="concat(*[local-name()='defaultName'],'_',*[local-name()='locale'])"/>
  141. </impl:display>
  142. </xsl:when>
  143. <xsl:otherwise>
  144. <impl:display>
  145. <xsl:value-of select="*[local-name()='defaultName']"/>
  146. </impl:display>
  147. </xsl:otherwise>
  148. </xsl:choose>
  149. <impl:id>
  150. <xsl:value-of select="*[local-name()='searchPath']"/>
  151. </impl:id>
  152. <impl:format>
  153. <xsl:value-of select="*[local-name()='format']"/>
  154. </impl:format>
  155. <impl:locale>
  156. <xsl:value-of select="*[local-name()='locale']"/>
  157. </impl:locale>
  158. </impl:taskLink>
  159. </xsl:for-each>
  160. </impl:taskLinksList>
  161. </xsl:if>
  162. </xsl:if>
  163. <xsl:choose>
  164. <xsl:when test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='agentStudio'] = 'true'">
  165. <xsl:variable name="links" select="/root/*[local-name()='links']/*[local-name()='item']"/>
  166. <!-- links -->
  167. <xsl:if test="$links">
  168. <impl:linksList>
  169. <xsl:for-each select="$links">
  170. <impl:link>
  171. <impl:display>
  172. <xsl:value-of select="*[local-name()='displayName']"/>
  173. </impl:display>
  174. <impl:objectClass>
  175. <xsl:choose>
  176. <xsl:when test="*[local-name()='objectClass'] != ''">
  177. <xsl:value-of select="*[local-name()='objectClass']"/>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <xsl:text>nil</xsl:text>
  181. </xsl:otherwise>
  182. </xsl:choose>
  183. </impl:objectClass>
  184. <impl:id>
  185. <xsl:value-of select="*[local-name()='searchPath']"/>
  186. </impl:id>
  187. </impl:link>
  188. </xsl:for-each>
  189. </impl:linksList>
  190. </xsl:if>
  191. </xsl:when>
  192. <xsl:when test="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='subscription'] = 'true'">
  193. <xsl:if test="/root/param[@name='m_ro_taskAsURL']='true'">
  194. <impl:linksList>
  195. <impl:link>
  196. <impl:display>TO BE REPLACED</impl:display>
  197. <impl:id>TO BE REPLACED</impl:id>
  198. </impl:link>
  199. </impl:linksList>
  200. </xsl:if>
  201. </xsl:when>
  202. </xsl:choose>
  203. <xsl:if test="key('param','m_ro_readExpiry_start')">
  204. <impl:startFor>
  205. <xsl:text>P</xsl:text>
  206. <!-- need to add the 'T' designator if specifying a time. In our case we need to resolve minutes or hours-->
  207. <xsl:if test="key('param','m_ro_readExpireUnit_start')='H' or key('param','m_ro_readExpireUnit_start')='M'">
  208. <xsl:text>T</xsl:text>
  209. </xsl:if>
  210. <xsl:value-of select="key('param','m_ro_readExpireUnitCount_start')"/>
  211. <xsl:value-of select="key('param','m_ro_readExpireUnit_start')"/>
  212. </impl:startFor>
  213. </xsl:if>
  214. <xsl:if test="/root/param[@name='m_ro_readReceipt']">
  215. <impl:recordReadReceipt>
  216. <xsl:value-of select="/root/param[@name='m_ro_readReceipt']"/>
  217. </impl:recordReadReceipt>
  218. </xsl:if>
  219. <xsl:if test="/root/param[@name='m_ro_sub_notifyOnCreation']">
  220. <impl:notifyOnCreation>
  221. <xsl:call-template name="makeSubscriptionParam">
  222. <xsl:with-param name="selected" select="/root/param[@name='m_ro_sub_notifyOnCreation']"/>
  223. </xsl:call-template>
  224. </impl:notifyOnCreation>
  225. </xsl:if>
  226. <xsl:if test="/root/param[@name='email_subject']">
  227. <impl:subject xml:lang="en-us">
  228. <xsl:value-of select="/root/param[@name='email_subject']"/>
  229. </impl:subject>
  230. </xsl:if>
  231. <!-- sort out the body -->
  232. <xsl:if test="key('param','email_body')!='' ">
  233. <xsl:call-template name="htmlBody"/>
  234. </xsl:if>
  235. </impl:manualTask>
  236. </impl:createNotificationManualTask>
  237. </xsl:template>
  238. <xsl:template name="makeSubscriptionParam">
  239. <xsl:param name="selected"/>
  240. <xsl:param name="global" select="'true'"/>
  241. <xsl:choose>
  242. <xsl:when test="$selected = 'true' or $selected = 'checked'">
  243. <xsl:choose>
  244. <xsl:when test="$global = 'true'">
  245. <xsl:text>GLOBAL_SUBSCRIBE</xsl:text>
  246. </xsl:when>
  247. <xsl:otherwise>
  248. <xsl:text>INDIVIDUAL_SUBSCRIBE</xsl:text>
  249. </xsl:otherwise>
  250. </xsl:choose>
  251. </xsl:when>
  252. <xsl:otherwise>
  253. <xsl:choose>
  254. <xsl:when test="$global = 'true'">
  255. <xsl:text>GLOBAL_UNSUBSCRIBE</xsl:text>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:text>INDIVIDUAL_UNSUBSCRIBE</xsl:text>
  259. </xsl:otherwise>
  260. </xsl:choose>
  261. </xsl:otherwise>
  262. </xsl:choose>
  263. </xsl:template>
  264. <xsl:template name="htmlBody">
  265. <impl:description xml:lang="en-us" contentType="text/plain">
  266. <xsl:value-of select="key('param','email_body')"/>
  267. </impl:description>
  268. <xsl:variable name="body">
  269. <xsl:choose>
  270. <xsl:when test="key('param','hidden_richEditBody') != ''">
  271. <xsl:value-of select="key('param','hidden_richEditBody')"/>
  272. </xsl:when>
  273. <xsl:otherwise>
  274. <xsl:value-of select="key('param','email_body')"/>
  275. </xsl:otherwise>
  276. </xsl:choose>
  277. </xsl:variable>
  278. <!-- build up a head and meta element to palce in the HTML email. -->
  279. <xsl:variable name="head">
  280. <xsl:if test="key('param','richEditMode') = 'true'">
  281. <xsl:value-of select="'&lt;HEAD&gt;&lt;META name=&quot;user-entered-html-email-body&quot;&gt;&lt;/META&gt;&lt;/HEAD&gt;'"/>
  282. </xsl:if>
  283. </xsl:variable>
  284. <!-- make sure the body has openning and closing BODY and HTML tags -->
  285. <xsl:variable name="htmlBody">
  286. <xsl:choose>
  287. <xsl:when test="starts-with($body,'&lt;HTML')">
  288. <xsl:value-of select="$body"/>
  289. </xsl:when>
  290. <xsl:when test="starts-with($body,'&lt;BODY')">
  291. <xsl:value-of select="concat('&lt;HTML&gt;',$head, $body,'&lt;/HTML&gt;')"/>
  292. </xsl:when>
  293. <xsl:otherwise>
  294. <xsl:value-of select="concat('&lt;HTML&gt;', $head, '&lt;BODY&gt;',$body,'&lt;/BODY&gt;&lt;/HTML&gt;')"/>
  295. </xsl:otherwise>
  296. </xsl:choose>
  297. </xsl:variable>
  298. <!-- if we need to add a link in the body -->
  299. <xsl:variable name="completeBody">
  300. <xsl:choose>
  301. <xsl:when test="key('param','m_ro_emailAsURL')='true' and /root/*[local-name()='requestParams']/*[local-name()='param' and @name='linkToReport']!= ''">
  302. <xsl:value-of select="substring-before($htmlBody, '&lt;/BODY&gt;&lt;/HTML&gt;')"/>
  303. <xsl:value-of select="'&lt;BR/&gt;'"/>
  304. <xsl:value-of select="/root/*[local-name()='requestParams']/*[local-name()='param' and @name='linkToReport']"/>
  305. <xsl:value-of select="'&lt;/BODY&gt;&lt;/HTML&gt;'"/>
  306. </xsl:when>
  307. <xsl:otherwise>
  308. <xsl:value-of select="$htmlBody"/>
  309. </xsl:otherwise>
  310. </xsl:choose>
  311. </xsl:variable>
  312. <impl:description xml:lang="en-us" contentType="text/html">
  313. <xsl:value-of select="$completeBody" disable-output-escaping="yes"/>
  314. </impl:description>
  315. </xsl:template>
  316. </xsl:stylesheet>