Aurora_Gaimon

CA PPM: Use "HASHMAPS" in your GEL Scripts

Blog Post created by Aurora_Gaimon Employee on Mar 20, 2017

You may heard about "hashmaps", but you don't use the yet. I understand the big headache a gel script can be sometimes and specially when you are learning. But  ... every time you create a script, you become more knowledgeable and better.

 

Why don't you try to code with "hashmaps"? It's advised to reduce the "core:set" usage and use whenever is possible hashmaps.

 

Advantages:

-  It will improve performance due better memory JVM usage.

 

Disadvantages:

- You have to get used to it

 

Sample

This is a sample to show hashmap syntax/structure for GEL scripts:

 

<gel:script xmlns:core="jelly:core"
xmlns:file="jelly:com.niku.union.gel.FileTagLibrary"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:sql="jelly:sql"

xmlns:util="jelly:util">


<gel:setDataSource dbId="niku"/>

 

<sql:query escapeText="false" var="getData">
select id id from inv_investments
</sql:query>

 

<core:new className="java.util.HashMap" var="myHash"/>
<core:forEach items="${getData.rows}" var="row">
<core:invoke on="${myHash}" method="put">
<core:arg value="id"/>
<core:arg value="${row.id}"/>
</core:invoke>
<gel:log level="info"> id hashmap: ${myHash.get('id')}</gel:log>
</core:forEach>

 

</gel:script>

 

 

 

 

Related and insetting link:

Clarity performance  (Page 25)

 

If you need help with GEL scripting, engage CA Services or ask questions in CA Communities.

 

That’s all. Thanks for reading until here. Did you like it? Please, don’t be shy and share it.

Outcomes