Support

 View Only
  • 1.  Category Name in Velocity Report instead of Path?

    Posted 09-14-2023 14:49

    In velocity reports, how do you convert the Category Path from getAllCategoryPathsByDocumentId​(java.lang.Integer documentIds) to the name of the category?

    For tags I used:

    #set( $docTags = $tagDao.getAllTagsByDocumentId($vDoc.document.id))

    ...

    #foreach( $dt in $docTags)
    $dt.tagName

    But the synonymous version below doesn't work and I can't find a method to convert the path (ex. com.jamasoftware.contour.categories.model.CategoryPathInfo@2d06b650) to the readable category name

    #set( $docCategories = $catDao.getAllCategoryPathsByDocumentId($vDoc.document.id))

    ...

    #foreach( $dc in $docCategories)
    $dc.categoryName



    ------------------------------
    Charlotte Dyck
    ON
    ------------------------------


  • 2.  RE: Category Name in Velocity Report instead of Path?

    Posted 09-14-2023 19:46

    #set( $docCategories = $catDao.getAllCategoryPathsByDocumentId($vDoc.document.id)) does not even return a list for me, empty or otherwise, for an item ID that I know has Category Paths associated with it. I realize the shape of the list contents varies between tag and categories. Do you have an example of how to access categories for an item by id correctly and, as Charlotte states above, retrieve their names?



    ------------------------------
    lynne banki
    Blue Origin
    Kent WA
    ------------------------------



  • 3.  RE: Category Name in Velocity Report instead of Path?

    Posted 09-15-2023 08:11

    Hello

    I also spent some time figuring out how to extract the categories. Here is an example of a code snippet that can be used get the categories in an HTML page.  To get only the "category name" out of the "category path", I have used the function Substring:

    <html>
    <head>
      <title>Example Report Categories</title>
    </head>
    #set($docus = $documentSource)
    <table>
    	<thead><tr>
    		<th>ID</th>
    		<th>Category Path</th>
    		<th>Category Name</th>
    	</tr></thead>
    #foreach ($vDoc in $documentList)
    	#set( $doc = $vDoc.document )
    	<tbody>
    	<tr><td>$doc.documentKey</td>
    	#set( $categories = [])
    	#set( $categories = $docus.getAllCategoryPathsByDocumentId($doc.id))
    	<td>
    	#foreach( $cat in $categories)
    		<br>$cat.categoryPathName</br>
    	#end
    	</td><td>
    	#foreach( $cat in $categories)
    		#set( $catPath = $cat.categoryPathName )
    		<br>$catPath.substring($catPath.lastIndexOf("/") + 1)</br>
    	#end
    	</td></tr></tbody>
    #end
    </table>
    </body>
    </html>
    


    ------------------------------
    Iwan Kutter
    Requirement Engineer
    ------------------------------



  • 4.  RE: Category Name in Velocity Report instead of Path?

    Posted 09-15-2023 10:44

    Thank you for the example!
    Is there a version cutoff for access to categories though the Velocity DAOs?



    ------------------------------
    lynne banki
    Blue Origin
    Kent WA
    ------------------------------



  • 5.  RE: Category Name in Velocity Report instead of Path?
    Best Answer

    Posted 09-19-2023 02:30

    Hello,

    I am not sure about the exact difference to DAOs and I'm also no familiar with it. According to my understanding, with the #set($docus = $documentSource) you get the DAO. When there is a report without using the "context", the $documentList is empty. You can get the document IDs like this for e.g. project ID 113:

    #set($docus = $documentSource)
    #set( $docuIds = $docus.getActiveDocumentIdsInProject(113))
    #foreach ($docuId in $docuIds)
    	#set( $categories = [])
    	#set( $categories = $docus.getAllCategoryPathsByDocumentId($docuId))
    	#if( !$categories.isEmpty() ) 
    		<tbody>
    		<tr><td>$docus.getDocument($docuId).documentKey</td><td>
    		#foreach( $cat in $categories)
    			<br>$cat.categoryPathName</br>
    		#end
    		</td>
    	#end
    	</tr></tbody>
    #end

     



    ------------------------------
    Iwan Kutter
    Requirement Engineer
    ------------------------------



  • 6.  RE: Category Name in Velocity Report instead of Path?

    Posted 09-25-2023 10:01

    Using the .categoryPathName was able to convert the path data into the actual category name and is showing up in the report in a readable way!

    Thank you Iwan!



    ------------------------------
    Charlotte Dyck
    ON
    ------------------------------



  • 7.  RE: Category Name in Velocity Report instead of Path?

    Posted 10-26-2023 04:33

    I have found out you can access these properties:

    • categoryPathName
    • categoryPathId
    • itemVersionIdApplied
    • pathIdsToRoot


    ------------------------------
    Alessandro
    Systems Engineer
    SICK AG
    ------------------------------