Context Object Parameters
Parameter Name | Type | Read/Write | Comments |
---|
Mode | String |
Read | Add to validate the creation of the link for new content and Remove to validate the deletion of the link for existing content. |
ActionList | List | Read | List of content on which Add or Remove are applied on. |
ExistingList | List | Read | List of content to help the user defining his business rule. |
Sample
The following sample checks whether or not the reservation will contain unique named pins and checks that the reservation must have at least two pins. If not, routing is interrupted and a message issued.
/* Rule : ELE_ValidateAllocationPin */
/*
ThisObject : #In RFLVPMLogicalPort
Parameters : #In RuleContext
Validation : #Out Boolean
*/
let sMode (String) /* "Add" or "Remove" modes */
let ActionList (List) /* Ends to validate action on */
let ExistingList (List) /* Existing ends */
let nbActionEnds (Integer)
let nbExistingEnds (Integer)
let ActionEnd (RFLVPMLogicalInstance)
let ExistingEnd (RFLVPMLogicalInstance)
let NetOwner (RFLVPMLogicalReference)
let WireOwner (RFLVPMLogicalReference)
let ConnectionOwner (RFLVPMLogicalReference)
let i (Integer)
let j (integer)
set Owner = Parameters->GetAttributeObject("Owner")
set sMode = Parameters->GetAttributeString("Mode")
set ActionList = Parameters->GetAttributeObject("ActionList")
set ExistingList = Parameters->GetAttributeObject("ExistingList")
Validation=true
nbActionEnds = ActionList->Size()
nbExistingEnds = ExistingList->Size()
set i = 1
if (sMode == "Add")
{
for i while i <= nbActionEnds AND Validation == true
{
ActionEnd = ActionList.GetItem (i)
set j = 1
for j while j <= nbExistingEnds AND Validation == true
{
ExistingEnd = ExistingList.GetItem (j)
if (ActionEnd.PLM_ExternalID == ExistingEnd.PLM_ExternalID)
{
Validation = false
Parameters.Message = "Pin " + ActionEnd.PLM_ExternalID + " already exists"
Parameters.Severity = 1
}
}
}
}
if (sMode == "Remove")
{
if ((nbExistingEnds - nbActionEnds) < 2)
{
Validation = false
Parameters.Message = "Reservation must have at least 2 pins"
Parameters.Severity = 2
}
}