[jboss-svn-commits] JBL Code SVN: r17141 - in labs/jbossrules/trunk/drools-core/src: test/java/org/drools/reteoo and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 9 22:38:35 EST 2007
Author: mark.proctor at jboss.com
Date: 2007-12-09 22:38:35 -0500 (Sun, 09 Dec 2007)
New Revision: 17141
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessImpl.java
labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
Log:
JBRULES-1375 Create initial ePDL language parser implementation
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessImpl.java 2007-12-10 03:37:32 UTC (rev 17140)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/ruleflow/core/impl/RuleFlowProcessImpl.java 2007-12-10 03:38:35 UTC (rev 17141)
@@ -37,15 +37,15 @@
implements
RuleFlowProcess {
- public static final String RULEFLOW_TYPE = "RuleFlow";
+ public static final String RULEFLOW_TYPE = "RuleFlow";
- private static final long serialVersionUID = 400L;
+ private static final long serialVersionUID = 400L;
- private Map nodes;
- private List variables;
- private long lastNodeId;
- private List imports;
- private Map globals;
+ private Map nodes;
+ private List variables;
+ private long lastNodeId;
+ private List<String> imports;
+ private Map<String, String> globals;
public RuleFlowProcessImpl() {
super();
@@ -76,15 +76,15 @@
return (Node) this.nodes.get( idLong );
}
-// private EndNode getEnd() {
-// for ( final Iterator it = this.nodes.values().iterator(); it.hasNext(); ) {
-// final Node node = (Node) it.next();
-// if ( node instanceof EndNode ) {
-// return (EndNode) node;
-// }
-// }
-// return null;
-// }
+ // private EndNode getEnd() {
+ // for ( final Iterator it = this.nodes.values().iterator(); it.hasNext(); ) {
+ // final Node node = (Node) it.next();
+ // if ( node instanceof EndNode ) {
+ // return (EndNode) node;
+ // }
+ // }
+ // return null;
+ // }
public void removeNode(final Node node) {
if ( node == null ) {
@@ -109,10 +109,10 @@
public String[] getVariableNames() {
final String[] result = new String[this.variables.size()];
- if (this.variables != null) {
- for ( int i = 0; i < this.variables.size(); i++ ) {
- result[i] = ((Variable) this.variables.get( i )).getName();
- }
+ if ( this.variables != null ) {
+ for ( int i = 0; i < this.variables.size(); i++ ) {
+ result[i] = ((Variable) this.variables.get( i )).getName();
+ }
}
return result;
}
@@ -130,35 +130,35 @@
if ( (node instanceof StartNode) && (getStart() != null) ) {
throw new IllegalArgumentException( "A ruleflow process cannot have more than one start node!" );
}
-// if ( (node instanceof EndNode) && (getEnd() != null) ) {
-// throw new IllegalArgumentException( "A ruleflow process cannot have more than one end node!" );
-// }
+ // if ( (node instanceof EndNode) && (getEnd() != null) ) {
+ // throw new IllegalArgumentException( "A ruleflow process cannot have more than one end node!" );
+ // }
}
- public List getImports() {
- return imports;
- }
+ public List<String> getImports() {
+ return imports;
+ }
- public void setImports(List imports) {
- this.imports = imports;
- }
-
- public Map getGlobals() {
- return globals;
- }
+ public void setImports(List imports) {
+ this.imports = imports;
+ }
- public void setGlobals(Map globals) {
- this.globals = globals;
- }
+ public Map<String, String> getGlobals() {
+ return globals;
+ }
+ public void setGlobals(Map globals) {
+ this.globals = globals;
+ }
+
public String[] getGlobalNames() {
final List result = new ArrayList();
- if (this.globals != null) {
- for ( Iterator iterator = this.globals.keySet().iterator(); iterator.hasNext(); ) {
- result.add((String) iterator.next());
- }
+ if ( this.globals != null ) {
+ for ( Iterator iterator = this.globals.keySet().iterator(); iterator.hasNext(); ) {
+ result.add( (String) iterator.next() );
+ }
}
- return (String[]) result.toArray(new String[result.size()]);
+ return (String[]) result.toArray( new String[result.size()] );
}
}
Modified: labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2007-12-10 03:37:32 UTC (rev 17140)
+++ labs/jbossrules/trunk/drools-core/src/test/java/org/drools/reteoo/RuleFlowGroupTest.java 2007-12-10 03:38:35 UTC (rev 17141)
@@ -59,13 +59,14 @@
public class RuleFlowGroupTest extends DroolsTestCase {
private ReteooRuleBase ruleBase;
- private BuildContext buildContext;
-
+ private BuildContext buildContext;
+
protected void setUp() throws Exception {
- ruleBase = ( ReteooRuleBase ) RuleBaseFactory.newRuleBase();
- buildContext = new BuildContext( ruleBase, ((ReteooRuleBase)ruleBase).getReteooBuilder().getIdGenerator() );
+ ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
+ buildContext = new BuildContext( ruleBase,
+ ((ReteooRuleBase) ruleBase).getReteooBuilder().getIdGenerator() );
}
-
+
public void testRuleFlowGroup() {
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
@@ -95,7 +96,7 @@
new MockTupleSource( 2 ),
rule0,
rule0.getLhs(),
- buildContext);
+ buildContext );
final Rule rule1 = new Rule( "test-rule1" );
rule1.setRuleFlowGroup( "rule-flow-group-1" );
@@ -150,29 +151,29 @@
final EndNode end = new EndNodeImpl();
// connections
new ConnectionImpl( start,
- ruleSet0,
- Connection.TYPE_NORMAL );
+ ruleSet0,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet0,
- split,
- Connection.TYPE_NORMAL );
+ split,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( split,
- ruleSet1,
- Connection.TYPE_NORMAL );
+ ruleSet1,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( split,
- ruleSet2,
- Connection.TYPE_NORMAL );
+ ruleSet2,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet1,
- join,
- Connection.TYPE_NORMAL );
+ join,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet2,
- join,
- Connection.TYPE_NORMAL );
+ join,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( join,
- ruleSet3,
- Connection.TYPE_NORMAL );
+ ruleSet3,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet3,
- end,
- Connection.TYPE_NORMAL );
+ end,
+ Connection.TYPE_NORMAL );
// process
final RuleFlowProcess process = new RuleFlowProcessImpl();
@@ -308,7 +309,7 @@
assertEquals( ProcessInstance.STATE_COMPLETED,
processInstance.getState() );
}
-
+
/** XOR split and join */
public void testRuleFlowGroup2() {
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
@@ -394,35 +395,37 @@
final EndNode end = new EndNodeImpl();
// connections
new ConnectionImpl( start,
- ruleSet0,
- Connection.TYPE_NORMAL );
+ ruleSet0,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet0,
- split,
- Connection.TYPE_NORMAL );
+ split,
+ Connection.TYPE_NORMAL );
Connection out1 = new ConnectionImpl( split,
- ruleSet1,
- Connection.TYPE_NORMAL );
+ ruleSet1,
+ Connection.TYPE_NORMAL );
Connection out2 = new ConnectionImpl( split,
- ruleSet2,
- Connection.TYPE_NORMAL );
+ ruleSet2,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet1,
- join,
- Connection.TYPE_NORMAL );
+ join,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet2,
- join,
- Connection.TYPE_NORMAL );
+ join,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( join,
- ruleSet3,
- Connection.TYPE_NORMAL );
+ ruleSet3,
+ Connection.TYPE_NORMAL );
new ConnectionImpl( ruleSet3,
- end,
- Connection.TYPE_NORMAL );
+ end,
+ Connection.TYPE_NORMAL );
ConstraintEvaluator constraint1 = new org.drools.ruleflow.core.impl.RuleFlowConstraintEvaluator();
- constraint1.setPriority(1);
- split.setConstraint(out1, constraint1);
+ constraint1.setPriority( 1 );
+ split.setConstraint( out1,
+ constraint1 );
ConstraintEvaluator constraint2 = new org.drools.ruleflow.core.impl.RuleFlowConstraintEvaluator();
- constraint2.setPriority(2);
- split.setConstraint(out2, constraint2);
+ constraint2.setPriority( 2 );
+ split.setConstraint( out2,
+ constraint2 );
// process
final RuleFlowProcess process = new RuleFlowProcessImpl();
@@ -437,24 +440,24 @@
process.addNode( end );
// rules for split
- final Rule splitRule1 = new Rule( "RuleFlow-Split-1-" + split.getId() + "-" + ruleSet1.getId());
+ final Rule splitRule1 = new Rule( "RuleFlow-Split-1-" + split.getId() + "-" + ruleSet1.getId() );
splitRule1.setRuleFlowGroup( "DROOLS_SYSTEM" );
splitRule1.setConsequence( consequence );
final RuleTerminalNode splitNode1 = new RuleTerminalNode( 7,
- new MockTupleSource( 2 ),
- splitRule1,
- splitRule1.getLhs(),
+ new MockTupleSource( 2 ),
+ splitRule1,
+ splitRule1.getLhs(),
buildContext );
- final Rule splitRule2 = new Rule( "RuleFlow-Split-1-" + split.getId() + "-" + ruleSet2.getId());
+ final Rule splitRule2 = new Rule( "RuleFlow-Split-1-" + split.getId() + "-" + ruleSet2.getId() );
splitRule2.setRuleFlowGroup( "DROOLS_SYSTEM" );
splitRule2.setConsequence( consequence );
final RuleTerminalNode splitNode2 = new RuleTerminalNode( 8,
- new MockTupleSource( 2 ),
- splitRule2,
- splitRule2.getLhs(),
+ new MockTupleSource( 2 ),
+ splitRule2,
+ splitRule2.getLhs(),
buildContext );
// proces instance
@@ -500,20 +503,18 @@
workingMemory );
final ReteTuple splitTuple1 = new ReteTuple( new DefaultFactHandle( 1,
- "cheese" ) );
- splitNode1.assertTuple( splitTuple1,
- context0,
- workingMemory );
+ "cheese" ) );
+ splitNode1.assertTuple( splitTuple1,
+ context0,
+ workingMemory );
final ReteTuple splitTuple2 = new ReteTuple( new DefaultFactHandle( 1,
- "cheese" ) );
- splitNode2.assertTuple( splitTuple2,
- context0,
- workingMemory );
+ "cheese" ) );
+ splitNode2.assertTuple( splitTuple2,
+ context0,
+ workingMemory );
final RuleFlowGroupImpl systemRuleFlowGroup = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "DROOLS_SYSTEM" );
-
-
// RuleFlowGroups should be populated, but the agenda shouldn't
assertEquals( 2,
@@ -525,7 +526,7 @@
assertEquals( 1,
ruleFlowGroup3.size() );
assertEquals( 2,
- systemRuleFlowGroup.size() );
+ systemRuleFlowGroup.size() );
assertEquals( 0,
agenda.agendaSize() );
@@ -564,9 +565,9 @@
assertEquals( 0,
ruleFlowGroup1.size() );
assertEquals( 1,
- ruleFlowGroup2.size() );
+ ruleFlowGroup2.size() );
assertEquals( 1,
- ruleFlowGroup3.size() );
+ ruleFlowGroup3.size() );
assertEquals( 1,
agenda.agendaSize() );
More information about the jboss-svn-commits
mailing list