Question
Fibercop S.p.A.
IT
Last activity: 24 Mar 2017 6:37 EDT
How to get the source code for an Activity
Hi
I'd like to know which are the tables/Classes used for storing the source code for the activity rules. In fact I'd like to implement a new report/activity that allows to export (in excel) the activity's code as well we see it in the Designer Studio.
I've seen that the table could be "PR4_RULE" but I'm not able to find the class. Am I on the right way?
Thanks,
Vincenzo
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
GB
Rule Definitions are stored as XML; so you would need to parse this XML in a way to render to EXCEL.*
To view the XML of a particular rule from the Designer Studio - open up the Rule (say 'HTMLTOPDF') - and then click on 'Actions | View XML'.
This will show the definition of the Activity Rule.
If you want to do this programmatically , you can create another PRPC Activity to perform an 'Obj-Open' on the rule.
First you'll need to know the 'keys' for the Rule Type; to do this - choose your class (in this case it is 'Rule-Obj-Activity'); put this in your Rule Explorer in Designer Studio, and then right click the leaf node and choose 'Definition':
This will bring up the Rule Form for the class, which will identify the keys, in this case
pyClassName
pyActivityName
Rule Definitions are stored as XML; so you would need to parse this XML in a way to render to EXCEL.*
To view the XML of a particular rule from the Designer Studio - open up the Rule (say 'HTMLTOPDF') - and then click on 'Actions | View XML'.
This will show the definition of the Activity Rule.
If you want to do this programmatically , you can create another PRPC Activity to perform an 'Obj-Open' on the rule.
First you'll need to know the 'keys' for the Rule Type; to do this - choose your class (in this case it is 'Rule-Obj-Activity'); put this in your Rule Explorer in Designer Studio, and then right click the leaf node and choose 'Definition':
This will bring up the Rule Form for the class, which will identify the keys, in this case
pyClassName
pyActivityName
You can now use this in an 'Obj-Open' to get at the XML of the Activity of your choice.
(Actually: it turns out you actually get slightly different XML when compared with the 'View XML' method; I *assume* that this is because 'Obj-Open' is also 'Rule-Resolving' (with respect to 'Rulesets' ; which we are not specifying here) but the 'View XML' is opening up an exact instance - but I'm not sure on that).
Here's an Activity that retrieves the XML for the Activity '@baseclass.HTMLTOPDF' for instance:
Now comes the difficult bit:
You need to reverse engineer the Page Data here that defines the Activity; some of it is self evident, most of it is not. For instance you can locate the 'History | Description' text in the pyDescription property:
Change the Activity Above; comment out the 'Show-Page' step and instead put in a 'Show-Property' Step like this:
And you'll get the description of the Activity out instead.
You could probably pull apart this structure using a series of 'Data Transforms'; and rebuild your own model which represents the output you need for your Excel File; but it will probably take quite a bit of experimentation.
I tried something similar a while back: but I wanted to output the Activity as a standalone 'HTML' file; I got so far but then got stuck. I went for a different approach - I got the XML outside of PRPC and then applied an XSLT stylesheet to reformat the XML; I'll share that here for what its worth - you might be to use to , to get some of the structure (which I reverse-engineered - so I could have got it wrong) of the Page.
Here's what the output looks like - its actually using JQuery to provide tabs etc - but this is incomplete I'm afraid. (not all step-types can be expanded).
If you want to try this approach; you'll need an XSLT processor (actually PRPC has a mechanism to do this also) like Saxon.
The attachment is actually a 'ZIP' file ,but we are not allowed to upload ZIPs here; so I renamed the extension to 'TXT'.
[*EDIT: Rule Definitions are actually stored in the Pega Model ; that is as 'Pages' of data; so you don't have to work at the XML level; you can work 'within the model' here - using Data Transforms, Activities etc;I meant that the Page Data is de-serialized into XML really. ]
Pegasystems Inc.
US
Hi Vincenzo,
As per my knowledge all the generated Java code of the activity will be stored in the pr_assembledclasses table not in the pr4_rule table.
Hope this information might be helpful to you.
Regards
Mahesh
Fibercop S.p.A.
IT
Thanks Mahesh,
Do you know the class as well?
Anyway, I'd like to export the HTML page (regarding the activity's code) in excel, I'm trying to use a chrome extesion to get the text like "Data Miner" or "Web scraper" but they don't work with the Pega web page (they don't support the forms and frames).
Any suggestion?
Thnaks,
V.
Fibercop S.p.A.
IT
Hi,
I have used the activity "GetActivityDetails" (customizing it in private mode in order to export the xml generated).
Pegasystems Inc.
IN
Hi ,
You can find the generated java of an activity in the temp folders configured during installation
for eg: C:\tempfolders\temp61sp2\PRGenJava\com\pegarules\generated\activity
Fibercop S.p.A.
IT
Hi,
thanks for the answer, but I'd like to have the code as well it is written in Designer studio and not in Java.
In fact I'd like to export the HTML page (regarding the activity's code) in excel, I'm trying to use a chrome extesion to get the text like "Data Miner" or "Web scraper" but they don't work with the Pega web page (they don't support the forms and frames).
Thnaks,
V.
Pegasystems
US
You can study the activity pyExtractCode for an example of how to obtain the java. /Eric
Fibercop S.p.A.
IT
Hi,
this activity calls the Java method "pega.getGeneratedJavaSourceCode(className)" that returns the Java source code. I'd like to have instead the source code as displayed in Designer Studio (Pega code and instructions).
Thanks,
V.
Accepted Solution
Pegasystems Inc.
GB
Rule Definitions are stored as XML; so you would need to parse this XML in a way to render to EXCEL.*
To view the XML of a particular rule from the Designer Studio - open up the Rule (say 'HTMLTOPDF') - and then click on 'Actions | View XML'.
This will show the definition of the Activity Rule.
If you want to do this programmatically , you can create another PRPC Activity to perform an 'Obj-Open' on the rule.
First you'll need to know the 'keys' for the Rule Type; to do this - choose your class (in this case it is 'Rule-Obj-Activity'); put this in your Rule Explorer in Designer Studio, and then right click the leaf node and choose 'Definition':
This will bring up the Rule Form for the class, which will identify the keys, in this case
pyClassName
pyActivityName
Rule Definitions are stored as XML; so you would need to parse this XML in a way to render to EXCEL.*
To view the XML of a particular rule from the Designer Studio - open up the Rule (say 'HTMLTOPDF') - and then click on 'Actions | View XML'.
This will show the definition of the Activity Rule.
If you want to do this programmatically , you can create another PRPC Activity to perform an 'Obj-Open' on the rule.
First you'll need to know the 'keys' for the Rule Type; to do this - choose your class (in this case it is 'Rule-Obj-Activity'); put this in your Rule Explorer in Designer Studio, and then right click the leaf node and choose 'Definition':
This will bring up the Rule Form for the class, which will identify the keys, in this case
pyClassName
pyActivityName
You can now use this in an 'Obj-Open' to get at the XML of the Activity of your choice.
(Actually: it turns out you actually get slightly different XML when compared with the 'View XML' method; I *assume* that this is because 'Obj-Open' is also 'Rule-Resolving' (with respect to 'Rulesets' ; which we are not specifying here) but the 'View XML' is opening up an exact instance - but I'm not sure on that).
Here's an Activity that retrieves the XML for the Activity '@baseclass.HTMLTOPDF' for instance:
Now comes the difficult bit:
You need to reverse engineer the Page Data here that defines the Activity; some of it is self evident, most of it is not. For instance you can locate the 'History | Description' text in the pyDescription property:
Change the Activity Above; comment out the 'Show-Page' step and instead put in a 'Show-Property' Step like this:
And you'll get the description of the Activity out instead.
You could probably pull apart this structure using a series of 'Data Transforms'; and rebuild your own model which represents the output you need for your Excel File; but it will probably take quite a bit of experimentation.
I tried something similar a while back: but I wanted to output the Activity as a standalone 'HTML' file; I got so far but then got stuck. I went for a different approach - I got the XML outside of PRPC and then applied an XSLT stylesheet to reformat the XML; I'll share that here for what its worth - you might be to use to , to get some of the structure (which I reverse-engineered - so I could have got it wrong) of the Page.
Here's what the output looks like - its actually using JQuery to provide tabs etc - but this is incomplete I'm afraid. (not all step-types can be expanded).
If you want to try this approach; you'll need an XSLT processor (actually PRPC has a mechanism to do this also) like Saxon.
The attachment is actually a 'ZIP' file ,but we are not allowed to upload ZIPs here; so I renamed the extension to 'TXT'.
[*EDIT: Rule Definitions are actually stored in the Pega Model ; that is as 'Pages' of data; so you don't have to work at the XML level; you can work 'within the model' here - using Data Transforms, Activities etc;I meant that the Page Data is de-serialized into XML really. ]
Pegasystems Inc.
GB
And to answer you original query about 'what tables are used to store the rules' - although the data is available in PRPC tables; it is best to access them it at the PRPC Class Level : since data is (at least partially) stored in BLOB fields; and cannot be easily extracted from SQL tools etc.
Using Pega 'Obj-Open' (etc) methods abstracts this detail away ; properties just appear as properties - there is no need to know whether they are in 'exposed' columns or 'blobs'.
-
Arpit Sharma