Velocity - How to generate report of items in a Baseline

Dimitrios Pananakis
Dimitrios Pananakis Member, Jama Validation Kit (JVK) + Functional Safety Kit (FSK) Posts: 57

Hello all,

I am trying to write a Velocity script that generates a document containing the baseline item name, version and description (of all non-Test Case items), along with their upstream relationships (for the baseline version)

So far I've managed to print all the information but I cannot retrieve the upstream relationships for the baselined version.
It also prints the items in creation order rather than the visible order...

#set($docDao = $documentSource)
#set($verDao = $documentSource)
#set($baseline = $baselineSource.getBaseLine($mathTool.abs($myBaseline)))
#set($baselineId = $baseline.getId())
#set($documentIds = $baselineSource.getDocumentIds($baselineId))
#set($baseDocNodes = [] )
#foreach ($documentId in $documentIds)
    #set($dN1=$docDao.getDocumentNodeForBaseLine( 5, $documentId, $baselineId))
    #if($dN1.scopeId == 5)
        #if( $baseDocNodes.add($dN1))
        #end
    #end
#end
#foreach($dn in $baseDocNodes)
    #set($baseDoc = $docDao.getDocument($dn.refId))
    #set($baseVer = $verDao.getVersionByDocumentId($baseDoc.id))

    Dn.refId = $dn.refId

    <h1>$baseDoc.documentKey - $baseDoc.name - v$baseVer.versionNumber</h1>
    ## Upstream Items
    #set($upstreamIds = $docDao.getUpstreamDocumentIds($dn.refId))

    #if($upstreamIds.size() > 0)
        <p>Upstream Items</p>
        <ul>
        #foreach($upstreamId in $upstreamIds)
            #set($upstreamDoc = $docDao.getDocument($upstreamId))
            <li> $upstreamDoc.documentKey - $upstreamDoc.name
        #end
        </ul>
    #end
    #if($baseDoc.description)
        <p>Description</p>
        <p>$baseDoc.description</p>
    #end
#end

Does anyone have an idea how to improve this? 

Warm regards

Dimitrios

Comments

  • [Deleted User]
    [Deleted User] Posts: 152
    edited March 2023

    Hi Dimitrios, 

    So that we can take a deeper look into this, can you open a Support ticket and reference this thread in the ticket description (as well as your version/type of Jama and any other pertinent info) on it, please

    Thank you!

    ------------------------------
    Carly Rossi // she/her
    Community Manager // Jama Software
    Portland, OR
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 03-08-2023 00:40
    From: Dimitrios Pananakis
    Subject: Velocity - How to generate report of items in a Baseline

    Hello all,

    I am trying to write a Velocity script that generates a document containing the baseline item name, version and description (of all non-Test Case items), along with their upstream relationships (for the baseline version)

    So far I've managed to print all the information but I cannot retrieve the upstream relationships for the baselined version.
    It also prints the items in creation order rather than the visible order...

    #set($docDao = $documentSource)
    #set($verDao = $documentSource)
    #set($baseline = $baselineSource.getBaseLine($mathTool.abs($myBaseline)))
    #set($baselineId = $baseline.getId())
    #set($documentIds = $baselineSource.getDocumentIds($baselineId))
    #set($baseDocNodes = [] )
    #foreach ($documentId in $documentIds)
    &nbsp; &nbsp; #set($dN1=$docDao.getDocumentNodeForBaseLine( 5, $documentId, $baselineId))
    &nbsp; &nbsp; #if($dN1.scopeId == 5)
    &nbsp; &nbsp; &nbsp; &nbsp; #if( $baseDocNodes.add($dN1))
    &nbsp; &nbsp; &nbsp; &nbsp; #end
    &nbsp; &nbsp; #end
    #end
    #foreach($dn in $baseDocNodes)
    &nbsp; &nbsp; #set($baseDoc = $docDao.getDocument($dn.refId))
    &nbsp; &nbsp; #set($baseVer = $verDao.getVersionByDocumentId($baseDoc.id))

    &nbsp; &nbsp; Dn.refId = $dn.refId

    &nbsp; &nbsp; <h1>$baseDoc.documentKey - $baseDoc.name - v$baseVer.versionNumber</h1>
    &nbsp; &nbsp; ## Upstream Items
    &nbsp; &nbsp; #set($upstreamIds = $docDao.getUpstreamDocumentIds($dn.refId))

    &nbsp; &nbsp; #if($upstreamIds.size() > 0)
    &nbsp; &nbsp; &nbsp; &nbsp; <p>Upstream Items</p>
    &nbsp; &nbsp; &nbsp; &nbsp; <ul>
    &nbsp; &nbsp; &nbsp; &nbsp; #foreach($upstreamId in $upstreamIds)
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #set($upstreamDoc = $docDao.getDocument($upstreamId))
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li> $upstreamDoc.documentKey - $upstreamDoc.name
    &nbsp; &nbsp; &nbsp; &nbsp; #end
    &nbsp; &nbsp; &nbsp; &nbsp; </ul>
    &nbsp; &nbsp; #end
    &nbsp; &nbsp; #if($baseDoc.description)
    &nbsp; &nbsp; &nbsp; &nbsp; <p>Description</p>
    &nbsp; &nbsp; &nbsp; &nbsp; <p>$baseDoc.description</p>
    &nbsp; &nbsp; #end
    #end

    Does anyone have an idea how to improve this? 

    Warm regards

    Dimitrios