Velocity reporting engine update in Jama 8.10

By Kristina posted 11-29-2016 17:45

  

We updated the Velocity reporting engine to version 1.7 in Jama 8.10. With this change we have identified one potential issue so far. Custom Velocity reports using macros will need to be modified to function correctly. In Jama 8.8 and prior, it was possible to pass a reference to a variable to a macro and #set that variable inside the macro. (See section 1.7-beta1 regarding VELOCITY-681 on Apache's release notes for technical details.)

Many custom reports created by Jama's Services team will need to be updated, as will any reports created independently that make use of macros in this manner. We recommend updating the report templates before upgrading to Jama 8.10. It is not possible to provide a universal fix, however, you can find an example documented below that should assist you in updating your templates. If you are unable to get your Jama-created reports working after making the changes and upgrading to Jama 8.10, please submit a support ticket.

Here is an example of a macro that does not work because it's #setting a variable passed in from outside the macro's scope:

#########################################################################################################################       
##      Helper: Sorts the documents in order of the tree (global sort order)                                          ###
##      @sDocs - array: array of documents                                                                            ###
##      @return - array: array of sorted documents                                                                    ###
#########################################################################################################################
#macro( sortDocs4 $sDocs $return )  
    Running sortDocs4
#set( $nodes = []) #set( $sortedDocs = []) #set( $return = []) ## Can't use #set with variables from outside the macro in 8.10 #foreach( $d in $sDocs) #if( $d.document.id) #set( $node = $documentNodeDao.getDocumentNode(5, $d.document.id )) #else #set( $node = $documentNodeDao.getDocumentNode(5, $d.id )) #end #if( $nodes.add($node)) #end #end #foreach( $node in $sortTool.sort($nodes,"globalSortOrder")) #set( $document = $docDao.getDocument( $node.refId ) ) #if( $sortedDocs.add( $document)) #end #end ## This SET line is also the problem - no longer works in Jama 8.10 #set( $return = $sortedDocs) #end #######################################################################################################################

 

Here is an example of a macro that will work with Velocity 1.7:

#########################################################################################################################       
##      Helper: Sorts the documents in order of the tree (global sort order)                                          ###
##      @sDocs - array: array of documents                                                                            ###
##      @return - array: array of sorted documents                                                                    ###
#########################################################################################################################
#macro( sortDocs4f $sDocs $return )  
    #set( $nodes = [])
    #set( $sortDocs = [])
    $return.clear()                 ## Clear list instead of #set-ing to an empty list

    #foreach( $d in $sDocs)
        #if( $d.document.id)
            #set( $node = $documentNodeDao.getDocumentNode(5, $d.document.id ))
        #else
            #set( $node = $documentNodeDao.getDocumentNode(5, $d.id ))
        #end
        #if( $nodes.add($node)) #end
    #end 

    #foreach( $node in $sortTool.sort($nodes,"globalSortOrder"))
        #set( $document = $docDao.getDocument( $node.refId ) )
        #if( $return.add( $document)) #end          ## Add items directly to $return
    #end    
#end
####################################################################################################################### 



 



#velocity
0 comments
421 views