Fun with Oracle DRM and JavaScript

Episode 1: PropDefObject

Good day all! I thought I would start a new blog series detailing the different (Oracle DRM) Data Relationship Objects and how to work with them using the newer JavaScript option available for derived property types. In this first episode, we will look at the PropDefObject object since I recently worked with it. The PropDefObject object provides several properties about a DRM property. The table below, courtesy of the Oracle Data Relationship Administrator’s Guide, details all the properties for the PropDefObject along with a description.

Name Description
Abbrev The property definition name (including fully qualified namespace)
Cascade True if the property values are inherited
ColumnWidth The default export column width
DataType A DataType enumeration value, for example DataType.String (see Enumeration Constants)
Descr Description
DefaultValue Default Value of the property definition. The type depends on the data type of the property definition.
EditorLabel Label
Global True if property is a Global Node property
Hidden True if property is hidden from the property grid
ID ID
Level A PropLevel enumeration value, for example, PropLevel.Node (see Enumeration Constants)
List True if prop lets user select from a list of values
ListValues Array of values from which a user can select
LookupValues Lookup key-value pairs for a lookup property. Use the Key and Value properties of the objects in this array.
MaxValue Maximum value
MinValue Minimum value
Namespace Namespace of property definition
PropType A PropType enumeration value, for example, PropType.Defined (see Enumeration Constants)
PropClass Deriver class (Formula or Script)
ReadOnly True if property is read-only (such as a Core stats property)

 

If you read the Oracle DRM Administrator’s guide, you’ll quickly realize that it’s great at listing the various objects in the DRM object model. But it falls way short in providing examples of how to actually use the objects in the JavaScript-based properties. So, I thought I’d step in and provide some coding examples of how to manipulate and access  DRM scripting objects and their properties and methods. So let’s dive right in.

Many of the PropDefObject properties are very straight-forward and simply return a value that can be referenced within JavaScript. I’ll demonstrate the use of these properties shortly. First though, we must get an object reference to the PropDefObject and it is here where I think the admin guide is really lacking. For someone not familiar with coding, it may be difficult to figure out how to start working with the DRM JavaScript object model. For many of the objects, the biggest hurdle is obtaining an instance of the object. Once we have the object, using the properties and methods becomes fairly straight forward. The screenshot below demonstrates how we can get the PropDefObject for a given property ( called “TEST_PROPERTY” for our examples).

First step is to use the “node” (NodeObject/LocalNodeObject) object and it’s Prop() method to return a NodePropObject. Second step is to use the newly obtained NodePropObject and its GetPropDef() method to in-turn obtain a PropDefObject. Notice how we use a given object to obtain another related object reference? Once you grasp this concept of using an object and its available method(s) to return another object and so on, you will start to understand how to leverage the DRM object model to accomplish some really cool custom-derived properties. If we refer to the first couple lines in the code example below, we could even combine those into a single statement.

Here’s another representation of the same code but combined into a single statement. This might make it easier to see how we’re using objects and their method in almost a daisy-chain fashion to work our way “up” and “down” the object model if you will.

Now that we have our PropDefObject, let’s start working with the properties of this object. Note that this object does not have any methods associated with it. The code example below shows the simple properties that return a single value. The first section shows the code and the second section shows the output.

Generates this output…

Many of these properties are simple boolean values or numbers representing column widths or maximum values. However, some of these numbers represent enumerations or constants. In other words, the numerical value represents a textual value. For example, what the heck does a “PropType” of 2 mean exactly. Too bad the admin guide doesn’t actually list out the index-text pairings. I’ve tested and broken down the enumerations for the different enumeration based properties as shown below.

Now, when you retrieve one of these enumeration type of properties, you can reference this list to see what a given index represents text-wise. For our PropType value of 2, we can see that that equates to a PropType of “Defined”.  If we look at our “TEST_PROPERTY” property, we see that indeed the Property Type listed is “Defined”.

That covers the majority of the properties for the PropDefObject. There are still two other properties that are a little more complex in that they return arrays of values instead of a single value. The ListValue and LookupValue properties both return arrays. The former returns a single dimensional array while the LookupValue return a two-dimensional array of key and value pairings.

The next screen shot demonstrates the usage of the ListValue and how to enumerate over its values.

And finally, here’s an example of the LookupValue arrays and enumerating over its key-value pairings.

As you can see, the PropDefObject lets you access almost all settings of a given property (for a given node). The only shortcoming that I’ve come across so far is the inability to access the LookupValues for an external lookup property. Unfortunately, at this time, it doesn’t appear that you can programmatically access the external list for an external lookup property. Oracle are you listening???

Pete Strayer

About Pete Strayer

Setting aside aspirations to become a professional bass fisherman or race car driver, Pete Strayer instead opted for the glorious career as an EPM consultant. When he’s not making his dad’s secret sloppy joe recipe, you’ll likely find him creating some MDX calculations or exploring new possibilities with Oracle Data Integrator. An Arizona native, Pete’s hobbies include eating (especially pizza or Mexican food), fast cars, HPDE events (google it) and spending time with his family.

Leave a Reply

Your email address will not be published. Required fields are marked *