OPA 12 - Data Model Visualisation Load Viewer

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!