mru.xslt 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/"
  15. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  16. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  17. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  18. xmlns:mf="http://developer.cognos.com/schemas/xts/logicsheets/presentation/main/mf"
  19. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  20. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  21. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  22. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  23. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  24. xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/"
  25. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  26. xmlns:mru="http://developer.cognos.com/schemas/xts/mru/"
  27. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  28. xmlns:out="dummy-uri">
  29. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  30. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  31. <xsl:template match="mru:update">
  32. <out:variable name="mruFolder" select="concat(string(/root/session/param[@name='e_hp']),'/mruFolder')"/>
  33. <out:variable name="targetObjSearchPath">
  34. <out:value-of select="$mruTargetObjectSearchPath"/>
  35. </out:variable>
  36. <out:variable name="shorcutName">
  37. <out:value-of select="$mruTargetObjectId"/>
  38. </out:variable>
  39. <out:if test="string($targetObjSearchPath) != '' and string($shorcutName) != ''">
  40. <xts:sequence>
  41. <xts:append>
  42. <send:request provider="cm">
  43. <cm:add xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  44. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  45. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  46. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  47. xmlns:cm2="http://developer.cognos.com/schemas/contentManagerService/1"
  48. xmlns:cm="http://developer.cognos.com/schemas/bibus/3/"
  49. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  50. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/">
  51. <cm:search><out:value-of select="$mruFolder"/></cm:search>
  52. <objects xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:baseClass[1]">
  53. <item xsi:type="cm:shortcut">
  54. <target xsi:type="cm:baseClassArrayProp">
  55. <value xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="cm:baseClass[1]">
  56. <item xsi:type="cm:nil">
  57. <searchPath xsi:type="cm:stringProp">
  58. <value xsi:type="xsd:string">
  59. <out:value-of select="$targetObjSearchPath"/>
  60. </value>
  61. </searchPath>
  62. </item>
  63. </value>
  64. </target>
  65. <defaultName xsi:type="cm:tokenProp">
  66. <value xsi:type="xsd:string">
  67. <out:value-of select="$shorcutName"/>
  68. </value>
  69. </defaultName>
  70. </item>
  71. </objects>
  72. <options xsi:type="cm:addOptions">
  73. <updateAction xsi:type="cm:updateActionEnum">update</updateAction>
  74. </options>
  75. </cm:add>
  76. </send:request>
  77. </xts:append>
  78. </xts:sequence>
  79. </out:if>
  80. </xsl:template>
  81. <xsl:template match="mru:read">
  82. <out:variable name="mruPath">
  83. <out:text>/mruFolder/*[@objectClass = 'shortcut']</out:text>
  84. </out:variable>
  85. <out:variable name="mruFolder" select="concat(string(/root/session/param[@name='e_hp']), $mruPath)"/>
  86. <cm:query>
  87. <cm:search><out:value-of select="$mruFolder"/></cm:search>
  88. <cm:properties>
  89. <cm:property name="defaultName"/>
  90. <cm:property name="permissions"/>
  91. <cm:property name="effectiveUserCapabilities"/>
  92. <cm:property name="searchPath"/>
  93. <cm:property name="storeID"/>
  94. </cm:properties>
  95. <cm:options schemaInfo="true">
  96. <cm:refProps>
  97. <cm:refProp refPropName="target">
  98. <cm:properties>
  99. <cm:property name="defaultName"/>
  100. <cm:property name="searchPath"/>
  101. <cm:property name="userInterfaces"/>
  102. <cm:property name="effectiveUserCapabilities"/>
  103. </cm:properties>
  104. </cm:refProp>
  105. </cm:refProps>
  106. </cm:options>
  107. <cm:sortBy>
  108. <!-- most recently used entry percolated to the top -->
  109. <cm:sort name="modificationTime" order="descending"/>
  110. </cm:sortBy>
  111. </cm:query>
  112. </xsl:template>
  113. <xsl:template match="mru:filter">
  114. <!--
  115. * Apply filter to objects in the MRU folder to:
  116. * a] return applicable (studio, permission) packages
  117. * b] suppress stale entries (entries whose referenced targets do not exist or have been renamed)
  118. * c] get rid of duplicate(s) (e.g.: same pkg redeployed)
  119. -->
  120. <mruPackages>
  121. <out:if test="count($mruShortcutNodes) > 0">
  122. <out:variable name="mruPkgs">
  123. <packages>
  124. <out:for-each select="$mruShortcutNodes">
  125. <out:variable name="userInterface"><out:value-of select="/root/launchComponent/userInterface"/></out:variable>
  126. <out:variable name="requiredCapability"><out:value-of select="/root/launchComponent/capability/@name"/></out:variable>
  127. <out:variable name="name" select="cm:target/*/cm:defaultName"/>
  128. <out:variable name="isPackage" select="string(cm:target/*/cm:objectClass) = 'package'"/>
  129. <out:if test="not(preceding-sibling::*[cm:target/*/cm:defaultName = $name])">
  130. <out:if test="$isPackage and (not(cm:target/*/cm:userInterfaces/child::node()) or cm:target/*/cm:userInterfaces/*[local-name()='uiComponentEnum' and string(.)=$userInterface])">
  131. <out:variable name="hasCapability" select="string($requiredCapability) = '' or boolean(cm:target/*/*[local-name()='effectiveUserCapabilities']/*[local-name() = $requiredCapability])"/>
  132. <out:if test="$hasCapability">
  133. <package>
  134. <out:value-of select="cm:target/*/cm:searchPath"/>
  135. <out:value-of select="/root/selectionSpec/item[@name='requestPredicate']"/>
  136. <out:value-of select="/root/selectionSpec/item[@name='selectionPermissions']"/>
  137. </package>
  138. </out:if>
  139. </out:if>
  140. </out:if>
  141. </out:for-each>
  142. </packages>
  143. </out:variable>
  144. <out:if test="count($mruPkgs/packages/package)>0">
  145. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  146. <send:request provider="cm">
  147. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  148. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  149. <cm:requests>
  150. <out:for-each select="$mruPkgs/packages/package">
  151. <cm:query>
  152. <cm:search><out:value-of select="string(.)"/></cm:search>
  153. <cm:properties>
  154. <cm:property name="objectClass"/>
  155. <cm:property name="defaultName"/>
  156. <cm:property name="storeID"/>
  157. <cm:property name="searchPath"/>
  158. <cm:property name="permissions"/>
  159. <cm:property name="effectiveUserCapabilities"/>
  160. </cm:properties>
  161. </cm:query>
  162. </out:for-each>
  163. </cm:requests>
  164. </cm:query>
  165. </xts:transform>
  166. </send:request>
  167. </xts:transform>
  168. </out:if>
  169. </out:if>
  170. </mruPackages>
  171. </xsl:template>
  172. <xsl:template match="*">
  173. <xsl:copy>
  174. <xsl:copy-of select="@*"/>
  175. <xsl:apply-templates/>
  176. </xsl:copy>
  177. </xsl:template>
  178. </xsl:stylesheet>