Category Name in Velocity Report instead of Path?

Charlotte Dyck
Charlotte Dyck Member Posts: 10

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
------------------------------

Comments

  • lynnebanki
    lynnebanki Member, Jama Connect Interchange™ (JCI) Posts: 7
    edited September 2023

    #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
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
  • Iwan Kutter
    Iwan Kutter Member Posts: 26
    edited September 2023

    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
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-14-2023 19:46
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

    #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
    ------------------------------

    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
    Iwan Kutter
    Requirement Engineer
    Bernina International
  • lynnebanki
    lynnebanki Member, Jama Connect Interchange™ (JCI) Posts: 7
    edited September 2023

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

    ------------------------------
    lynne banki
    Blue Origin
    Kent WA
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-15-2023 08:11
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------

    Original Message:
    Sent: 09-14-2023 19:46
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

    #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

    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
  • Iwan Kutter
    Iwan Kutter Member Posts: 26
    edited September 2023

    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
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-15-2023 10:44
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

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

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

    Original Message:
    Sent: 09-15-2023 08:11
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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

    Original Message:
    Sent: 09-14-2023 19:46
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

    #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

    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
    Iwan Kutter
    Requirement Engineer
    Bernina International
  • Charlotte Dyck
    Charlotte Dyck Member Posts: 10
    edited September 2023

    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
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-19-2023 02:30
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------

    Original Message:
    Sent: 09-15-2023 10:44
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

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

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

    Original Message:
    Sent: 09-15-2023 08:11
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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

    Original Message:
    Sent: 09-14-2023 19:46
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

    #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

    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
  • Alessandro Valli
    Alessandro Valli Member, Data Exchange, Jama Connect Interchange™ (JCI) Posts: 789
    edited October 2023

    I have found out you can access these properties:

    • categoryPathName
    • categoryPathId
    • itemVersionIdApplied
    • pathIdsToRoot
    ------------------------------
    Alessandro
    Systems Engineer
    SICK AG
    ------------------------------
    -------------------------------------------
    Original Message:
    Sent: 09-25-2023 10:01
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------

    Original Message:
    Sent: 09-19-2023 02:30
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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

    Original Message:
    Sent: 09-15-2023 10:44
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

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

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

    Original Message:
    Sent: 09-15-2023 08:11
    From: Iwan Kutter
    Subject: Category Name in Velocity Report instead of Path?

    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

    Original Message:
    Sent: 09-14-2023 19:46
    From: lynne banki
    Subject: Category Name in Velocity Report instead of Path?

    #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

    Original Message:
    Sent: 09-14-2023 14:49
    From: Charlotte Dyck
    Subject: Category Name in Velocity Report instead of Path?

    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
    ------------------------------
    Alessandro
    Systems Engineer
    SICK AG