Mercurial > pub > buggler
diff bug-list.xsl @ 11:4eb9fdf4efa9
refactoring, non-working bookings
author | cin |
---|---|
date | Mon, 07 Sep 2015 19:18:21 +0300 |
parents | 14a966369278 |
children | 52b34ea50eff |
line wrap: on
line diff
--- a/bug-list.xsl Mon Sep 07 01:37:11 2015 +0300 +++ b/bug-list.xsl Mon Sep 07 19:18:21 2015 +0300 @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" - extension-element-prefixes="exsl"> + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="exsl date"> <xsl:output method="text" indent="yes" /> <!-- PARAMETERS --> @@ -113,6 +114,8 @@ <xsl:element name="bug"> <xsl:attribute name="id"><xsl:value-of select="$id" /></xsl:attribute> <xsl:attribute name="desc"><xsl:value-of select="summary" /></xsl:attribute> + <xsl:attribute name="estimated"><xsl:value-of + select="number((time/estimated | estimated_time)[1])" /></xsl:attribute> <xsl:if test="$children"> <xsl:attribute name="group"><xsl:value-of select="boolean($children)" /></xsl:attribute> @@ -143,15 +146,12 @@ </xsl:apply-templates> </xsl:template> + <!-- task --> <xsl:template match="bug"> <xsl:param name="indent" select="0" /> <xsl:param name="chargeset" /> - <xsl:variable name="id" select="@id" /> - <xsl:variable name="details" select="$bugs[id = $id]" /> - <xsl:variable name="hasTime" - select="number($details/estimated_time) or number($details/actual_time) or number($details/remaining_time)" /> - <!-- task header --> + <!-- format the task header --> <xsl:call-template name="start-task"> <xsl:with-param name="indent" select="$indent" /> <xsl:with-param name="id"> @@ -162,6 +162,7 @@ <xsl:with-param name="desc" select="@desc" /> </xsl:call-template> + <!-- specify chargeset if present --> <xsl:if test="$chargeset"> <xsl:call-template name="println"> <xsl:with-param name="indent" select="$indent + 1" /> @@ -170,48 +171,12 @@ </xsl:call-template> </xsl:if> - <!-- task details --> - <xsl:choose> - <xsl:when test="@group"> - <!-- DEBUG --> - <xsl:call-template name="comment"> - <xsl:with-param name="indent" select="$indent + 1" /> - <xsl:with-param name="comment" select="'group'" /> - </xsl:call-template> - - - <xsl:apply-templates select="$details/node()" - mode="group-details"> - <xsl:with-param name="indent" select="$indent + 1" /> - </xsl:apply-templates> + <!-- print task contents --> + <xsl:apply-templates select="." mode="task-content"> + <xsl:with-param name="indent" select="$indent + 1" /> + </xsl:apply-templates> - <xsl:if test="$hasTime"> - <xsl:call-template name="start-task"> - <xsl:with-param name="indent" select="$indent + 1" /> - <xsl:with-param name="id" select="'manage'" /> - <xsl:with-param name="desc" select="@desc" /> - </xsl:call-template> - <xsl:apply-templates - select="$details/estimated_time | $details/actual_time | $details/remaining_time | $details/assigned_to" - mode="task-details"> - <xsl:with-param name="indent" select="$indent + 2" /> - <xsl:with-param name="hasTime" select="$hasTime" /> - </xsl:apply-templates> - <xsl:call-template name="end-task"> - <xsl:with-param name="indent" select="$indent + 1" /> - </xsl:call-template> - </xsl:if> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="$details/node()" - mode="task-details"> - <xsl:with-param name="indent" select="$indent + 1" /> - <xsl:with-param name="hasTime" select="$hasTime" /> - </xsl:apply-templates> - </xsl:otherwise> - </xsl:choose> - - <!-- subtasks and dependencies --> + <!-- prints subtasks and dependencies --> <xsl:apply-templates> <xsl:with-param name="indent" select="$indent + 1" /> <xsl:with-param name="referer" select="." /> @@ -222,9 +187,11 @@ </xsl:call-template> </xsl:template> + <!-- dependency --> <xsl:template match="dependency"> - <xsl:param name="indent" /> + <xsl:param name="indent" select="0" /> <xsl:param name="referer" /> + <xsl:call-template name="println"> <xsl:with-param name="indent" select="$indent" /> <xsl:with-param name="text"> @@ -237,40 +204,84 @@ </xsl:call-template> </xsl:template> + <!-- an organizational task with spent/estimated time will contain a generated + task which will contain the information about resource allocation and bookings --> + <xsl:template match="bug[@group][@estimated > 0]" mode="task-content" + priority="3"> + <xsl:param name="indent" select="0" /> + <xsl:variable name="id" select="@id" /> - <xsl:template match="text()" /> + <!-- DEBUG --> + <xsl:call-template name="comment"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="comment" select="'group'" /> + </xsl:call-template> - <!-- TASK ATTRIBUTES --> + <!-- print group details --> + <xsl:apply-templates select="$bugs[id = $id]/node()" + mode="group-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> - <xsl:template match="estimated_time" mode="task-details"> - <xsl:param name="indent" /> - <xsl:if test="number(.)"> - <xsl:call-template name="println"> - <xsl:with-param name="indent" select="$indent" /> - <xsl:with-param name="text" select="concat('effort ', .,'h')" /> - </xsl:call-template> - </xsl:if> + <xsl:variable name="metabug"> + <bug id="{@id}" estimated="{@estimated}" desc="{@desc}" /> + </xsl:variable> + + <!-- write an administrative bug for this group-task --> + <xsl:apply-templates select="exsl:node-set($metabug)/bug[1]"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> + </xsl:template> + + <!-- an organizational task without resource allocations --> + <xsl:template match="bug[@group]" mode="task-content"> + <xsl:param name="indent" select="0" /> + <xsl:variable name="id" select="@id" /> + <xsl:apply-templates select="$bugs[id = $id]/node()" + mode="group-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> </xsl:template> - <xsl:template match="assigned_to" mode="task-details"> - <xsl:param name="indent" /> - <xsl:param name="hasTime" /> - <xsl:if test="$hasTime"> - <xsl:variable name="email" select="string(.)" /> - <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> - <xsl:if test="$resource"> - <xsl:call-template name="println"> - <xsl:with-param name="indent" select="$indent" /> - <xsl:with-param name="text" - select="concat('allocate ', $resource)" /> - </xsl:call-template> - </xsl:if> - </xsl:if> - </xsl:template> - <xsl:template match="text()" mode="task-details"> + <!-- a work task --> + <xsl:template match="bug[@estimated > 0]" mode="task-content"> + <xsl:param name="indent" select="0" /> + <xsl:variable name="id" select="@id" /> + + <!-- DEBUG --> + <xsl:call-template name="comment"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="comment" select="'work'" /> + </xsl:call-template> + + <xsl:apply-templates select="$bugs[id = $id]/node()" + mode="work-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> </xsl:template> - <xsl:template match="assigned_to" mode="group-details"> + <!-- a milestone task --> + <xsl:template match="bug" mode="task-content"> + <xsl:param name="indent" select="0" /> + <xsl:variable name="id" select="@id" /> + + <!-- DEBUG --> + <xsl:call-template name="comment"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="comment" select="'milestone'" /> + </xsl:call-template> + + <xsl:apply-templates select="$bugs[id = $id]/node()" + mode="milestone-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> + </xsl:template> + + <!-- each type of task processed in the corresponding mode MODES: * group-task + * work-task * milestone-task --> + + <!-- group-task --> + <xsl:template match="assigned_to" mode="group-task"> <xsl:param name="indent" /> <xsl:variable name="email" select="string(.)" /> <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> @@ -282,13 +293,104 @@ </xsl:call-template> </xsl:if> </xsl:template> - <xsl:template match="text()" mode="group-details"> + + <xsl:template match="*" mode="group-task"> + <xsl:param name="indent" select="0" /> + <xsl:apply-templates mode="group-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> + </xsl:template> + + <xsl:template match="text()" mode="group-task"> + </xsl:template> + + + <!-- work-task --> + <xsl:template match="assigned_to" mode="work-task"> + <xsl:param name="indent" /> + <xsl:variable name="email" select="string(.)" /> + <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> + <xsl:if test="$resource"> + <xsl:call-template name="println"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="text" select="concat('allocate ', $resource)" /> + </xsl:call-template> + </xsl:if> + </xsl:template> + + <!-- if we have a timereports --> + <xsl:template match="time/estimated[. > 0]" mode="work-task"> + <xsl:param name="indent" /> + <xsl:call-template name="println"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="text" select="concat('effort ', .,'h')" /> + </xsl:call-template> + </xsl:template> + + <!-- if we have an estimated_time --> + <xsl:template match="estimated_time[../time/estimated = 0]" + mode="work-task"> + <xsl:param name="indent" /> + <xsl:call-template name="comment"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="comment" select="'original estimated'" /> + </xsl:call-template> + <xsl:call-template name="println"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="text" select="concat('effort ', .,'h')" /> + </xsl:call-template> + </xsl:template> + + <!-- time reports --> + <xsl:template match="time/report" mode="work-task"> + <xsl:param name="indent" /> + <xsl:variable name="email" select="string(who)" /> + <xsl:variable name="start" select="start" /> + <xsl:variable name="work_time" select="work_time" /> + <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> + <xsl:call-template name="println"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="text" + select="concat('booking ', $resource, ' ', $start, ' +', $work_time,'h { overtime 2 }')" /> + </xsl:call-template> + </xsl:template> + + <xsl:template match="*" mode="work-task"> + <xsl:param name="indent" select="0" /> + <xsl:apply-templates mode="work-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> + </xsl:template> + + <xsl:template match="text()" mode="work-task"> + </xsl:template> + + <!-- milestone-task --> + <xsl:template match="assigned_to" mode="milestone-task"> + <xsl:param name="indent" /> + <xsl:variable name="email" select="string(.)" /> + <xsl:variable name="resource" select="$resources[@email = $email]/@id" /> + <xsl:if test="$resource"> + <xsl:call-template name="println"> + <xsl:with-param name="indent" select="$indent" /> + <xsl:with-param name="text" + select="concat('responsible ', $resource)" /> + </xsl:call-template> + </xsl:if> + </xsl:template> + + <xsl:template match="*" mode="milestone-task"> + <xsl:param name="indent" select="0" /> + <xsl:apply-templates mode="milestone-task"> + <xsl:with-param name="indent" select="$indent" /> + </xsl:apply-templates> + </xsl:template> + + <xsl:template match="text()" mode="milestone-task"> </xsl:template> <!-- PRIMITIVES --> - - <xsl:template name="bug-local-name"> <xsl:param name="id" /> <xsl:value-of select="concat('bug',$id)" />