On 08/13/2013 03:02 PM, Joe Ammann wrote: > Hi all > > Trying to do the following: as one pattern of a rule, I want to bind a > variable to a fact with code "7001", or (if such a fact does not exist) > to one with the value "7000". > > Until now, I haven't been able to formulate this in one single rule, as > simple as it sounds - probably I'm just overlooking something basic ... > > Currently I have 2 rules: > > rule "R7012: UpdateInstrumentsIssuerFrom7001" > agenda-group "TRANSFER_TO_LIVE" > salience 100 > when > sirole : SourcingInstitutionRole(sourcing_Status == > SourcingStatus.IMPORTED, > roleCd == "7001" ) > insti : Institution ( ids != null, ids.sspFI == > sirole.institutionProviderId ) > instr : Instrument ( ids != null, ids.sspFI == sirole.providerId, > issuer.issuerId != insti.id ) > then > tlog.info("Modify issuer of {} to {} (from role code 7001)", instr, > insti); > modify (instr) { > issuer.issuerId = insti.id > } > end > > rule "R7012: UpdateInstrumentsIssuerFrom7000" > agenda-group "TRANSFER_TO_LIVE" > salience 100 > when > sirole : SourcingInstitutionRole(sourcing_Status == > SourcingStatus.IMPORTED, roleCd == "7000" ) > insti : Institution ( ids != null, ids.sspFI == > sirole.institutionProviderId ) > instr : Instrument ( ids != null, ids.sspFI == sirole.providerId, > issuer.issuerId != insti.id ) > not SourcingInstitutionRole(sourcing_Status == SourcingStatus.IMPORTED, > providerId == instr.ids.sspFI, > institutionProviderId == instr.ids.sspFI, > roleCd == "7001" ) > then > tlog.info("Modify issuer of {} to {} (from role code 7000)", instr, > insti); > modify (instr) { > issuer.issuerId = insti.id > } > end > > This seems to work, but I would have expected that it should be easy to > do this in one single rule !? But I just can't come up with a rule that > does what I want... > > How would I formulate such as rule? > BTW: Just realized that those 2 rules would - in some cases - result in and endless loop. Fixed that with a guard fact, but still my original question remains.
-- CU, Joe _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users