How to Implement the Relationship Establishment Validation Business Logic?

Technical Article

Abstract

This article details how you can implement the Relationship establishment validation Business Logic based on the knowledge scripting technology.

Business Logic Intent

For Materials

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:

  1. Warnings (Severity equals to 1): in such a case, the material is assigned.
  2. Errors (Severity equals to 2 or greater): in such a case, the assignment of the material is refused.

For Documents Attached to Objects

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.

For Documents Inserted into a Folder

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.

PLM Opening Definition

This section describes the objects defining the PLM opening: its global information, its kind of input object, its context object parameters.

General Information

PLM Opening ID PLMRelationEstablishmentCheck
Customization Intent Validation

Input Objects

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.

Context Object Parameters (in addition to standard Message and Severity parameters for validation BL)

For Materials

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.

For Documents Attached to Objects

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.

For Documents Inserted into a Folder

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.

Implementation Sample

For Materials

The following BL samples show how to:

  1. Check the material's maturity, the maturity of the support, the project and the kind of object on which the material is applied.
/*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
    }
  }
}

For Documents Attached to Objects

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 
}

For Documents Inserted into a Folder

The following BL sample shows how to:

  1. Check some attributes values (e.g. V_description) of the object inserted under the folder.
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 
}

Recommendations

References

History

Version: 1 [Jul 2007] Document created
Version: 2 [Feb 2011] Document updated