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

share this page via facebook share this page via LinkedIn share this page via Twitter share this page via Google+ share this page via email More sharing services

Installation

Unzip file com.polarion.alm.extension.vcontext_<version>.zip into <Polarion Installation Folder>/polarion/plugins/ and restart Polarion.

 

Included Generic Velocity Tools

Context Varaible Name Description
$dateTool ComparisonDateTool A tool with the abillity 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 over values 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 arbitary 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


Exaples 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.4

Updated October 2020

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.4 - October 2020
Categories
Products
Price Free
2452 Downloads
Community Supported Extension This extension is not supported by Siemens PLM.
Requirements Polarion 2010 and newer
Last tested with Polarion 20 R2 (3.20.2)