listTenants.xts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. 2012, 2013
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/portal.xml, messages/portalRL.xml">
  9. <xts:block id="getContent" nodelist="header,env,configProps" processor="XSLT" type="exec">
  10. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  11. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  12. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  13. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  14. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  15. exclude-result-prefixes="xsl send bus">
  16. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  17. <xsl:template match="/">
  18. <xts:sequence>
  19. <xts:append>
  20. <availableTenants>
  21. <xsl:choose>
  22. <xsl:when test="/root/env/param[@name='src']='listTenants'">
  23. <send:request provider="cm">
  24. <bus:listTenants xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"/>
  25. </send:request>
  26. </xsl:when>
  27. <xsl:otherwise>
  28. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  29. <send:request provider="cm">
  30. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  31. <cm:query>
  32. <cm:requests>
  33. <cm:query>
  34. <cm:search>/directory/tenants/tenant</cm:search>
  35. <cm:properties>
  36. <cm:property name="tenantID"/>
  37. <cm:property name="defaultName"/>
  38. </cm:properties>
  39. <cm:sortBy>
  40. <cm:sort name="defaultName" order="ascending"/>
  41. </cm:sortBy>
  42. </cm:query>
  43. </cm:requests>
  44. </cm:query>
  45. </xts:transform>
  46. </send:request>
  47. </xts:transform>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </availableTenants>
  51. </xts:append>
  52. </xts:sequence>
  53. </xsl:template>
  54. </xsl:stylesheet>
  55. </xts:block>
  56. <xts:block id="test" type="exec" mode="interpret" nodelist="env, availableTenants" dependency="getContent" processor="XSLT" xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  57. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  58. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  59. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  60. exclude-result-prefixes="xsl xtsext bus">
  61. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  62. <xsl:template match="/">
  63. <xts:sequence>
  64. <xts:append select="/root/output">
  65. <xos:part>
  66. <xos:entityHeader>
  67. <xos:param name="Content-Type">application/json; charset=utf-8</xos:param>
  68. </xos:entityHeader>
  69. <xos:entityBody>
  70. <xsl:text>{identifier:"id",label: "name",items: [</xsl:text>
  71. <xsl:variable name="comma" select="','"/>
  72. <xsl:if test="/root/env/param[@name='isFilter']='true'">
  73. <xsl:variable name="any"><xts:string id="IDS_ANY" encode="javascript"/></xsl:variable>
  74. <xsl:value-of select="concat('{id: &quot;','any','&quot;',$comma, 'name:&quot;',$any,'&quot;',$comma, 'isAny:true}',$comma)"/>
  75. </xsl:if>
  76. <xsl:if test="/root/env/param[@name='isFilter']='true' or /root/env/param[@name='isImpersonate']='true'">
  77. <xsl:variable name="none"><xts:string id="IDS_NONE" encode="javascript"/></xsl:variable>
  78. <xsl:value-of select="concat('{id: &quot;',' ','&quot;',$comma, 'name:&quot;',$none,'&quot;}',$comma)"/>
  79. </xsl:if>
  80. <xsl:for-each select="/root/availableTenants/*[local-name()='queryResponse']/*[local-name()='queryReply']/*[local-name()='tenant'] | /root/availableTenants//*[local-name()='item']/*[local-name()='tenantID' and text() != '']/..">
  81. <xsl:sort select="*[local-name()='defaultName']"/>
  82. <xsl:variable name="tenantID" select="*[local-name()='tenantID']"/>
  83. <xsl:variable name="tenantName" select="*[local-name()='defaultName']"/>
  84. <xsl:variable name="encodedID" select="xtsext:javascriptencode(string($tenantID))"/>
  85. <xsl:variable name="encodedName" select="xtsext:javascriptencode(string($tenantName))"/>
  86. <xsl:value-of select="concat('{id: &quot;',$encodedID,'&quot;',$comma, 'name:&quot;',$encodedName,'&quot;}')"/>
  87. <xsl:if test="position() != last()">
  88. <xsl:text>,</xsl:text>
  89. </xsl:if>
  90. </xsl:for-each>
  91. <xsl:text>]}</xsl:text>
  92. </xos:entityBody>
  93. </xos:part>
  94. </xts:append>
  95. </xts:sequence>
  96. </xsl:template>
  97. </xsl:stylesheet>
  98. </xts:block>
  99. </xts:morphlet>