agentDefinition.xsl 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2009
  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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:agsad="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/agentDefinition/" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:doc="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/doc/" xmlns:out="dummy-uri" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="doc">
  9. <xsl:output method="html" encoding="UTF-8" indent="no"/>
  10. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  11. <doc:group prefix="agsad">
  12. <doc:location>
  13. <doc:namespace>http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/agentDefinition/</doc:namespace>
  14. <doc:ref>ps/ags/logicsheets/agentDefinition.xsl</doc:ref>
  15. </doc:location>
  16. </doc:group>
  17. <!-- +++++++++++++++++++++++
  18. outputs the relevant suppression state text according to the agent definition in the input dom
  19. +++++++++++++++++++++++++++++-->
  20. <doc:template type="ui">
  21. <doc:name>taskSuppressionStateText</doc:name>
  22. <doc:desc>This tag creates an &quot;out&quot; template named &lt;getTaskSuppressionStateText&gt; that outputs an label and string for the relevant suppression state</doc:desc>
  23. <doc:notes>See &lt;getTaskSuppressionStateText&gt;</doc:notes>
  24. </doc:template>
  25. <xsl:template match="agsad:taskSuppressionStateText" xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/" xmlns:agscnd="http://developer.cognos.com/schemas/xts/logicsheets/xslt/ags/condition/">
  26. <doc:template type="out">
  27. <doc:name>getTaskSuppressionStateText</doc:name>
  28. <doc:desc>This template outputs alabel and text for the relevant suppression state</doc:desc>
  29. <doc:param>
  30. <doc:param-name>suppression-node</doc:param-name>
  31. <doc:param-desc>This points to the suppression node within the action of the agent definition that we want the state gif for i.e. "/root/agent_definition/items/item [./id = 'task_id']/suppression"</doc:param-desc>
  32. </doc:param>
  33. </doc:template>
  34. <out:template name="getTaskSuppressionStateText">
  35. <out:param name="suppression-node"/>
  36. <out:variable name="suppressionStates">
  37. <out:if test="$suppression-node/following-sibling::node()[local-name()='runCondition'] != 'runOnFailure' or $suppression-node/preceding-sibling::node()[local-name()='runCondition'] != 'runOnFailure' ">
  38. <out:if test="$suppression-node/param[@name='Filter_new']">
  39. <state>
  40. <xts:string id="DIALOG_SUPPRESSION_NEW"/>
  41. </state>
  42. </out:if>
  43. <out:if test="$suppression-node/param[@name='Filter_changed' or @name='Filter_unchanged']">
  44. <state>
  45. <xts:string id="DIALOG_SUPPRESSION_ONGOING"/>
  46. <out:if test="$suppression-node/param[@name='Action_topic_filter'] and not($suppression-node/param[@name='Action_topic_filter']/text() = '')">
  47. <xts:string id="IDS_LIST_START"/>
  48. <out:text> </out:text>
  49. <out:call-template name="translate-filter-topic-list">
  50. <out:with-param name="keyItems" select="$suppression-node/param[@name='Action_topic_filter']"/>
  51. </out:call-template>
  52. <xts:text id="IDS_LIST_END"/>
  53. </out:if>
  54. </state>
  55. </out:if>
  56. <out:if test="$suppression-node/param[@name='Filter_deleted']">
  57. <state>
  58. <xts:string id="DIALOG_SUPPRESSION_CEASED"/>
  59. </state>
  60. </out:if>
  61. <out:if test="$suppression-node/param[@name='Filter_nil']">
  62. <state>
  63. <xts:string id="DIALOG_SUPPRESSION_NO_EVENTS"/>
  64. </state>
  65. </out:if>
  66. <out:if test="$suppression-node/following-sibling::node()[local-name()='taskLevelFilter']!= ''">
  67. <state>
  68. <xts:string id="DIALOG_SUPPRESSION_CONDITION"/>
  69. </state>
  70. </out:if>
  71. </out:if>
  72. </out:variable>
  73. <out:if test="count($suppressionStates/state) > 0">
  74. <!--out put the list to text -->
  75. <out:for-each select="$suppressionStates/state">
  76. <out:value-of select="."/>
  77. <out:if test="not(position() = last())">
  78. <out:text>; </out:text>
  79. </out:if>
  80. </out:for-each>
  81. </out:if>
  82. </out:template>
  83. <out:template name="translate-filter-topic-list">
  84. <out:param name="keyItems" select="''"/>
  85. <out:variable name="before">
  86. <out:value-of select="substring-before(normalize-space($keyItems),';')"/>
  87. </out:variable>
  88. <out:variable name="after">
  89. <out:value-of select="substring-after(normalize-space($keyItems),';')"/>
  90. </out:variable>
  91. <out:call-template name="topicFilterDisplayLogic">
  92. <out:with-param name="topicFilter" select="$before"/>
  93. </out:call-template>
  94. <out:if test="string-length($after) > 0">
  95. <xts:string id="IDS_LIST_SEPARATOR"/>
  96. <out:text> </out:text>
  97. <out:call-template name="translate-filter-topic-list">
  98. <out:with-param name="keyItems">
  99. <out:value-of select="$after"/>
  100. </out:with-param>
  101. </out:call-template>
  102. </out:if>
  103. </out:template>
  104. <!--convert from [beh-bleurgh-blahhh]; to blahhh -->
  105. <out:template name="topicFilterDisplayLogic">
  106. <out:param name="topicFilter" select="''"/>
  107. <out:choose>
  108. <out:when test="contains($topicFilter,'.')">
  109. <out:call-template name="topicFilterDisplayLogic">
  110. <out:with-param name="topicFilter">
  111. <out:value-of select="substring-after($topicFilter,'.')"/>
  112. </out:with-param>
  113. </out:call-template>
  114. </out:when>
  115. <out:otherwise>
  116. <out:value-of select="translate($topicFilter, '[]', '')"/>
  117. </out:otherwise>
  118. </out:choose>
  119. </out:template>
  120. <!--tem,plate to trim whatever is passed to length -->
  121. <out:template name="chopText">
  122. <out:param name="trimSize" select="'45'"/>
  123. <out:param name="text"/>
  124. <!--trims the descriptions to length -->
  125. <out:variable name="ellipsis">
  126. <xts:string id="IDS_LIST_ELLIPSIS"/>
  127. </out:variable>
  128. <out:choose>
  129. <out:when test="string-length($text) > number($trimSize)">
  130. <out:value-of select="concat(substring($text,1, number($trimSize) - 3),$ellipsis)"/>
  131. </out:when>
  132. <out:otherwise>
  133. <out:value-of select="$text"/>
  134. </out:otherwise>
  135. </out:choose>
  136. </out:template>
  137. </xsl:template>
  138. <!-- +++++++++++++++++++++++
  139. outputs the relevant suppression state gif according to the agent definition in the input dom
  140. +++++++++++++++++++++++++++++-->
  141. <doc:template type="ui">
  142. <doc:name>taskSuppressionState</doc:name>
  143. <doc:desc>This tag creates an &quot;out&quot; template named &lt;getTaskSuppressionStateGif&gt; that outputs an img tag for the relevant suppression state</doc:desc>
  144. <doc:notes>See &lt;getTaskSuppressionStateGif&gt;</doc:notes>
  145. </doc:template>
  146. <xsl:template match="agsad:taskSuppressionState">
  147. <doc:template type="out">
  148. <doc:name>getTaskSuppressionStateGif</doc:name>
  149. <doc:desc>This template outputs an img tag for the relevant suppression state</doc:desc>
  150. <doc:param>
  151. <doc:param-name>suppression-node</doc:param-name>
  152. <doc:param-desc>This points to the suppression node within the action of the agent definition that we want the state gif for i.e. "/root/agent_definition/items/item [./id = 'task_id']/suppression"</doc:param-desc>
  153. </doc:param>
  154. </doc:template>
  155. <out:template name="getTaskSuppressionStateGif">
  156. <out:param name="suppression-node">
  157. <suppression_test/>
  158. </out:param>
  159. <out:variable name="gif_data">
  160. <gif state="ongoing" name="icon_ongoing.gif">
  161. <out:attribute name="stateInfo">
  162. <xts:string id="AGS_TASK_STATE_ONGOING"/>
  163. </out:attribute>
  164. </gif>
  165. <gif state="ceased" name="icon_ceased.gif">
  166. <out:attribute name="stateInfo">
  167. <xts:string id="AGS_TASK_STATE_CEASED"/>
  168. </out:attribute>
  169. </gif>
  170. <gif state="new" name="icon_new.gif">
  171. <out:attribute name="stateInfo">
  172. <xts:string id="AGS_TASK_STATE_NEW"/>
  173. </out:attribute>
  174. </gif>
  175. <gif state="none" name="icon_empty.gif">
  176. <out:attribute name="stateInfo">
  177. <xts:string id="AGS_TASK_STATE_NONE"/>
  178. </out:attribute>
  179. </gif>
  180. <gif state="ongoingceased" name="icon_ongoing_ceased.gif">
  181. <out:attribute name="stateInfo">
  182. <xts:string id="AGS_TASK_STATE_ONGOING_CEASED"/>
  183. </out:attribute>
  184. </gif>
  185. <gif state="ongoingnew" name="icon_new_ongoing.gif">
  186. <out:attribute name="stateInfo">
  187. <xts:string id="AGS_TASK_STATE_NEW_ONGOING"/>
  188. </out:attribute>
  189. </gif>
  190. <gif state="ongoingnone" name="icon_ongoing_empty.gif">
  191. <out:attribute name="stateInfo">
  192. <xts:string id="AGS_TASK_STATE_ONGOING_NONE"/>
  193. </out:attribute>
  194. </gif>
  195. <gif state="ongoingceasednew" name="icon_new_ongoing_ceased.gif">
  196. <out:attribute name="stateInfo">
  197. <xts:string id="AGS_TASK_STATE_NEW_ONGOING_CEASED"/>
  198. </out:attribute>
  199. </gif>
  200. <gif state="ongoingceasednone" name="icon_ongoing_ceased_empty.gif">
  201. <out:attribute name="stateInfo">
  202. <xts:string id="AGS_TASK_STATE_ONGOING_CEASED_NONE"/>
  203. </out:attribute>
  204. </gif>
  205. <gif state="ongoingnewnone" name="icon_new_ongoing_empty.gif">
  206. <out:attribute name="stateInfo">
  207. <xts:string id="AGS_TASK_STATE_NEW_ONGOING_NONE"/>
  208. </out:attribute>
  209. </gif>
  210. <gif state="ongoingceasednewnone" name="icon_new_ongoing_ceased_empty.gif">
  211. <out:attribute name="stateInfo">
  212. <xts:string id="AGS_TASK_STATE_NEW_ONGOING_CEASED_NONE"/>
  213. </out:attribute>
  214. </gif>
  215. <gif state="ceasednew" name="icon_new_ceased.gif">
  216. <out:attribute name="stateInfo">
  217. <xts:string id="AGS_TASK_STATE_NEW_CEASED"/>
  218. </out:attribute>
  219. </gif>
  220. <gif state="ceasednone" name="icon_ceased_empty.gif">
  221. <out:attribute name="stateInfo">
  222. <xts:string id="AGS_TASK_STATE_CEASED_NONE"/>
  223. </out:attribute>
  224. </gif>
  225. <gif state="ceasednewnone" name="icon_new_ceased_empty.gif">
  226. <out:attribute name="stateInfo">
  227. <xts:string id="AGS_TASK_STATE_NEW_CEASED_NONE"/>
  228. </out:attribute>
  229. </gif>
  230. <gif state="newnone" name="icon_new_empty.gif">
  231. <out:attribute name="stateInfo">
  232. <xts:string id="AGS_TASK_STATE_NEW_NONE"/>
  233. </out:attribute>
  234. </gif>
  235. <gif state="ceasedcondition" name="icon_ceased_condition.gif">
  236. <out:attribute name="stateInfo">
  237. <string id="AGS_TASK_STATE_CEASED_CONDITION"/>
  238. </out:attribute>
  239. </gif>
  240. <gif state="ceasednonecondition" name="icon_ceased_empty_condition.gif">
  241. <out:attribute name="stateInfo">
  242. <string id="AGS_TASK_STATE_CEASED_EMPTY_CONDITION"/>
  243. </out:attribute>
  244. </gif>
  245. <gif state="ceasednewcondition" name="icon_new_ceased_condition.gif">
  246. <out:attribute name="stateInfo">
  247. <string id="AGS_TASK_STATE_NEW_CEASED_CONDITION"/>
  248. </out:attribute>
  249. </gif>
  250. <gif state="ceasednewnonecondition" name="icon_new_ceased_empty_condition.gif">
  251. <out:attribute name="stateInfo">
  252. <string id="AGS_TASK_STATE_NEW_CEASED_EMPTY_CONDITION"/>
  253. </out:attribute>
  254. </gif>
  255. <gif state="newcondition" name="icon_new_condition.gif">
  256. <out:attribute name="stateInfo">
  257. <string id="AGS_TASK_STATE_NEW_CONDITION"/>
  258. </out:attribute>
  259. </gif>
  260. <gif state="newnonecondition" name="icon_new_empty_condition.gif">
  261. <out:attribute name="stateInfo">
  262. <string id="AGS_TASK_STATE_NEW_EMPTY_CONDITION"/>
  263. </out:attribute>
  264. </gif>
  265. <gif state="ongoingceasednewcondition" name="icon_new_ongoing_ceased_condition.gif">
  266. <out:attribute name="stateInfo">
  267. <string id="AGS_TASK_STATE_NEW_ONGOING_CEASED_CONDITION"/>
  268. </out:attribute>
  269. </gif>
  270. <gif state="ongoingceasednewnonecondition" name="icon_new_ongoing_ceased_empty_condition.gif">
  271. <out:attribute name="stateInfo">
  272. <string id="AGS_TASK_STATE_NEW_ONGOING_CEASED_EMPTY_CONDITION"/>
  273. </out:attribute>
  274. </gif>
  275. <gif state="ongoingnewcondition" name="icon_new_ongoing_condition.gif">
  276. <out:attribute name="stateInfo">
  277. <string id="AGS_TASK_STATE_NEW_ONGOING_CONDITION"/>
  278. </out:attribute>
  279. </gif>
  280. <gif state="ongoingnewnonecondition" name="icon_new_ongoing_empty_condition.gif">
  281. <out:attribute name="stateInfo">
  282. <string id="AGS_TASK_STATE_NEW_ONGOING_EMPTY_CONDITION"/>
  283. </out:attribute>
  284. </gif>
  285. <gif state="ongoingceasedcondition" name="icon_ongoing_ceased_condition.gif">
  286. <out:attribute name="stateInfo">
  287. <string id="AGS_TASK_STATE_ONGOING_CEASED_CONDITION"/>
  288. </out:attribute>
  289. </gif>
  290. <gif state="ongoingceasednonecondition" name="icon_ongoing_ceased_empty_condition.gif">
  291. <out:attribute name="stateInfo">
  292. <string id="AGS_TASK_STATE_ONGOING_CEASED_EMPTY_CONDITION"/>
  293. </out:attribute>
  294. </gif>
  295. <gif state="ongoingcondition" name="icon_ongoing_condition.gif">
  296. <out:attribute name="stateInfo">
  297. <string id="AGS_TASK_STATE_ONGOING_CONDITION"/>
  298. </out:attribute>
  299. </gif>
  300. <gif state="ongoingnonecondition" name="icon_ongoing_empty_condition.gif">
  301. <out:attribute name="stateInfo">
  302. <string id="AGS_TASK_STATE_ONGOING_EMPTY_CONDITION"/>
  303. </out:attribute>
  304. </gif>
  305. <gif state="runonfailure" name="icon_failed.gif">
  306. <out:attribute name="stateInfo">
  307. <string id="AGS_TASK_STATE_RUN_ON_FAILURE"/>
  308. </out:attribute>
  309. </gif>
  310. </out:variable>
  311. <out:variable name="state">
  312. <out:choose>
  313. <out:when test="$suppression-node/following-sibling::node()[local-name()='runCondition'] != 'runOnFailure' or $suppression-node/preceding-sibling::node()[local-name()='runCondition'] != 'runOnFailure'">
  314. <out:if test="$suppression-node/param[@name='Filter_changed' or @name='Filter_unchanged']">
  315. <out:text>ongoing</out:text>
  316. </out:if>
  317. <out:if test="$suppression-node/param[@name='Filter_deleted']">
  318. <out:text>ceased</out:text>
  319. </out:if>
  320. <out:if test="$suppression-node/param[@name='Filter_new']">
  321. <out:text>new</out:text>
  322. </out:if>
  323. <out:if test="$suppression-node/param[@name='Filter_nil']">
  324. <out:text>none</out:text>
  325. </out:if>
  326. <out:if test="$suppression-node/following-sibling::node()[local-name()='taskLevelFilter'] != '' or $suppression-node/preceding-sibling::node()[local-name()='taskLevelFilter'] != ''">
  327. <out:text>condition</out:text>
  328. </out:if>
  329. </out:when>
  330. <out:when test="$suppression-node/following-sibling::node()[local-name()='runCondition'] = 'runOnFailure' or $suppression-node/preceding-sibling::node()[local-name()='runCondition'] = 'runOnFailure'">
  331. <out:text>runonfailure</out:text>
  332. </out:when>
  333. </out:choose>
  334. </out:variable>
  335. <out:variable name="selected_gif" select="$gif_data/gif[@state=$state]"/>
  336. <out:choose>
  337. <out:when test="$selected_gif">
  338. <out:attribute name="src">
  339. <out:value-of select="concat('../ags/images/summary/', $selected_gif/@name)"/>
  340. </out:attribute>
  341. </out:when>
  342. <out:otherwise>
  343. <out:attribute name="src">../ags/images/spacer.gif</out:attribute>
  344. </out:otherwise>
  345. </out:choose>
  346. </out:template>
  347. </xsl:template>
  348. <!-- +++++++++++++++++++++++
  349. outputs a script that when called converts agent blob to js object
  350. +++++++++++++++++++++++++++++-->
  351. <doc:template type="script">
  352. <doc:name>agentDefinition</doc:name>
  353. <doc:desc>This writes a java script that will load in the page containing all the params of the agent definition and its actions</doc:desc>
  354. <doc:attr>
  355. <doc:attr-name>agent-path</doc:attr-name>
  356. <doc:attr-desc>this points to wherever the actions of the agent definition are found in the input dom something like "/root/agent_definition/items/item"</doc:attr-desc>
  357. </doc:attr>
  358. </doc:template>
  359. <xsl:template match="agsad:agentDefinition">
  360. <script type="text/javascript">
  361. <out:variable name="agent-path" select="{@agent-path}"/>
  362. <out:variable name="event-key">
  363. <out:value-of select="{concat(@agent-path, '/summaryEventKey')}"/>
  364. </out:variable>
  365. <xsl:variable name="text-area" select="@text-area"/>
  366. function loadAgentActions() {
  367. var cf = parent.getConfigFrame();
  368. var agent_action = "";
  369. parent.setAgentDefinition(new parent.AgentDefinition());
  370. <!--
  371. //window.alert("loading agents with event key : <out:value-of select="$event-key"/> and text-area: <xsl:value-of select="$text-area"/> agent path: <out:value-of select="$agent-path"/>" );
  372. -->
  373. parent.getAgentDefinition().summaryEventKey = new parent.NonDuplicationItems();
  374. <out:if test="$event-key and $event-key != ''">
  375. parent.getAgentDefinition().setSummaryEventKeyValueFromPortalStyleTopics("<out:value-of select="xtsext:urlencode($event-key)"/>");
  376. //alert(parent.getAgentDefinition().getSummaryEventKeyValueWithPortalStyleTopics());
  377. //alert(parent.getAgentDefinition().summaryEventKey.toString());
  378. </out:if>
  379. <out:for-each select="$agent-path/items/item">
  380. <out:variable name="name" select="./name"/>
  381. <out:variable name="id" select="./id"/>
  382. <out:variable name="displayDetails">
  383. <out:call-template name="displayDetails">
  384. <out:with-param name="type"><out:value-of select="./type"/></out:with-param>
  385. </out:call-template>
  386. </out:variable>
  387. <out:variable name="taskLevelFilter" select="./taskLevelFilter"/>
  388. <out:variable name="runCondition" select="./runCondition"/>
  389. agent_action = new parent.ActionDefinition("<out:value-of select="xtsext:javascriptencode(string($name))"/>", "<out:value-of select="$id"/>", "<out:value-of select="xtsext:javascriptencode(string($displayDetails/text))"/>", "<out:value-of select="$displayDetails/image"/>","<out:value-of select="xtsext:javascriptencode(string($taskLevelFilter))"/>","<out:value-of select="xtsext:javascriptencode(string($runCondition))"/>");
  390. <out:for-each select="./suppression/param">
  391. <out:variable name="param_name" select="@name"/>
  392. <out:variable name="param_value" select="text()"/>
  393. <out:variable name="corrected_param_value" select="xtsext:urlencode($param_value)"/>
  394. agent_action.addPortalStyleParam('<out:value-of select="$param_name"/>', '<out:value-of select="$corrected_param_value"/>');
  395. </out:for-each>
  396. <out:if test="$runCondition != 'runOnFailure' ">
  397. //set the defaults if there are no params set
  398. addDefaultFilterValues(agent_action);
  399. </out:if>
  400. parent.getAgentDefinition().addAction(agent_action);
  401. </out:for-each>
  402. }
  403. </script>
  404. </xsl:template>
  405. <!--+++++++++++++++++++++++ js validation methods containing localised messages
  406. +++++++++++++++++++++++-->
  407. <doc:template type="script">
  408. <doc:name>AgentValidation</doc:name>
  409. <doc:desc>This writes a java script that will validate the current agent and do appropriate warnings</doc:desc>
  410. </doc:template>
  411. <xsl:template match="agsad:AgentValidation">
  412. </xsl:template>
  413. <!--+++++++++++++++++++++++
  414. decode agent blobs
  415. +++++++++++++++++++++++-->
  416. <doc:template type="interpret">
  417. <doc:name>decodeAgentDefinition</doc:name>
  418. <doc:desc>This expands out to a set of xts that will extract the agent definition blob and from its env param </doc:desc>
  419. <doc:attr>
  420. <doc:attr-name>destination</doc:attr-name>
  421. <doc:attr-desc>this points to wherever the agent should go</doc:attr-desc>
  422. </doc:attr>
  423. <doc:notes>this must be used within an xts:sequence element</doc:notes>
  424. </doc:template>
  425. <xsl:template match="agsad:decodeAgentDefinition">
  426. <xsl:variable name="destination">
  427. <xsl:choose>
  428. <xsl:when test="@destination">
  429. <xsl:value-of select="@destination"/>
  430. </xsl:when>
  431. <xsl:otherwise>
  432. <xsl:text>/root</xsl:text>
  433. </xsl:otherwise>
  434. </xsl:choose>
  435. </xsl:variable>
  436. <xsl:variable name="clean">
  437. <xsl:choose>
  438. <xsl:when test="@clean">
  439. <xsl:value-of select="@clean"/>
  440. </xsl:when>
  441. <xsl:otherwise>
  442. <xsl:text>false</xsl:text>
  443. </xsl:otherwise>
  444. </xsl:choose>
  445. </xsl:variable>
  446. <out:choose>
  447. <out:when test="/root/env/param[@name = 'agent_definition_blob']">
  448. <xts:append select="{$destination}">
  449. <out:value-of select="xtsext:web64decode(xtsext:cafaction('sign_unwrap_settemplatename_decodeagentdefinition_settemplateid_agentdefinition001', string( /root/env/param[@name = 'agent_definition_blob'] )),true() )" disable-output-escaping="yes"/>
  450. </xts:append>
  451. <out:if test="'{$clean}' = 'true'">
  452. <!-- get rid of the blob for the time being-->
  453. <xts:delete select="/root/env/param[@name = 'agent_definition_blob']"/>
  454. </out:if>
  455. </out:when>
  456. <out:otherwise>
  457. <xts:append select="{$destination}">
  458. <out:element name="agent_definition">
  459. <deletedItems>
  460. </deletedItems>
  461. <items>
  462. </items>
  463. </out:element>
  464. </xts:append>
  465. </out:otherwise>
  466. </out:choose>
  467. </xsl:template>
  468. <!--+++++++++++++++++++++++
  469. display condition logic
  470. +++++++++++++++++++++++-->
  471. <doc:template type="interpret">
  472. <doc:name>conditionDisplayLogic</doc:name>
  473. <doc:desc>This expands out to a template that converts the agent condition to a display form </doc:desc>
  474. <doc:notes>the resulting template takes a param p1, which is the conditiont</doc:notes>
  475. </doc:template>
  476. <xsl:template match="agsad:conditionDisplayLogic">
  477. <!-- The summary of the condition only shows the actual agent item names,
  478. and not their path or notation, regardless of what is shown in the condition field.
  479. For example, if the condition is [Trakker].[Bug].[Product] = 'PowerPlay' and
  480. [Trakker].[Bug].[Status] = 'Open', Product = 'PowerPlay' and Status = 'Open'
  481. is displayed in the Condition area.
  482. -->
  483. <out:template name="conditionDisplayLogic">
  484. <out:param name="p1"/>
  485. <!-- split the string -->
  486. <out:variable name="before" select="substring-before($p1,'[')"/>
  487. <out:variable name="after" select="substring-after($p1,'[')"/>
  488. <!-- what to do ??? -->
  489. <out:choose>
  490. <!-- 1) we don't have that character present - this could be the case
  491. if character is at the end but in that case we still can't go further -->
  492. <out:when test="not($after)">
  493. <out:value-of select="$p1"/>
  494. </out:when>
  495. <!-- 2) we have the character and it's in the middle -->
  496. <out:when test="$after">
  497. <!-- output what came before an then start parsing -->
  498. <out:value-of select="$before"/>
  499. <out:call-template name="parseRefObj">
  500. <out:with-param name="p2" select="$after"/>
  501. </out:call-template>
  502. </out:when>
  503. </out:choose>
  504. </out:template>
  505. <out:template name="parseRefObj">
  506. <out:param name="p2"/>
  507. <out:variable name="before" select="substring-before($p2,']')"/>
  508. <out:variable name="after" select="substring-after($p2,']')"/>
  509. <!-- what to do -->
  510. <out:choose>
  511. <!-- we found a start but no end - leave things alone -->
  512. <out:when test="not($before) and not($after)">
  513. <out:value-of select="'['"/>
  514. <out:value-of select="$p2"/>
  515. </out:when>
  516. <!-- not an immediate end - may have a name -->
  517. <out:when test="$after">
  518. <out:choose>
  519. <out:when test="starts-with($after,'.[')">
  520. <!-- we're not at the end - need to go on -->
  521. <out:call-template name="conditionDisplayLogic">
  522. <out:with-param name="p1" select="substring-after($after, '.')"/>
  523. </out:call-template>
  524. </out:when>
  525. <out:otherwise>
  526. <out:value-of select="$before"/>
  527. <out:call-template name="conditionDisplayLogic">
  528. <out:with-param name="p1" select="$after"/>
  529. </out:call-template>
  530. </out:otherwise>
  531. </out:choose>
  532. </out:when>
  533. <out:when test="$before and not($after)">
  534. <!-- end tag is right at the end so use it -->
  535. <out:value-of select="$before"/>
  536. </out:when>
  537. </out:choose>
  538. </out:template>
  539. </xsl:template>
  540. <!--+++++++++++++++++++++++
  541. Encode agent blob
  542. +++++++++++++++++++++++-->
  543. <doc:template type="interpret">
  544. <doc:name>encodeAgentDefinition</doc:name>
  545. <doc:desc>This expands out to a set of xts that will encode the agent definition blob to its env param </doc:desc>
  546. <doc:attr>
  547. <doc:attr-name>source</doc:attr-name>
  548. <doc:attr-desc>this points to wherever the agent is</doc:attr-desc>
  549. </doc:attr>
  550. <doc:attr>
  551. <doc:attr-name>name</doc:attr-name>
  552. <doc:attr-desc>this is an optional tag name for the agent definition</doc:attr-desc>
  553. </doc:attr>
  554. <doc:notes>this must be used within an xts:sequence element</doc:notes>
  555. </doc:template>
  556. <xsl:template match="agsad:encodeAgentDefinition">
  557. <xsl:variable name="name">
  558. <xsl:choose>
  559. <xsl:when test="@name">
  560. <xsl:value-of select="@name"/>
  561. </xsl:when>
  562. <xsl:otherwise>
  563. <xsl:text>agent_definition</xsl:text>
  564. </xsl:otherwise>
  565. </xsl:choose>
  566. </xsl:variable>
  567. <xsl:variable name="source">
  568. <xsl:choose>
  569. <xsl:when test="@source">
  570. <xsl:value-of select="@source"/>
  571. </xsl:when>
  572. <xsl:otherwise>
  573. <xsl:text>/root</xsl:text>
  574. </xsl:otherwise>
  575. </xsl:choose>
  576. </xsl:variable>
  577. <xsl:variable name="clean">
  578. <xsl:choose>
  579. <xsl:when test="@clean">
  580. <xsl:value-of select="@clean"/>
  581. </xsl:when>
  582. <xsl:otherwise>
  583. <xsl:text>true</xsl:text>
  584. </xsl:otherwise>
  585. </xsl:choose>
  586. </xsl:variable>
  587. <out:variable name="markup">
  588. <out:call-template name="serialize-xml">
  589. <out:with-param name="node-set" select="{$source}/{$name}"/>
  590. </out:call-template>
  591. </out:variable>
  592. <xts:append select="/root/env">
  593. <param name="agent_definition_blob">
  594. <out:value-of select="xtsext:cafaction( concat('sign_wrap_setpassportid_', $passport, '_settemplatename_encodeagentdefinition_settemplateid_agentdefinition002'), xtsext:web64encode( string( $markup ), true()))"/>
  595. </param>
  596. </xts:append>
  597. <out:if test="'{$clean}' = 'true'">
  598. <xts:delete select="{$source}/{$name}"/>
  599. </out:if>
  600. </xsl:template>
  601. <!--+++++++++++++++++++++++
  602. Merge agent blobs
  603. +++++++++++++++++++++++-->
  604. <doc:template type="interpret">
  605. <doc:name>mergeAgentDefinition</doc:name>
  606. <doc:desc>This expands out to a set of xts that will extract the agent definition blob and from its env param and take a modified or partial agent_definition
  607. and add to and overwrite any common parts
  608. The target for the merge is always /root/agent_definition, but the tree to merge over can be specified by over
  609. </doc:desc>
  610. <doc:attr>
  611. <doc:attr-name>over</doc:attr-name>
  612. <doc:attr-desc>this points to wherever the ad to merged over is.... the agent_definition node by name</doc:attr-desc>
  613. </doc:attr>
  614. <doc:notes>this must be used within an xts:sequence element</doc:notes>
  615. </doc:template>
  616. <xsl:template match="agsad:mergeAgentDefinition">
  617. <xsl:variable name="under">
  618. <!-- hard set to the standard location -->
  619. <xsl:text>/root/agent_definition</xsl:text>
  620. </xsl:variable>
  621. <xsl:variable name="over">
  622. <xsl:choose>
  623. <xsl:when test="@over">
  624. <xsl:value-of select="@over"/>
  625. </xsl:when>
  626. <xsl:otherwise>
  627. <xsl:text>/root/agent_definition</xsl:text>
  628. </xsl:otherwise>
  629. </xsl:choose>
  630. </xsl:variable>
  631. <!-- merge the over tree to the temp location -->
  632. <out:if test="{$over}/summaryEventKey">
  633. <out:choose>
  634. <out:when test="{$under}/summaryEventKey">
  635. <xts:replace select="{$under}/summaryEventKey">
  636. <out:copy-of select="{$over}/summaryEventKey"/>
  637. </xts:replace>
  638. </out:when>
  639. <out:otherwise>
  640. <xts:append select="{$under}">
  641. <out:copy-of select="{$over}/summaryEventKey"/>
  642. </xts:append>
  643. </out:otherwise>
  644. </out:choose>
  645. </out:if>
  646. <out:if test="{$over}/condition">
  647. <out:choose>
  648. <out:when test="{$under}/condition">
  649. <xts:replace select="{$under}/condition">
  650. <out:copy-of select="{$over}/condition"/>
  651. </xts:replace>
  652. </out:when>
  653. <out:otherwise>
  654. <xts:append select="{$under}">
  655. <out:copy-of select="{$over}/condition"/>
  656. </xts:append>
  657. </out:otherwise>
  658. </out:choose>
  659. </out:if>
  660. <out:if test="{$over}/schedule">
  661. <out:choose>
  662. <out:when test="{$under}/schedule">
  663. <xts:replace select="{$under}/schedule">
  664. <out:copy-of select="{$over}/schedule"/>
  665. </xts:replace>
  666. </out:when>
  667. <out:otherwise>
  668. <xts:append select="{$under}">
  669. <out:copy-of select="{$over}/schedule"/>
  670. </xts:append>
  671. </out:otherwise>
  672. </out:choose>
  673. </out:if>
  674. <!-- merge the over keeping the suppression state -->
  675. <out:if test="{$over}/suppressionSet">
  676. <out:choose>
  677. <out:when test="{$under}/suppressionSet">
  678. <xts:replace select="{$under}/suppressionSet">
  679. <out:copy-of select="{$over}/suppressionSet"/>
  680. </xts:replace>
  681. </out:when>
  682. <out:otherwise>
  683. <xts:append select="{$under}">
  684. <out:copy-of select="{$over}/suppressionSet"/>
  685. </xts:append>
  686. </out:otherwise>
  687. </out:choose>
  688. </out:if>
  689. <out:if test="{$over}/items">
  690. <!-- remove all suppression blocks if they exist-->
  691. <xts:delete select="{$under}/items/item/suppression" mandatory="false"/>
  692. <!-- remove all taskLevelFilters blocks if they exist-->
  693. <xts:delete select="{$under}/items/item/taskLevelFilter" mandatory="false"/>
  694. <xts:delete select="{$under}/items/item/runCondition" mandatory="false"/>
  695. <out:for-each select="{$over}/items/item">
  696. <out:variable name="myid" select="./id"/>
  697. <!--out:message>over id = <out:value-of select="$myid"/> under ids = <out:value-of select="{$under}/items/item/id"/></out:message-->
  698. <xts:append select="{$under}/items/item[./id = '{{./id}}']">
  699. <out:copy-of select="./suppression"/>
  700. </xts:append>
  701. <xts:append select="{$under}/items/item[./id = '{{./id}}']">
  702. <out:copy-of select="./taskLevelFilter"/>
  703. </xts:append>
  704. <xts:append select="{$under}/items/item[./id = '{{./id}}']">
  705. <out:copy-of select="./runCondition"/>
  706. </xts:append>
  707. </out:for-each>
  708. </out:if>
  709. <!-- clean up -->
  710. <xts:delete select="{$over}"/>
  711. </xsl:template>
  712. <xsl:template match="agsad:displayDetails">
  713. <out:template name="displayDetails">
  714. <out:param name="type"/>
  715. <out:variable name="path">
  716. <out:value-of select="'../ags/images/tasks/'"/>
  717. </out:variable>
  718. <out:choose>
  719. <out:when test="$type = 'job'"><text><xts:string id="AGS_JOB_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_job.gif'"/></image></out:when>
  720. <out:when test="$type = 'message'"><text><xts:string id="AGS_EMAIL_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_email.gif'"/></image></out:when>
  721. <out:when test="$type = 'agent'"><text><xts:string id="AGS_AGENT_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_agent.gif'"/></image></out:when>
  722. <out:when test="$type = 'sql'"><text><xts:string id="AGS_SQL_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_SQL_writeback.gif'"/></image></out:when>
  723. <out:when test="$type = 'report'"><text><xts:string id="AGS_REPORT_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_report.gif'"/></image></out:when>
  724. <out:when test="$type = 'web'"><text><xts:string id="AGS_WEB_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_web_service.gif'"/></image></out:when>
  725. <out:when test="$type = 'import'"><text><xts:string id="AGS_IMPORT_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_import.gif'"/></image></out:when>
  726. <out:when test="$type = 'export'"><text><xts:string id="AGS_EXPORT_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_export.gif'"/></image></out:when>
  727. <out:when test="$type = 'content'"><text><xts:string id="AGS_CONTENT_MANAGEMENT_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_content_maintenance.gif'"/></image></out:when>
  728. <out:when test="$type = 'url' or $type = 'news'"><text><xts:string id="AGS_URL_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_newsitem.gif'"/></image></out:when>
  729. <out:when test="$type = 'metric'"><text><xts:string id="AGS_METRICS_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_metrics_maintenance.gif'"/></image></out:when>
  730. <out:when test="$type = 'index'"><text><xts:string id="AGS_INDEX_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_index_update.gif'"/></image></out:when>
  731. <out:when test="$type = 'planningMacro'"><text><xts:string id="AGS_PLANNING_MACRO_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_planning_macro.gif'"/></image></out:when>
  732. <out:when test="$type = 'migration'"><text><xts:string id="AGS_MIGRATION_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_new_migration.gif'"/></image></out:when>
  733. <out:when test="$type = 'approval'"><text><xts:string id="AGS_APPROVAL_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_approval.gif'"/></image></out:when>
  734. <out:when test="$type = 'notification'"><text><xts:string id="AGS_NOTIFICATION_TASK"/></text><image><out:value-of select="$path"/><out:value-of select="'action_notification.gif'"/></image></out:when>
  735. <out:otherwise><text/><image><out:value-of select="'../../images/spacer.gif'"/></image></out:otherwise>
  736. </out:choose>
  737. </out:template>
  738. </xsl:template>
  739. <!--
  740. * - This next template is required to copy all other elements into the result.
  741. -->
  742. <xsl:template match="*">
  743. <xsl:copy>
  744. <xsl:copy-of select="@*"/>
  745. <xsl:apply-templates/>
  746. </xsl:copy>
  747. </xsl:template>
  748. </xsl:stylesheet>