Author: mar...@jb...
Date: 2006-06-12 22:04:04 -0400 (Mon, 12 Jun 2006)
New Revision: 4747
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaInvokers.stg
labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaRule.stg
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/globals_rule_test.drl
Log:
JBRULES-304 RuleBuilder incorrectly adds used identifiers for expressions
-Correct RuleBuilder to correctly pass used identifiers
-Correct templates to handle , for globals
Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaInvokers.stg
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaInvokers.stg 2006-06-12 22:12:18 UTC (rev 4746)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaInvokers.stg 2006-06-13 02:04:04 UTC (rev 4747)
@@ -68,7 +68,7 @@
<globalTypes, globals:{ type, identifier | <type> <identifier> = ( <type> ) workingMemory.getGlobal( "<identifier>" );<\n>}>
return <ruleClassName>.<methodName>(
- <declarations:{ declr | <declr.identifier>}; separator=",\n"><if(globals)>,<endif>
+ <declarations:{ declr | <declr.identifier>}; separator=",\n"><if(globals)><if(declarations)>,<endif><endif>
<globals:{ identifier | <identifier>}; separator=",\n"> );
}
@@ -131,7 +131,7 @@
<globalTypes, globals:{ type, identifier | <type> <identifier> = ( <type> ) workingMemory.getGlobal( "<identifier>" );<\n>}>
return <ruleClassName>.<methodName>(
- <declarations:{ declr | <declr.identifier>}; separator=",\n"><if(globals)>,<endif>
+ <declarations:{ declr | <declr.identifier>}; separator=",\n"><if(globals)><if(declarations)>,<endif><endif>
<globals:{ identifier | <identifier>}; separator=",\n"> );
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaRule.stg
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaRule.stg 2006-06-12 22:12:18 UTC (rev 4746)
+++ labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/semantics/java/javaRule.stg 2006-06-13 02:04:04 UTC (rev 4747)
@@ -1,7 +1,7 @@
group javaMethods;
returnValueMethod(declarations, declarationTypes, globals, globalTypes, methodName, text) ::= <<
-public static Object <methodName>(<declarationTypes, declarations:{ type, declr | <type> <declr.identifier>}; separator=","><if(globals)>,<endif> <globalTypes, globals:{ type, identifier | <type> <identifier>}; separator=","> ) throws Exception {
+public static Object <methodName>(<declarationTypes, declarations:{ type, declr | <type> <declr.identifier>}; separator=","><if(globals)><if(declarations)>,<endif><endif> <globalTypes, globals:{ type, identifier | <type> <identifier>}; separator=","> ) throws Exception {
return ( <text> );
}
>>
@@ -13,7 +13,7 @@
>>
evalMethod(declarations, declarationTypes, globals, globalTypes, methodName, text) ::= <<
-public static boolean <methodName>(<declarationTypes, declarations:{ type, declr | <type> <declr.identifier>}; separator=","><if(globals)>,<endif> <globalTypes, globals:{ type, identifier | <type> <identifier>}; separator=","> ) throws Exception {
+public static boolean <methodName>(<declarationTypes, declarations:{ type, declr | <type> <declr.identifier>}; separator=","><if(globals)><if(declarations)>,<endif><endif> <globalTypes, globals:{ type, identifier | <type> <identifier>}; separator=","> ) throws Exception {
return ( <text> );
}
>>
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-06-12 22:12:18 UTC (rev 4746)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java 2006-06-13 02:04:04 UTC (rev 4747)
@@ -88,6 +88,9 @@
final List list = new ArrayList();
workingMemory.setGlobal( "list",
list );
+
+ workingMemory.setGlobal( "string",
+ "stilton" );
final Cheese stilton = new Cheese( "stilton",
5 );
Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/globals_rule_test.drl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/globals_rule_test.drl 2006-06-12 22:12:18 UTC (rev 4746)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/globals_rule_test.drl 2006-06-13 02:04:04 UTC (rev 4747)
@@ -3,10 +3,14 @@
import org.drools.Cheese;
global java.util.List list
+global java.lang.String string
+
rule "global rule test"
when
- Cheese( )
+ Cheese( $type : type -> ( $type.equals( string ) ), type == ( string.toString() ) )
+ eval( string.equals( "stilton" ) )
+ eval( $type.equals( string ) )
then
list.add( new Integer(5) );
end
\ No newline at end of file
|