Bookshelf Home | Contents | Index | PDF |
Siebel Product Administration Guide > Creating Validation Rules for Customizable Products > About Creating Custom Rule Checkers > Validate MethodThe 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. ExampleThe 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 application 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) var productId = Inputs.GetProperty("Product Id"); var product = Inputs.GetProperty("Product"); var assetCacheKey = Inputs.GetProperty("Asset Cache Key"); // Retrieve rules checker specific parameters for (var i = 0; i < Inputs.GetChildCount(); i++) var child = Inputs.GetChild(i); throw "Unknown argument: " + child.GetType(); 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 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 for (var i = 0; i < svcOutputs.GetChildCount(); i++) var child = svcOutputs.GetChild(i); throw "Unknown argument: " + child.GetType(); throw "Missing output argument 'Result'"; // Since a single query cannot get the bandwidth of connections into and out of // a node, the code retrieves this using 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 // Get the bandwidth going into each node from the projected asset cache 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); for (var i = 0; i < svcOutputs.GetChildCount(); i++) var child = svcOutputs.GetChild(i); throw "Unknown argument: " + child.GetType(); if (nodeFromPropSet == undefined) throw "Missing output argument 'Result'"; // Get the bandwidth going out of each node from the projected asset cache 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); for (var i = 0; i < svcOutputs.GetChildCount(); i++) var child = svcOutputs.GetChild(i); throw "Unknown argument: " + child.GetType(); 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 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 if (nodeFromPropSet.GetChild(nodeFromIndex).GetProperty("Node") == thisNodeName) fromNodeBandwidth = parseInt(nodeFromPropSet.GetChild(nodeFromIndex).GetProperty("Sum")); // Find the current node in the 'total to' property set if (nodeToPropSet.GetChild(nodeToIndex).GetProperty("To Node") == thisNodeName) parseInt(nodeToPropSet.GetChild(nodeToIndex).GetProperty("Sum")); // 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 + ")", ""); |
Siebel Product Administration Guide | Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |