Community
Thumb_1-wiki-scripting

Wiki Scripting Tools

 Adds the Velocity tools and Polarion specific objects to the Velocity Context of active Wiki and LiveReport pages to extend scripting possibilities.

Description

Installation

  • Download the extension from this page and extract it
  • Extract file com.polarion.alm.extension.vcontext_<version>.zip into the Polarion extensions folder
- ​a complete path should look like this:
<Polarion>\polarion\extensions\yourFolder\eclipse\plugins\com.polarion.alm.extension.vcontext_<version>\
- working example:
C:\Polarion\polarion\extensions\myPlugins\eclipse\plugins\com.polarion.alm.extension.vcontext_1.3.5\
  • ​Shutdown Polarion
  • Remove folders (you will not lose any data, all content of these folders will be regenerated):
    <Polarion>\data\workspace\.config
    <Polarion>\data\workspace\.metadata
  • Start Polarion

 

To verify the correct deployment of the extension, you can check the main Polarion log (search for "vcontext") - it should contain these two lines:

2022-05-04 21:36:28,878 [main] INFO  com.polarion.platform.hivemind.EclipseHiveMindPlatform  -   [20] - com.polarion.alm.extension.vcontext
2022-05-04 21:36:28,881 [main] INFO  com.polarion.platform.hivemind.EclipseHiveMindPlatform  - Add bundle com.polarion.alm.extension.vcontext to HiveMind

 

Included Generic Velocity Tools

Context Variable Name Description
$dateTool ComparisonDateTool A tool with the ability to manipulate, format, compare and describe the periods between dates.
$mathTool MathTool A tool for performing floating-point math.
$numberTool NumberTool A tool for formatting numbers.
$renderTool RenderTool A tool to evaluate and render arbitrary strings of VTL (Velocity Template Language).
$escapeTool EscapeTool A tool to help with common escaping needs in Velocity templates.
$resouceTool ResourceTool A tool to simplify access to ResourceBundles for internationalization or other dynamic content needs.
$alternatorTool AlternatorTool Utility class for easily alternating overvalues in a list and tool for easy creation of Alternators in templates.
$valueParser ValueParser A tool to retrieve and parse String values pulled from a map. This provides the basis for the ParameterParser in VelocityView.
$listTool ListTool A tool to help when working with arrays or Lists. This tool transparently handles both the same way.
$sortTool SortTool A tool that allows a user to sort a collection (or array, iterator, etc) on any arbitrary set of properties exposed by the objects contained within the collection.
$iteratorTool IteratorTool A convenience tool to use with #foreach loops. It wraps a list to let the designer specify a condition to terminate the loop and reuse the same list in different loops.

 

Polarion Tool, XML Tool, and Fact Base Factory

  • The Polarion Tool is stored in the context variable $polarionTool
    • This is a custom service designed as a part of this extension - polarionTool
  • The XML Tool in the variable $xmlTool
    • com.polarion.alm.extension.vcontext.XMLTool
  • The Fact Base Repository in the variable $factBaseRepository
    • com.polarion.qcentre.factbase.serialization.FactBaseRepository
  • ​The Object Factory in variable $objectFactory
    • ​com.polarion.alm.extension.vcontext.ObjectFactory


Examples of use follow:

Read a file from the repository and parse it as DOM

#set($repoService = $polarionTool.getRepositoryService())
#set($connection = $repoService.getReadOnlyConnection($polarionTool.getLocation()))
#set($path = "/.polarion/announcements/announcements.rss")
#set($input = $connection.getContent($polarionTool.getLocation().getLocation($path)))
#set($doc = $xmlTool.getDocumentBuilderFactory().newDocumentBuilder().parse($input))
RSS contains $doc.getDocumentElement().getElementsByTagName("item").length items.

Load a metric value

#set($fbRepository = $polarionTool.getFactBaseRepository())
#set($fbId = "workitems-data")
#set($prjId = "drivepilot")
#set($workItemsData  = $fbRepository.loadFactBase($fbId, $prjId, null, false))
#set($factId = "RESOLVED-UNRESOLVED.UNRESOLVED")
Unresolved Work Items: $workItemsData.findElement($factId).getValue()

Access a custom enumeration

#set($enumType = $polarionTool.getTypeFactory().getEnumType("status"))
#set($contextId = $trackerService.getTrackerProject("drivepilot").getContextId())
#set($dataService = $trackerService.getDataService())
#set($statusEnum = $dataService.getEnumerationForEnumId($enumType, $contextId))
$statusEnum.getAllOptions()

Load the modules of a project

#set($project = $trackerService.getTrackerProject("drivepilot"))
#set($moduleManager = $trackerService.getModuleManager())
$moduleManager.getModules($project, $polarionTool.getLocation())

 

Useful Tips

The source code of the extension is part of the distribution package - see com.polarion.alm.extension.vcontext_<version>/src/.

This extension was originally created to support Wiki Pages only - support for the Rich Pages was added later and there are some dissimilarities.

  • The ObjectFactory is part of the OOTB context of the Rich Pages as $objectFactory
    • It is realized using a different class - com.polarion.alm.shared.api.utils.velocity.ObjectFactory
    • The offered functionality is very similar - see Polarion SDK for details
  • Some of the Generic Velocity Tools are offered OOTB but under different variables
    • $mathTool as $math
    • $escapeTool as $escape
    • ...
    • You can use either variant, it always references the same class
  • The VelocityContext (org.apache.velocity.VelocityContext) is not available on Rich Pages
    • Methods of RenderTool requiring this object cannot, therefore, be used

 

What's New in Version 1.3.5

Updated August 2022

Changes for 1.3.5
- Adjusted for Log4j incompatibility issues
- Added support for Polarion 22 R1 (3.22.1)

Changes for 1.3.4
- Extension adjusted to work with all supported Polarion versions including Polarion 20 R2
- Updated Extension description - added section with Useful Tips

Changes for 1.3.3
- Added support for velocity context of LiveReport Pages

Information

Vendor Siemens PLM
Published Version 1.3.5 - August 2022
Categories
Products
Price Free
4026 Downloads
Community Supported Extension This extension is not supported by Siemens PLM.
Requirements Polarion 2010 and newer
Last tested with Polarion 2404 (3.24.4)