relationships.xslt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2005, 2014
  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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ui="http://developer.cognos.com/schemas/ui/presentation/markup/" xmlns:uic="http://developer.cognos.com/schemas/uic/presentation/markup/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:resource-prop="http://developer.cognos.com/admin/properties" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:ns1="http://docs.oasis-open.org/wsdm/muws1-2.xsd" xmlns:admui="http://developer.cognos.com/schemas/xts/admui" xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2" xmlns:cogadminext="xalan://com.cognos.admin.xts.ext.XTSExt" exclude-result-prefixes="wsrf-rp resource-prop admui xtsext xsl ns1 ui uic SOAP-ENV muws2 xts">
  13. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  14. <!-- display variables -->
  15. <admui:variables/>
  16. <ui:commonTemplates/>
  17. <xsl:variable name="sortColumn">
  18. <xsl:choose>
  19. <xsl:when test="key('env-param', 'sort_column') != ''">
  20. <xsl:value-of select="key('env-param', 'sort_column')"/>
  21. </xsl:when>
  22. <xsl:otherwise>
  23. <xsl:value-of select="''"/>
  24. </xsl:otherwise>
  25. </xsl:choose>
  26. </xsl:variable>
  27. <xsl:variable name="sortOrder">
  28. <xsl:choose>
  29. <xsl:when test="normalize-space(key('env-param', 'sort_order')) != ''">
  30. <xsl:value-of select="key('env-param', 'sort_order')"/>
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <xsl:value-of select="''"/>
  34. </xsl:otherwise>
  35. </xsl:choose>
  36. </xsl:variable>
  37. <xsl:template match="/root" priority="2">
  38. <xsl:variable name="relationshipTypes" select="/root/relationships/wsrf-rp:GetResourcePropertyResponse/resource-prop:SupportedRelationships"/>
  39. <uic:fragment>
  40. <!-- find out what the root relationship type is -->
  41. <xsl:variable name="selectedRelationshipType">
  42. <xsl:choose>
  43. <xsl:when test="key('env-param','rootRelationshipType') != ''">
  44. <xsl:value-of select="key('env-param','rootRelationshipType')"/>
  45. </xsl:when>
  46. <xsl:when test="key('env-param','selectedRelationshipType') != ''">
  47. <xsl:value-of select="key('env-param','selectedRelationshipType')"/>
  48. </xsl:when>
  49. <xsl:when test="key('env-param','relationshipType') != ''">
  50. <xsl:value-of select="key('env-param','relationshipType')"/>
  51. </xsl:when>
  52. <xsl:otherwise>
  53. <xsl:value-of select="$relationshipTypes//resource-prop:Relationship[@default='true']/resource-prop:Name"/>
  54. </xsl:otherwise>
  55. </xsl:choose>
  56. </xsl:variable>
  57. <xsl:variable name="application">
  58. <xsl:value-of select="key('env-param','application')"/>
  59. </xsl:variable>
  60. <xsl:variable name="defaultResourceId">
  61. <xsl:value-of select="cogadminext:getDefaultResourceId(string($application))"/>
  62. </xsl:variable>
  63. <!-- get the caption for the root breadcrumb -->
  64. <xsl:variable name="rootCaption" select="$relationshipTypes//resource-prop:Relationship[resource-prop:Name = string($selectedRelationshipType)]/resource-prop:Caption"/>
  65. <script>
  66. <xsl:if test="not($selectedRelationshipType = 'templates')">
  67. _THIS_onReloadEvent = function(evt) {
  68. if (evt.source != _THIS_) {
  69. removeReloadEventListener(_THIS_, "_THIS_onReloadEvent");
  70. raiseReloadEvent(_THIS_);
  71. _THIS_.raiseEvent("fragment.refresh");
  72. }
  73. }
  74. addReloadEventListener(_THIS_, "_THIS_onReloadEvent");
  75. </xsl:if>
  76. function getBCDepth(depth) {
  77. return depth ? depth : 1;
  78. }
  79. var _THIS_context = new relationships_context(
  80. {
  81. sortColumn: '<xsl:value-of select="$sortColumn"/>',
  82. sortOrder: '<xsl:value-of select="$sortOrder"/>'
  83. });
  84. _THIS_setContext = function(resourceID, storeID) {
  85. _THIS_.relationshipsObj.breadcrumbArray[_THIS_.relationshipsObj.breadcrumbArray.length-1].selectedResourceID=resourceID;
  86. _THIS_.relationshipsObj.breadcrumbArray[_THIS_.relationshipsObj.breadcrumbArray.length-1].selectedStoreID=storeID;
  87. }
  88. if (!_THIS_.relationshipsObj) {
  89. _THIS_.relationshipsObj = new cogadmin_relationships(_THIS_, '_THIS_', '<xts:string id="IDS_ADM_ACT_NO_SELECTION" encode="javascript"/>');
  90. <!-- first time we hit the page, so add the root breadcrumb information -->
  91. _THIS_.relationshipsObj.addBreadcrumb('<xsl:value-of select="xtsext:javascriptencode(string($selectedRelationshipType))"/>','<xsl:value-of select="xtsext:javascriptencode(string($defaultResourceId))"/>','<xsl:value-of select="xtsext:javascriptencode(string(./muws2:QueryRelationshipsByTypeResponse/muws2:Relationship/muws2:Participant[1]/resource-prop:StoreID))"/>');
  92. }
  93. else {
  94. _THIS_.relationshipsObj.clearResourceInfo();
  95. }
  96. <!-- if we're at the root, then we need to keep track of the action and group action context id's -->
  97. <xsl:variable name="resourceID" select="key('env-param','resourceID')"/>
  98. <xsl:if test="$resourceID='' or $resourceID=$defaultResourceId">
  99. <!-- get the currently selected relationship for the system -->
  100. <xsl:variable name="relationshipName">
  101. <xsl:choose>
  102. <xsl:when test="key('env-param','relationshipType') != ''">
  103. <xsl:value-of select="key('env-param','relationshipType')"/>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <!-- get the default relationship -->
  107. <xsl:value-of select="$relationshipTypes/resource-prop:Relationship[@default='true'][1]/*[local-name()='Name']"/>
  108. </xsl:otherwise>
  109. </xsl:choose>
  110. </xsl:variable>
  111. <!-- need to get the action and groupAction ID's -->
  112. <!-- the action can be nested inside a sub-menu, hence the // in the searchpath -->
  113. <xsl:variable name="currentAction" select="$relationshipTypes//resource-prop:Relationship[resource-prop:Name = string($relationshipName)]"/>
  114. <xsl:variable name="groupActionID">
  115. <xsl:choose>
  116. <!-- check the current relationship -->
  117. <xsl:when test="$currentAction/resource-prop:ActionContexts/resource-prop:Context[@type='GroupAction']/@id != ''">
  118. <xsl:value-of select="$currentAction/resource-prop:ActionContexts/resource-prop:Context[@type='GroupAction']/@id"/>
  119. </xsl:when>
  120. <!-- if we're in a container, then check to see if the contain has the action ID's -->
  121. <xsl:when test="$currentAction/parent::*[@container='true']/resource-prop:ActionContexts/resource-prop:Context[@type='GroupAction']/@id != ''">
  122. <xsl:value-of select="$currentAction/parent::*[@container='true']/resource-prop:ActionContexts/resource-prop:Context[@type='GroupAction']/@id"/>
  123. </xsl:when>
  124. </xsl:choose>
  125. </xsl:variable>
  126. <xsl:variable name="actionID">
  127. <xsl:choose>
  128. <!-- check the current relationship -->
  129. <xsl:when test="$currentAction/resource-prop:ActionContexts/resource-prop:Context[@type='Action']/@id != ''">
  130. <xsl:value-of select="$currentAction/resource-prop:ActionContexts/resource-prop:Context[@type='Action']/@id"/>
  131. </xsl:when>
  132. <!-- if we're in a container, then check to see if the contain has the action ID's -->
  133. <xsl:when test="$currentAction/parent::*[@container='true']/resource-prop:ActionContexts/resource-prop:Context[@type='Action']/@id != ''">
  134. <xsl:value-of select="$currentAction/parent::*[@container='true']/resource-prop:ActionContexts/resource-prop:Context[@type='Action']/@id"/>
  135. </xsl:when>
  136. </xsl:choose>
  137. </xsl:variable>
  138. _THIS_.relationshipsObj.setRootActionContext('<xsl:value-of select="xtsext:javascriptencode(string($actionID))"/>','<xsl:value-of select="xtsext:javascriptencode(string($groupActionID))"/>');
  139. </xsl:if>
  140. function _THIS_getJSHandler() {
  141. return _THIS_.relationshipsObj;
  142. }
  143. function closeSettingsDialog() {
  144. ui_modal_dialog.close();
  145. raiseReloadEvent(_THIS_);
  146. }
  147. <!-- build the supported relationships menu -->
  148. var g_THIS_relationshipsMenu=new ui_menu({id: "_THIS_", fragment: "_THIS_", items:[
  149. <xsl:for-each select="$relationshipTypes/resource-prop:Relationship[not(@container)]">
  150. <xsl:variable name="isSelected">
  151. <xsl:value-of select="resource-prop:Name = $selectedRelationshipType"/>
  152. </xsl:variable>
  153. {
  154. title: "<xsl:value-of select="resource-prop:Caption"/>",
  155. selected: <xsl:value-of select="$isSelected"/>,
  156. action: function(evt) {
  157. _THIS_.relationshipsObj.keepBreadcrumbs(1);
  158. _THIS_.relationshipsObj.switchRelationshipType('<xsl:value-of select="xtsext:javascriptencode(string(resource-prop:Name))"/>');
  159. _THIS_.retrieve(_THIS_.relationshipsObj.buildURLParams(_THIS_context));
  160. }
  161. }
  162. <xsl:if test="position() != last()">,</xsl:if>
  163. </xsl:for-each>
  164. <xsl:for-each select="$relationshipTypes/resource-prop:Relationship[@container]">
  165. , {
  166. title: "<xsl:value-of select="xtsext:javascriptencode(string(resource-prop:Caption))"/>",
  167. items: [
  168. <xsl:for-each select="resource-prop:Relationship">
  169. <xsl:variable name="isSelected">
  170. <xsl:value-of select="resource-prop:Name = $selectedRelationshipType"/>
  171. </xsl:variable>
  172. {
  173. title: "<xsl:value-of select="resource-prop:Caption"/>",
  174. selected: <xsl:value-of select="$isSelected"/>,
  175. action: function(evt) {
  176. _THIS_.relationshipsObj.keepBreadcrumbs(1);
  177. _THIS_.relationshipsObj.switchRelationshipType('<xsl:value-of select="xtsext:javascriptencode(string(resource-prop:Name))"/>');
  178. _THIS_.retrieve(_THIS_.relationshipsObj.buildURLParams(_THIS_context));
  179. }
  180. }
  181. <xsl:if test="position() != last()">,</xsl:if>
  182. </xsl:for-each>
  183. ]
  184. }
  185. </xsl:for-each>
  186. ]});
  187. _THIS_.navigate = function(resourceID, storeID,depth) {
  188. _THIS_.relationshipsObj.addBreadcrumb('containedBy', resourceID, storeID,depth);
  189. _THIS_.retrieve(_THIS_.relationshipsObj.buildURLParams(_THIS_context));
  190. }
  191. <!-- init the popup for the properties dialog -->
  192. <xsl:variable name="progressImage">
  193. <admui:imageURL image="progress.gif" type="cogadmin"/>
  194. </xsl:variable>
  195. initPopup('<xsl:value-of select="xtsext:javascriptencode(string($progressImage))"/>', '<xts:string id="IDS_ADM_MESSAGE_STOP" encode="javascript"/>');
  196. </script>
  197. <table width="100%" border="0" cellpadding="0" cellspacing="0" role="presentation">
  198. <tr>
  199. <td width="90%">
  200. <!-- breadcrumbs -->
  201. <uic:breadcrumbs width="100%" height="18">
  202. <xsl:variable name="bcDepth">
  203. <xsl:value-of select="key('env-param','bcDepth')"/>
  204. </xsl:variable>
  205. <!-- root -->
  206. <uic:complexBreadcrumb>
  207. <xsl:choose>
  208. <xsl:when test="$bcDepth = '' or $bcDepth = 1">
  209. <uic:text>
  210. <xsl:variable name="parentCaption"><xsl:value-of select="$relationshipTypes/resource-prop:Relationship[@container and ./resource-prop:Relationship/resource-prop:Name = string($selectedRelationshipType)]/resource-prop:Caption"/></xsl:variable>
  211. <!-- if the relationships is contained, prefix the caption with the parent caption -->
  212. <xsl:if test="$parentCaption != ''">
  213. <xsl:value-of select="concat($parentCaption,' - ')"/>
  214. </xsl:if>
  215. <xsl:value-of select="$rootCaption"/>
  216. </uic:text>
  217. </xsl:when>
  218. <xsl:otherwise>
  219. <uic:link>
  220. <uic:text>
  221. <xsl:variable name="parentCaption"><xsl:value-of select="$relationshipTypes/resource-prop:Relationship[@container and ./resource-prop:Relationship/resource-prop:Name = string($selectedRelationshipType)]/resource-prop:Caption"/></xsl:variable>
  222. <!-- if the relationships is contained, prefix the caption with the parent caption -->
  223. <xsl:if test="$parentCaption != ''">
  224. <xsl:value-of select="concat($parentCaption,' - ')"/>
  225. </xsl:if>
  226. <xsl:value-of select="$rootCaption"/>
  227. </uic:text>
  228. <uic:href>#</uic:href>
  229. <uic:onclick>_THIS_.relationshipsObj.keepBreadcrumbs(1); _THIS_.retrieve(_THIS_.relationshipsObj.buildURLParams(_THIS_context));</uic:onclick>
  230. </uic:link>
  231. </xsl:otherwise>
  232. </xsl:choose>
  233. <uic:icon uic:noSpace="true" aria-haspopup="true" aria-labelledBy="{concat('_THIS_breadcrumb',position())}">
  234. <uic:src>
  235. <admui:imageURL image="dropdown_arrow.gif" type="skin_shared"/>
  236. </uic:src>
  237. <uic:tooltip>
  238. <xts:string id="IDS_ADM_TOP_CHANGE_VIEW"/>
  239. </uic:tooltip>
  240. <uic:onclick>ui_menuShow(event,g_THIS_relationshipsMenu);</uic:onclick>
  241. </uic:icon>
  242. </uic:complexBreadcrumb>
  243. <!-- build up the breadcrumbs -->
  244. <xsl:for-each select="//root/breadcrumbs/*[local-name()='GetMultipleResourcePropertiesResponse'][position() &lt; $bcDepth]/*[local-name()='Caption']">
  245. <xsl:sort select="@name"/>
  246. <xsl:variable name="jsEncodedResourceID" select="xtsext:javascriptencode(string(key('env-param',concat('bc_resid_',position()))))"/>
  247. <xsl:variable name="jsEncodedStoreID" select="xtsext:javascriptencode(string(key('env-param',concat('bc_id_',position()))))"/>
  248. <xsl:variable name="displayName" select="."/>
  249. <uic:complexBreadcrumb>
  250. <xsl:choose>
  251. <xsl:when test="position() != last()">
  252. <uic:link>
  253. <uic:text>
  254. <xsl:value-of select="$displayName"/>
  255. </uic:text>
  256. <uic:href>#</uic:href>
  257. <uic:onclick>_THIS_.relationshipsObj.keepBreadcrumbs(<xsl:value-of select="position() + 1"/>); _THIS_.retrieve(_THIS_.relationshipsObj.buildURLParams(_THIS_context));</uic:onclick>
  258. </uic:link>
  259. </xsl:when>
  260. <xsl:otherwise>
  261. <uic:text>
  262. <xsl:value-of select="$displayName"/>
  263. </uic:text>
  264. </xsl:otherwise>
  265. </xsl:choose>
  266. <uic:icon uic:noSpace="true" aria-haspopup="true" aria-labelledBy="{concat('_THIS_breadcrumb',position()+1)}">
  267. <uic:src>
  268. <admui:imageURL image="dropdown_arrow.gif" type="skin_shared"/>
  269. </uic:src>
  270. <uic:tooltip>
  271. <xts:string id="IDS_ADM_TOP_SIBLING_NAVIGATION"/>
  272. </uic:tooltip>
  273. <uic:onclick>_THIS_.relationshipsObj.getSiblingMenu(event, '<xsl:value-of select="position()"/>');</uic:onclick>
  274. </uic:icon>
  275. </uic:complexBreadcrumb>
  276. </xsl:for-each>
  277. </uic:breadcrumbs>
  278. </td>
  279. <xsl:if test="not($selectedRelationshipType = 'templates')">
  280. <!-- group actions (if it's not Templates-->
  281. <td width="10%" align="right">
  282. <uic:icon>
  283. <uic:src>
  284. <admui:imageURL image="action_toolbar.gif" type="cogadmin"/>
  285. </uic:src>
  286. <uic:tooltip>
  287. <xts:string id="IDS_ADM_TOP_GROUP_ACTIONS"/>
  288. </uic:tooltip>
  289. <uic:onclick>_THIS_.relationshipsObj.showGroupActionsMenu(event);</uic:onclick>
  290. </uic:icon>
  291. </td>
  292. </xsl:if>
  293. </tr>
  294. </table>
  295. </uic:fragment>
  296. </xsl:template>
  297. <xsl:template match="node()" priority="-1">
  298. <xsl:copy>
  299. <xsl:copy-of select="@*"/>
  300. <xsl:apply-templates/>
  301. </xsl:copy>
  302. </xsl:template>
  303. <xsl:template match="text()" priority="-1">
  304. <xsl:value-of select="."/>
  305. </xsl:template>
  306. </xsl:stylesheet>