Adapt Text

The Imixs WorkflowService provides the method ‘adaptText(text, document)’ which can be called when a text fragment should be adapted to a custom format or custom values.

The Imixs WorkflowService includes two custom text adapters:

  • TextItemValueAdapter
  • TextPropertyAdapter

Adapting Item Values

The TextItemValueAdapter adapts a text fragment containing the XML tag itemvalue with the item values of a given Document. This adapter is useful if a string constant need to be updated with values from the current workitem.

For example, a BPMN mail message text can be adapted with information from the current workitem.

The invoice was generated by <itemvalue>namcreator</itemvalue> 
at <itemvalue format="EEE, MMM d, yyyy">$created</itemvalue>

This message text-block will be automatically adapted with the workitem properties ‘namcreator’ and ‘$created’ into:

The invoice was generated by Ralph 
at Wed, Jul 4, 2010

Format multi-value Items

If a item contains a multi-value list, all the values can be separated by a character sequence defined by the tag ‘separator’. For example the following message text based on an item ‘_parts’ with the values {“pants”, “shirt”, “jacket”} and a separator ‘, ’:

The following item has been ordered: <itemvalue separator=", ">_parts</itemvalue>

will be replaced with:

The following item has been ordered: pants, shirt, jacket

Note: If no separator is defined, only the first value will be returned.

To get the last value of a multi-value list the tag ‘position’ can be set to ‘last’

The last order item was: <itemvalue position="last">_parts</itemvalue>

This example extract the last value of the mulit-value item ‘_parts’.

Format date/number values by locale

To format a date or number value into a language specific format the tags ‘format’ and ‘locale’ can be used. The following example shows how to format a date value into the German date format:

 The Date in german format is: <itemvalue format="EEEE, d. MMMM yyyy" locale="de_DE">datdate</itemvalue>.

Adapting Property Values

The TextPropertyAdapter adapts a text fragment adapts text blocks with values stored in the file. A static message text will be automatically replaced with the values ​​from the file if the tag “propertyvalue” is used.

Please use the following Link to open the Application: 

The values from the imixs.prperties file are accessed by the PropertyService.

Custom Text Adapters

A application can extend the AdaptText method by implementing a service with the CDI Observer pattern. The CDI Event TextEvent is send to registered observers. See the following example:

public class CustomTextAdapter {
    // Observer method for CDI TextEvetns
    public void onEvent(@Observes TextEvent event) {
       String text = event.getText();
       text+=" Hello World";

Adapt a TestList

A custom adapter can also adapt a text into a text list. For example a Custom Adapter can compute a list of values based on a text pattern. The custom adapter can set the result test list with the method ‘setTextList()’. This feature is for example used from the AccessPlugin method mergeRoles. The method expects that the adapter provide a list with roles.