Aegis ‘Depot’ Activity – String Replace Map

Aegis ‘Depot’ Activity – String Replace Map

The String Replace Map activity takes an input string, and replaces all occurrences of characters/strings based on a map table.

In Europe we are normally more concerned with preserving non English Language characters in pieces of text than removing them, so when i got asked about this it was an interesting reversal of a problem I am familiar with.  Many systems do not support non-English characters so providing a method in a workflow as part of a bigger solution to replace characters with a more suitable alternative for a target system can be of great benefit.

To make this a little more clear, for example we might want to replace all these characters in the first column with those in the second...

À    A
Á    A
    A
à    A
Ä    A
Å    A
Æ   A
Ç    C
È    E
É    E
Ê    E
Ë    E

 

There is a string operations activity which does text replacements, but it only replaces one string per activity - so for example you would have to have a series of those together in order to replace the list above and it could be a very long list.  First replace À with A, next activity replace Á with A etc.  This type of thing is a pet hate of mine in a workflow, a workflow can get bloated very easily by repeating simple operations like these, I normally like to replace the operation with a script or an activity which can do it more efficiently and tidily.

Originally planned just to replace characters, replacing strings was chosen for more flexibility, for example to replace Æ with AE

 

So the activity takes 2 inputs, the string to manipulate and a table containing the map values.  This table is a standard Aegis table, with original values in column 1 and new values in column 2.  The activity ignores column names so they are not important in this scenario.

11

At runtime the inputs looks like this :

22

And the output is the updated text...

A c3 80 LATIN CAPITAL LETTER A WITH GRAVE
A c3 81 LATIN CAPITAL LETTER A WITH ACUTE
A c3 82 LATIN CAPITAL LETTER A WITH CIRCUMFLEX
A c3 83 LATIN CAPITAL LETTER A WITH TILDE
A c3 84 LATIN CAPITAL LETTER A WITH DIAERESIS
A c3 85 LATIN CAPITAL LETTER A WITH RING ABOVE
A c3 86 LATIN CAPITAL LETTER AE
C c3 87 LATIN CAPITAL LETTER C WITH CEDILLA
E c3 88 LATIN CAPITAL LETTER E WITH GRAVE
E c3 89 LATIN CAPITAL LETTER E WITH ACUTE
E c3 8a LATIN CAPITAL LETTER E WITH CIRCUMFLEX
E c3 8b LATIN CAPITAL LETTER E WITH DIAERESIS

 

This is a very big improvement over using multiple activities, but it is specialized to the task at hand.  But how to generate the map table in the first place?  Manually building a table can be really tedious - try it and see - fine for a few rows and columns, but even my example only went to letter E of the alphabet.

A common ways of creating the table is to have a CSV file with the map in it - read the file direct into an Aegis table.  Another method is to run a query against a database which has the mappings defined.  Having the map data available outside of a workflow means that you can add extra mappings without altering the workflow - it just reads in new mappings dynamically.

 

There is of course a bit of a gotcha in this.  The replace is done on a row by row basis starting on the first line of the table.  If you say replace color with colour  on table row 1 and then our to your on table row 2, color will change to colour and then to colyour.   So replacing special characters will be easy but replacing strings will be a challenge requiring a bit of planning of ordering the values in the table!

 

Activity Installation Instructions are here:

https://www.netiq.com/communities/cool-solutions/how-to-install-a-custom-depot-aegis-activity-from-netiq-cool-tools
Attachments

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2015-03-02 20:13
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.