[jboss-svn-commits] JBL Code SVN: r17139 - in labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml: rules and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 9 22:36:12 EST 2007
Author: mark.proctor at jboss.com
Date: 2007-12-09 22:36:11 -0500 (Sun, 09 Dec 2007)
New Revision: 17139
Added:
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_Dump.drl
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseAccumulate.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseCollect.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseComplex.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseExists.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseForall.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFrom.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFunction.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseGlobal.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseImport.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseLhs.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParsePackageName.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseQuery.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRhs.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRule.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.drl
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.xml
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_accumulateall.drl
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_complex.drl
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_from.drl
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_simplerule.drl
Log:
JBRULES-1375 Create initial ePDL language parser implementation
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_Dump.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_Dump.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_Dump.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_Dump.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,24 @@
+package foo;
+
+rule "simple_rule"
+ salience 10
+ no-loop true
+ agenda-group "agenda-group"
+ activation-group "activation-group"
+ when
+ foo2 : Bar( a ( > 60 && < 70 ) || ( > 50 && < 55 ) && a3 == "black" || a == 40 && a3 == "pink" || a == 12 && a3 == "yellow" || a3 == "blue")
+ foo3 : Bar( a == 3 || == 4, a3 == "hello", a4 == null )
+ foo4 : Bar( a4 : a != 4 && != 5)
+ foo5 : Bar( b == (a4 + 1) || > a4)
+ foo6 : Bar( a4 : a, b == 6)
+ foo7 : Bar( a4 : a, b4 : b)
+ $cheeseList : ArrayList(size > 2) from collect( Cheese( type == $likes ) );
+ Baz()
+ then
+ if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+end
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseAccumulate.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseAccumulate.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseAccumulate.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseAccumulate.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="import java.util.List"/>
+ <import name="org.drools.Person" />
+ <import name="org.drools.Cheese" />
+ <import name="org.drools.Cheesery" />
+
+ <global identifier="cheesery" type="Cheesery" />
+ <global identifier="list1" type="List" />
+
+ <rule name="simple_rule">
+ <rule-attribute name="salience" value="10" />
+ <rule-attribute name="no-loop" value="true" />
+ <rule-attribute name="agenda-group" value="agenda-group" />
+ <rule-attribute name="activation-group" value="activation-group" />
+
+ <lhs>
+ <pattern identifier="cheese" object-type="Cheese">
+ <from>
+ <accumulate>
+ <pattern object-type="Person"></pattern>
+ <init>
+ int total = 0;
+ </init>
+ <action>
+ total += $cheese.getPrice();
+ </action>
+ <result>
+ new Integer( total ) );
+ </result>
+ </accumulate>
+ </from>
+ </pattern>
+
+ <pattern identifier="max" object-type="Number">
+ <from>
+ <accumulate>
+ <pattern identifier="cheese" object-type="Cheese"></pattern>
+ <external-function evaluator="max" expression="$price"/>
+ </accumulate>
+ </from>
+ </pattern>
+ </lhs>
+ <rhs>
+ list1.add( $cheese );
+ </rhs>
+ </rule>
+
+ <rule name="multipatternaccumulate_rule">
+ <rule-attribute name="salience" value="10" />
+ <lhs>
+ <pattern identifier="cheese" object-type="Cheese">
+ <from>
+ <accumulate>
+ <and-conditional-element>
+ <pattern object-type="Milk"></pattern>
+ <pattern object-type="Cup"></pattern>
+ </and-conditional-element>
+
+ <init>
+ int total = 0;
+ </init>
+ <action>
+ total += $cheese.getPrice();
+ </action>
+ <result>
+ new Integer( total ) );
+ </result>
+ </accumulate>
+ </from>
+ </pattern>
+ </lhs>
+ <rhs>
+ list1.add( $cheese );
+ </rhs>
+ </rule>
+
+
+
+</package>
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseCollect.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseCollect.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseCollect.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseCollect.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample" xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="import java.util.List"/>
+ <import name="org.drools.Cheese"/>
+ <import name="org.drools.Cheesery"/>
+
+ <global identifier="cheesery" type="Cheesery"/>
+ <global identifier="list" type="List"/>
+
+ <rule name="simple_rule">
+ <rule-attribute name="salience" value="10"/>
+ <rule-attribute name="no-loop" value="true"/>
+ <rule-attribute name="agenda-group" value="agenda-group"/>
+ <rule-attribute name="activation-group" value="activation-group"/>
+
+ <lhs>
+ <pattern identifier="cheese" object-type="Cheese" >
+ <field-constraint field-name="type">
+ <literal-restriction evaluator="==" value="1"/>
+ </field-constraint>
+ <from>
+ <collect>
+ <pattern object-type="Person">
+ <field-constraint field-name="hair">
+ <literal-restriction evaluator="==" value="pink" />
+ </field-constraint>
+ </pattern>
+ </collect>
+ </from>
+ </pattern>
+ </lhs>
+ <rhs> list.add( $cheese ); </rhs>
+ </rule>
+
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseComplex.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseComplex.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseComplex.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseComplex.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="pt.inescporto.cec.rules"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+ <import name="pt.inescporto.cec.entities.SetupInUse"/>
+ <import name="pt.inescporto.cec.entities.SetupUse"/>
+ <import name="pt.inescporto.cec.entities.ArtigoProducao"/>
+ <import name="pt.inescporto.cec.entities.Parameter"/>
+ <import name="pt.inescporto.cec.entities.BestParms"/>
+ <import name="pt.inescporto.cec.entities.AccaoInspeccaoOperacao"/>
+ <import name="pt.inescporto.cec.entities.MelhorEmNaoConformidades"/>
+ <import name="pt.inescporto.cec.entities.OtherInspectionMethod"/>
+ <import name="pt.inescporto.cec.entities.AccaoInspeccao"/>
+ <rule name="ruleBestProductionOrderCreator">
+ <lhs>
+ <pattern object-type="AccaoInspeccao">
+ <field-binding field-name="recursoID" identifier="resource"/>
+ <field-constraint field-name="artigoID">
+ <literal-restriction evaluator="==" value="3"/>
+ </field-constraint>
+ <field-binding field-name="operacaoID" identifier="operation"/>
+ <field-binding field-name="ordemProducaoID" identifier="ProductionOrder"/>
+ <field-binding field-name="recursoID" identifier="resourceID"/>
+ <field-binding field-name="accaoInspeccaoID" identifier="InspectionAction"/>
+ </pattern>
+ <pattern object-type="AccaoInspeccaoOperacao">
+ <field-binding field-name="inspAccaoOperacaoID" identifier="inspectionActionOperation"/>
+ <field-constraint field-name="inspectionActionID">
+ <variable-restriction evaluator="==" identifier="InspectionAction"/>
+ </field-constraint>
+ </pattern>
+ <pattern object-type="OtherInspectionMethod">
+ <field-binding field-name="numeroNaoConformidades" identifier="NCNumber"/>
+ <field-constraint field-name="inspAccaoOperacaoID">
+ <variable-restriction evaluator="==" identifier="inspectionActionOperation"/>
+ </field-constraint>
+ </pattern>
+ <not>
+ <pattern object-type="MelhorEmNaoConformidades">
+ <field-constraint field-name="operacaoID">
+ <variable-restriction evaluator="==" identifier="operation"/>
+ </field-constraint>
+ <field-constraint field-name="recursoID">
+ <variable-restriction evaluator="==" identifier="resource"/>
+ </field-constraint>
+ </pattern>
+ </not>
+ </lhs>
+ <rhs>insert(new MelhorEmNaoConformidades(ProductionOrder,NCNumber,operation,resource));</rhs>
+ </rule>
+ <rule name="Best Checker">
+ <lhs>
+ <pattern object-type="AccaoInspeccao">
+ <field-constraint field-name="artigoID">
+ <literal-restriction evaluator="==" value="3"/>
+ </field-constraint>
+ <field-binding field-name="recursoID" identifier="resource"/>
+ <field-binding field-name="operacaoID" identifier="operation"/>
+ <field-binding field-name="ordemProducaoID" identifier="ProductionOrder"/>
+ <field-binding field-name="recursoID" identifier="resourceID"/>
+ <field-binding field-name="accaoInspeccaoID" identifier="InspectionAction"/>
+ </pattern>
+ <pattern object-type="AccaoInspeccaoOperacao">
+ <field-binding field-name="inspAccaoOperacaoID" identifier="inspectionActionOperation"/>
+ <field-constraint field-name="inspectionActionID">
+ <variable-restriction evaluator="==" identifier="InspectionAction"/>
+ </field-constraint>
+ </pattern>
+ <pattern object-type="OtherInspectionMethod">
+ <field-binding field-name="numeroNaoConformidades" identifier="NCNumber"/>
+ <field-constraint field-name="inspAccaoOperacaoID">
+ <variable-restriction evaluator="==" identifier="inspectionActionOperation"/>
+ </field-constraint>
+ </pattern>
+ <pattern identifier="TheBest" object-type="MelhorEmNaoConformidades">
+ <field-constraint field-name="operacaoID">
+ <variable-restriction evaluator="==" identifier="operation"/>
+ </field-constraint>
+ <field-constraint field-name="recursoID">
+ <variable-restriction evaluator="==" identifier="resource"/>
+ </field-constraint>
+ <field-constraint field-name="numeroDefeitos">
+ <variable-restriction evaluator=">" identifier="NCNumber"/>
+ </field-constraint>
+ </pattern>
+ </lhs>
+ <rhs>TheBest.setNumeroDefeitos(NCNumber);
+TheBest.setOrdemProducaoID(ProductionOrder);
+update(TheBest);
+</rhs>
+ </rule>
+ <rule name="ruleBestParametersCreator">
+ <rule-attribute name="salience" value="-100"/>
+ <lhs>
+ <pattern object-type="MelhorEmNaoConformidades">
+ <field-binding field-name="ordemProducaoID" identifier="$poID"/>
+ <field-binding field-name="numeroDefeitos" identifier="$NC"/>
+ </pattern>
+ <pattern object-type="SetupInUse">
+ <field-binding field-name="setupUseID" identifier="$setup"/>
+ <field-constraint field-name="productionOrderID">
+ <variable-restriction evaluator="==" identifier="$poID"/>
+ </field-constraint>
+ </pattern>
+ <pattern identifier="$p" object-type="Parameter">
+ <field-binding field-name="parameterID" identifier="$parID"/>
+ <field-constraint field-name="setupUseID">
+ <variable-restriction evaluator="==" identifier="$setup"/>
+ </field-constraint>
+ </pattern>
+ <not>
+ <pattern object-type="BestParms">
+ <field-constraint field-name="parameterID">
+ <variable-restriction evaluator="==" identifier="$parID"/>
+ </field-constraint>
+ </pattern>
+ </not>
+ </lhs>
+ <rhs>BestParms newBest=new BestParms();
+newBest.setParameterID($parID);
+newBest.setNominalValue(new Float($p.getNominalValue()));
+newBest.setMaxLimit(new Float($p.getMaxLimit()));
+newBest.setMinLimit(new Float($p.getMinLimit()));
+newBest.setMaxLimitAlarm(new Float($p.getMaxLimitAlarm()));
+newBest.setMinLimitAlarm(new Float($p.getMinLimitAlarm()));
+newBest.setNonConformities(new Float($NC));
+insert(newBest);
+</rhs>
+ </rule>
+ <rule name="ruleBestParametersChecker">
+ <rule-attribute name="salience" value="-100"/>
+ <lhs>
+ <pattern object-type="MelhorEmNaoConformidades">
+ <field-binding field-name="ordemProducaoID" identifier="$poID"/>
+ <field-binding field-name="numeroDefeitos" identifier="$NC"/>
+ </pattern>
+ <pattern object-type="SetupInUse">
+ <field-binding field-name="setupUseID" identifier="$setup"/>
+ <field-constraint field-name="productionOrderID">
+ <variable-restriction evaluator="==" identifier="$poID"/>
+ </field-constraint>
+ </pattern>
+ <pattern identifier="$p" object-type="Parameter">
+ <field-binding field-name="parameterID" identifier="$parID"/>
+ <field-constraint field-name="setupUseID">
+ <variable-restriction evaluator="==" identifier="$setup"/>
+ </field-constraint>
+ </pattern>
+ <pattern identifier="$newBest" object-type="Parameter">
+ <field-constraint field-name="parameterID">
+ <variable-restriction evaluator="==" identifier="$parID"/>
+ </field-constraint>
+ <field-constraint field-name="nonConformities">
+ <variable-restriction evaluator=">" identifier="$NC"/>
+ </field-constraint>
+ </pattern>
+ </lhs>
+ <rhs>$newBest.setNominalValue(new Float(p.getNominalValue()));
+$newBest.setMaxLimit(new Float(p.getMaxLimit()));
+$newBest.setMinLimit(new Float(p.getMinLimit()));
+$newBest.setMaxLimitAlarm(new Float(p.getMaxLimitAlarm()));
+$newBest.setMinLimitAlarm(new Float(p.getMinLimitAlarm()));
+$newBest.setNonConformities(new Float($NC));
+update($newBest);
+</rhs>
+ </rule>
+ <rule name="print">
+ <rule-attribute name="salience" value="-110"/>
+ <lhs>
+ <pattern identifier="bp" object-type="BestParms"> </pattern>
+ </lhs>
+ <rhs>System.out.println("Parameter: "+bp.getParameterID()+" Value: "+bp.getNominalValue()+" NC: "+bp.getNonConformities());
+</rhs>
+ </rule>
+</package>
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseExists.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseExists.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseExists.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseExists.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample" xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <rule name="simple_rule">
+ <lhs>
+ <exists>
+ <pattern object-type="Person">
+ <field-constraint field-name="likes">
+ <variable-restriction evaluator="==" identifier="type"/>
+ </field-constraint>
+ </pattern>
+ </exists>
+
+ <not>
+ <exists>
+ <pattern object-type="Cheese">
+ <field-constraint field-name="likes">
+ <variable-restriction evaluator="==" identifier="type"/>
+ </field-constraint>
+ </pattern>
+ </exists>
+ </not>
+ </lhs>
+ <rhs> list.add( $cheese ); </rhs>
+ </rule>
+
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseForall.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseForall.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseForall.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseForall.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <global identifier="results" type="java.util.List" />
+
+<rule name="simple_rule">
+ <rule-attribute name="salience" value="10" />
+ <rule-attribute name="no-loop" value="true" />
+ <rule-attribute name="agenda-group" value="agenda-group" />
+ <rule-attribute name="activation-group" value="activation-group" />
+
+ <lhs>
+ <forall>
+ <pattern object-type="State">
+ <field-binding field-name="state" identifier="state" />
+ </pattern>
+
+ <pattern object-type="Person">
+ <field-constraint field-name="status">
+ <variable-restriction evaluator="==" identifier="state" />
+ </field-constraint>
+ <field-binding field-name="likes" identifier="likes" />
+ </pattern>
+
+ <pattern object-type="Cheese">
+ <field-binding field-name="type" identifier="likes" />
+ </pattern>
+ </forall>
+
+ </lhs>
+ <rhs>
+ results.add("OK");
+ </rhs>
+</rule>
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFrom.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseFrom.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFrom.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFrom.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="import java.util.List"/>
+ <import name="org.drools.Cheese" />
+ <import name="org.drools.Cheesery" />
+
+ <global identifier="cheesery" type="Cheesery" />
+ <global identifier="list1" type="List" />
+
+<rule name="simple_rule">
+ <rule-attribute name="salience" value="10" />
+ <rule-attribute name="no-loop" value="true" />
+ <rule-attribute name="agenda-group" value="agenda-group" />
+ <rule-attribute name="activation-group" value="activation-group" />
+
+ <lhs>
+ <pattern identifier="cheese" object-type="Cheese" >
+ <from>
+ <expression>
+ cheesery.getCheeses(i+4)
+ </expression>
+ </from>
+ </pattern>
+ </lhs>
+ <rhs>
+ list1.add( $cheese );
+ </rhs>
+</rule>
+
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFunction.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseFunction.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFunction.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseFunction.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+
+ <function return-type="void" name="myFunc">
+ <parameter identifier="foo" type="Bar" />
+ <parameter identifier="bada" type="Bing" />
+
+ <body>
+ System.out.println("hello world");
+ </body>
+ </function>
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseGlobal.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseGlobal.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseGlobal.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseGlobal.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseImport.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseImport.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseImport.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseImport.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+ <importfunction name="org.drools.function" />
+
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseLhs.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseLhs.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseLhs.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseLhs.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+
+ <function return-type="void" name="myFunc">
+ <parameter identifier="foo" type="Bar" />
+ <parameter identifier="bada" type="Bing" />
+
+ <body>
+ System.out.println("hello world");
+ </body>
+ </function>
+
+ <rule name="my rule">
+ <lhs>
+
+ <and-conditional-element></and-conditional-element>
+
+ <or-conditional-element></or-conditional-element>
+
+ <pattern object-type="Foo" >
+ </pattern>
+
+ <pattern identifier="bar" object-type="Bar" >
+ </pattern>
+
+ <pattern object-type="Foo">
+ <field-constraint field-name="field1">
+ <literal-restriction evaluator="==" value="value1" />
+ <return-value-restriction evaluator="==">1==1</return-value-restriction>
+ <variable-restriction evaluator="==" identifier="var1" />
+ </field-constraint>
+
+ <predicate field-name="field1" identifier="var1">1==1</predicate>
+
+ <field-binding field-name="field1" identifier="var1" />
+ </pattern>
+
+ <not>
+ <pattern object-type="Bar" />
+ </not>
+
+ <exists>
+ <pattern object-type="Bar" />
+ </exists>
+
+ <and-conditional-element>
+ <pattern object-type="Yada"/>
+ <or-conditional-element>
+ <pattern object-type="Bar"/>
+ </or-conditional-element>
+
+ </and-conditional-element>
+
+ <or-conditional-element>
+ <pattern object-type="Zaa"/>
+ <and-conditional-element>
+ <pattern object-type="Foo"/>
+ </and-conditional-element>
+ </or-conditional-element>
+ <eval>1==1</eval>
+ </lhs>
+
+ <rhs>
+ </rhs>
+ </rule>
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParsePackageName.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParsePackageName.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParsePackageName.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParsePackageName.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseQuery.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseQuery.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseQuery.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseQuery.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+
+ <function return-type="void" name="myFunc">
+ <parameter identifier="foo" type="Bar" />
+ <parameter identifier="bada" type="Bing" />
+
+ <body>
+ System.out.println("hello world");
+ </body>
+ </function>
+
+ <query name="my query">
+ <lhs>
+ <pattern object-type="Foo" />
+ </lhs>
+ </query>
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRhs.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseRhs.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRhs.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRhs.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+
+ <function return-type="void" name="myFunc">
+ <parameter identifier="foo" type="Bar" />
+ <parameter identifier="bada" type="Bing" />
+
+ <body>
+ System.out.println("hello world");
+ </body>
+ </function>
+
+ <rule name="my rule">
+ <lhs>
+ </lhs>
+
+ <rhs>
+ System.out.println( "hello" );
+ </rhs>
+ </rule>
+</package>
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRule.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_ParseRule.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRule.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_ParseRule.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<package name="com.sample"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+
+ <import name="java.util.HashMap" />
+ <import name="org.drools.*" />
+
+ <global identifier="x" type="com.sample.X" />
+ <global identifier="yada" type="com.sample.Yada" />
+
+ <function return-type="void" name="myFunc">
+ <parameter identifier="foo" type="Bar" />
+ <parameter identifier="bada" type="Bing" />
+
+ <body>
+ System.out.println("hello world");
+ </body>
+ </function>
+
+<rule name="simple_rule">
+ <rule-attribute name="salience" value="10" />
+ <rule-attribute name="no-loop" value="true" />
+ <rule-attribute name="agenda-group" value="agenda-group" />
+ <rule-attribute name="activation-group" value="activation-group" />
+
+ <lhs>
+ <pattern identifier="foo2" object-type="Bar" >
+ <or-constraint-connective>
+ <and-constraint-connective>
+ <field-constraint field-name="a">
+ <or-restriction-connective>
+ <and-restriction-connective>
+ <literal-restriction evaluator=">" value="60" />
+ <literal-restriction evaluator="<" value="70" />
+ </and-restriction-connective>
+ <and-restriction-connective>
+ <literal-restriction evaluator="<" value="50" />
+ <literal-restriction evaluator=">" value="55" />
+ </and-restriction-connective>
+ </or-restriction-connective>
+ </field-constraint>
+
+ <field-constraint field-name="a3">
+ <literal-restriction evaluator="==" value="black" />
+ </field-constraint>
+ </and-constraint-connective>
+
+ <and-constraint-connective>
+ <field-constraint field-name="a">
+ <literal-restriction evaluator="==" value="40" />
+ </field-constraint>
+
+ <field-constraint field-name="a3">
+ <literal-restriction evaluator="==" value="pink" />
+ </field-constraint>
+ </and-constraint-connective>
+
+ <and-constraint-connective>
+ <field-constraint field-name="a">
+ <literal-restriction evaluator="==" value="12"/>
+ </field-constraint>
+
+ <field-constraint field-name="a3">
+ <or-restriction-connective>
+ <literal-restriction evaluator="==" value="yellow"/>
+ <literal-restriction evaluator="==" value="blue" />
+ </or-restriction-connective>
+ </field-constraint>
+ </and-constraint-connective>
+ </or-constraint-connective>
+ </pattern>
+
+ <not>
+ <pattern object-type="Person">
+ <field-constraint field-name="likes">
+ <variable-restriction evaluator="==" identifier="type"/>
+ </field-constraint>
+ </pattern>
+
+ <exists>
+ <pattern object-type="Person">
+ <field-constraint field-name="likes">
+ <variable-restriction evaluator="==" identifier="type"/>
+ </field-constraint>
+ </pattern>
+ </exists>
+ </not>
+
+ <or-conditional-element>
+ <pattern identifier="foo3" object-type="Bar" >
+ <field-constraint field-name="a">
+ <or-restriction-connective>
+ <literal-restriction evaluator="==" value="3" />
+ <literal-restriction evaluator="==" value="4" />
+ </or-restriction-connective>
+ </field-constraint>
+ <field-constraint field-name="a3">
+ <literal-restriction evaluator="==" value="hello" />
+ </field-constraint>
+ <field-constraint field-name="a4">
+ <literal-restriction evaluator="==" value="null" />
+ </field-constraint>
+ </pattern>
+
+ <pattern identifier="foo4" object-type="Bar" >
+ <field-binding field-name="a" identifier="a4" />
+ <field-constraint field-name="a">
+ <literal-restriction evaluator="!=" value="4" />
+ <literal-restriction evaluator="!=" value="5" />
+ </field-constraint>
+ </pattern>
+ </or-conditional-element>
+
+ <pattern identifier="foo5" object-type="Bar" >
+ <field-constraint field-name="b">
+ <or-restriction-connective>
+ <return-value-restriction evaluator="==" >a4 + 1</return-value-restriction>
+ <variable-restriction evaluator=">" identifier="a4" />
+ <qualified-identifier-restriction evaluator="==">
+ org.drools.Bar.BAR_ENUM_VALUE
+ </qualified-identifier-restriction>
+ </or-restriction-connective>
+ </field-constraint>
+ </pattern>
+
+ <pattern identifier="foo6" object-type="Bar" >
+ <field-binding field-name="a" identifier="a4" />
+ <field-constraint field-name="b">
+ <literal-restriction evaluator="==" value="6" />
+ </field-constraint>
+ </pattern>
+
+ <pattern identifier="foo7" object-type="Bar" >
+ <field-binding field-name="a" identifier="a4" />
+ <field-binding field-name="b" identifier="b4" />
+ </pattern>
+ <pattern object-type="Baz" > </pattern>
+ </lhs>
+ <rhs>
+ if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+ </rhs>
+</rule>
+
+<rule name="Check_NotNullof_rfqId">
+
+<rule-attribute name="agenda-group" value="Check" />
+
+<lhs><pattern object-type="RFQBean" >
+
+<or-constraint-connective><field-constraint field-name="m_rfqId">
+
+<literal-restriction evaluator="==" value="null" />
+
+</field-constraint>
+
+<field-constraint field-name="m_rfqId">
+
+<literal-restriction evaluator="==" value="" />
+
+</field-constraint>
+
+</or-constraint-connective>
+
+</pattern>
+
+</lhs><rhs> response.setStatus("For RFQ Bean: The value of m_rfqId is null.");
+
+System.out.println(response.getStatus());
+
+</rhs>
+
+</rule>
+
+</package>
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_RoundTrip.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,61 @@
+package foo;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.utilArrayList;
+
+global HashMap m;
+global HashSet s;
+global org.drools.Person p;
+
+import function org.drools.xml.DumperTest.testStaticMethod1;
+import function org.drools.xml.DumperTest.testStaticMethod2;
+import function org.drools.xml.DumperTest.testStaticMethod3;
+
+rule "simple_rule"
+ salience 10
+ no-loop true
+ agenda-group "agenda-group"
+ activation-group "activation-group"
+ ruleflow-group "xxx"
+ lock-on-active true
+ auto-focus true
+ date-effective "01-Jan-2007"
+ date-expires "01-Feb-2007"
+ when
+ foo2 : Bar( a ( > 60 && < 70 ) || ( > 50 && < 55 ) && a3 == "black" || a == 40 && a3 == "pink" || a == 12 && a3 == "yellow" || a3 == "blue")
+ foo3 : Bar( a == 3 || == 4, a3 == "hello", a4 == null )
+ foo4 : Bar( a4 : a != 4 && != 5)
+ foo5 : Bar( b == (a4 + 1) || > a4)
+ foo6 : Bar( a4 : a, b == 6)
+ foo7 : Bar( a4 : a, b4 : b)
+ $cheeseList : ArrayList(size > 2) from collect( Cheese( type == $likes ) );
+ Baz()
+ then
+ if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+ testStaticMethod1();
+ testStaticMethod2();
+ testStaticMethod3();
+end
+
+rule "simple_rule2"
+ salience (10 + a)
+ dialect "mvel"
+ when
+ foo4 : Bar( a4 : a != 4 && != 5)
+ then
+ if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+ testStaticMethod1();
+ testStaticMethod2();
+ testStaticMethod3();
+end
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.xml (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_RoundTrip.xml)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.xml (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_RoundTrip.xml 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<package name="foo"
+ xmlns="http://drools.org/drools-4.0"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
+<import name="java.util.HashMap" />
+<import name="java.util.HashSet" />
+<import name="java.utilArrayList" />
+
+<global identifier="m" type="HashMap" />
+<global identifier="s" type="HashSet" />
+<global identifier="p" type="org.drools.Person" />
+
+<importfunction name="org.drools.xml.DumperTest.testStaticMethod1"/>
+<importfunction name="org.drools.xml.DumperTest.testStaticMethod2"/>
+<importfunction name="org.drools.xml.DumperTest.testStaticMethod3"/>
+
+
+<rule name="simple_rule">
+<rule-attribute name="salience" value="10" />
+<rule-attribute name="no-loop" value="true" />
+<rule-attribute name="agenda-group" value="agenda-group" />
+<rule-attribute name="activation-group" value="activation-group" />
+<rule-attribute name="ruleflow-group" value="xxx" />
+<rule-attribute name="lock-on-active" value="true" />
+<rule-attribute name="auto-focus" value="true" />
+<rule-attribute name="date-effective" value="01-Jan-2007" />
+<rule-attribute name="date-expires" value="01-Feb-2007" />
+
+<lhs><pattern identifier="foo2" object-type="Bar" >
+<or-constraint-connective><and-constraint-connective><field-constraint field-name="a">
+<or-restriction-connective><and-restriction-connective><literal-restriction evaluator=">" value="60" />
+
+<literal-restriction evaluator="<" value="70" />
+
+
+</and-restriction-connective>
+<and-restriction-connective><literal-restriction evaluator=">" value="50" />
+
+<literal-restriction evaluator="<" value="55" />
+
+
+</and-restriction-connective>
+
+</or-restriction-connective>
+</field-constraint>
+<field-constraint field-name="a3">
+<literal-restriction evaluator="==" value="black" />
+
+</field-constraint>
+
+</and-constraint-connective>
+<and-constraint-connective><field-constraint field-name="a">
+<literal-restriction evaluator="==" value="40" />
+
+</field-constraint>
+<field-constraint field-name="a3">
+<literal-restriction evaluator="==" value="pink" />
+
+</field-constraint>
+
+</and-constraint-connective>
+<and-constraint-connective><field-constraint field-name="a">
+<literal-restriction evaluator="==" value="12" />
+
+</field-constraint>
+<field-constraint field-name="a3">
+<literal-restriction evaluator="==" value="yellow" />
+
+</field-constraint>
+
+</and-constraint-connective>
+<field-constraint field-name="a3">
+<literal-restriction evaluator="==" value="blue" />
+
+</field-constraint>
+
+</or-constraint-connective>
+
+
+</pattern>
+
+<pattern identifier="foo3" object-type="Bar" >
+<field-constraint field-name="a">
+<or-restriction-connective><literal-restriction evaluator="==" value="3" />
+
+<literal-restriction evaluator="==" value="4" />
+
+
+</or-restriction-connective>
+</field-constraint>
+<field-constraint field-name="a3">
+<literal-restriction evaluator="==" value="hello" />
+
+</field-constraint>
+<field-constraint field-name="a4">
+<literal-restriction evaluator="==" value="null" />
+
+</field-constraint>
+
+
+</pattern>
+
+<pattern identifier="foo4" object-type="Bar" >
+<field-binding field-name="a" identifier="a4" />
+
+<field-constraint field-name="a">
+<literal-restriction evaluator="!=" value="4" />
+<literal-restriction evaluator="!=" value="5" />
+
+</field-constraint>
+
+
+</pattern>
+
+<pattern identifier="foo5" object-type="Bar" >
+<field-constraint field-name="b">
+<or-restriction-connective><return-value-restriction evaluator="==" >a4 + 1</return-value-restriction>
+
+<variable-restriction evaluator=">" identifier="a4" />
+
+
+</or-restriction-connective>
+</field-constraint>
+
+
+</pattern>
+
+<pattern identifier="foo6" object-type="Bar" >
+<field-binding field-name="a" identifier="a4" />
+
+<field-constraint field-name="b">
+<literal-restriction evaluator="==" value="6" />
+
+</field-constraint>
+
+
+</pattern>
+
+<pattern identifier="foo7" object-type="Bar" >
+<field-binding field-name="a" identifier="a4" />
+
+<field-binding field-name="b" identifier="b4" />
+
+
+
+</pattern>
+
+<pattern identifier="$cheeseList" object-type="ArrayList" >
+<field-constraint field-name="size">
+<literal-restriction evaluator=">" value="2" />
+
+</field-constraint>
+
+
+<from> <collect><pattern object-type="Cheese" >
+<field-constraint field-name="type">
+<variable-restriction evaluator="==" identifier="$likes" />
+
+</field-constraint>
+
+
+</pattern>
+ </collect> </from> </pattern>
+
+<pattern object-type="Baz" >
+
+
+</pattern>
+
+
+</lhs>
+
+<rhs> if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+ testStaticMethod1();
+ testStaticMethod2();
+ testStaticMethod3();
+</rhs>
+
+
+</rule>
+
+<rule name="simple_rule2">
+<rule-attribute name="salience" value="(10 + a)" />
+<rule-attribute name="dialect" value="mvel" />
+
+<lhs><pattern identifier="foo4" object-type="Bar" >
+<field-binding field-name="a" identifier="a4" />
+
+<field-constraint field-name="a">
+<literal-restriction evaluator="!=" value="4" />
+<literal-restriction evaluator="!=" value="5" />
+
+</field-constraint>
+
+
+</pattern>
+
+
+</lhs><rhs> if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+ testStaticMethod1();
+ testStaticMethod2();
+ testStaticMethod3();
+</rhs>
+</rule>
+</package>
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_accumulateall.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_accumulateall.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_accumulateall.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_accumulateall.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,79 @@
+package org.drools.test;
+
+import org.drools.Cheese;
+import org.drools.Person;
+import org.drools.Cheesery;
+
+global java.util.List results;
+
+rule "AccumulateTest" salience 100
+ when
+ $totalAmount : Integer() from accumulate( $cheese : Cheese( ),
+ init( int total = 0; ),
+ action( total += $cheese.getPrice(); ),
+ result( new Integer( total ) ) );
+ then
+ //System.out.println("Total amount = US$ "+$totalAmount );
+ results.add($totalAmount);
+end
+
+rule "Accumulate with Bindings" salience 90
+ when
+ $person : Person( name == "Bob", $likes : likes )
+ $totalAmount : Integer() from accumulate( $cheese : Cheese( type == $likes ),
+ init( int total = 0; ),
+ action( total += $cheese.getPrice(); ),
+ result( new Integer( total ) ) );
+ then
+ //System.out.println($person.getName() +" will spend US$ "+ $totalAmount + " buying cheese");
+ results.add($totalAmount);
+end
+
+rule "Constraints everywhere" salience 80
+ when
+ $person : Person( $likes : likes )
+ $cheesery : Cheesery( totalAmount > 100 )
+ from accumulate( $cheese : Cheese( type == $likes ),
+ init( Cheesery cheesery = new Cheesery(); ),
+ action( cheesery.addCheese( $cheese ); ),
+ result( cheesery ) );
+ then
+ //System.out.println($person.getName() +" is spending a lot buying cheese ( US$ "+$cheesery.getTotalAmount()+" )!");
+ results.add(new Integer($cheesery.getTotalAmount()));
+end
+
+rule "Source pattern binds" salience 70
+ when
+ $person : Person( name == "Bob", $likes : likes )
+ $totalAmount : Integer() from accumulate( $cheese : Cheese( type == $likes, $price: price ),
+ init( int total = 0; ),
+ action( total += $price; ),
+ result( new Integer( total ) ) );
+ then
+ //System.out.println($person.getName() +" will spend US$ "+ $totalAmount + " buying cheese");
+ results.add($totalAmount);
+end
+
+rule "Accumulate with previous Bindings" salience 60
+ when
+ $person : Person( name == "Bob", $likes : likes, $age : age )
+ $totalAmount : Integer() from accumulate( $cheese : Cheese( type == $likes, $price : price ),
+ init( int total = $age * 10; ),
+ action( total += $price; ),
+ result( new Integer( total ) ) );
+ then
+ results.add($totalAmount);
+end
+
+
+rule "External Function" salience 80
+ when
+ $person : Person( $likes : likes )
+ $max : Number( intValue >= 5 )
+ from accumulate( $cheese : Cheese( type == $likes, $price : price ),
+ max( $price ) );
+ then
+ results.add( $max );
+end
+
+
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_complex.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_complex.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_complex.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_complex.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,83 @@
+package rules;
+
+
+import pt.inescporto.cec.entities.SetupUse;
+import pt.inescporto.cec.entities.SetupInUse;
+import pt.inescporto.cec.entities.Parameter;
+import pt.inescporto.cec.entities.OrdemFabrico;
+import pt.inescporto.cec.entities.AccaoInspeccao;
+import pt.inescporto.cec.entities.AccaoInspeccaoOperacao;
+import pt.inescporto.cec.entities.MelhorEmNaoConformidades;
+import pt.inescporto.cec.entities.OtherInspectionMethod;
+import pt.inescporto.cec.entities.BestParms;
+
+
+rule "ruleBestProductionOrderCreator"
+when
+ AccaoInspeccao( artigoID == 3 , $operID: operacaoID , $resourceID: recursoID, $ProdOrderID: ordemProducaoID, $IAID: accaoInspeccaoID )
+ AccaoInspeccaoOperacao( inspectionActionID == $IAID, $tmp: inspAccaoOperacaoID )
+ OtherInspectionMethod(inspActionOperacaoID == $tmp, $NCNumber: numeroNaoConformidades )
+ not (MelhorEmNaoConformidades( operacaoID == $operID, recursoID == $resourceID ) )
+ then
+ insert(new MelhorEmNaoConformidades($ProdOrderID,$NCNumber,$operID,$resourceID));
+end
+
+rule "ruleBestProductionOrderChecker"
+when
+ AccaoInspeccao( artigoID ==3 , $operID: operacaoID, $resourceID: recursoID, $ProdOrderID: ordemProducaoID, $IAID: accaoInspeccaoID )
+ AccaoInspeccaoOperacao( inspectionActionID == $IAID, $tmp: inspAccaoOperacaoID )
+ OtherInspectionMethod( inspActionOperacaoID == $tmp, $NCNumber: numeroNaoConformidades )
+ $t: MelhorEmNaoConformidades( operacaoID == $operID, recursoID == $resourceID, numeroDefeitos > $NCNumber )
+ then
+ $t.setNumeroDefeitos($NCNumber);
+ $t.setOrdemProducaoID($ProdOrderID);
+ update($t);
+end
+
+rule "ruleBestParametersCreator"
+salience -100
+when
+ MelhorEmNaoConformidades($poID: ordemProducaoID, $nonConformities: numeroDefeitos )
+ SetupInUse( $setup: setupUseID , productionOrderID == $poID )
+ p: Parameter( $parID: parameterID, setupUseID == $setup )
+ not (BestParms( parameterID == $parID ))
+then
+ BestParms newBest=new BestParms();
+ newBest.setParameterID($parID);
+ newBest.setNominalValue(new Float(p.getNominalValue()));
+ newBest.setMaxLimit(new Float(p.getMaxLimit()));
+ newBest.setMinLimit(new Float(p.getMinLimit()));
+ newBest.setMaxLimitAlarm(new Float(p.getMaxLimitAlarm()));
+ newBest.setMinLimitAlarm(new Float(p.getMinLimitAlarm()));
+ newBest.setNonConformities($nonConformities);
+ insert(newBest);
+end
+
+rule "ruleBestParametersChecker"
+salience -10
+when
+ MelhorEmNaoConformidades($poID: ordemProducaoID, $NC: numeroDefeitos )
+ SetupInUse( $setup: setupUseID , productionOrderID == $poID )
+ p: Parameter( $parID: parameterID, setupUseID == $setup )
+ newBest: BestParms( parameterID == $parID, nonConformities > $NC )
+then
+ newBest.setNominalValue(new Float(p.getNominalValue()));
+ newBest.setMaxLimit(new Float(p.getMaxLimit()));
+ newBest.setMinLimit(new Float(p.getMinLimit()));
+ newBest.setMaxLimitAlarm(new Float(p.getMaxLimitAlarm()));
+ newBest.setMinLimitAlarm(new Float(p.getMinLimitAlarm()));
+ newBest.setNonConformities($NC);
+ update(newBest);
+end
+
+rule "print"
+salience -20
+when
+ bp: BestParms( )
+then
+ System.out.println("Parameter: "+bp.getParameterID()+" Value: "+bp.getNominalValue()+" NC: "+bp.getNonConformities());
+end
+
+query "get results"
+ mnc: BestParms( )
+end
\ No newline at end of file
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_from.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_from.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_from.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_from.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,25 @@
+package org.drools.test;
+
+import org.drools.Cheese;
+import org.drools.Cheesery;
+import java.util.List;
+
+global List list1;
+global List list2;
+global List list3;
+global Cheesery cheesery;
+
+rule "test from using a global"
+ when
+ $cheese : Cheese() from cheesery.getCheeses()
+ then
+ list1.add( $cheese );
+end
+
+rule "test from using a global against a map lookup"
+ when
+ Person( $stilton : type == "stilton" )
+ $cheese : Cheese( type == $stilton ) from cheesery.getCheeseMap["stilton"]
+ then
+ list1.add( $cheese );
+end
Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_simplerule.drl (from rev 17135, labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/test_simplerule.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_simplerule.drl (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/xml/rules/test_simplerule.drl 2007-12-10 03:36:11 UTC (rev 17139)
@@ -0,0 +1,15 @@
+package foo;
+
+rule "simple_rule"
+ when
+ foo3 : Bar(a==3)
+ foo4 : Bar(a4:a==4)
+ Baz()
+ then
+ if ( a == b ) {
+ assert( foo3 );
+ } else {
+ retract( foo4 );
+ }
+ System.out.println( a4 );
+end
\ No newline at end of file
More information about the jboss-svn-commits
mailing list