[jboss-svn-commits] JBL Code SVN: r28654 - in labs/jbossrules/trunk/drools-process/drools-jpdl/src: test/java/org/drools and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jul 31 10:59:38 EDT 2009
Author: salaboy21
Date: 2009-07-31 10:59:38 -0400 (Fri, 31 Jul 2009)
New Revision: 28654
Added:
labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/
labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/gpd.xml
labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/processdefinition.xml
Modified:
labs/jbossrules/trunk/drools-process/drools-jpdl/src/main/java/org/drools/jpdl/EpdlWriter.java
labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/java/org/drools/ParseSimpleProcessTest.java
Log:
add the inports and outports generation for composite nodes
Modified: labs/jbossrules/trunk/drools-process/drools-jpdl/src/main/java/org/drools/jpdl/EpdlWriter.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-jpdl/src/main/java/org/drools/jpdl/EpdlWriter.java 2009-07-31 14:35:19 UTC (rev 28653)
+++ labs/jbossrules/trunk/drools-process/drools-jpdl/src/main/java/org/drools/jpdl/EpdlWriter.java 2009-07-31 14:59:38 UTC (rev 28654)
@@ -74,7 +74,8 @@
generatedConnections += suggestJoinNode(node);
System.out.println("<composite id=\""+ node.getId() +"\" name=\""+ node.getName() +"\">");
List<org.drools.jpdl.core.node.JpdlNode> nodesList = ((org.drools.jpdl.core.node.SuperState)node).getNodes();
- printNodesAndConnections(nodesList.toArray(new Node[nodes.length]));
+ printNodesAndConnections(nodesList.toArray(new Node[nodesList.size()]));
+ printInPortsAndOutPorts(nodesList.toArray(new Node[nodesList.size()]));
System.out.println("</composite>");
} else if (node instanceof org.drools.jpdl.core.node.State) {
@@ -179,7 +180,7 @@
if(fromNode instanceof org.drools.jpdl.core.node.State){
System.out.println("<!-- Take a look at the State Node that is pointing here, " +
"you will need to change the constraint for signal it to the new JoinNode id -->");
- System.out.println("<!-- in node id: "+fromNode.getId()+ "-- name: "+fromNode.getName()+" -->");
+ System.out.println("<!-- in node id: "+fromNode.getId()+ " / name: "+fromNode.getName()+" -->");
System.out.println("<!-- you should change the fromId ("+fromNodeId+") attribute to: "+suggestedNodeId+"-->");
System.out.println("<!-- you can also change the name for something that reference the JoinNode -->");
}
@@ -209,7 +210,7 @@
}
if(suggestSplitNode){
System.out.println("<!-- This is a suggested Split Node -->");
- System.out.println("<split id=\"" + (suggestedNodeId) + "\" name=\"Split XOR\" type=\"2\" >");
+ System.out.println("<split id=\"" + (suggestedNodeId) + "\" name=\"Split XOR - "+suggestedNodeId+"\" type=\"2\" >");
System.out.println(" <constraints>");
Set<String> keys = node.getOutgoingConnections().keySet();
for(String key: keys){
@@ -251,5 +252,19 @@
return resultGeneratedConnection;
}
+ private static void printInPortsAndOutPorts(Node[] toArray) {
+ int lastNode = 0;
+ if(toArray.length > 1){
+ lastNode = toArray.length -1;
+ }
+
+ System.out.println("<in-ports>");
+ System.out.println(" <in-port type=\"DROOLS_DEFAULT\" nodeId=\""+toArray[0].getId()+"\" nodeInType=\"DROOLS_DEFAULT\" />");
+ System.out.println("</in-ports>");
+ System.out.println("<out-ports>");
+ System.out.println(" <out-port type=\"DROOLS_DEFAULT\" nodeId=\""+toArray[lastNode].getId()+"\" nodeOutType=\"DROOLS_DEFAULT\" />");
+ System.out.println("</out-ports>");
+ }
+
}
Modified: labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/java/org/drools/ParseSimpleProcessTest.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/java/org/drools/ParseSimpleProcessTest.java 2009-07-31 14:35:19 UTC (rev 28653)
+++ labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/java/org/drools/ParseSimpleProcessTest.java 2009-07-31 14:59:38 UTC (rev 28654)
@@ -112,5 +112,27 @@
EpdlWriter.write(process);
}
+ public void testWriteEPDLNestedForksWithSuperState() throws Exception {
+ JpdlParser parser = new JpdlParser();
+ JpdlProcess process = parser.loadJpdlProcess("simpleNestedForkWithSuperState/processdefinition.xml");
+ ProcessValidationError[] errors = parser.getErrors();
+ EpdlWriter.write(process);
+
+ for (ProcessValidationError error: errors) {
+ System.err.println(error);
+ }
+ assertEquals(0, errors.length);
+
+ RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+ Package p = new Package("com.sample");
+ p.addProcess(process);
+ ruleBase.addPackage( p );
+
+ WorkingMemory workingMemory = ruleBase.newStatefulSession();
+ ProcessInstance processInstance = workingMemory.startProcess("simple");
+
+ }
+
+
}
Added: labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/gpd.xml
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/gpd.xml (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/gpd.xml 2009-07-31 14:59:38 UTC (rev 28654)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="simple" width="846" height="499">
+ <node name="start-state1" x="236" y="60" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="state1" x="235" y="125" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node-container name="super-state1" x="70" y="183" width="516" height="283">
+ <node name="fork1" x="101" y="16" width="252" height="24">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="fork2" x="194" y="86" width="252" height="24">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="node1" x="25" y="85" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="node2" x="178" y="134" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="node3" x="335" y="134" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="join1" x="200" y="183" width="252" height="24">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="join2" x="95" y="224" width="252" height="24"/>
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node-container>
+ <node name="state2" x="627" y="306" width="132" height="36">
+ <edge>
+ <label x="5" y="-10"/>
+ </edge>
+ </node>
+ <node name="end-state1" x="633" y="388" width="132" height="36"/>
+</root-container>
Added: labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/processdefinition.xml
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/processdefinition.xml (rev 0)
+++ labs/jbossrules/trunk/drools-process/drools-jpdl/src/test/resources/simpleNestedForkWithSuperState/processdefinition.xml 2009-07-31 14:59:38 UTC (rev 28654)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple">
+
+
+ <start-state name="start-state1">
+ <transition to="state1"></transition>
+ </start-state>
+
+
+ <state name="state1">
+ <transition to="super-state1"></transition>
+ </state>
+
+ <super-state name="super-state1">
+ <fork name="fork1">
+ <transition to="node1"></transition>
+ <transition to="fork2" name="to fork2"></transition>
+ </fork>
+ <fork name="fork2">
+ <transition to="node2"></transition>
+ <transition to="node3" name="to node3"></transition>
+ </fork>
+ <node name="node1">
+ <transition to="join2"></transition>
+ </node>
+ <node name="node2">
+ <transition to="join1"></transition>
+ </node>
+ <node name="node3">
+ <transition to="join1"></transition>
+ </node>
+ <join name="join1">
+ <transition to="join2"></transition>
+ </join>
+ <join name="join2"></join>
+ <transition to="state2"></transition>
+ </super-state>
+
+ <state name="state2">
+ <transition to="end-state1"></transition>
+ </state>
+
+
+ <end-state name="end-state1"></end-state>
+
+
+</process-definition>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list