[jbpm-commits] JBoss JBPM SVN: r4999 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/util and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jun 5 04:23:28 EDT 2009


Author: jim.ma
Date: 2009-06-05 04:23:28 -0400 (Fri, 05 Jun 2009)
New Revision: 4999

Added:
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/MailNodeConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SuperStateConverter.java
   jbpm4/branches/jimma/modules/migration/src/test/resources/superstate-mail.xml
Modified:
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
   jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java
   jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Log:
Added warning for SuperState, mail-node and mailAction conversion

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java	2009-06-05 08:22:19 UTC (rev 4998)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -42,9 +42,11 @@
 import org.jbpm.graph.def.Event;
 import org.jbpm.graph.def.Node;
 import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.def.SuperState;
 import org.jbpm.graph.node.EndState;
 import org.jbpm.graph.node.Fork;
 import org.jbpm.graph.node.Join;
+import org.jbpm.graph.node.MailNode;
 import org.jbpm.graph.node.StartState;
 import org.jbpm.graph.node.State;
 import org.jbpm.graph.node.TaskNode;
@@ -54,9 +56,11 @@
 import org.jbpm.jpdl.internal.convert.util.ExceptionHandlersConverter;
 import org.jbpm.jpdl.internal.convert.util.ForkConverter;
 import org.jbpm.jpdl.internal.convert.util.JoinConverter;
+import org.jbpm.jpdl.internal.convert.util.MailNodeConverter;
 import org.jbpm.jpdl.internal.convert.util.NodeConverter;
 import org.jbpm.jpdl.internal.convert.util.StartStateConverter;
 import org.jbpm.jpdl.internal.convert.util.StateConverter;
+import org.jbpm.jpdl.internal.convert.util.SuperStateConverter;
 import org.jbpm.jpdl.internal.convert.util.SwimlaneConverter;
 import org.jbpm.jpdl.internal.convert.util.TaskNodeConverter;
 import org.jbpm.jpdl.xml.JpdlXmlReader;
@@ -97,8 +101,18 @@
 				process.getSwimlaneAndOnAndTimer().add(item);
 			}
 		}
-		
+
 		for (Node node : def.getNodes()) {
+			if (node instanceof SuperState) {
+				SuperState superState = (SuperState)node;
+				SuperStateConverter.run(superState, this);
+				continue;
+			}
+			
+			if (node instanceof MailNode) {
+				MailNode mailNode = (MailNode)node;
+				MailNodeConverter.run(mailNode, this);
+			}
 			Node.NodeType nodeType = node.getNodeType();
 			switch(node.getNodeType()) {
 			case StartState :

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java	2009-06-05 08:22:19 UTC (rev 4998)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -26,6 +26,7 @@
 import javax.xml.bind.JAXBElement;
 
 import org.jbpm.context.def.VariableAccess;
+import org.jbpm.graph.action.MailAction;
 import org.jbpm.graph.action.Script;
 import org.jbpm.graph.def.Action;
 import org.jbpm.instantiation.Delegation;
@@ -36,6 +37,11 @@
 public class EventActionConverter {
 	public static JAXBElement<?> run(Action action, ProblemCollector collector) {
 		JAXBElement<?> result = null;
+		
+		if (action instanceof MailAction) {
+			collector.addWarning("Unsupported MailAction conversion in node [" + action.getName() + "]");
+		}
+		
 		if (action instanceof Script) {
 			ScriptType scriptType = new ScriptType();
 			Script script = (Script) action;
@@ -52,7 +58,11 @@
 			result = new ObjectFactory().createOnScript(scriptType);
 		} else {
 			if (action.getActionExpression() != null) {
-				//TODO: handle action expression
+				ScriptType scriptType = new ScriptType();
+				scriptType.setExpr(action.getActionExpression());
+				scriptType.setLang("juel");
+				result = new ObjectFactory().createOnScript(scriptType);
+				
 			}
 			if (action.getActionDelegation() != null) {
 				Delegation delegation = action.getActionDelegation();

Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/MailNodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/MailNodeConverter.java	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/MailNodeConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -0,0 +1,31 @@
+/*
+ * 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.util;
+
+import org.jbpm.graph.node.MailNode;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
+
+public class MailNodeConverter {
+	public static void run(MailNode node, ProblemCollector collector) {
+		collector.addWarning("Unsupported mailNode conversion in node [" + node.getName() + "]");		
+	}
+}

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java	2009-06-05 08:22:19 UTC (rev 4998)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -55,18 +55,24 @@
 			return result;		    
 		}
 		if (action instanceof Action) {
-			Process.Java result = new Process.Java();
-			result.setName(nodeName);
 			if (action.getActionExpression() != null)  {
-			  //REVISIT how to map expression  	
+				Process.Script result = new Process.Script();
+			    result.setLang("juel");
+			    result.setExpr(action.getActionExpression());
+			    result.setName(action.getName());
+			    result.getOn().addAll(ons);
+			    return result;
 			}
 			if (action.getActionDelegation() != null) {
+				Process.Java result = new Process.Java();
+				result.setName(nodeName);
 			    result.setClazz(action.getActionDelegation().getClassName());
 			    result.setMethod("execute");
+			    result.getOn().addAll(ons);
+			    return result;
 			}
+
 			
-			result.getOn().addAll(ons);
-			return result;
 		}
 		//TODO:convert other action types:create-timer,cancel-timer, mail
 		//process exceptionHandler

Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java	2009-06-05 08:22:19 UTC (rev 4998)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/StartStateConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -47,7 +47,7 @@
 		TaskMgmtDefinition taskMgmtDef = jpdl3start.getProcessDefinition().getTaskMgmtDefinition();
 		if (taskMgmtDef != null) {
 			if (taskMgmtDef.getStartTask() != null) {
-				collector.addWarning("Unsupported task conersion in StartState [" + jpdl3start.getName() + "]");
+				collector.addWarning("Unsupported task conversion in StartState [" + jpdl3start.getName() + "]");
 			}
 		}
 		List<On> ons = EventsConverter.run(jpdl3start.getEvents(), collector);

Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SuperStateConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SuperStateConverter.java	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SuperStateConverter.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -0,0 +1,33 @@
+/*
+ * 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.util;
+
+import org.jbpm.graph.def.SuperState;
+import org.jbpm.jpdl.internal.convert.ProblemCollector;
+
+public class SuperStateConverter {
+	public static void run(SuperState node, ProblemCollector collector) {
+		collector.addWarning("Unsupported superstate conversion in node [" + node.getName() + "]");
+		
+	}
+
+}

Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java	2009-06-05 08:22:19 UTC (rev 4998)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java	2009-06-05 08:23:28 UTC (rev 4999)
@@ -56,6 +56,20 @@
 		testConvert("timer.xml");
 	}
 	
+	
+	
+	@Test
+	public void testWarning() throws Exception {
+		URL url = getClass().getClassLoader().getResource("superstate-mail.xml");
+		//Convert to process file to jpdl4
+		JpdlConverter converter = new JpdlConverter();
+		org.jbpm.jpdl4.model.Process process = converter.run(url);
+		Assert.assertNotNull(process);
+		Assert.assertEquals(converter.getProblems().size(), 3);
+		
+	}
+	
+	
 	public void testConvert(String resourcefile) throws Exception {
 		URL url = getClass().getClassLoader().getResource(resourcefile);
 		//Convert to process file to jpdl4

Added: jbpm4/branches/jimma/modules/migration/src/test/resources/superstate-mail.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/superstate-mail.xml	                        (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/superstate-mail.xml	2009-06-05 08:23:28 UTC (rev 4999)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition 
+  xmlns="urn:jbpm.org:jpdl-3.2"
+  name="simple">
+   <start-state name="start">
+      <transition name="to_state" to="phase one">
+         <action name="action" class="com.sample.action.MessageActionHandler">
+            <message>Going to the first state!</message>
+         </action>
+      </transition>
+   </start-state>
+
+   <super-state name="phase one">
+     <node name="node1"/>
+     <transition to="mail-node"/> 
+   </super-state>
+   
+   <mail-node name="mail-node" to="simple">
+      <subject>test</subject>
+      <text>test</text>
+       <transition to="first"/> 
+   </mail-node>
+   
+    <state name="first">
+      <event type="transistion">
+        <mail name="test"/>
+      </event>
+      <transition name="to_end" to="end">
+         <action name="action" class="com.sample.action.MessageActionHandler">
+            <message>About to finish!</message>
+         </action>
+      </transition>
+   </state>
+   <end-state name="end"></end-state>
+</process-definition>




More information about the jbpm-commits mailing list