Nothing Special   »   [go: up one dir, main page]

Hands-On With GEL Scripting, Xog and The Rest Api

Download as pdf or txt
Download as pdf or txt
You are on page 1of 166

Hands-on with GEL Scripting,

XOG and the REST API


Introductions
Let us introduce ourselves
Clarity PPM Consultant

KRITIKA RANA
2015 - TODAY

About Me
Clarity PPM Consultant with experience in
implementations, support & Integrating PPM with other
systems.

Active Community Member & CA Community Champion.


Agenda
Hands-on with GEL Scripting, XOG and the REST API
Session Agenda
Hands-on with GEL Scripting, XOG and the REST API

XOG
REST APIs
GEL Scripting
XOG
Hands-on with GEL Scripting, XOG and the REST API
XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
What is XOG?
Basic Information

• Supported Web service interface


• Available since Niku6.0 onwards
• Exchange information with other applications using
• Extensible Markup Language (XML)
• Simple Object Access Protocol (SOAP)
• Web Services Description Language (WSDL)
Why XOG?
• Uses industry standard Web services
• Supported Mechanism
• Capable of moving Data as well as configuration
• Secure and rights-enabled
• Typically upward compatible, making upgrades easier
• Can be used by any programming language that support SOAP
• Extensively used within Clarity workflows to update data
How XOG Works
Architecture diagram

• Client makes a
SOAP call to
Clarity Server ClientClient Request
Clarity
• Clarity Server Client Clarity
processes the Response
Server
Server
request
• Sends a SOAP
1. Installed Client
response back to 2. Browser XOG Client
the client 3. External Applications
4. Programming
Languages
Sample XOG Requests
Read Request

• Read request
gives us filters to
be used to get
the required
data.
Sample XOG Requests
Write Request

• Write request
provide us
with the
ability to
modify the
data in Clarity.
XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Working with XOG
Multiple ways to use XOG

• Browser XOG
• Command Line XOG
• Using XOG commands
• Using Properties file
• From external applications
• Programming Languages
• GEL, JAVA, C# etc.
Browser XOG
Enabling browser XOG
• Navigate to the file path to
enable browser XOG
[Clarity-Home]\META-INF\xog\wmd
• Take a backup of existing
xog.xml file
• Amend xog.xml as in screen
shot
• Flush the caches using
security.caches or restart
services
• Then try :
http://server/niku/nu#action:xog.client
Browser XOG
Browser Window

• Visible at server URL


http://server/niku/nu#action:xog.client

• XML field for XOG request


• XML Output is the
response from Clarity
Server
Command Line XOG
Download and Install XOG Client

• Packaged within Clarity


• Navigate to
“Administration” menu >
“Client Downloads”
• “Windows Installer” for
Windows OS
• “Cross-Platform Zip” for
Windows or Linux /UNIX
operating systems.
Command Line XOG
Using Command Line Parameters

• Navigate to the
Clarity_home\bin
folder.
• Type the required
XOG command.
• To see the command
usage, issue the
following
command:
• bin\xog -?
Command Line XOG
Using Properties File
• Modify the test.properties
file.
• Location:
Clarity_Home\xog-
unzipped\bin
• Another option is to make
your own .properties file
and store it in the bin
directory.
• At the XOG
prompt(Clarity_home\bin)
issue the following
command
• bin\xog -propertyfile
bin/test.properties
• View the output
Command Line XOG
Sample Properties File
Other ways to use XOG
External Applications and Programming Languages

• Any application that is capable of • Various programming languages can be


making a soap call, can use XOG to used to form a SOAP request to use
interact with Clarity Server. XOG.
• Examples:
• JAVA
• C++
• C#
• Visual Basic
• Perl
• GEL(Mostly Used)

External Applications Programming Languages


XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Limitations
Data Deletion

• Deletion is not possible


• Complete=“true” tags available in some cases, but these are
cumbersome
• OBS Associations,
• Skill Associations,
• Group Assignments,
• Global Rights,
• Instance Rights,
• OBS Rights and Rate Matrices
Limitations
Limited Granularity

• Limited options for granularity


• To XOG-out project team, XOG-out of entire project is needed.
• Similarly, To XOG-in a task, it must be part of a project XOG write request.
Limitations
Performance

• Performance of XOG requests is exponentially affected by data volumes


imported or exported
• Large XOG requests can take hours to process, and very large requests can time-out the XOG
session.
• Although, XOG in newer versions paginates the number of records processed, reducing the
possibility of timing out, but this requires special logic in the code to handle pagination.
XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Best Practices
• Keep XOG requests as small as possible,
• Many smaller requests will usually execute faster than one large request
• XOG-read only what is necessary
• Use Filters while querying data
• Remove unnecessary tags while XOG-write
• XOG is very powerful, Be absolutely sure on what you are updating in the
system.

Make sure to specify an external ID when defining project tasks. This provides a cleaner project XOG,
especially when dealing with assignments.
XML OPEN GATEWAY
Session Outline

01 Introduction
02 Working with XOG
03 Limitations
04 Best Practices
05 Hands On Exercise
Hands on Exercise
Summarize XOG
Let’s take a look back on XOG session

Introduction
What is XOG
Why XOG
How XOG works
Sample XOG Requests
Summarize XOG
Let’s take a look back on XOG session

Working with XOG


Browser XOG
Command Line XOG
Other ways to use XOG
Summarize XOG
Let’s take a look back on XOG session

Limitations
Data Deletion
Limited Granularity
Performance
Summarize XOG
Let’s take a look back on XOG session

Best Practices
Small requests
XOG-read only what is necessary
Remove unnecessary tags
Summarize XOG
Let’s take a look back on XOG session

Introduction Best Practices


What is XOG Small requests
Why XOG XOG-read only what is necessary
How XOG works Remove unnecessary tags
Sample XOG Requests

Working with XOG Limitations


Browser XOG Data Deletion
Command Line XOG Limited Granularity
Other ways to use XOG Performance
REST APIs
Hands-on with GEL Scripting, XOG and the REST API
REST APIs
Session Outline

05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
REST APIs
Session Outline

01 Introduction 05
04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
What is API
Getting Started

• API - Application Programming Interface


• A set of functions and procedures allowing the creation of applications
• There are two types of APIs
• SOAP
• REST
What are Rest APIs
Rest APIs Explained

• Based on representational state transfer (REST) technology, an


architectural style
• Uses HTTP requests to GET, PUT, POST and DELETE data
• REST leverages less bandwidth, more suitable for internet usage.
• Breaks down a transaction to create a series of small modules

The Rest API documentation URL for Clarity can be found in System options → API → API Documentation URL.
Why Rest APIs
What makes the Rest APIs so popular

• Separation between the client and the server


• Visibility, reliability and scalability
• Platform Independent
• Variety of Data formats
• Superior Performance
How REST API Works
Architecture diagram

Client • Client makes a REST


JSON/XML Request call (JSON/XML) to
Server.
• Clarity Server
Methods processes the request.
Delete, put, get, post, patch, http methods • Sends a response back
to the client.
• In Clarity PPM, the
Application Server responses are in JSON
Response format.
Sample REST Requests
GET Request

• GET request is
the read request
for REST
Sample REST Requests
PATCH Request

• PUT and PATCH


requests allow
us to modify
data in Clarity.
REST APIs
Session Outline

05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Working with Rest APIS
Demonstrate Rest APIs
• Rest API URL is : https://lab1.pemari.com/niku/rest/describe/index.html
Working with Rest APIS
Steps

• Authenticate & Connect


• Set headers
• Form and send the request
• Process the Output
STEP ONE Authenticate & Connect
Authenticate the user to send a request
• Sample of Authentication
• The username & password are the same username and password used for Clarity Login.
• URL for the request can be obtained from the Clarity Rest API Documentation.
STEP TWO Set Headers
Setting the type of request

• We can set in the headers the type of request and response


STEP THREE Form and Send the Request
Form the Request

• The REST request in JSON


format.
STEP THREE Form and Send the Request
Send the Request

• The REST request in JSON format.


STEP FOUR Process the Output
Checking the output for further processing

• The Response window shows


the output for the request sent.
REST APIs
Session Outline

05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Limitations
• Stateless APIs increase the latency in request processing times and
bandwidth usage
• The reason is that the client is sending all messages with redundant information.
• Limited options for processing the requests
• Rest APIs use the HTTP methods for processing data.
• Typically, the protocol has a limited number of methods to operate upon the data.
• HTTP combines application-level and transport-level status codes
• e.g., 304 Not Modified and 400 Bad Request are the HTTP codes
• 407 Proxy Authentication Required and 502 Bad Gateway are transport level
status codes
• Broadcom has not made the REST APIs available yet for public
consumption.
REST APIs
Session Outline

05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Best Practices
Clean Request

• Keep requests clean by using Nouns


• For an easy understanding use this structure for every resource
• Use HATEOAS
• Hypermedia As The Engine Of Application State is a principle that hypertext links should be used
to create a better navigation through the API.

REST APIs is planned to be available for customer use from the next release 15.6.1.
Best Practices
Error Handling

• Handle errors with HTTP error codes


• 200 – OK – Everything is working
• 201 – OK – New resource has been created
• 204 – OK – The resource was successfully deleted
• 304 – Not Modified – The client can use cached data
• 400 – Bad Request – The request was invalid or cannot be served.
• 401 – Unauthorized – The request requires an user authentication
• 403 – Forbidden – The server understood the request, but is refusing it or the access is not allowed.
• 404 – Not found – There is no resource behind the URI.
• 422 – Not Processable Entity – Should be used if the server cannot process the entity
Best Practices
Overriding Methods

• Allow overriding HTTP method


• Some proxies support only POST and GET methods. To support a RESTful API with these
limitations, the API needs a way to override the HTTP method.
• Use the custom HTTP Header X-HTTP-Method-Override to override the POST Method.
REST APIs
Session Outline

05
01 Introduction 04
03
02 Working with REST APIs 02
01
03 Limitations
04 Best Practices
05 Hands On Exercise
Hands on Exercise
Practice makes a man perfect
Summarize REST
Let’s take a look back on Rest APIs session

Introduction
What is API
What are Rest APIs
Why Rest APIs
How Rest API Works
Sample Rest Requests
Summarize REST
Let’s take a look back on Rest APIs session

Working with Rest APIs


Authenticate & Connect
Set headers
Form and send the request
Process the Output
Summarize REST
Let’s take a look back on Rest APIs session

Limitations
Latency
Very Few Verbs
Combined Codes are confusing
Unavailability for Public Consumption
Summarize REST
Let’s take a look back on Rest APIs session

Best Practices
Clean Request
Error Handling
Overriding Methods
Summarize REST
Let’s take a look back on Rest APIs session

Introduction
What is API
Best Practices
What are Rest APIs
Clean Request
Why Rest APIs
Error Handling
How Rest API Works
Overriding Methods
Sample Rest Requests

Working with Rest APIs Limitations


Authenticate & Connect Latency
Set headers Very Few Verbs
Form and send the request Combined Codes are confusing
Process the Output Unavailability for Public Consumption
GEL Scripting
Hands-on with GEL Scripting, XOG and the REST API
GEL Scripting
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
GEL Scripting
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
What is GEL
Getting Started
• Generic Execution Language
• Can be used to turn XML into executable code.
• It is based on Jelly, a jakarta.apache.org Commons project.
• extended and embedded into Clarity PPM
• GEL run-time is packaged with XOG in the XOG client
• Additional references and information can be found in the CA Documentation
(Developer Guide) – https://docops.ca.com/ca-ppm/15-6/en
• At the Apache Jelly website at - http://jakarta.apache.org/commons/jelly/index.html
Capabilities of GEL
• GEL can be used in following areas
• Web services
• File system
• JDBC
• FTP
• email
GEL Scripting
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
GEL Script Structure
• A typical GEL script
contains
• Header
• Namespaces
• Body/Code
• Tags
• Footer
GEL Script Structure
Header

• Header contains the


namespaces and the
libraries to be used
in the script.
GEL Script Structure
Namespaces

• Inclusion of the
namespaces for any
library gives GEL the
ability to perform
operations defined in
that library.
• Many libraries are
contained as Clarity
OOTB libraries.
• Core
• GELTagLibrary
GEL Script Structure
Body/Code

• Body includes the queries, XMLs, tags for processing etc.


• Includes the logic to perform certain action using GEL script
GEL Script Structure
Tags

• A GEL script is an
executable XML file
that is built from
qualified elements Regular Tag
bound to Java code
called tags.
• Every opening tag
contains its
corresponding closing
tag except for singular
tags.

Singular Tag
GEL Script Structure
Footer

• Footer marks the end of the GEL Script


XML.

An entire script always resides within the GEL script tag.


GEL Script Structure
Common & Workflow Control Tags

• Tags can be divided into following categories:


• Variables/parameters
• Loops
• Conditionals

Information contained within GEL tags is case sensitive


GEL Script Structure
Variables/Parameters

• <gel:parameter>
• Allows values to be passed
into a GEL script from a
Clarity process.
• Inside the GEL script, a
parameter can be referred
as any other variable using
the ${variablename}
syntax.

The optional attribute secure="true" causes Clarity to hide the actual value in the user interface with
asterisks (*).
GEL Script Structure
Variables/Parameters

• <core:set>
• Used to set basic java
variables.
• ones those do not need to
be extracted from an XML
document.
• Refer to the variable using
the ${variablename}
syntax.
GEL Script Structure
Variables/Parameters

• <gel:set>
• Used when it is necessary to extract the value of the variable from an XML document.
• This tag differs from the <core:set> tag in that it takes a select attribute which in turn
requires an Xpath statement.
• If you are unfamiliar with XPath, think of it as a hierarchy mapping of the XML
document.
GEL Script Structure
Variables/Parameters

• <gel:persist>
• This tag allows you to set
variables with a scope that
extends beyond the
current script.
• There are three scopes:
• Process
• Instance
• Global
GEL Script Structure
Variables/Parameters

• <gel:parse>
• To create an XML document in memory.
• Used to generate an entire XML document, or specific nodes.
GEL Script Structure
Built-In Parameters

• GEL scripts associated with processes have the following parameters


available to them:
• Object Instance ID
• If no object is associated with the process, the ID is -1.
• Else the ${gel_objectInstanceId} parameter contains the object instance ID.
• Process ID
• ${gel_processId} is the process identifier; all instances of a process share this
identifier.
• Process instance ID
• ${gel_processInstanceId} is the process instance identifier; all instances have a
unique value.
GEL Script Structure
Loop Tags

<core:forEach> <gel:forEach>

1. The core for-Each loop is used as a simple programming loop whereas the gel-for-each loop is a
special loop which is used to loop through tags inside a XML document.
2. In gel-For-each loop the select attribute contains the XPATH string as an input, which in-turn helps to
parse the XML document.
GEL Script Structure
Loop Tags

• <core:while>
• Similar to the while loop in other programming languages like JAVA, C, C++
GEL Script Structure
Conditional Tags

• <core:if>
• Similar to the if loop in
other programming
languages like JAVA, C,
C++
• <core:choose>
• Similar to the if-else loop
in other programming
languages like JAVA, C,
C++
GEL Script Structure
Conditional Tags

• <core:switch>
• Similar to the switch statement in other programming languages like JAVA, C, C++
GEL Scripting
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


Various Operations
Connect to DB

• There are two ways to connect to the database


• <gel:setDataSource>
• <sql:setDataSource/>
Database Operations
Connect to DB

• <gel:setDataSource>
• Uses the connection
properties from Clarity
PPM’s properties (set in the
CSA)
• Var attribute is optional.
• If not specified and only one
datasource is set, then all
SQL calls will use that
• If a datasource variable is
set, it is required to
reference it in subsequent
tags.
Database Operations
Connect to DB

• <sql:setDataSource>
• To use any external
connection, by creating an
external connection entry in
the NSA
• Value of dbID is name of the
connection in NSA.
• To use the external database
connection; without having an
entry in NSA
Database Operations
Single Result Query

• Single Result Query


• Given syntax can be
used to extract data
from a query which
returns single row.
Database Operations
Multiple Result Queries

• Multiple Result Query


• Following ways can be used to extract data from multiple result queries

Using Column labels Using Row by Index


Database Operations
Update Via SQL

• Updates should be
done using the
transaction tag.
• This ensures that they
follow the all or none
update.
Database Operations
Binding Variables

• Binding variables help


in:
• code reusability
• prevention of SQL
injection
Database Operations
SQL DOs and DON’Ts

• Try not to set any unnecessary variables.


• Do not insert using SQL.
• Do not update OOTB tables.
• SQL updates are best suited for Custom objects and custom attributes.
• Do update the 'last_updated_date' and 'last_updated_by' columns when updating
audited attributes.
• CDATA tag should be used in all queries to prevent the errors due to (‘<‘, ‘>’)
characters in the query.
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


Logging

• <gel:log> tag is used to add logs in the process and to create the log data
in the log tables.
• Logs prove to be useful in debugging and troubleshooting
• Different levels of logging are:
• Info
• Warn
• Error
Logging

• In recent Clarity releases, an additional log setting has been introduced


to control logging, which can be found at:
<servername>/niku/nu#action:security.loggerConfig

• Its default value after upgrade is set to ‘Error’.


Logging
Different Levels of Logging

• Info

• Warning

• Error
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


JAVA Operations

• Core library defines the JAVA methods that can be used inside GEL.
• Not all the JAVA methods are available inside the library.
JAVA Operations
Basic Methods

• <core:new>
• It is used to instantiate Java classes
JAVA Operations
Basic Methods

• <core:invoke>
• It is used to call a method on an instantiated object
JAVA Operations
Basic Methods

• <core:expr>
• It is used to call a method on an instantiated Java object where the access to the
result of the operation is not required.
JAVA Operations
Basic Methods

• <core:invokeStatic>
• It is used to call a static method of a Java class
JAVA Operations
Usage of JAVA in GEL

• To fill the gaps in functionality which cannot be provided by GELTagLibrary


• E.g., Moving, copying, and deleting files or directories.
• Making file operations more flexible
• To perform any action which cannot be done using GEL libraries
• Better exception handling (covered in later slides)
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


File Operations
Introduction to File Operations

• There are various operations that GEL can perform for handling files
• GEL can open a file
• read the file
• parse out all the nodes and attributes
• write to the file
• It can also perform FTP operations on files.
• Following are not allowed
• It cannot create a directory
• Move files around
• Delete files

JAVA operations can overcome the exceptions for file handling.


File Operations
Read File

• GEL Script code block to read a file


File Operations
Read File

• GEL Script code block to write to a file


File Operations
FTP

• FTPTagLibrary can be used to read or write files on FTP server


• Following tags are available
• ftp:open
• ftp:put
• ftp:get
File Operations
FTP

• Following are the sample FTP read & write code blocks
Read Operation Write Operation
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


Emails
Sending emails

• To send dynamic emails based on specific events.


• There are two tags for email:
• <gel:email> : to send text/html emails
• <email:email> : to send text emails with attachments

Make Sure to choose the right type as per your requirement of content in the email being sent.
File Operations
FTP

• Following are the sample <gel:email> and <email:email> code blocks


<gel:email> <email:email>
GEL Scripting
Various Operations

Database Operations File Operations

Logging Emails

JAVA Operations SOAP & REST in GEL


SOAP & REST in GEL
SOAP & Rest requests in GEL

• SOAP & REST calls can be used to read and write the data in Clarity PPM.
• SOAP calls are generally done by XOG
• REST calls are performed by the REST APIs given by Clarity PPM
SOAP in GEL
Namespaces required for SOAP Call

• In order to use a SOAP call via GEL, we need to import respective


namespaces.
SOAP in GEL
Basic SOAP structure

• Basic soap structure:


SOAP Message : XML Document
• Envelope: (Mandatory) - defines the start and the end of the message.
• SOAP
Header: (Optional) - Contains any optional Envelope of the message
attributes
• Body: (Mandatory) - Contains the XML data comprising the message being sent.

SOAP Body
SOAP in GEL
Steps

• Steps:
SOAP Message : XML Document
• Login & Authenticate
SOAP Envelope
• Form & Send the Request
• Process the output
• Log out

SOAP Body
SOAP in GEL
Login & Authenticate using Session ID

• Code block for obtaining Session ID for authentication


SOAP Message : XML Document

SOAP Envelope

SOAP Body
SOAP in GEL
Form the request

• Code block for forming the request


SOAP Message : XML Document

SOAP Envelope

SOAP Body
SOAP in GEL
Processing the Response

• Code block for processing the output


SOAP Message : XML Document

SOAP Envelope
SOAP in GEL
Logging out

• Code block logging out


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Using REST in GEL

• Rest calls can be made using the GEL scripts as well.


• The steps are as following: SOAP Envelope
• Authenticate
• Connect
• Set headers
• Form the request
• Send the request
• Process the Output
REST in GEL
Authenticate

• GEL Script Code block to Authenticate


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Connect

• GEL Script Code block to connect


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Set Headers

• GEL Script Code block to Set Headers


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Sample Request

• Sample Request for Rest call


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Send the request

• Code block for sending the request


SOAP Message : XML Document

SOAP Envelope
REST in GEL
Process the output

• Code block for processing the


SOAP Message : XML Document
response
SOAP Envelope
REST APIs
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
XML Manipulation
Different ways of Manipulating XML

• XML is at heart of GEL scripting.


• Following are the possible ways to manipulate an XML in Memory.
• Create the complete XML
• Read, Update & Delete a node
• Read & Update an attribute
• Insert smaller XML into Existing XML
• Save & Print the XML
XML Manipulation
Manipulating the Nodes

• Read, Update & Delete a node


• <gel:set> tag is used for xml operations
• Value of a node from XML can be saved in a variable as below:

• Updating Value of a node


XML Manipulation
Manipulating the Nodes

• Delete a Node
XML Manipulation
Manipulating the Attributes

• Read & Update an attribute


• <gel:set> tag is used for xml operations
• Value of an attribute can be saved in a variable as below:

• Updating Value of an attribute


XML Manipulation
Add XMLs to make a big one

• Insert smaller XML into Existing XML


XML Manipulation
Print XML

• Printing the XML


• <gel:expr> tag is used for printing the xml by converting that into string.
• <gel:out> tag is used to print the xml in bg-ca logs
XML Manipulation
Save XML

• Saving the XML


• <gel:serialize> tag is used to save the XML document
REST APIs
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
Exception/Error Handling
Catch & Rectify the Exceptions/Errors

• <core:catch> tag is used


(Replica of try-catch in
JAVA)
• Errors/exceptions can
occur while doing XOG,
SQL query or file related
operations.
• Example of SQL exception
handling
Exception/Error Handling
Catch & Rectify the Exceptions/Errors

• Java tags also support error handling on that specific tag

1. The exception handling of GEL is only meant for handling programming exceptions but if there
is an error in your script which is a parsing error then that will not be caught by Catch tag.
2. For example if you use symbols like ‘>’ ‘<’ or ‘&’ in your script which will cause parsing error ,
then these are these are not caught by catch tag.
REST APIs
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
Limitations
Limited Functionality

• JAVA method access is restricted by Core library


• GEL is dependent on core library.
• If any JAVA method is not included in the core library, that is not accessible
using GEL script.

• Casting a data type to another is not supported in Core library


• Thus, making it impossible to cast data types
Limitations
Sequential Execution and Absence of Customization

• GEL script executes code sequentially.


• The drawback is loss of modularity.
• Customization is not possible
• The code cannot incorporate any custom defined methods, classes etc.

This drawback is well handled by the structure of Processes in Clarity PPM


REST APIs
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
Best Practices
Syntax Related Practices

• GEL is case sensitive. This statement includes variable names.


• All GEL scripts are contained in XML, therefore all XML rules apply to
structure, tags, and special characters.
• Use BETWEEN instead of less than and greater than
Best Practices
Make the code Easy to Understand

• Always make sure to use the proper name spaces and aliases
• Properly indent and format your script, which makes it readable
Best Practices
Avoid Impacting Business

• Avoid sending emails in non-prod environments


• by either disabling mail server or
• masking emails
• Use caution when dealing with large XML files.
• GEL XML tags typically load the entire XML document into memory.
Best Practices
Best coding practices

• When possible, pull server info from properties file on server.


• Dynamic values should be pulled from the gel parameters.
• Make sure you write all your code inside a catch block.
• Put enough comments inside your script, so that the code is readable.
• Avoid excessive logging as it can slow the performance.
• Try to keep the hardcoding as minimum as possible.
REST APIs
Session Outline

01 Introduction
02 GEL Script Structure 08

03 Operations 07
06
04 XML Manipulation
05
05 Exception Handling
04
06 Limitations 03

07 Best Practices 02
01
08 Hands On Exercise
Hands on Exercise
Practice makes a man perfect
Summarize GEL Scripting

Introduction
What is GEL
Capabilities of GEL
Summarize GEL Scripting

• Introduction
What is GEL
Capabilities of GEL

• GEL Script
Structure
• Most Common &
WorkFlow Tags
Summarize GEL Scripting

• Introduction
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations
• GEL Script • Emails
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations
• GEL Script • Emails
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations
• File Operations Exception
• GEL Script • Emails Handling
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations Limitations
• File Operations Exception
• GEL Script • Emails Handling
Structure • SOAP & REST in
• Most Common & GEL
WorkFlow Tags
Summarize GEL Scripting
• XML
• Introduction Manipulation
• Operations
What is GEL
• DB Operations
Capabilities of GEL
• Logging
• JAVA Operations Limitations
• File Operations Exception
• GEL Script • Emails Handling Best
Structure • SOAP & REST in Practices
• Most Common & GEL
WorkFlow Tags
Questions?
Hands-on with GEL Scripting, XOG and the REST API
Thank you for attending
Hands-on with GEL Scripting, XOG and the REST API

Phone
+44 844 736 2500

Email
ppmacademy@pemari.com Let us know how we can
improve!
Don’t forget to fill out the
Website feedback forms!
www.pemari.com
References
Hands-on with GEL Scripting, XOG and the REST API

• https://supportcontent.ca.com/
• http://www.gelscripting.com
• https://www.restapitutorial.com/

You might also like