If the
standard change log functionality in the script language is not enough to suit
your needs, it is possible to create your own change logs. One scenario where
this is applicable is when you want to compare one version to another version
that is a few versions back, as in the below picture.
Meta model
In this
example we use the following structure as the base. Below is an example
of a generated report containing one section for the Function Specification: Audio Control with four sub sections. Every sub section lists one of the
possible states for the Function Requirements. Either they are unchanged,
added, removed or updated (new version):
This is the XML Definition:
<Report>
<Parameters>
<!-- This parameter lets you choose the version you want to compare the current version to.-->
<Parameter name="prevFunction" caption="Previous Function Version">
<Values>
<!--Get all versions. Order by version from highest to lowest.-->
<ForEach select="AllVersions.OrderByDescending(VersionNumber)">
<AddValue/>
</ForEach>
</Values>
</Parameter>
</Parameters>
<!-- Create a set of the Items in the previous version. We focus on requirements in this example.-->
<Variable name="previousFunctionSpecReqs" select="$prevFunction/5IRS/ITSR" as="Items"/>
<Section title="#{Name}">
<Choose>
<!-- Check if the versions are the same, then nothing has changed. -->
<When test=". in $prevFunction">
<Text>Nothing has changed. It is the same version</Text>
</When>
<Otherwise>
<!-- If not the same versions, check for changes.-->
<Section title="Summary of changes">
<!-- Collect all the current requirements for future comparison -->
<Variable name="functionSpecRequirements" select="/5IRS/ITSR" as="Items"/>
<!-- For comparing versions we use functions since they are easy to reuse with Copy + Paste between reports, Grids etc. -->
<Section title="Unchanged requirements">
<ForEach select="GetUnchangedItems($previousFunctionSpecReqs, $functionSpecRequirements)">
<Text>#{Name}</Text>
</ForEach>
</Section>
<Section title="Added requirements">
<ForEach select="GetAddedItems($previousFunctionSpecReqs, $functionSpecRequirements)">
<Text>#{Name}</Text>
</ForEach>
</Section>
<Section title="Removed requirements">
<ForEach select="GetRemovedItems($previousFunctionSpecReqs, $functionSpecRequirements)">
<Text>#{Name}</Text>
</ForEach>
</Section>
<Section title="Updated requirements">
<ForEach select="GetUpdatedItems($previousFunctionSpecReqs, $functionSpecRequirements)">
<Text>#{Name}</Text>
</ForEach>
</Section>
</Section>
</Otherwise>
</Choose>
</Section>
<!-- Returns the unchanged Items in newVersionItems when comparing to prevVersionItems. -->
<Function name="GetUnchangedItems" as="Items">
<Parameter name="prevVersionItems" as="Items"/>
<Parameter name="newVersionItems" as="Items"/>
<!-- Unchanged Items are available in the set of Items from the previous version. -->
<Value select="$newVersionItems[. in $prevVersionItems]"/>
</Function>
<!-- Returns the added Items in newVersionItems when comparing to prevVersionItems. -->
<Function name="GetAddedItems" as="Items">
<Parameter name="prevVersionItems" as="Items"/>
<Parameter name="newVersionItems" as="Items"/>
<!-- Added Items have AncestorHandles that are not part of the Items in the previous version. -->
<Value select="$newVersionItems[not AncestorHandle in $prevVersionItems.Select(AncestorHandle)]"/>
</Function>
<!-- Returns the removed Items in prevVersionItems when comparing to newVersionItems. -->
<Function name="GetRemovedItems" as="Items">
<Parameter name="prevVersionItems" as="Items"/>
<Parameter name="newVersionItems" as="Items"/>
<!-- Removed Items are available in the set of Items from the previous version but not in the new one. -->
<!-- Use AncestorHandle when filtering to not get false positives on new versions. -->
<Value select="$prevVersionItems[not AncestorHandle in $newVersionItems.Select(AncestorHandle)]"/>
</Function>
<!-- Returns the updated Items in newVersionItems when comparing to prevVersionItems. -->
<Function name="GetUpdatedItems" as="Items">
<Parameter name="prevVersionItems" as="Items"/>
<Parameter name="newVersionItems" as="Items"/>
<!-- Updated requirements have AncestorHandles that are available in the set of Items from the previous version, but Handles that are not. -->
<Value select="$newVersionItems[not . in $prevVersionItems and AncestorHandle in $prevVersionItems.Select(AncestorHandle)]"/>
</Function>
</Report>
Fredrik Dannberg
If the standard change log functionality in the script language is not enough to suit your needs, it is possible to create your own change logs. One scenario where this is applicable is when you want to compare one version to another version that is a few versions back, as in the below picture.
Meta model
In this example we use the following structure as the base. Below is an example of a generated report containing one section for the Function Specification: Audio Control with four sub sections. Every sub section lists one of the possible states for the Function Requirements. Either they are unchanged, added, removed or updated (new version):
This is the XML Definition: