Siebel Product Administration Guide > Creating Validation Rules for Customizable Products > About Creating Custom Rule Checkers >

Validate Method


The Validate method implements the logic of the rules checker and returns rules violations. It may optionally use the Product Id to retrieve product specific data related to the rule, or other parameters that may influence the logic of the rule. It then queries the Projected Asset Cache using the supplied Asset Cache Key for rule violations and returns an error string for each to the Compound Product Validation Engine.

Example

The Port Over-Subscription Checker business service checks that the sum of the bandwidths of the connections going into or out of a node does not exceed the bandwidth of the node. The checker has two parameters that specify the name of the Bandwidth attribute of the Node product and the name of the bandwidth of the Connection product. The Validate method first queries the Projected Asset Cache using the Asset Cache Key passed as an input argument for all Network Node components and sorts the output by Node name. It then queries the Projected Asset cache for the sum of the bandwidth attribute for all Network Connection components grouped by the Node field. Finally, it queries the Projected Asset cache for the sum of the bandwidth attribute for all Network Connection components grouped by the To Node field. Using the results from the three queries, the Validate method then calculates the sum of the sum of the bandwidths of the connections going into or out of each node and constructs an error message string for each instance where the bandwidth of the node is exceeded. The error strings are returned in the Rule Violation output argument.

NOTE:  This sample code is provided for instructional purposes only. Different code may be needed, depending on how your system is configured. This sample script contains some fields that may not be present in your application, because they are only available in Siebel Industry Applications.

function Validate (Inputs, Outputs)

{

// Retrieve input arguments

var productId = Inputs.GetProperty("Product Id");

var product = Inputs.GetProperty("Product");

var assetCacheKey = Inputs.GetProperty("Asset Cache Key");

var parameter;

// Retrieve rules checker specific parameters

for (var i = 0; i < Inputs.GetChildCount(); i++)

{

var child = Inputs.GetChild(i);

switch (child.GetType())

{

case 'Parameter':

parameter = child;

break;

default:

throw "Unknown argument: " + child.GetType();

break;

}

}

if (parameter == undefined)

{

throw "Missing input argument 'Parameter'";

}

var connectionAttrib = parameter.GetProperty("Connection Attribute");

var nodeAttrib = parameter.GetProperty("Node Attribute");

// Queries the Projected Asset Cache to retrieve a list of nodes sorted by node

// name.

var assetCacheSvc =

TheApplication().GetService("VORD Projected Asset Cache");

var svcInputs = TheApplication().NewPropertySet();

var svcOutputs = TheApplication().NewPropertySet();

svcInputs.SetProperty("Asset Cache Key", assetCacheKey);

svcInputs.SetProperty("Search Expression",

"([Network Element Type] = \"Network Node\")");

var sortByField = TheApplication().NewPropertySet();

sortByField.SetType("Sort By Field");

sortByField.SetProperty("Node", "ASC");

svcInputs.AddChild(sortByField);

assetCacheSvc.InvokeMethod("Query", svcInputs, svcOutputs);

// Retrieves the result from the output of the Query method

var nodePropSet;

for (var i = 0; i < svcOutputs.GetChildCount(); i++)

{

var child = svcOutputs.GetChild(i);

switch (child.GetType())

{

case 'Result':

   nodePropSet = child;

   break;

default:

   throw "Unknown argument: " + child.GetType();

   break;

}

}

if (nodePropSet == undefined)

{

throw "Missing output argument 'Result'";

}

// Since we cannot construct a single query to get the bandwidth of connections

// into and out of a node, we retrieve this in two queries, one for connections

// going in and one for connections going out. This maximizes the use of high

// performance C++ code in the projected asset cache and minimizes the work

// done by this script.

// Get the bandwidth going into each node from the projected asset cache

var assetCacheSvc =

TheApplication().GetService("VORD Projected Asset Cache");

// Set up the inputs to the Query method

var svcInputs = TheApplication().NewPropertySet();

var svcOutputs = TheApplication().NewPropertySet();

svcInputs.SetProperty("Asset Cache Key", assetCacheKey);

svcInputs.SetProperty("Search Expression",

"([Network Element Type] = \"Network Connection\")");

svcInputs.SetProperty("Aggregate Field", connectionAttrib);

svcInputs.SetProperty("Aggregate Function", "Sum");

var groupByField = TheApplication().NewPropertySet();

groupByField.SetType("Group By Field");

groupByField.SetProperty("Node", "");

svcInputs.AddChild(groupByField);

var sortByField = TheApplication().NewPropertySet();

sortByField.SetType("Sort By Field");

sortByField.SetProperty("Node", "ASC");

svcInputs.AddChild(sortByField);

// Invoke the Projected Asset Cache Query method

assetCacheSvc.InvokeMethod("Query", svcInputs, svcOutputs);

// Get the Query result

var nodeFromPropSet;

for (var i = 0; i < svcOutputs.GetChildCount(); i++)

{

var child = svcOutputs.GetChild(i);

switch (child.GetType())

{

case 'Result':

   nodeFromPropSet = child;

   break;

default:

   throw "Unknown argument: " + child.GetType();

   break;

}

}

if (nodeFromPropSet == undefined)

{

throw "Missing output argument 'Result'";

}

// Get the bandwidth going out of each node from the projected asset cache

var assetCacheSvc =

TheApplication().GetService("VORD Projected Asset Cache");

ar svcInputs = TheApplication().NewPropertySet();

ar svcOutputs = TheApplication().NewPropertySet();

// Set up the inputs to the Query method

svcInputs.SetProperty("Asset Cache Key", assetCacheKey);

svcInputs.SetProperty("Search Expression",

"([Network Element Type] = \"Network Connection\")");

svcInputs.SetProperty("Aggregate Field", connectionAttrib);

svcInputs.SetProperty("Aggregate Function", "Sum");

var groupByField = TheApplication().NewPropertySet();

groupByField.SetType("Group By Field");

groupByField.SetProperty("To Node", "");

svcInputs.AddChild(groupByField);

var sortByField = TheApplication().NewPropertySet();

sortByField.SetType("Sort By Field");

sortByField.SetProperty("To Node", "ASC");

svcInputs.AddChild(sortByField);

// Invoke the Projected Asset Cache Query method

assetCacheSvc.InvokeMethod("Query", svcInputs, svcOutputs);

// Get the Query result

var nodeToPropSet;

for (var i = 0; i < svcOutputs.GetChildCount(); i++)

{

var child = svcOutputs.GetChild(i);

switch (child.GetType())

{

case 'Result':

   nodeToPropSet = child;

   break;

default:

   throw "Unknown argument: " + child.GetType();

   break;

}

}

if (nodeToPropSet == undefined)

{

throw "Missing output argument 'Result'";

}

// Create a property set for the errors

var ruleViolation = TheApplication().NewPropertySet();

ruleViolation.SetType("Rule Violation");

// Check whether each node is over-loaded

var nodeFromIndex = 0;

var nodeToIndex = 0;

for (var i = 0; i < nodePropSet.GetChildCount(); i++)

{

// Get details for the current node

var thisNode = nodePropSet.GetChild(i);

var thisNodeName = thisNode.GetProperty("Node");

var thisNodeBandwidth = parseInt(thisNode.GetProperty(nodeAttrib));

var thisNodeProduct = thisNode.GetProperty("Product Name");

// Find the current node in the 'total from' property set

var fromNodeBandwidth = 0;

if (nodeFromPropSet.GetChild(nodeFromIndex).GetProperty("Node") == thisNodeName)

{

fromNodeBandwidth = parseInt(nodeFromPropSet.GetChild(nodeFromIndex).GetProperty("Sum"));

nodeFromIndex++;

}

// Find the current node in the 'total to' property set

var toNodeBandwidth = 0;

if (nodeToPropSet.GetChild(nodeToIndex).GetProperty("To Node") == thisNodeName)

{

toNodeBandwidth =

   parseInt(nodeToPropSet.GetChild(nodeToIndex).GetProperty("Sum"));

   nodeToIndex++;

}

// Raise an error if the bandwidth of the connections exceeds that of the node

if (thisNodeBandwidth < (fromNodeBandwidth + toNodeBandwidth))

{

ruleViolation.SetProperty(thisNodeProduct + " '"

+ thisNodeName + "' is overloaded (" + (fromNodeBandwidth

+ toNodeBandwidth) + " > " + thisNodeBandwidth + ")", "");

}

}

// Return any errors

Outputs.AddChild(ruleViolation);

}

Siebel Product Administration Guide Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices.