Multiple Objects in Constraint not working

22 views
Skip to the first unread message

Tanweer Gilani

unread,
5 May 2022, 11:29:2405/05/2022
to Drools Usage
Hi there:

I am performing a join in the WHEN clause for my rule and it is not firing when expected. The rule is as follows:

package com.hatch.datahub.h111503;

import java.lang.Number;
import java.util.UUID;

function UUID getNewGUID(){
    UUID uuid = UUID.randomUUID();  
   
        return uuid;
}

rule "H111503_MechanicalNewComponentAssociation"
    dialect "mvel"
    when
        $mech : H111503_MechanicalEquipment_WIP( supplyPackageNumber != null )
        $tsp : H111503_TechnicalSpecificationPackage_WIP( packageNumber == ( $mech.supplyPackageNumber + "-TSP" ) )
        $wpca : H111503_WorkPackageComponentAssociation_WIP( componentGlobalCorrelationID != $mech.sourceUniqueID, packageClass == "Technical Specification Package" )
    then
        H111503_WorkPackageComponentAssociation_WIP $NewWPCA = new H111503_WorkPackageComponentAssociation_WIP();
        $NewWPCA.setAffinityProject( $tsp.affinityProject );
        $NewWPCA.setComponentGlobalCorrelationID( $mech.sourceUniqueID.toString() );
        $NewWPCA.setPackageGlobalCorrelationID( $tsp.globalCorrelationID.toString() );
        $NewWPCA.setAssociationMethod( "TAG" );
        $NewWPCA.setPackageClass( "Technical Specification Package" );
        $NewWPCA.setAssociationId( getNewGUID().toString() );
        insert( $NewWPCA );
end

rule "H111503_MechanicalEditComponentAssociation"
    dialect "mvel"
    when
        $mech : H111503_MechanicalEquipment_WIP( supplyPackageNumber != null )
        $tsp : H111503_TechnicalSpecificationPackage_WIP( packageNumber == ( $mech.supplyPackageNumber + "-TSP" ) )
        $wpca : H111503_WorkPackageComponentAssociation_WIP( componentGlobalCorrelationID == $mech.sourceUniqueID, packageClass == "Technical Specification Package" )
    then
        $wpca.setAffinityProject( $tsp.affinityProject );
        $wpca.setComponentGlobalCorrelationID( $mech.sourceUniqueID.toString() );
        $wpca.setPackageGlobalCorrelationID( $tsp.globalCorrelationID.toString() );
        $wpca.setAssociationMethod( "TAG" );
        //$wpca.setPackageClass( "Technical Specification Package" );
        $wpca.setAssociationId( getNewGUID().toString() );
        update( $wpca );
end


Using one object in the constraint is not an issue.\

Please advise,
Thank you, 
Tanweer

Toshiya Kobayashi

unread,
18 Jun 2022, 19:55:0918/06/2022
to Drools Usage
Hi Tanweer,

Could you share a simple reproducer (a maven project) which reproduces the issue?

Regards,
Toshiya

2022年5月6日金曜日 0:29:24 UTC+9 mztan...@gmail.com:
Reply all
Reply to author
Forward
0 new messages