generateCMQueriesForDeliveryInfo.xslt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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, 2011
  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. <!--
  13. NOTE: The logic to determine the order of the queries MUST match the logic found in dt:generateInitialUIHelpers
  14. if checkUIHelpers is true, then only build the CM query if the associated UIHelper is empty.
  15. -->
  16. <xsl:stylesheet version="1.0"
  17. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  18. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  19. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  20. exclude-result-prefixes="xsl">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  22. <xsl:key name="ui-helpers" match="/root/*[local-name()='UIHelpers']/*" use="local-name()"/>
  23. <xsl:template match="*[local-name()='root']" priority="1">
  24. <xsl:choose>
  25. <xsl:when test="not(/root/*[local-name()='queryReply']/*/*[local-name()='options']/*) and /root/jobOptions/*[local-name()='options']/*">
  26. <xsl:for-each select="/root/jobOptions">
  27. <xsl:call-template name="genQueries">
  28. <xsl:with-param name="checkUIHelpers" select="/root/*[local-name()='checkUIHelpers']"/>
  29. </xsl:call-template>
  30. </xsl:for-each>
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <xsl:for-each select="/root/*[local-name()='queryReply']/*">
  34. <xsl:call-template name="genQueries">
  35. <xsl:with-param name="checkUIHelpers" select="false()"/>
  36. </xsl:call-template>
  37. </xsl:for-each>
  38. </xsl:otherwise>
  39. </xsl:choose>
  40. </xsl:template>
  41. <xsl:template name="genQueries">
  42. <xsl:param name="checkUIHelpers"/>
  43. <xsl:variable name="typedRecipientsCount" select="count(*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and (.='toAddress' or .='ccAddress' or .='bccAddress')]]/*[local-name()='value']/*[local-name()='item'])"/>
  44. <xsl:variable name="selectedRecipients" select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and (.='to' or .='cc' or .='bcc')]][@xsi:type='bus:deliveryOptionSearchPathMultipleObjectArray']/*[local-name()='value']/*[local-name()='item']"/>
  45. <xsl:variable name="selectedRecipientsCount" select="count($selectedRecipients)"/>
  46. <!-- if we only have 1 recipient and it's a reference to another object -->
  47. <xsl:if test="$typedRecipientsCount = 0 and $selectedRecipientsCount = 1 and (not($checkUIHelpers='true') or key('ui-helpers','emailRecipients')='')">
  48. <cm:query>
  49. <cm:search><xsl:value-of select="$selectedRecipients"/></cm:search>
  50. <cm:properties>
  51. <cm:property name="defaultName"/>
  52. <cm:property name="userName"/>
  53. </cm:properties>
  54. </cm:query>
  55. </xsl:if>
  56. <!-- If we don't have any recipients, then make sure there aren't any that are specified in the old runOptions format -->
  57. <!-- Upgrade from runOptions recipients to deliveryOptions recipients -->
  58. <xsl:if test="$typedRecipientsCount = 0 and $selectedRecipientsCount = 0">
  59. <xsl:variable name="old_typedRecipientsCount" select="count(*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and .='emailToAddress']]/*[local-name()='value']/*[local-name()='item'])"/>
  60. <xsl:variable name="old_selectedRecipients" select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name' and .='emailTo']]/*[local-name()='value']/*[local-name()='item']"/>
  61. <xsl:variable name="old_selectedRecipientsCount" select="count($old_selectedRecipients)"/>
  62. <!-- if we only have 1 recipient and it's a reference to another object -->
  63. <xsl:if test="$old_typedRecipientsCount = 0 and $old_selectedRecipientsCount = 1 and (not($checkUIHelpers='true') or key('ui-helpers','emailRecipients')='')">
  64. <cm:query>
  65. <cm:search><xsl:value-of select="$old_selectedRecipients"/></cm:search>
  66. <cm:properties>
  67. <cm:property name="defaultName"/>
  68. <cm:property name="userName"/>
  69. </cm:properties>
  70. </cm:query>
  71. </xsl:if>
  72. </xsl:if>
  73. <!-- is print set to true and are we referencing a printer object -->
  74. <xsl:if test="(not($checkUIHelpers='true') or key('ui-helpers','printerSummary')='') and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='print']/*[local-name()='value'] = 'true' and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='printer']/*[local-name()='value'] != ''">
  75. <cm:query>
  76. <cm:search><xsl:value-of select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='printer']/*[local-name()='value']"/></cm:search>
  77. <cm:properties>
  78. <cm:property name="defaultName"/>
  79. <cm:property name="printerAddress"/>
  80. </cm:properties>
  81. </cm:query>
  82. </xsl:if>
  83. <!-- are we saving as a report view -->
  84. <xsl:if test="(not($checkUIHelpers='true') or key('ui-helpers','saveAsSummary')='') and *[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='saveAs']/*[local-name()='parentSearchPath'] != ''">
  85. <cm:query>
  86. <cm:search><xsl:value-of select="*[local-name()='options']/*[local-name()='value']/*[local-name()='item' and ./*[local-name()='name']='saveAs']/*[local-name()='parentSearchPath']"/></cm:search>
  87. <cm:properties>
  88. <cm:property name="defaultName"/>
  89. <cm:property name="ancestors"/>
  90. </cm:properties>
  91. </cm:query>
  92. </xsl:if>
  93. </xsl:template>
  94. <xsl:template match="text()" priority="0"/>
  95. </xsl:stylesheet>