How to Implement the Relationship Establishment Validation Business Logic? |
Technical Article |
AbstractThis article details how you can implement the Relationship establishment validation Business Logic based on the knowledge scripting technology. |
This business logic is called when assigning a material to a product (its intent is wider since it concerns the establishment of relationship between two objects. But at the moment, it is limited to this particular scenario) The goal of the Business logic is to validate that the material that we want to assign to a product is compliant with some enterprise rules. When the check fails, a message can be provided to the end-user, explaining the reason why. Two severity of message can be generated: When the check fails, a message can be provided to the end-user, explaining the reason why. Two severity of message can be generated:
This business logic is called when you want to attach a document to an object, both the document and the object are compliant with corporate rules. A Check Business Logic is called when you attach a document to an object to enable custom checks in particular checks on the maturity of the future parent and attributes of the document.
This business logic is called when the object you want to insert into a folder is compliant with corporate rules. The rule implementing the PLMOpening "establishment of relationship validation" will be triggered when an object is inserted into a folder.
This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.
PLM Opening ID | PLMRelationEstablishmentCheck |
---|---|
Customization Intent | Validation |
The Business Logic can be invoked for at least the listed PLM Component Type. It means that your implementation can safely use the PLM attributes of the default PLM Component. Three possible uses of the BL are possible depending on their purpose:
PLM Component Class Types | Purpose | Note |
---|---|---|
CATMatConnection | Materials | |
PLMCoreRepReference | Documents attached to objects | |
ENOFLD_FolderReference | Documents inserted into a folder | The input object is the folder into which the object is inserted. |
Parameter Names | Types | Read/Write | Comments |
---|---|---|---|
Target | PLMCoreReference | Read | Material that we want to assign (in the future, object that we want to be pointed by the relationship). |
RelationType | String | Read | Type of the relationship. In this case, its value is CATMaterialToReferenceLink |
Context | PLM Entity | Read | Context where the material is applied (the object that aggregates the material connection). |
Support | Feature | Read | Support on which the material is applied. It can be a product reference, a representation instance, or a mechanical body. |
RepInstance | PLMCoreRepInstance | Read | When the support is a reference, it contains the rep instance. |
Parameter Names | Types | Read/Write | Comments |
---|---|---|---|
Target | PLMDMTDocument | Read | Parameter in input that contains the target object of the relation to be created, i.e. the document. |
RelationType | String | Read | String parameter in input of the rule. In this case, its value is PLMDocConnection. |
Note: Attributes of both the input object and the target are available in the Business Logic and can be used to determine the check validity. The attribute that can prove useful is the current state.
Parameter Names | Types | Read/Write | Comments |
---|---|---|---|
Target | PLMCoreReference PLMCoreRepReference |
Read | Parameter in input that contains the target object of the relation to be created, i.e. the object being inserted. |
RelationType | String | Read | String parameter in input of the rule. In this case, its value is PLMFolderConnection. |
Note: This works both with folders and workspace vaults.
The following BL samples show how to:
/*The following rule is an example of what can be done*/ /* ----------------- */ /* Declare */ /* ----------------- */ Let Reference (CATMatReference)/*The material reference*/ Let SupportFeat (Feature) /*The support of the material */ Let ProductContext (PLMEntity) /*The product context in which the material is applied*/ Let RepInstance (PLMEntity) /*The RepInstance in which the material is applied*/ Let s="" Let maturity="" Let matProject="" /* ------------------ */ /* Affectations */ /* ------------------ */ if ( true == Parameters -> HasAttribute("Target") ) { set Reference = Parameters->GetAttributeObject("Target") } if ( true == Parameters -> HasAttribute("Context") ) { set ProductContext = Parameters->GetAttributeObject("Context") } if ( true == Parameters -> HasAttribute("Support") ) { set SupportFeat = Parameters->GetAttributeObject("Support") } if ( true == Parameters -> HasAttribute("RepInstance") ) { set RepInstance = Parameters->GetAttributeObject("RepInstance") } /* ------------------ */ /* Sample Tests */ /* ------------------ */ Validation=true /* Test on context maturity */ if ( ProductContext == NULL ) { Validation=false Parameters.Message = "Context must not be NULL" Parameters.Severity=2 } else { if ( true == ProductContext -> HasAttribute( "V_maturity" ) ) { maturity = ProductContext -> GetAttributeString( "V_maturity" ) if ( "IN_WORK" <> maturity ) { Validation=false Parameters.Message = "Applying material requires an \"IN_WORK\" product context" Parameters.Severity=2 } } } /* Test on Support type */ if ( SupportFeat == NULL ) { Validation=false Parameters.Message = "Support must not be NULL" Parameters.Severity=2 } else { if ( false == (SupportFeat -> IsASortOf( "PLMEntity" )) ) { Validation=false Parameters.Message = "Applying materials on feature is forbidden" Parameters.Severity=2 } } /* Test on material reference */ if (Reference == NULL) { Validation=false Parameters.Message = "Material Reference must not be NULL" Parameters.Severity=2 } else { if ( true == Reference -> HasAttribute( "V_project" ) ) { matProject = Reference -> GetAttributeString( "V_project" ) if ( "Default" <> matProject ) { Validation=false Parameters.Message = "Material reference must be in \"Default\" project" Parameters.Severity=2 } } }
The following rule sample shows how to check some attributes values (e.g. V_description) of the product to which the document is attached.
If (ThisObject.V_description == "Test") { Validation = TRUE } else { Validation = FALSE } if (Validation == FALSE) { Parameters.Message = "Cannot attach the document under the Product" Parameters.Severity=2 }
The following BL sample shows how to:
Let FolderReference(PLMCoreReference) Let ObjectReference(PLMEntity) Let FolderReferenceDescription(String) Let ObjectDescription(String) set FolderReferenceDescription = ThisObject.V_description if(true==Parameters->HasAttribute("Target")) { set ObjectReference = Parameters->GetAttributeObject("Target") } if(true==ObjectReference->HasAttribute("V_description")) { set ObjectDescription = ObjectReference->GetAttributeString("V_description") } if (ObjectDescription==FolderReferenceDescription) { Validation = true } else { Validation = false } if (Validation == false) { Parameters.Message = "Cannot insert the Object under the Folder" Parameters.Severity=2 }
Version: 1 [Jul 2007] | Document created |
Version: 2 [Feb 2011] | Document updated |