You can dynamically assign compensation strategies to tasks by creating XQuery expressions in the Design Studio Task Editor Compensation tab for re-evaluation compensation strategies or compensation strategies for when a task is no longer required.
Note:
If the XQuery expression is invalid OSM logs the error but does not rollback the transaction. Instead, OSM uses the static compensation strategy as the default.This section refers to the Design Studio OSM Automated Task or Manual Task editor, Compensation tab Compensation Expression XQuery field for re-evaluation compensation strategies:
Context: The context for this XQuery is the current order data. You can get the current order data using the XML API GetOrder.Response function.
Prolog: You can declare the XML API namespace to use the GetOrder.Response function in the XQuery body to extract the order information. You must declare the java:oracle:communications.ordermanagement.compensation. ReevaluationContext OSM Java package that provides methods that access the contemporary and historical order perspectives and compares the two. You can use the results of this comparison to determine what compensation strategy is required for a task based on revision order data.
For example:
declare namespace osm = "urn:com:metasolv:oms:xmlapi:1"; declare namespace context = "java:oracle.communications.ordermanagement.compensation.ReevaluationContext"; declare namespace log = "java:org.apache.commons.logging.Log"; declare variable $log external; declare variable $context external;
For more information about the classes in the OSM packages extract the OSM_home/SDK/osm7.2.x-javadocs.zip OSM Java docs (where OSM_home is the location where the OSM software is installed and x is the software build numbers).
Body: The body must return a valid compensation option.
For example, the following XQuery expression creates variables for the ReevaluationContext methods. The expression then checks that a specific value exists in the $value variable and that the value in the $significantValue variable both exists and is significant. If the value exists and is significant, then the expression sets the compensation strategy for the task to Undo then Do (undoThenDo in the ReevaluationContext Java class). If not, then the expression sets the compensation strategy to Redo (redo in the ReevaluationContext Java class).
let $inputDoc := self::node() let $hopDoc := context:getHistoricalOrderDataAsDOM($context) let $ropDoc := context:getCurrentOrderDataAsDOM($context) let $diffDoc := context:getDataChangesAsDOM($context) let $value := $inputDoc/GetOrder.Response/_root/service[name='BB']//orderItemRef/specificationGroup//specification[value='100'] let $significantValue := $diffDoc/Changes/Add[@significant='true']/specification[value='100'] let $currentValue := $ropDoc/ GetOrder.Response/_root/service[name='BB']//orderItemRef/specificationGroup//specification[value='100'] return if (fn:exists($value) and fn:exists($significantValue)) then context:undoThenDo($context) else context:redo($context)
This section refers to the Design Studio OSM Automated Task or Manual Task editor, Compensation tab Compensation Expression XQuery field for when a task is no longer required. The context, prolog, and body are similar to the XQuery expression for the re-evaluation strategy, except that the XQuery expression implements the java:oracle:communications.ordermanagement.compensation.RollbackContext package.
For example:
declare namespace osm = "urn:com:metasolv:oms:xmlapi:1"; declare namespace context = "java:oracle.communications.ordermanagement.compensation.RollbackContext"; declare namespace log = "java:org.apache.commons.logging.Log"; declare variable $log external; declare variable $context external; let $inputDoc := self::node() let $hopDoc := context:getHistoricalOrderDataAsDOM($context) let $ropDoc := context:getCurrentOrderDataAsDOM($context) let $diffDoc := context:getDataChangesAsDOM($context) let $value := $inputDoc/GetOrder.Response/_root/service[name='BB']//orderItemRef/specificationGroup//specification[value='100'] return if (fn:exists($value)) then context:undo($context) else context:doNothing($context)