The robustness analysis implies some behavioral rules between objects. For example, an actor should always communicate with a boundary object (an interface), entity objects should always communicate with control objects, and so on. To represent these constraints, you are going to define custom checks on the instance links.
Custom checks do not prevent users from performing a syntactically erroneous action, but they allow you to define rules that will be verified by the Check Model function.
You define custom checks with VB scripting.
For more information on VBS syntax, see Scripting PowerDesigner.
The Metaclass Selection dialog box is displayed.
The InstanceLink category is displayed under Profile.
A new check is created.
This check verifies if actors are linked to boundary objects. Linking actors to control or entity objects is not allowed in the robustness analysis.
This text is displayed in the message box that is displayed when the user selects Help in the custom check context menu in the Check Model Parameters dialog box.
The Check Script tab is the tab where you type the script for the additional check.
Function %Check%(link) ' Default return is True %Check% = True ' The object must be an instance link If link is Nothing or not link.IsKindOf(PdOOM.cls_InstanceLink) then Exit Function End If ' Retrieve the link extremities Dim src, dst Set src = link.ObjectA Set dst = link.ObjectB ' Source is an Actor ' Call CompareObjectKind() global function defined in Global Script pane If CompareObjectKind(src, PdOOM.Cls_Actor) Then ' Check if destination is an UML Object with "Boundary" Stereotype If not CompareStereotype(dst, PdOOM.Cls_UMLObject, "Boundary") Then %Check% = False End If Elsif CompareObjectKind(dst, PdOOM.Cls_Actor) Then ' Check if source is an UML Object with "Boundary" Stereotype If not CompareStereotype(src, PdOOM.Cls_UMLObject, "Boundary") Then %Check% = False End If End If End Function
The Global Script tab is the tab where you store functions and static attributes that may be reused among different functions.
' This global function check if an object is of given kind ' or is a shortcut of an object of given kind Function CompareObjectKind(Obj, Kind) ' Default return is false CompareObjectKind = False ' Check object If Obj is Nothing Then Exit Function End If ' Shortcut specific case, ask to its target object If Obj.IsShortcut() Then CompareObjectKind = CompareObjectKind(Obj.TargetObject) Exit Function End If If Obj.IsKindOf(Kind) Then ' Correct object kind CompareObjectKind = True End If End Function ' This global function check if an object is of given kind ' and compare its stereotype value Function CompareStereotype(Obj, Kind, Value) ' Default return is false CompareStereotype = False ' Check object If Obj is Nothing or not Obj.HasAttribute("Stereotype") Then Exit Function End If ' Shortcut specific case, ask to its target object If Obj.IsShortcut() Then CompareStereotype = CompareStereotype(Obj.TargetObject) Exit Function End If If Obj.IsKindOf(Kind) Then ' Correct object kind If Obj.Stereotype = Value Then ' Correct Stereotype value CompareStereotype = True End If End If End Function
You are going to repeat steps 4 to 14 and create one check to verify that an instance link is not defined between two boundary objects:
Function %Check%(link) ' Default return is True %Check% = True ' The object must be an instance link If link is Nothing or not link.IsKindOf(PdOOM.cls_InstanceLink) then Exit Function End If ' Retrieve the link extremities Dim src, dst Set src = link.ObjectA Set dst = link.ObjectB ' Error if both extremities are 'Boundary' objects If CompareStereotype(src, PdOOM.Cls_UMLObject, "Boundary") Then If CompareStereotype(dst, PdOOM.Cls_UMLObject, "Boundary") Then %Check% = False End If End If End Function
Function %Check%(link) ' Default return is True %Check% = True ' The object must be an instance link If link is Nothing or not link.IsKindOf(PdOOM.cls_InstanceLink) then Exit Function End If ' Retrieve the link extremities Dim src, dst Set src = link.ObjectA Set dst = link.ObjectB ' Source is and UML Object with "Entity" stereotype? ' Call CompareStereotype() global function defined in Global Script pane If CompareStereotype(src, PdOOM.Cls_UMLObject, "Entity") Then ' Check if destination is an UML Object with "Control" Stereotype If not CompareStereotype(dst, PdOOM.Cls_UMLObject, "Control") Then %Check% = False End If Elsif CompareStereotype(dst, PdOOM.Cls_UMLObject, "Entity") Then ' Check if source is an UML Object with "Control" Stereotype If not CompareStereotype(src, PdOOM.Cls_UMLObject, "Control") Then %Check% = False End If End If End Function
The custom checks appear in the Instance Link category.
You can test the checks by creating instance links between Customer and Application server for example, and then press F4 to start the check model feature.
For more information on the Check Model feature, see "Checking a Model" in the Models chapter of the Core Features Guide.