- Caching of traceability data
- Avoiding of wiki macros to accellerate Wikipage output
- id
- title
- project_id
- icon
- tracedWIs
Wiki Example Code I:
#set($list = $TraceTool.backtrace("type:customerrequirement","type:systemspecification"))
#set($lostChildren = $TraceTool.getUntraced($list).size())
#set($count = $TraceTool.getItemsWithNoChildren($list).size())
#set($AllItems = $list.size())
#info("*$count untraceable* items found of $AllItems items found. *$lostChildren* items are lost children")
<table border="1">
#foreach($wi in $list)
#set($icon = $wi.getProperty("icon"))
#set($title = $wi.getProperty("title"))
#set($$project_id = $wi.getProperty("project_id"))
#set($id = $wi.getId())
<tr>
<td>
## output "untraceable" as title for WIs without matching parents
#if($id != "-1")
<span onmouseout="this.className='wiItem_normal'" onmouseover="this.className='wiItem_active'" class="wiItem_normal">
<a target="_blank" href="/polarion/#/project/$project_id/workitem?id=$id" style="font-size: 11px; color: rgb(0, 0, 0);" class="">
<span title="$title">
<img alt="" src="$icon" style="vertical-align: middle; border: 0px none; margin-right: 2px;"/>
<span style="color: rgb(0, 0, 0);">$id - $title</span>
</span>
</a>
</span>
#else
$title
#end
</td>
<td>
## output all traced WIs
#foreach($twi in $wi.getTracedWIs())
#set($icon = $twi.getProperty("icon"))
#set($title = $twi.getProperty("title"))
#set($project_id = $twi.getProperty("project_id"))
#set($id = $twi.getId())
<span onmouseout="this.className='wiItem_normal'" onmouseover="this.className='wiItem_active'" class="wiItem_normal">
<a target="_blank" href="/polarion/#/project/$project_id/workitem?id=$id" style="font-size: 11px; color: rgb(0, 0, 0);" class="">
<span title="$title">
<img alt="" src="$icon" style="vertical-align: middle; border: 0px none; margin-right: 2px;"/>
<span style="color: rgb(0, 0, 0);">$id - $title</span>
</span>
</a>
</span>
#end
</td>
</tr>
#end
</table>
Extensions Job:
The TraceTool Extension's heart is a Polarion job which will provide the caching of WI:
The Job runs every 5 minutes (configurable) and refreshs the WI-Cache used by the TraceTool Wiki Extension
The XML-snipplet to enables the Caching job:
<job cronExpression="0 0/30 5-22 * * ?" id="TraceTool_updater" name="TraceTool Update Job" scope="system">
<query>project.id:elibrary AND NOT type:heading</query>
</job>
The query parameter limits the Work Items which are indexed for Tracetool.
MultiQuery traces:
You can also use more than two queries for a Traceability Table but with slightly worse performance and more complex wiki rendering. You are also able to ask for other fields than the standard fields:
#set($tableList = $TraceTool.backtrace(["type:userstory AND project.id:$page.space.projectId","type:testcase","type:defect"]))
#set($tableList = $TraceTool.trace(["type:defect AND project.id:$page.space.projectId","type:testcase","type:userstory"]))
#set($wiList = $TraceTool.detailBackTrace(["type:userstory AND project.id:$page.space.projectId","type:testcase","type:defect"],["assignee","status"]))
#set($wiList = $TraceTool.detailTrace(["type:defect AND project.id:$page.space.projectId","type:testcase","type:userstory"]))
Wiki Example Code II:
#macro(renderItem $tableData)
#set($icon = $tableData.getProperty("icon"))
#set($title = $tableData.getProperty("title"))
#set($project_id = $tableData.getProperty("project_id"))
#set($id = $tableData.getId())
#set($status = $tableData.getProperty("status").getId())
#set($assignees = [])
#set($assignees = $tableData.getProperty("assignee"))
#if($assignees.size() != 0)
#set($assignees = $assignees.get(0).getId()) ## just tacking the first assignee for example reasons
#else
#set($assignees = "none")
#end
<span onmouseout="this.className='wiItem_normal'" onmouseover="this.className='wiItem_active'" class="wiItem_normal">
<a target="_blank" href="/polarion/#/project/$project_id/workitem?id=$id" style="font-size:11px; color: rgb(0, 0, 0);" class="">
<span title="{pre}$title{/pre}">
<img alt="" src="$icon" style="vertical-align: middle; border: 0px none; margin-right:2px;"/>
<span style="color: rgb(0, 0, 0);">$id - ($assignees) |$status| {pre}$title{/pre}</span>
</span>
</a>
</span>
#end
#macro(showTableCells $cell $firstInRow $currentLevel $maxLevel)
#if($firstInRow == true)
<tr>
#end
<td rowspan="$cell.getTracedWIs().getTotalLeafCount()"> #renderItem($cell)</td>
#if($cell.getTracedWIs().size() == 0) ## End of traceability path reached?
#if($maxLevel != $currentLevel) ## Yes: put an optional last <td> with colspan to fill up </tr>
#set($spans = $maxLevel - $currentLevel)
<td colspan="$spans"> </td>
#end
</tr>
#set($firstInRow = true)
#else ## No: just change FirstInRow to notify next cell to ommit the <tr>
#set($firstInRow = false)
#end
#foreach($nextCell in $cell.getTracedWIs())
#set($currentLevel = $currentLevel + 1)
#showTableCells($nextCell $firstInRow $currentLevel $maxLevel) ## Recursion into next column
#set($firstInRow = true)
#end
#set($currentLevel = $currentLevel - 1)
#end
#macro(showTraceTableRow $row)
<tr>
#foreach($column in $row)
<td align="center">
<br/>
#foreach($cell in $column)
#set($icon = $cell.getProperty("icon"))
#set($title = $cell.getProperty("title"))
#set($project_id = $cell.getProperty("project_id"))
#set($id = $cell.getId())
<span onmouseout="this.className='wiItem_normal'" onmouseover="this.className='wiItem_active'" class="wiItem_normal">
<a target="_blank" href="/polarion/#/project/$project_id/workitem?id=$id" style="font-size:11px; color: rgb(0, 0, 0);" class="">
<span title="{pre}$title{/pre}">
<img alt="" src="$icon" style="vertical-align: middle; border: 0px none; margin-right:2px;"/>
<span style="color: rgb(0, 0, 0);">$id</span>
</span>
</a>
</span>
#end
</td>
#end
</tr>
#end
TraceTool Demo
Here we show the different approaches to visualize traceability:
You can see back and forward trace in condensed view for briefly checking traceability coverage and a detailed analysis. You can also ask for more WI data, like **assignees**, **status**, etc as demonstrated in detailed Traceanalysis. Both views, condensed and Detailed are showing basically the same data.
Condensed Traceview
Trace
#set($tableList = $TraceTool.backtrace(["type:userstory AND project.id:$page.space.projectId","type:testcase","type:defect"]))
<table border="1">
<tr>
<td align="center"><b>type:userstory</b></td>
<td align="center"><b>type:testcase</b></td>
<td align="center"><b>type:defect</b></td>
</tr>
#foreach($traceRow in $tableList)
#showTraceTableRow($traceRow)
#end
</table>
Impact Trace
#set($tableList = $TraceTool.trace(["type:defect AND project.id:$page.space.projectId","type:testcase","type:userstory"]))
<table border="1">
<tr>
<td align="center"><b>type:defect</b></td>
<td align="center"><b>type:testcase</b></td>
<td align="center"><b>type:userstory</b></td>
</tr>
#foreach($traceRow in $tableList)
#showTraceTableRow($traceRow)
#end
</table>
Detailed Traceanalysis
Detail Trace
#set($wiList = $TraceTool.detailBackTrace(["type:userstory AND project.id:$page.space.projectId","type:testcase","type:defect"],["assignee","status"]))
<table border="1">
<tr>
<td align="center"><b>type:userstory</b></td>
<td align="center"><b>type:testcase</b></td>
<td align="center"><b>type:defect</b></td>
</tr>
#foreach($row in $wiList)
#showTableCells($row true 0 3)
#end
</table>
Detailed Impact Trace(BackTrace)
#set($wiList = $TraceTool.detailTrace(["type:defect AND project.id:$page.space.projectId","type:testcase","type:userstory"]))
<table border="1">
<tr>
<td align="center"><b>type:defect</b></td>
<td align="center"><b>type:testcase</b></td>
<td align="center"><b>type:userstory</b></td>
</tr>
#foreach($row in $wiList)
#showTableCells($row true 0 2)
#end
</table>