Welcome to the OPA Hub!

Blog

Temporal Reasoning in Oracle Policy Automation #4 : Time Travel

Temporal Reasoning in Oracle Policy Automation #4 : Time Travel

In this, the fourth part of our little series about Temporal Reasoning, we are going to look at the business of entering data. Specifically how users can enter the information they need during an interview. Thinking back to the scenario we have been discussing in the previous posts (part one, two and three) we need to enter information about our bank balance.

In a non-temporal world, entering the data would be as simple as entering a value in an input box. But we cannot have that, since there is no built-in capability to enter different values on different dates. Unlike some CRM systems like my old friend Oracle Siebel, there is no user interface element designed to facilitate the entry of temporal data.

So what options do we have. We can ask our users to enter data in row format, with each row representing a specific amount on a specific date. Put simply we can create an Entity and each instance can be converted into a temporal value. Let’s see how that works. Consider the following new Project with a simple data model:

Temporal Reasoning in Oracle Policy Automation 3

As you can do doubt see, a single entity has been added and a few attributes. In addition I have changed the default text provided for the Containment Relationship to make it more natural. For our purposes we are interested in the date and the currency attributes which will form the basis of our conversion. To make this easier, we are going to use an Excel table to infer instances of the bank balance entry using the following table:

Temporal Reasoning in Oracle Policy Automation 4

With this data we can now use one or other of the Temporal Reasoning functions that allow us to build temporal values from entity instances. As a first example, enter the following in a Word document in the project.

Temporal Reasoning in Oracle Policy Automation 5

The expression targets a new attribute, the temporal bank balance, which will be populated with the output of the TemporalFromStartDate function. The function takes the relationship as the initial argument, followed by the date attribute and our currency attribute. The result in the Debugger is this (note I have superimposed the Temporal Visualization from the Debugger on the Interview output) :

Temporal Reasoning in Oracle Policy Automation 6

Awesome. Our instances have become temporal values for our temporal attribute. But beware what this function is giving you. The implication of From Start Date is that any date prior to the first date in your Excel will show a temporal value of uncertain. Change the function to the following:

Temporal Reasoning Oracle Policy Automation 7

In this case, you are indicating that From the End Date of your instances, the temporal attribute will be uncertain.

Temporal Reasoning Oracle Policy Automation 8

If you have instances where there is both an end and a start date for each instance (which is not the case in our bank balance Excel table), you could also use this function to calculate when something was (for example) valid or invalid:

Temporal Reasoning Oracle Policy Automation 9

This of course assumes you have an entity, relationship and attributes that match the example above. It produces output like this:

Temporal Reasoning Oracle Policy Automation 10

In case you were wondering, you can reverse this process (go from temporal to instances) using a different method. In the final part of this series we will look at displaying the temporal data in cool ways.

OPA 12 - Data Model Visualisation Load Viewer

Visualize the Data Model in Oracle Policy Automation 12

Visualize the Data Model in Oracle Policy Automation 12

One of the very few areas where I feel that Oracle Policy Automation 10 is slightly better than Oracle Policy Automation 12 is in the area of visualisations. You may remember that in version 10, getting a visual representation for the data model was very easy. To visualize the Data Model in Oracle Policy Automation 12 is not so easy!

Visualize the Data Model in Oracle Policy Automation 12 - Data Model

And what was particularly useful was that it could be copied and pasted into Word or PowerPoint or any other productivity tool.

So the other day I was stuck on a plane and I began to think about this from an Oracle Policy Automation 12 perspective. The data model is stored, as you probably are aware, in the file called projectDataModel.xml which is in the Project folder. It is updated live as you add things to the data model via the Data tab of the Oracle Policy Modeller.

In this file there are, simply put, three sections. Entities and Attributes and Relationships.  There are other sections but these are not of interest today.

Visualize the Data Model in Oracle Policy Automation 12 XML

Oracle Policy Modeller 10 used a third-party component family, Mind Fusions – notably the Diagram Control (from www.mindfusion.eu) to do a lot of the heavy graphical lifting in the old interface. That component is not, to my knowledge, used in Oracle Policy Modelling 12.

So what if we decided to use it again? The Mind Fusion controls are available as a free trial download. so I popped them into my free Visual Studio 17 and began to think about how to get this up and running. Remember, that this is not professional code because that is not what I do. It’s supposed to be interesting and valuable but you will have to do it properly yourselves.

Firstly, the XML structure is very simple indeed, so loading it into a DataGrid was a matter of a few lines of code. Create a DataSet, load the XML and display it as the data source of the DataGrid.

Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnLoad.Click
        Dim fileDialog As OpenFileDialog = New OpenFileDialog()
 
        fileDialog.Title = "Open File Dialog"
        fileDialog.InitialDirectory = "C:\Users\SADMIN\Desktop"
        fileDialog.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
        fileDialog.FilterIndex = 1
        fileDialog.RestoreDirectory = True
 
        If fileDialog.ShowDialog() = DialogResult.OK Then
 
 
            FileNameAndPath = fileDialog.FileName
            dataProject.ReadXml(fileDialog.FileName)
 
            dataGrid.DataSource = dataProject
        dataGrid.DataMember = "entity"
        dataGrid2.DataSource = dataProject
            dataGrid2.DataMember = "relationship"
        End If
    End Sub

So now we can display the data in a Grid. Boring, but useful.

OPA 12 - Data Model Visualisation Load DataGrid

The next step is to find out how to display the data in a Diagram. Since the Mind Fusion Diagram control is thoroughly modern, we need to add both a Diagram and a DiagramView to our Project. Then we can load the data into the Diagram, creating Nodes (boxes) and Links (connections) as we go.

I broke it into three steps : Global and it’s attributes, Child Entities and Attributes, and finally Relationships. All Nodes can have a tag so it is a good idea to store the unique identifier in there, which makes it easier to find the correct “source” or “target” for anything you want to do with your Nodes.

Here is a snippet from the initial build up of Child Entities:

    Private Sub CreateFirstLevelChildren(ByVal parentDiagNode As DiagramNode, ByVal parentXmlNode As XmlNode)
        ' Create a loop for all the entities in the XML
        For Each element As XmlElement In parentXmlNode.SelectNodes("entity")
 
            If element.GetAttribute("ref") <> "global" And element.GetAttribute("containment-parent-id") = "global" Then
                ' find all the first level children and add a new shape
                Dim node As ShapeNode = Diagram1.Factory.CreateShapeNode(nodeBounds)
                node.Brush = New MindFusion.Drawing.LinearGradientBrush(Color.Yellow, Color.BurlyWood, 20)
                node.Text = element.GetAttribute("name")
                node.Tag = element.GetAttribute("id")
                node.Shape = Shape.FromId("DividedProcess")
                'draw a line between parent and child
                Diagram1.Factory.CreateDiagramLink(parentDiagNode, node)
                'get the attributes
                CreateAttributes(node, element, element.GetAttribute("id"))
                'get the children of the child
                CreateChildren(node, element, element.GetAttribute("id"))
            End If
        Next
 
    End Sub

Given that the Mind Fusion Diagram supports Printing, Zooming and Saving to SVG or Visio, this means that you can be up and running in no time. I experimented with different viewers hooked in to some simple XPath-based searches of the XML file:

Standard Viewer

OPA 12 - Data Model Visualisation Load Viewer

The standard viewer let’s me move things around and generally get a good view of the data model. In addition, as I mentioned you can output to PDF, SVG or Visio. Pretty neat! I experimented with the relationships loaded on top of the data model and it can get pretty crowded, but now we can visualize the Data Model in Oracle Policy Automation 12.

OPA 12 - Data Model Visualisation Load Viewer Crowded

3D Viewer

Less flexible and probably misused in this case, the 3D Viewer looked good but didn’t really offer anything over and above the standard Viewer.

OPA 12 - Data Model Visualisation Load 3D Viewer

It just looked neat, I grant you!

Given that Office 2016 supports SVG Vector files – and for that matter PDF files – it was then a simple task to copy my data model into PowerPoint just by Saving As.

  If SaveFileDialog.ShowDialog() = DialogResult.OK Then
            Dim svgExp As MindFusion.Diagramming.Export.SvgExporter = New MindFusion.Diagramming.Export.SvgExporter()
            svgExp.ExternalImages = False
            svgExp.Export(DiagramView1.Diagram, SaveFileDialog.FileName)
        End If

See how easy it is! I really save time when creating slides and documents.

OPA 12 - Data Model Visualisation Load Viewer PPT

Visualize the Data Model in Oracle Policy Automation 12

That’s enough for now. If you are interested and want a copy of my kindergarten code just leave a comment and I will pass it on. My next job is to add a few options (Show / Hide attributes and the like, to make the content a little more customizable), and to investigate the Visual Browser concept that we had in Oracle Policy Modeller 10. That, on the other hand will be much more difficult!

Detail Pop-up in Oracle Policy Automation

Detail Pop-up in Oracle Policy Automation

The other day someone came to me with a curious and interesting problem. They had a number of entity instances, inferred in an Excel spreadsheet. These had to be displayed in the usual way with an Entity Container in a Screen of Oracle Policy Modeller. So far so good, I hear you say.

Detail Pop-up in Oracle Policy Automation 1

The inferred attributes (which in the end would probably be coming from a data source, but for now come from Excel as inferred instances) included a Text attribute that was frankly far too large to display correctly in the Screen, given that there might be a few rows of instances in the final result.

We experimented with lots of different layouts, dynamically hiding and showing items based on various criteria in order to make room, but in the end we came to the conclusion that we needed some sort of Detail Pop-up in Oracle Policy Automation – something that could be called upon by the user as and when they needed it, but ignored (and invisible) when not needed.

Here is the starting point for our adventure.

The Screen above is populated with all the instances of the student’s scholarship. On the left is a set of information that we need to display on request. Normally we will only display the name of the Scholarship. You will see in the list of attributes there is an overview ( a text attribute), a deduction ( a currency attribute) and a renewable status (a boolean attribute). There are a few others, including the contact details (a text attribute, which is a URL).

So we are going to customise the label control I have just described. It is “inside” the Entity instance loop : so in reality there will be one per instance. We need our label to contain, as you would expect, the correct information. We wish to avoid pop-ups (nasty!) and dialogs (too complex for a simple window) and tool-tips are too small and simple for the data we have. The label shown will have a custom property called “name” and will be used as a hook for our JavaScript Extension.

We experimented with all sort of things before we went for this option : JavaScript is a last resort. We were frustrated by the behaviour of hidden items that appeared slowly (we could see “uncertain” appearing before the out of the box JavaScript populated the bound controls). So it was going to be JavaScript.

So,  our Detail Pop-up in Oracle Policy Automation needs to meet these challenges. We are going, as a simple demonstration, to use a CSS toggle to show or hide the relevant data for our instances. We can set the scene as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.area {
position:relative;
color:#0645AD;
font-weight:400;
}
 
.area:hover {
text-decoration:underline;
text-decoration-color:blue;
cursor: pointer;
}
 
.fixed {
position:absolute;
top:190px;
left:465px;
border:0;
z-index:9999;
background-color:#FFF;
display:none;
height:300px;
width:420px;
float:right;
text-decoration:none;
text-decoration-color:#000;
text-color:#000;
padding:5px;
}

The above CSS file sets up two main classes and a pseudo-class for a mouse hovering over our row. The area is the area we will normally show – with just the name – and the fixed area is a fixed DIV which will display (or not) when we decide we want to visualise the information. Now for the main content of our customLabel extension. Here is the mount key with as usual, my simplistic attempts at coding : for the umpteenth time I’m not a professional – but my job is to show something can be done, and let other’s get on with making it happen.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
 
if (control.getProperty("name") == "xLabel") {
return {
mount: function (el) {
var maindiv = document.createElement("div");
maindiv.style.visibility = 'visible';
maindiv.innerHTML = interview.getValue("scholarship_award", "scholarship", control.instance);
maindiv.classList.add("area");
maindiv.setAttribute("id", interview.getValue("scholarship_award", "scholarship", control.instance));
el.appendChild(maindiv);
 
var tooltipdiv = document.createElement("div");
tooltipdiv.style.visibility = 'visible';
tooltipdiv.classList.add("fixed");
tooltipdiv.innerHTML = control.getCaption();
tooltipdiv.setAttribute("id", interview.getValue("scholarship_award", "scholarship", control.instance));
el.appendChild(tooltipdiv);
 
$("div [id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").click(function () {
$(".fixed").hide();
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").html("<h6>Name : " + interview.getValue("scholarship_award", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6>Overview : " + interview.getValue("scholarship_overview", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6><b>Renewable</b>: " + interview.getValue("scholarship_renewable", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6><b>Maximum Value</b>: " + interview.getValue("scholarship_deduction", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6><b>Eligibility</b>: " + interview.getValue("scholarship_eligibility", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6><b>Minimum Grade</b>: " + interview.getValue("scholarship_min_grade", "scholarship", control.instance) + "</h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").append("<h6><b>Contact</b>: <a href='" + interview.getValue("scholarship_contact", "scholarship", control.instance) + "' target='_blank'>SFAS Office</a></h6>");
$(".fixed[id='" + interview.getValue("scholarship_award", "scholarship", control.instance) + "']").toggle();
});
 
}

Here is the review of the Detail Pop-up in Oracle Policy Automation code shown above, starting with the usual check to make sure we are only working with our label and not any other label on the Screen. In lines 6 to 11 we add a new DIV (to replace the one that contained all those %substitution%s , and we populate it with only one attribute. Since that attribute is also unique, we use it as a handy way to populate the HTML id attribute.

In lines 13 to 18 we create a second, hidden DIV that uses the fixed class shown above.

In lines 20 to 29 we set up the click event so that the user can click on the label and the hidden text will be revealed. The code preview (I notice) has eaten the ending part of the line, so use the PDF version instead. Notice the use of getValue, with the entity name and the instance, to ensure that we create a DIV with a unique name and unique content. The content will be toggled (hidden or shown) when you click on it.

Finally the unmount is very standard, cleaning up our various pieces by removing them.

1
2
3
4
if (control.getProperty("name") == "xLabel") {
$(".area").remove();
$(".fixed").remove();
}

The end result looks like this, before the click:

Detail Pop-up in Oracle Policy Automation 3And after the click:

Detail Pop-up in Oracle Policy Automation 4

Our Detail Pop-up in Oracle Policy Automation prototype gives the user the information they need when they need it. Of course it can be extended and transformed into something much less ugly, but this is a good start. You can find the PDF in the Shop, it’s free!

OPA 12 - Data Validation

Data Validation in Oracle Policy Automation

Data Validation in Oracle Policy Automation

Some people assume that the only answer to a problem with my other favourite software (Oracle Siebel CRM) is to write some script. These days they mean JavaScript, jQuery, Web Services or anything else they can lay their hands on.

The same thing might happen one day with Oracle Policy Automation (and indeed, appears to be happening on an increasing basis). Let’s add some JavaScript! After all it’s just JavaScript, so what can go wrong? All JavaScript can do is pop up warnings and make text blink, right? Wrong. Before you know it you have altered (or at least attempted to interfere with ) the user experience beyond recognition, spent a lot of time and money and probably broken a few Oracle Policy Automation golden rules along the way.

So what has that rant got to do with Data Validation. Well, the other day a colleague and friend (thanks M!) came to me with a question and she was eager not to use JavaScript at all. She is learning some of the features of Oracle Policy Automation and she has the good reflex : think outside Scripting.

The question was, how to validate a data entry. The user must be able to enter between 1 and 100 characters in a Control, and the control can accept tabs, spaces, as well as certain accented characters (the language of data entry was not English). So what options does she have?

Error and Warning Rules for Data ValidationOPA 12 - Data Validation

Our rule designer could create rules that assist the user in at least understanding what they are doing wrong. They could also (assuming they are using at least a reasonably modern version, choose to have those error messages when the user navigates away from the Screen, or from the Control (Show Errors > Immediately or  On Navigate from the Interview tab Ribbon).

Attribute Type Specific Options for Data Validation

For attributes that are not textual – numbers, time of day, dates and so on, then there are a variety of further options that can be applied to the Attribute in the Modeller interface, on the Data tab.

OPA 12 - Data Validation 2

But our intrepid rule designer still didn’t get the level of fine detail she was looking for , in respect of her Text attribute. How to limit the  data input to only that specific set of characters?

RegEx in Data Validation

The most powerful form of Data Validation, and the one that benefits from a huge community of helpers, is Regular Expressions. They can be applied to Text Attributes and as such, can provide a high level of control. For the sake of your sanity, do check that the RegEx you are trying to use is compatible with the Oracle Policy Automation engines (Java and JavaScript – so as the official documentation says

“Be sure to only use regular expression syntax that is supported by both languages, and by all browsers. This is basically POSIX ERE regular expressions, with Perl/Tcl character classes. For more information, including examples on crafting regular expressions, see the Wikipedia article on Regular expressions.”

In the specific case mentioned above, our rule designer was able to use the Unicode values to create the range of characters for our character class. And she used our favorite site regexr.com to build and test the expression, that looked a little like this

^[\s\S\u00C0-\u024F]{1,100}$

All this proves that Oracle Policy Automation has a whole bundle of things you can achieve in Data Validation without going near JavaScript or jQuery.

What’s New in Oracle Policy Automation 18C?

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Oracle Policy Automation Workshop – Sept 24-27 North America (FINALIZED)

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Oracle Policy Automation at Oracle OpenWorld 2018

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Interviews, Languages and URL Arguments

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

Oracle Policy Automation Workshop – Sept 24-27 North America

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.

List of Values, Display Values and Translations in Oracle Policy Automation

Hi There!


This content is accessible only to logged in users of the OPA Hub.

To Register takes only 10 seconds and uses LinkedIn for authentication. It does not take your contacts or use any other permission.

Once registered you can change your OPA Hub password and manage it independently of LinkedIn.

We recommend you keep different passwords for all your sites.

To register, click the Log in link in the menu at the top of your page.

Thanks, the OPA Hub Website.