XSD Property generation in Pega
Pega QUIZ
Pega Certified System Architect Quiz 1
Pega Certified System Architect Quiz 2
Pega Certified System Architect Quiz 3
Pega Certified System Architect Quiz 4
Pega Certified System Architect Quiz 5
Pega Certified System Architect Quiz 6
One Time Processing
For an Application which is already in Production, we come across multiple scenario, where we have to run business logic to already existing work object and cases so that they can work with new updates.
Instead of running multiple OTA's (one time activity) every time for every release. We are gonna generalize few rules and let Pega take care of running the OTA's /
We need data table to store the instance and OTA Processing Activity to run the business logic,
Production Deployment Query
Run the Query and Put the results One below another in Excel sheet and mark duplicates.
The row which are not highlighted are the culprits!!
Use case | Ruleset and count of rules |
---|---|
Query |
|
Use case | Rulename,pzinskey With Op Name to compare the rules migrated |
---|---|
Query |
|
Java syntax in Activity
For a guy like me , who did not do java as curriculum always depends on google for the java code.
This post is going to help me to identify the syntax of certain java code which I have used
Click the button to copy the syntax and paste in the Java beautifier for alignment
https://codebeautify.org/javaviewer
Use case | Add Log message |
---|---|
Syntax |
|
Use case | Add try and catch block |
---|---|
Syntax |
|
Use case | To get current Date and Time |
---|---|
Syntax |
|
Use case | To get current Date and Time |
---|---|
Syntax |
|
Use case | Convert Bigdecimal(input) to date format |
---|---|
Syntax |
|
Use case | To create a Clipboard page object from step page/ Page/ datapage |
---|---|
Syntax |
|
Use case | To create a Clipboard property object from step page/ Page/ datapage |
---|---|
Syntax |
|
Use case | To Loop over PageList / datapage - (D_PageName.pxResults(1).PNAME) |
---|---|
Syntax |
|
Use case | For Loop Logic |
---|---|
Syntax |
|
Java to check the files in server
This post shows me how to check the files and folders in the server where pega is installed.
Since I don't have access to Pega production server directly , I have used Java here to display the list of files and folders in Pega logs.
This will help me to confirm if the file listener files are present in path or not.
try { oLog.infoForced("[FilesInDirectory] try block started "); java.io.File fileContents[] = new java.io.File(Path).listFiles(); if (fileContents != null) { for (int i = 0; i < fileContents.length; i++) { if (fileContents[i].isDirectory()) { oLog.infoForced("[FilesInDirectory] Folder: " + fileContents[i]); } else { oLog.infoForced("[FilesInDirectory] File: " + fileContents[i]); } } } oLog.infoForced("[FilesInDirectory] try block Ended "); } catch (Exception ex) { oLog.error("[FilesInDirectory] catch block expected", ex); }
try {
oLog.infoForced("[FilesInDirectory] try block started ");
java.io.File fileContents[] = new java.io.File(Path).listFiles();
if (fileContents != null) {
for (int i = 0; i < fileContents.length; i++) {
if (fileContents[i].isDirectory()) {
oLog.infoForced("[FilesInDirectory] Folder: " + fileContents[i]);
} else {
oLog.infoForced("[FilesInDirectory] File: " + fileContents[i]);
}
}
}
oLog.infoForced("[FilesInDirectory] try block Ended ");
} catch (Exception ex) {
oLog.error("[FilesInDirectory] catch block expected", ex);
}
Create a New Activity in Pega with parameter "Path" to pass to java step and Paste the above Java Code.
This activity contains only two steps .
1) First to set the Param.Path to Local.Path
2) Run the Java
Since I am running on my Local machine (windows) , I am passing the path as D:\InstallationApps\PRPCPersonalEdition\tomcat . If Its Linux ,we can just pass /opt
Now check the logs for the list of files and folders.
Connect Rest with Clash of clans Part 2
In the Previous Post Part 1, we saw how to get the API key from clash of clans and use it in postman to get the response.
In this Post , we will use the details from postman and create a integration in Pega.
Integration was always a difficult topic for me , there is so many topics around it (authorization, authentication, data model , integration layer ,connection time out, certificate failure) which makes it look like a nightmare. All the terms which developers use for while working integration like Parsing , converting Json/XML , Request DT , Response DT , Mapping makes it more complicated to understand the topic.
I am going to learn one at a time and write a post about it for my future reference here. This Post will help me to understand the basic of integration and how Pega helps in creating the most of the rules required for integration.
Why do we need integration ?
For example : Consider two web applications which is already built in Java and Python. Now if you need data from One application to another which does not understand each other, then Integration is the way to connect to these two systems.
There are two types of rules in Pega which helps in integrating two applications. (another confusing terminology)
Connector - When you need some data , you create a connector to get the data. (Get Data - connector)
Service - when you need to give data , you create a service to give the data.(Give Data - Service)
Which API are gonna be used?
From the list of operations , I have selected two simple operations.
- To get information about all the locations
- To get the information about the player rankings for a specific location (For you to try)
Requirement in Pega :
Create two dropdown , one to fetch the list of location . After selecting location , pass the location to get the list of Player ranking
First lets create the integration rules then create a section to display to location and player list.
Open designer studio and Navigate to Create Rest Integration
There are 4 screens which needs to be completed.
First screen:
Provide the name : COC ("Clash of clans") and End point URL : https://api.clashofclans.com/v1/locations
Since we are using token as authentication type , we don’t need a separate authentication profile instead we can pass the token as header (reference postman).
Second screen: Provide Resource name and select the method you want to use for this integration. (For eg Get Method , Reference from postman)
Third screen: One of the important screen, where our Data model for our integration is determined. Also we can check if our integration works too.
Two options to add the data model :1) Either you can add the REST response from postman 2) Trigger the integration and get the response .
I am going with option 2 , Add a REST response . In the header , Authorization field provide the token copied from postman and click run.
Forth Screen : Another important screen , whether the class structure is defined.
Make sure for Integration layer , Int class is selected as Parent class and the context as Integration ruleset.
Make sure for Data layer , Data class is selected as Parent class and the context as Application ruleset.
If required Preview records and Click create . Please find the list of rules Pega has created below
- Datapage
- Connect Rest
- Class required for Integration
- Property required for integration
- Response Data transform
- Request Data transform
Now Provide the dropdown source as Datapage and check if results are populated.
Food for thought : Similarly , Now you can try to create the next integration ( To get the information about the player rankings for a specific location) to pass the location and get the list of players ranking.
Connect Rest with Clash of clans Part 1
In this Post , We are gonna use API from Clash of Clans and Use Postman to check if API works.
What is clash of clans (COC) ?
Clash of Clans is an online strategy game for mobile. Well if you have no idea how this game is played, in brief, a Clasher has a village and an army. Clashers attack each other’s villages in multiplayer battles, form clans together, participate in wars against other clans, and lead their clans to victory.
How to access the clash of clans API ?
Registration an developer account with Clash of clans
- Go to https://developer.clashofclans.com/#/login
- Register and verify with new email address
- Complete the registration process
Create an API token to access the Clash of clans API
- Login to clash of clans
- Navigate to Account name and Select My account
- Under my account , Create New Key
- Provide Name , Description and for allowed IP Address check the IP address from https://whatismyipaddress.com
- click create key and copy the token to a notepad.
To check the list of API provided by clash of clans
- Go to https://developer.clashofclans.com/#/documentation
- Check the list of operations, we can use from clash of clans API.
From the list of operations , I have selected two simple operations.
- To get information about all the locations
- To get the information about the player rankings for a specific location
In the Authorization tab, select the type as Bearer token and provide the token from notepad.
Click send to check if status is 200 (connected successfully) and the response is returned in JSON format.
Food for thought : In the same way, you can use the other API's from clash of clans and use postman to check if API response is received or not.
In the below post , we will see how pega can use the clash of Clans API and display the results.
https://welearnpega.blogspot.com/2021/01/connect-rest-with-clash-of-clans-part-2.html
OAuth Explanation in simplest way
As I am from a non-computer background, It was really very hard to understand the concept of OAuth . All material online / YouTube which I referred appear to be Greek and Latin to understand the concept .
Finally ,I asked the same to one of my senior who explained me with a very simple concept .I am going to share the same conversation here translated in English.
Junior : Bro , You Do know about this OAuth ? I read online bro but did not understand it completely ?
Senior : Its Easy bro.
Junior : I need to understand from scratch and basics. Can you help?
Senior : Sure bro .
There are important terminology (client , Resource , token, Resource owner) . Once client get the token, client can access the resource of resource owner.
See this is the Definition of OAuth
OAuth is an open standard for access delegation, commonly used as a way for Internet users to grant websites or applications access to their information on other websites but without giving them the passwords
Junior : No no no no no !! Did not understand a word bro!!
Senior : Cool , Let's Consider a scenario here . Have you booked an hotel online . how did you book and access your room in the hotel ?
Junior : I booked the room using andriod app and went to receptionist to show my ID and got the room key.
Senior : Now think of your Scenario
We have a room = Resource
We have a hotel which is owned by Hotel owner =
Resource owner
We have a key which is used to access the hotel
room = token
You are the one who is using the key= client
So In order to use the room , you need a key , In order to get the key you need to show your ID. Once you got the key , you can go out and come in any time without showing the ID again. Right ? Let me put this in computer terms.
Scenario terms |
Computer terms |
If you need to use the room of
the Hotel , you need a Key. Once you get the key , you can access the room any no of times. |
If client
need to use the resource
of the resource owner ,client need a Token. Once client get the
token , client can
access the resource any no
of times. |
Junior :Interesting
bro!! Continue
Senior : Now the same is happening between services/two different applications.
Junior : What! between services.
Senior : Have you seen when you try to log in on some applications or website. They have the option to either SignUp or you can log in using your Google or Facebook account. You see options like “Sign in with Google” or “Sign in with Facebook”
Junior : Yes I have seen this a lot of times
Senior : They all work using concept of OAuth .Let’s understand with an example.
We have online photo editing application ( For eg. Lunapic) and we have file storage application (For eg. Google photos).
Now they are serveral ways you can upload the file to Lunapic.
https://www12.lunapic.com/editor/?action=moreupload
Method 1. Download the file from google drive and Store in File system (Computer) and upload from your file sytem(computer) to Lunapic
Method 2.You can give username and password to lunapic team to take the photos and edit it
Junior : First method looks more secure, Because what if lunapic team takes all my photos.
Senior : Exactly bro. But First method is overkill . Now, what if lunapic ask you permission to access the photo and you only give access to fetch only one photo.
Junior : How does that
happen bro ?
Senior : This happens using OAuth which involves below 4 steps :
Step 1: The Lunapic application will identify the account and will ask google photos to get access to your photos
Note the URL :
Step 2: The google photos service will ask you whether to allow Lunapic application to access your photos.
(It will show you the permissions this
application will have once you allow)
(assuming you say Yes)
Note the URL :
Step 3: The google photos service now hands over a key to the Lunapic called authorization token (Remember using the key to your hotel room)
Note the URL: (It changes in a fraction of second) and the bold highlighted text in URL is token here.
Step 4: Now the
Lunapic can get access to your photos using the access key or token
Junior : So whenever I see the login with facebook and login with google , it's all OAuth concept
Senior : Yes bro! Now tell me terminology involved in this scenario
Junior :
Resource | Photos in Google photos |
Resouce owner | Google photos |
Client | Lunapic |
Key | Authorization token |
Senior :Correct!! Last but not the least. Why the token is called Authorization token ?
OAuth doesn't act as authentication data between
client and service providers – but instead acts as an authorization
Now read the definition
OAuth is
an open standard for access delegation, commonly used as a way for
Internet users to grant websites or applications access to their information on
other websites but without giving them the passwords
Junior : Thanks Bro!! Now I know the basics , Let me check some use case with Pega.
Tracer Viewer
Why I used tracer viewer ?
How to run Pega tracer viewer ?
How to save the tracer and open with tool ?
Open the tracer , run the scenario and simply click on save , you will get the xml file. (I got it mailed from onshore)
Open tracer tool and go to file -> Load Pega tracer file and select the xml file.
What are the other things I can do ?
By using TracerViewer, you can do the following actions:
- View the Tracer data offline after the test is complete.
- Organize the data in a table or in tree views.
- Sort the data, for example, by slowest call.
- Search the Tracer tool output data.
- View Performance tool statistics for each interaction (for 6.2 and later).
- View alerts and SQL statements in the context of where and when they occurred (for 6.2 and later).
- Group traced events by a key, such as a unique SQL statement (for 6.2 and later), stream, activity, or method.