Skip navigation
All People > SupratikUBS > Supratik Dutta's Blog > 2018 > December
2018

We often after a release in our project push many gel scripts to a live environment and we need to validate and activate the processes which got released  from the front end.

It at times become a tedious job when the number of such processes are quite a few you need to validate and activate those.

 

A simpler way can be to keep the list of processes in an excel workbook and run a gel script on that to validate and activate the processes one by one.

 

A small snippet to validate and activate a process in CA PPM directly by the use of a Gel Script is as follows:

 

<gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:util="jelly:util" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="jelly:sql" xmlns:xog="http://www.niku.com/xog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<!-- GEL Script
SCRIPT
validate_activate_process.gel


HISTORY
v01 - Supratik Dutta -
-->
<core:catch var="err">
<gel:setDataSource dbId="niku"/>
<gel:parameter var="process_code" default="supratiktest"/>
<sql:query escapeText = "false" var="process_ver_id">
<![CDATA[Select id process_version_id
from bpm_def_process_versions where process_id=(Select id from
bpm_def_processes where process_code=?)]]>
<sql:param value="${process_code}" />
</sql:query>
<!-- get security ID -->
<core:invokeStatic className="com.niku.union.utility.UtilityThreadLocal" method="getSecurityIdentifier" var="utlSecID" />
<!-- get BPM Context -->
<core:invokeStatic className="com.niku.bpm.engine.persistence.BpmContext" method="getContext" var="bpmContext" >
<core:arg type="boolean" value="true"/>
</core:invokeStatic>

<core:invoke method="getConnection" on="${bpmContext}" var="conn"/>
<core:invoke method="getSchemaName" on="${bpmContext}" var="schemaName"/>
<core:invoke method="getVendor" on="${bpmContext}" var="dbVendor"/>
<!-- get Validation Context -->
<core:new className="com.niku.bpm.validator.ValidationContext" var="validationContext">
<core:arg type="com.niku.union.security.SecurityIdentifier" value="${utlSecID}" />
<core:arg type="java.sql.Connection" value="${conn}" />
</core:new>

<core:invoke method="setSchemaName" on="${validationContext}" var="SchemaName">
<core:arg type="java.lang.String" value="${schemaName}" />
</core:invoke>

<core:invoke method="setVendor" on="${validationContext}" var="VendorName">
<core:arg type="com.niku.union.config.properties.types.DbVendorType" value="${dbVendor}" />
</core:invoke>
<!--Pass the Process Version ID which needs to be validated and activated-->
<core:invokeStatic className="com.niku.bpm.defobjects.DefinitionPersistenceUtils" method="getProcess" var="process" >
<core:arg type="long" value="${process_ver_id.rows[0].process_version_id}"/>
<core:arg type="com.niku.bpm.engine.persistence.BpmContext" value="${bpmContext}" />
</core:invokeStatic>
<!--Invoke the Validate process method-->
<core:invoke method="validate" on="${process}" var="processvalidate">
<core:arg type="com.niku.bpm.validator.ValidationContext" value="${validationContext}" />
</core:invoke>
<sql:query escapeText = "false" var="internal_status">
<![CDATA[Select internal_status_code
from bpm_def_process_versions where process_id=(Select id from
bpm_def_processes where process_code=?)]]>
<sql:param value="${process_code}" />
</sql:query>
<core:set var="status_out" value="BPM_PIS_VALIDATED"/>
<core:if test="${status_out.equals(internal_status.rows[0].internal_status_code.toString().toUpperCase().trim())}">
<core:invoke method="activate" on="${process}" var="processactivate">
<core:arg type="com.niku.bpm.validator.ValidationContext" value="${validationContext}" />
</core:invoke>
</core:if>
</core:catch>

</gel:script>

 

Thanks and Regards,

Supratik Dutta

 

Kindly provide your feedback if you find this blog useful.

 

And Happy new year in advance 

Sometimes we require to run a Java Job in CAPPM using a gel script where we can change the parameters of the job on run time.

 

This can be achieved by a small code snippet which runs the XBL Executor in Gel and passes the parameter to the job.

 

The code goes here:

 

<gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope" xmlns:sql="jelly:sql" xmlns:util="jelly:util" xmlns:xog="http://www.niku.com/xog"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<core:catch var="excp">
<gel:parse var="inputDoc">
<data>

<!--job_name you can give any meaningful name and job_definition_id has to be the id of the job you want to run -->
<job job_name="Delete Process Instance-Supratik(Port Sync Java)" job_definition_id="50420" job_definition_type="JOB" recurrence_type="4" whenNow="1" whenRecur="1" />

<!-- Put the bind parameter code from the Job Definition pass the value in the similar format mentioned below-->
<param_process_name value="Portfolio Sync from Java"/>
</data>

 

</gel:parse>

 

<core:new className="com.niku.odf.object.xbl.XBLExecutor" var="xblInstance">
<core:arg value="scheduler/postSchedulerProperties.xbl"/>
<core:arg value="nmc"/>
<core:arg value="${inputDoc}"/>
</core:new> 
<core:invoke method="executeXBL" on="${xblInstance}" var="responseDoc"/>
<gel:log>Response Doc : <gel:expr select="$responseDoc"/> </gel:log>
</core:catch> 
</gel:script>

 

Thanks and Regards,

Supratik

 

Kindly comment if you find it useful.