Bug 1039558

Summary: GRE: inserted fact using already defined variable
Product: [Retired] JBoss BRMS Platform 6 Reporter: Jiri Locker <jlocker>
Component: Business CentralAssignee: manstis
Status: CLOSED CURRENTRELEASE QA Contact: Jiri Locker <jlocker>
Severity: medium Docs Contact:
Priority: high    
Version: unspecifiedCC: etirelli
Target Milestone: ER6   
Target Release: 6.0.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-08-06 20:16:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
step1: insert fact #1
none
step2: reopen the rule
none
step3: insert fact #2
none
step4: validate none

Description Jiri Locker 2013-12-09 13:01:05 UTC
Description of problem:
New facts are assigned to variables before inserting into WM so that they can be initialized via setter methods. Variable names are generated by GRE and can be later changed by user. GRE generates names like fact0, fact1, etc.

The problem occurs after opening an existing rule that contains inserted fact assigned to fact0 variable. GRE doesn't recognize that fact0 is already used and starts generating variable names from fact0 again. When user adds another fact, it is assigned to fact0 and so fact0 is declared twice. This seems to be valid as long as the two facts are of the same type. However, if the *types are different*, the declaration is erroneous. Even so, nothing appears to be wrong until user validates the rule or project build is triggered. This can be easily fixed by assigning the new inserted fact to a different variable, but the validation (or build) error is very unexpected and confusing.

Version-Release number of selected component (if applicable):
ER5

How reproducible:
-

Steps to Reproduce:
1. create new rule
2. insert Fact1 and set value of one of its fields
3. save the rule and close it
4. reopen the rule
5. insert Fact2 and set value of one of its fields (notice that Fact1 and Fact2 are different types)
6. check rule source and validate it

Actual results:
Variable fact0 declared twice with different types. This is generated by GRE, user may save the rule without noticing if validation is skipped.

Expected results:
GRE should keep the rule valid when generating DRL source. It should detect that variable fact0 is already declared and choose next available name.

Additional info:

Comment 1 Jiri Locker 2013-12-09 13:02:12 UTC
Created attachment 834314 [details]
step1: insert fact #1

Comment 2 Jiri Locker 2013-12-09 13:02:53 UTC
Created attachment 834315 [details]
step2: reopen the rule

Comment 3 Jiri Locker 2013-12-09 13:03:31 UTC
Created attachment 834316 [details]
step3: insert fact #2

Comment 4 Jiri Locker 2013-12-09 13:03:56 UTC
Created attachment 834317 [details]
step4: validate

Comment 6 Jiri Locker 2014-01-02 09:48:08 UTC
Verified on ER6.