[jbpm-commits] JBoss JBPM SVN: r5329 - in jbpm4/trunk/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/action and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jul 21 06:13:22 EDT 2009


Author: jim.ma
Date: 2009-07-21 06:13:21 -0400 (Tue, 21 Jul 2009)
New Revision: 5329

Added:
   jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/SuperState.java
Modified:
   jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java
   jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
   jbpm4/trunk/modules/migration/src/main/resources/node.converter.types.xml
   jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
   jbpm4/trunk/modules/migration/src/test/resources/superstate-mail.xml
Log:
JBPM-2388:Fixed action continue attribute;Added super-state conversion support

Modified: jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java
===================================================================
--- jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java	2009-07-21 05:55:48 UTC (rev 5328)
+++ jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/Jpdl3Converter.java	2009-07-21 10:13:21 UTC (rev 5329)
@@ -300,12 +300,6 @@
       Element nodeElement = (Element)nodeElementIter.next();
       String nodeName = nodeElement.getName();
       
-      //This will affect the transition, so add error and throw exception
-      if ("super-state".equalsIgnoreCase(nodeName)) {
-    	  this.addError("Unsupported " + nodeName + " conversion : <" + nodeName 
-    	          + " name=\"" + jpdl3Element.attributeValue("name") + "\"");
-      }
-      
       Class<?> nodeType = NodeConverterTypes.getNodeType(nodeName);
       if (nodeType != null) {
 
@@ -331,6 +325,13 @@
           
           // read the common node parts of the element
           node.setNodeElement(nodeElement);
+          Element actionElement = nodeElement.element("action");
+          //The node without action element can not be converted, report error
+          if (nodeName.equals("node") && actionElement == null) {
+        	  addError("Could not convert a node without action element:" + nodeElement.asXML());
+        	  return;
+          } 
+          
           node.createConvertedElement(jpdl4Element);
           convertNode(nodeElement,node.getConvertedElement());
 

Modified: jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java
===================================================================
--- jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java	2009-07-21 05:55:48 UTC (rev 5328)
+++ jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/action/Action.java	2009-07-21 10:13:21 UTC (rev 5329)
@@ -46,11 +46,11 @@
 		if (expression != null) {
 			convertedElement = jpdl4Doc.addElement("script");
 			
-		} 
-		
-		if (actionElement.attributeValue("class")!=null) {
-			convertedElement = jpdl4Doc.addElement("java");
-			
+		} else if (actionElement.attributeValue("class")!=null) {
+			convertedElement = jpdl4Doc.addElement("java");			
+		} else {
+			//both expression and class are null
+			convertedElement = jpdl4Doc.addElement("custom");
 		}
 		
         return convertedElement;
@@ -71,7 +71,7 @@
 			convertedElement.addAttribute("method", "execute");
 	      
 	    } else {
-	      jpdlReader.addWarning("action does not have class nor ref-name attribute "+actionElement.asXML());
+	      jpdlReader.addWarning("action does not have class nor ref-name attribute, generated the default node <custom>  "+actionElement.asXML());
 	    }
 	    //TODO: propagate...
 	    String acceptPropagatedEvents = actionElement.attributeValue("accept-propagated-events");
@@ -83,9 +83,9 @@
         
 	    String asyncText = actionElement.attributeValue("async");
 	    if ("true".equalsIgnoreCase(asyncText)) {
-	       convertedElement.addAttribute("async", "true");
+	       convertedElement.addAttribute("continue", "async");
 	    } else if ("exclusive".equalsIgnoreCase(asyncText)) {
-	       convertedElement.addAttribute("async", "exclusive");
+	       convertedElement.addAttribute("continue", "exclusive");
 	    }
 	  }
 

Added: jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/SuperState.java
===================================================================
--- jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/SuperState.java	                        (rev 0)
+++ jbpm4/trunk/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/node/SuperState.java	2009-07-21 10:13:21 UTC (rev 5329)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.convert.node;
+
+import org.dom4j.Element;
+import org.jbpm.jpdl.internal.convert.Jpdl3Converter;
+
+public class SuperState extends Node {
+	public Element createConvertedElement(Element jpdl4Doc) {
+		convertedElement = jpdl4Doc.addElement("group");
+		return convertedElement;
+	}
+	
+	public void read(Jpdl3Converter reader) {
+		String name = nodeElement.attributeValue("name");
+		convertedElement.attributeValue("name", name);		
+		reader.convertNodes(nodeElement, convertedElement);    
+	}
+}

Modified: jbpm4/trunk/modules/migration/src/main/resources/node.converter.types.xml
===================================================================
--- jbpm4/trunk/modules/migration/src/main/resources/node.converter.types.xml	2009-07-21 05:55:48 UTC (rev 5328)
+++ jbpm4/trunk/modules/migration/src/main/resources/node.converter.types.xml	2009-07-21 10:13:21 UTC (rev 5329)
@@ -9,9 +9,9 @@
   <node-type element="decision" class="org.jbpm.jpdl.internal.convert.node.Decision" />
   <node-type element="process-state" class="org.jbpm.jpdl.internal.convert.node.ProcessState" />
   <node-type element="mail-node" class="org.jbpm.jpdl.internal.convert.node.MailNode" />
-  <!--node-type element="super-state" class="org.jbpm.jpdl.internal.convert.node.SuperState" />
-  
-  <node-type element="merge" class="org.jbpm.jpdl.internal.convert.node.Merge" />
+  <node-type element="super-state" class="org.jbpm.jpdl.internal.convert.node.SuperState"/>
+
+  <!-- node-type element="merge" class="org.jbpm.jpdl.internal.convert.node.Merge" />
   <node-type element="milestone-node" class="oorg.jbpm.jpdl.internal.convert.node.MilestoneNode" />
   <node-type element="interleave-start" class="org.jbpm.jpdl.internal.convert.node.InterleaveStart" />
   <node-type element="interleave-end" class="org.jbpm.jpdl.internal.convert.node.InterleaveEnd"/> 

Modified: jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
--- jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java	2009-07-21 05:55:48 UTC (rev 5328)
+++ jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java	2009-07-21 10:13:21 UTC (rev 5329)
@@ -101,17 +101,14 @@
 
 	@Test
 	//Unsupported super-sate and mail node conversion
-	public void testSuperStateAndMailNode() {
+	public void testSuperStateAndMailNode() throws Exception {
 		InputStream inputStream = getClass().getClassLoader()
 				.getResourceAsStream("superstate-mail.xml");
 		// Convert to process file to jpdl4
 		InputSource ins = new InputSource(inputStream);
-		Jpdl3Converter converter = new Jpdl3Converter(ins);
-		try {
-			Document doc = converter.readAndConvert();
-			Assert.fail("The unsupported exception does not throw");
-		} catch (java.lang.Throwable e) {
-		}
+		Jpdl3Converter converter = new Jpdl3Converter(ins);		
+		Document doc = converter.readAndConvert();
+		validate(doc);		
 	}
 	
 	@Test
@@ -169,7 +166,7 @@
 		InputSource ins = new InputSource(inputStream);
 		Jpdl3Converter converter = new Jpdl3Converter(ins);
 		Document doc = converter.readAndConvert();
-		//System.out.println(doc.asXML());
+		System.out.println(doc.asXML());
 		return doc;
 	}
 	

Modified: jbpm4/trunk/modules/migration/src/test/resources/superstate-mail.xml
===================================================================
--- jbpm4/trunk/modules/migration/src/test/resources/superstate-mail.xml	2009-07-21 05:55:48 UTC (rev 5328)
+++ jbpm4/trunk/modules/migration/src/test/resources/superstate-mail.xml	2009-07-21 10:13:21 UTC (rev 5329)
@@ -5,14 +5,75 @@
   name="simple">
    <start-state name="start">
       <transition name="to_state" to="phase one">
-         <action name="action" class="com.sample.action.MessageActionHandler">
+         <action name="action" class="com.test.MessageActionHandler">
             <message>Going to the first state!</message>
          </action>
       </transition>
    </start-state>
 
-   <super-state name="phase one">
-     <node name="node1"/>
+   <super-state name="phase one">  
+
+	<join name="join">
+		<transition to="preparations"></transition>
+	</join>
+	
+	<fork name="preparations">
+		<transition to="make_decision" name="make_decision"></transition>
+		<transition to="state" name="state"></transition>
+	</fork>
+	
+
+  <decision name="make_decision">
+    <transition to="Approve Order Node">
+      <condition>a==&quot;OKOK&quot;</condition>
+    </transition>
+    <transition to="end">
+      <condition>a=="NOK"</condition>
+    </transition>
+  </decision>
+
+   <task-node name="Approve Order Node">
+      <task name="ApproveOrder1">
+         <assignment class="com.test.RulesAssignmentHandler" >
+           		<group>reviewers</group>
+   				<objectNames>
+					<element>order</element>
+				</objectNames>
+	       		<ruleFile>/assignment/Assignment.drl</ruleFile>
+			</assignment>
+      </task>
+      
+      <task name="ApproveOrder2">
+         <assignment class="com.test.RulesAssignmentHandler" >
+           		<group>reviewers</group>
+   				<objectNames>
+					<element>order</element>
+				</objectNames>
+	       		<ruleFile>/assignment/Assignment.drl</ruleFile>
+			</assignment>
+      </task>
+      
+      <transition name="" to="node1"></transition>
+   </task-node>
+
+     <node name="node1">
+        <action name="NodeEnterAction" class="com.test.MessageActionHandler">
+        </action>
+         <transition name="to_state" to="state"/>
+     </node>
+      <state name="state">
+      <event type="node-enter">
+        <action class="com.test.NodeEnterAction"/>
+      </event>
+      <transition name="to_end" to="end">
+         <action name="action" class="com.test.MessageActionHandler">
+            <message>About to finish!</message>
+         </action>
+      </transition>
+   </state>
+   <end-state name="end"></end-state>
+     
+     
      <transition to="mail-node"/> 
    </super-state>
    
@@ -27,7 +88,7 @@
         <mail name="test"/>
       </event>
       <transition name="to_end" to="end">
-         <action name="action" class="com.sample.action.MessageActionHandler">
+         <action name="action" class="com.test.MessageActionHandler">
             <message>About to finish!</message>
          </action>
       </transition>



More information about the jbpm-commits mailing list