[jbpm-commits] JBoss JBPM SVN: r4893 - in jbpm4/branches/jimma/modules/migration: src/main/java/org/jbpm/jpdl/internal/convert and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue May 26 05:57:23 EDT 2009
Author: jim.ma
Date: 2009-05-26 05:57:23 -0400 (Tue, 26 May 2009)
New Revision: 4893
Added:
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/EventConverter.java
jbpm4/branches/jimma/modules/migration/src/test/resources/process-event.xml
Modified:
jbpm4/branches/jimma/modules/migration/pom.xml
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/DecisionConverter.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/TaskNodeConverter.java
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Log:
Added event element converter
Modified: jbpm4/branches/jimma/modules/migration/pom.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/pom.xml 2009-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/pom.xml 2009-05-26 09:57:23 UTC (rev 4893)
@@ -1,177 +1,199 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ====================================================================== -->
-<!-- -->
-<!-- JBoss, the OpenSource J2EE webOS -->
-<!-- -->
-<!-- Distributable under LGPL license. -->
-<!-- See terms of license at http://www.gnu.org. -->
-<!-- -->
-<!-- ====================================================================== -->
+ <!--
+ ======================================================================
+ -->
+ <!--
+ -->
+ <!--
+ JBoss, the OpenSource J2EE webOS
+ -->
+ <!--
+ -->
+ <!--
+ Distributable under LGPL license.
+ -->
+ <!--
+ See terms of license at http://www.gnu.org.
+ -->
+ <!--
+ -->
+ <!--
+ ======================================================================
+ -->
-<!-- $Id: pom.xml 1790 2008-07-31 12:13:06Z tom.baeyens at jboss.com $ -->
+ <!-- $Id: pom.xml 1790 2008-07-31 12:13:06Z tom.baeyens at jboss.com $ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <name>jBPM 4 - Migration - Tool</name>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>migration</artifactId>
- <packaging>jar</packaging>
+ <name>jBPM 4 - Migration - Tool</name>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>migration</artifactId>
+ <packaging>jar</packaging>
- <!-- Parent -->
- <parent>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <!-- Properties -->
- <properties>
- </properties>
+ <!-- Properties -->
+ <properties>
+ </properties>
- <!-- Dependencies -->
- <dependencies>
- <dependency>
- <groupId>org.jbpm.jbpm3</groupId>
- <artifactId>jbpm-jpdl</artifactId>
- <version>3.3.1-SNAPSHOT</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- <exclusion>
- <groupId>bsh</groupId>
- <artifactId>bsh</artifactId>
- </exclusion>
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jbpm.jbpm3</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>3.3.1-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <!--
+ exclusion> <groupId>bsh</groupId> <artifactId>bsh</artifactId>
+ </exclusion
+ -->
- <exclusion>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <exclusion>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <!-- 3rd Party -->
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.0</version>
- <exclusions>
- <exclusion>
- <groupId>javax.activation</groupId>
- <artifactId>activation</artifactId>
- </exclusion>
+ <!-- 3rd Party -->
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
- <exclusion>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jsr173_api</artifactId>
- </exclusion>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jsr173_api</artifactId>
+ </exclusion>
- </exclusions>
+ </exclusions>
- </dependency>
+ </dependency>
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.0.3</version>
- </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.3</version>
+ </dependency>
- <!-- JBPM4 -->
- <dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-jpdl</artifactId>
- <version>${version}</version>
- <scope>test</scope>
- </dependency>
+ <!-- JBPM4 -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-pvm</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
- </dependencies>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
- <!-- Plugins -->
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jaxb2-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <goals>
- <goal>xjc</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includeSchemas>
- <includeSchema>**/*.xsd</includeSchema>
- </includeSchemas>
- <packageName>org.jbpm.jpdl4.model</packageName>
- </configuration>
- </plugin>
-
- <!--Add classpath to menifest -->
- <!--plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <finalName>jbpm-migration</finalName>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- </manifest>
- </archive>
- </configuration>
- </plugin-->
- </plugins>
- </build>
- <!-- Profiles -->
- <profiles>
- <!-- skip tests if this is an integration test run
- (only examples and test-db are part of the integration test runs) -->
- <profile>
- <id>integration.test</id>
- <activation>
- <property>
- <name>jboss.bind.address</name>
- </property>
- </activation>
- <properties>
- <skipTests>true</skipTests>
- </properties>
- </profile>
- </profiles>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
- <pluginRepositories>
- <pluginRepository>
- <id>codehaus</id>
- <name>codehaus</name>
- <url>http://repository.codehaus.org</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </pluginRepository>
- </pluginRepositories>
+ </dependencies>
+ <!-- Plugins -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includeSchemas>
+ <includeSchema>**/*.xsd</includeSchema>
+ </includeSchemas>
+ <packageName>org.jbpm.jpdl4.model</packageName>
+ </configuration>
+ </plugin>
+ <!--Add classpath to menifest -->
+ <!--
+ plugin> <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId> <configuration>
+ <finalName>jbpm-migration</finalName> <archive> <manifest>
+ <addClasspath>true</addClasspath> </manifest> </archive>
+ </configuration> </plugin
+ -->
+
+ </plugins>
+ </build>
+
+ <!-- Profiles -->
+ <profiles>
+ <!--
+ skip tests if this is an integration test run (only examples and
+ test-db are part of the integration test runs)
+ -->
+ <profile>
+ <id>integration.test</id>
+ <activation>
+ <property>
+ <name>jboss.bind.address</name>
+ </property>
+ </activation>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ </profile>
+ </profiles>
+
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>codehaus</id>
+ <name>codehaus</name>
+ <url>http://repository.codehaus.org
+ </url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+
</project>
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-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -35,6 +35,7 @@
import java.util.Map;
import java.util.Set;
+import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.node.EndState;
@@ -45,6 +46,7 @@
import org.jbpm.graph.node.TaskNode;
import org.jbpm.jpdl.internal.convert.util.DecisionConverter;
import org.jbpm.jpdl.internal.convert.util.EndStateConverter;
+import org.jbpm.jpdl.internal.convert.util.EventConverter;
import org.jbpm.jpdl.internal.convert.util.ForkConverter;
import org.jbpm.jpdl.internal.convert.util.JoinConverter;
import org.jbpm.jpdl.internal.convert.util.NodeConverter;
@@ -135,6 +137,17 @@
}
}
+
+ //Process Event
+ Map events = def.getEvents();
+ if (events != null) {
+ Set entries= events.entrySet();
+ for (Object entry : entries) {
+ Event event = ((Map.Entry<String, Event>)entry).getValue();
+ org.jbpm.jpdl4.model.On on = EventConverter.run(event);
+ process.getSwimlaneAndOnAndTimer().add(on);
+ }
+ }
return process;
}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java 2009-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -33,8 +33,7 @@
//node.getDecisionConditions()
for (Transition trans : node.getLeavingTransitions()) {
result.getTransition().add(TransitionConverter.run(trans, Process.Decision.Transition.class));
- }
-
+ }
return result;
}
Added: 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 (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventActionConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -0,0 +1,49 @@
+package org.jbpm.jpdl.internal.convert.util;
+
+import java.util.Set;
+
+import javax.xml.bind.JAXBElement;
+
+import org.jbpm.context.def.VariableAccess;
+import org.jbpm.graph.action.Script;
+import org.jbpm.graph.def.Action;
+import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl4.model.JavaType;
+import org.jbpm.jpdl4.model.ObjectFactory;
+import org.jbpm.jpdl4.model.ScriptType;
+
+public class EventActionConverter {
+ public static JAXBElement<?> run(Action action) {
+ JAXBElement<?> result = null;
+ if (action instanceof Script) {
+ ScriptType scriptType = new ScriptType();
+ Script script = (Script) action;
+ scriptType.setText(script.getExpression());
+ //scriptType.setExpr(script.getExpression());
+ if (script.getVariableAccesses() != null) {
+ for (VariableAccess variableAccess : (Set<VariableAccess>) script.getVariableAccesses()) {
+ if (variableAccess.isWritable()) {
+ scriptType.setVar(variableAccess.getVariableName());
+ }
+ //TODO:check if we should handle other variables
+ }
+
+ }
+ result = new ObjectFactory().createOnScript(scriptType);
+ } else {
+ if (action.getActionExpression() != null) {
+ //TODO: handle action expression
+ }
+ if (action.getActionDelegation() != null) {
+ Delegation delegation = action.getActionDelegation();
+ String className = delegation.getClassName();
+ JavaType javaType = new ObjectFactory().createJavaType();
+ javaType.setClazz(className);
+ javaType.setMethod("execute");
+ result = new ObjectFactory().createOnJava(javaType);
+ }
+ }
+ return result;
+ }
+
+}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/EventConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -0,0 +1,35 @@
+package org.jbpm.jpdl.internal.convert.util;
+
+import java.util.List;
+
+import org.jbpm.graph.def.Action;
+import org.jbpm.graph.def.Event;
+import org.jbpm.jpdl4.model.On;
+
+public class EventConverter {
+ public static On run(Event event) {
+ On result = new On();
+ //process-start and process-end
+ result.setEvent(convertEnvetType(event.getEventType()));
+ List<Action> actions = (List<Action>)event.getActions();
+ for (Action action : actions) {
+ result.getEventListenerGroup().add(EventActionConverter.run(action));
+ }
+
+ //There is no corresponding element in jpdl3 map to event listener...
+ return result;
+
+ }
+
+ private static String convertEnvetType(String type) {
+ if (type.toLowerCase().equals("process-start")) {
+ return "start";
+ }
+ if (type.toLowerCase().equals("process-end")) {
+ return "end";
+ }
+
+ return null;
+ }
+
+}
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-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -1,9 +1,14 @@
package org.jbpm.jpdl.internal.convert.util;
+import java.util.Set;
+
+import org.jbpm.context.def.VariableAccess;
+import org.jbpm.graph.action.Script;
import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.Node;
import org.jbpm.instantiation.Delegation;
import org.jbpm.jpdl4.model.Process;
+import org.jbpm.jpdl4.model.ScriptType;
/*
<action-type element="action" class="org.jbpm.graph.def.Action" />
@@ -15,6 +20,23 @@
public static Object run(Node node) {
String nodeName = node.getName();
Action action = node.getAction();
+ if (action instanceof Script) {
+ Process.Script result = new Process.Script();
+ result.setName(action.getName());
+ Script script = (Script) action;
+ result.setText(script.getExpression());
+ //scriptType.setExpr(script.getExpression());
+ if (script.getVariableAccesses() != null) {
+ for (VariableAccess variableAccess : (Set<VariableAccess>) script.getVariableAccesses()) {
+ if (variableAccess.isWritable()) {
+ result.setVar(variableAccess.getVariableName());
+ break;
+ }
+ }
+ }
+ return result;
+
+ }
if (action instanceof Action) {
Process.Java result = new Process.Java();
result.setName(nodeName);
@@ -27,21 +49,8 @@
}
return result;
}
- //TODO:convert other action types
- if (action instanceof org.jbpm.scheduler.def.CreateTimerAction) {
-
- }
- if (action instanceof org.jbpm.scheduler.def.CancelTimerAction) {
-
- }
- /*if (action instanceof org.jbpm.scheduler.def.Script) {
-
- }
+ //TODO:convert other action types:create-timer,cancel-timer, mail
- if (action instanceof org.jbpm.scheduler.def.MailAction) {
-
- }*/
-
return null;
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java 2009-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -68,6 +68,7 @@
newTask.setAssignmentHandler(object);
}
newTask.setName(task.getName());
+ //TODO:covert the controller and other stuff.
return newTask;
}
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-05-25 19:20:04 UTC (rev 4892)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-05-26 09:57:23 UTC (rev 4893)
@@ -34,22 +34,23 @@
public void runSimpleProcessFile() throws Exception {
testConvert("simple.xml");
}
-
@Test
public void runAssignmentProcessFile() throws Exception {
testConvert("assignment.xml");
}
-
@Test
public void runBusinessTrip() throws Exception {
testConvert("businesstrip.xml");
}
-
@Test
public void testDescision() throws Exception {
testConvert("testDecision.xml");
}
+ @Test
+ public void testEvent() throws Exception {
+ testConvert("process-event.xml");
+ }
@@ -67,7 +68,6 @@
//Validate it with Jpdl4Parser
String jpdl4xml = new String(bout.toByteArray());
-
List<Problem> problems = new JpdlParser().createParse().setString(jpdl4xml).execute().getProblems();
Assert.assertEquals(problems.toString(), 0, problems.size());
}
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/process-event.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/process-event.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/process-event.xml 2009-05-26 09:57:23 UTC (rev 4893)
@@ -0,0 +1,30 @@
+<?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="first">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>Going to the first state!</message>
+ </action>
+ </transition>
+ </start-state>
+ <state name="first">
+ <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>
+
+ <event type="process-start">
+
+ <action name="ation1" expression="a=b+c"></action>
+ <action name="action2" class="org.jbpm.Logger"></action>
+ <script>run this script</script>
+ </event>
+
+
+</process-definition>
\ No newline at end of file
More information about the jbpm-commits
mailing list