[jbpm-commits] JBoss JBPM SVN: r2940 - in jbpm3/branches/tdiesler: modules/integration and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Nov 15 06:17:47 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-11-15 06:17:46 -0500 (Sat, 15 Nov 2008)
New Revision: 2940
Added:
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/EndEventImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/SequenceFlowImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/StartEventImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/TaskImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/WaitStateImpl.java
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/ProcessBuilderImpl.java
Modified:
jbpm3/branches/tdiesler/modules/integration/pom.xml
jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/service/ProcessBuilderServiceImpl.java
jbpm3/branches/tdiesler/pom.xml
Log:
ProcessBuilderTest - ok
Modified: jbpm3/branches/tdiesler/modules/integration/pom.xml
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/pom.xml 2008-11-15 11:16:48 UTC (rev 2939)
+++ jbpm3/branches/tdiesler/modules/integration/pom.xml 2008-11-15 11:17:46 UTC (rev 2940)
@@ -33,15 +33,8 @@
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-spec-api</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-spec-cts</artifactId>
- <scope>provided</scope>
- <type>zip</type>
- </dependency>
- <dependency>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jbpm-jpdl</artifactId>
<version>${version}</version>
@@ -52,6 +45,23 @@
<classifier>config</classifier>
<version>${version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-spec-dialect-api10</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-spec-cts</artifactId>
+ <scope>test</scope>
+ <type>zip</type>
+ </dependency>
</dependencies>
<build>
@@ -77,6 +87,15 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>org/jbpm/test/preview/**/*Test.java</exclude>
+ <exclude>org/jbpm/test/pattern/**/*Test.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/EndEventImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/EndEventImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/EndEventImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,57 @@
+/*
+ * 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.integration.model;
+
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.graph.node.EndState;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class EndEventImpl extends NodeImpl implements EndEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private EndState oldEnd;
+
+ public EndEventImpl(ProcessDefinition procDef, EndState oldEnd)
+ {
+ super(procDef, oldEnd);
+ this.oldEnd = oldEnd;
+ }
+
+ @Override
+ public EventDetailType getResultType()
+ {
+ return EventDetailType.None;
+ }
+
+ @Override
+ public EventType getEventType()
+ {
+ return EventType.End;
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/EndEventImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,100 @@
+/*
+ * 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.integration.model;
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.graph.def.Transition;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class NodeImpl implements Node
+{
+ private static final long serialVersionUID = 1L;
+
+ private ProcessDefinition procDef;
+ private org.jbpm.graph.def.Node oldNode;
+
+ public NodeImpl(ProcessDefinition procDef, org.jbpm.graph.def.Node oldNode)
+ {
+ this.procDef = procDef;
+ this.oldNode = oldNode;
+ }
+
+ @Override
+ public ObjectName getKey()
+ {
+ throw new NotImplementedException();
+ }
+
+ public org.jbpm.graph.def.Node getOldNode()
+ {
+ return oldNode;
+ }
+
+ @Override
+ public String getName()
+ {
+ return oldNode.getName();
+ }
+
+ @Override
+ public ProcessDefinition getProcessDefinition()
+ {
+ return procDef;
+ }
+
+ @Override
+ public Process getProcess()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void addSequenceFlow(String targetName)
+ {
+ NodeImpl targetNode = (NodeImpl)procDef.getNode(targetName);
+ if (targetNode == null)
+ throw new InvalidProcessException("Cannot obtain target node: " + targetName);
+
+ Transition trans = new Transition();
+ trans.setFrom(this.getOldNode());
+ trans.setTo(targetNode.getOldNode());
+
+ oldNode.addLeavingTransition(trans);
+ targetNode.getOldNode().addArrivingTransition(trans);
+ }
+
+ @Override
+ public String toString()
+ {
+ return oldNode.toString();
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/NodeImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,160 @@
+/*
+ * 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.integration.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.graph.node.EndState;
+import org.jbpm.graph.node.StartState;
+import org.jbpm.graph.node.State;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class ProcessDefinitionImpl implements ProcessDefinition
+{
+ private static final long serialVersionUID = 1L;
+
+ private org.jbpm.graph.def.ProcessDefinition oldProcDef;
+ private ProcessEngine engine;
+
+ public ProcessDefinitionImpl(ProcessEngine engine, String name)
+ {
+ this.oldProcDef = new org.jbpm.graph.def.ProcessDefinition(name);
+ this.engine = engine;
+
+ if (name == null)
+ throw new InvalidProcessException("ProcessDefinition name cannot be null");
+ }
+
+ @Override
+ public ProcessEngine getProcessEngine()
+ {
+ return engine;
+ }
+
+ @Override
+ public ObjectName getKey()
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String getName()
+ {
+ return oldProcDef.getName();
+ }
+
+ @Override
+ public Process newInstance()
+ {
+ throw new NotImplementedException();
+ }
+
+ public void addNode(NodeImpl nodeImpl)
+ {
+ org.jbpm.graph.def.Node oldNode = nodeImpl.getOldNode();
+ oldProcDef.addNode(oldNode);
+ }
+
+ @Override
+ public Node getNode(String name)
+ {
+ org.jbpm.graph.def.Node oldNode = oldProcDef.getNode(name);
+ return adaptNode(oldNode);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<Node> getNodes()
+ {
+ List<Node> nodes = new ArrayList<Node>();
+ List<org.jbpm.graph.def.Node> oldNodes = oldProcDef.getNodes();
+ for (org.jbpm.graph.def.Node oldNode : oldNodes)
+ {
+ nodes.add(adaptNode(oldNode));
+ }
+ return nodes;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T extends Node> T getNode(Class<T> clazz, String name)
+ {
+ for (Node node : getNodes(clazz))
+ {
+ if (node.getName().equals(name))
+ return (T)node;
+ }
+ return null;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T extends Node> List<T> getNodes(Class<T> clazz)
+ {
+ List<T> retNodes = new ArrayList<T>();
+ for (Node node : getNodes())
+ {
+ if (clazz.isAssignableFrom(node.getClass()))
+ retNodes.add((T)node);
+ }
+ return retNodes;
+ }
+
+ private NodeImpl adaptNode(org.jbpm.graph.def.Node oldNode)
+ {
+ NodeImpl node = null;
+ if (oldNode != null)
+ {
+ if (oldNode instanceof StartState)
+ {
+ node = new StartEventImpl(this, (StartState)oldNode);
+ }
+ else if (oldNode instanceof State)
+ {
+ node = new WaitStateImpl(this, (State)oldNode);
+ }
+ else if (oldNode instanceof EndState)
+ {
+ node = new EndEventImpl(this, (EndState)oldNode);
+ }
+ else
+ {
+ node = new TaskImpl(this, oldNode);
+ }
+ }
+ return node;
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/ProcessDefinitionImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/SequenceFlowImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/SequenceFlowImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/SequenceFlowImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,72 @@
+/*
+ * 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.integration.model;
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.Transition;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class SequenceFlowImpl implements SequenceFlow
+{
+ private static final long serialVersionUID = 1L;
+
+ private Transition oldTrans;
+
+ public SequenceFlowImpl(Transition oldTrans)
+ {
+ this.oldTrans = oldTrans;
+ }
+
+ @Override
+ public Expression getConditionExpression()
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public ConditionType getConditionType()
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String getSourceRef()
+ {
+ Node from = oldTrans.getFrom();
+ return from != null ? from.getName() : null;
+ }
+
+ @Override
+ public String getTargetRef()
+ {
+ Node to = oldTrans.getTo();
+ return to != null ? to.getName() : null;
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/SequenceFlowImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/StartEventImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/StartEventImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/StartEventImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,80 @@
+/*
+ * 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.integration.model;
+
+import java.util.List;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.node.StartState;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class StartEventImpl extends NodeImpl implements StartEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private StartState oldStart;
+
+ public StartEventImpl(ProcessDefinition procDef, StartState oldStart)
+ {
+ super(procDef, oldStart);
+ this.oldStart = oldStart;
+
+ if (oldStart.getName() == null)
+ throw new InvalidProcessException("StartEvent name cannot be null");
+ }
+
+ @Override
+ public EventDetailType getTriggerType()
+ {
+ return EventDetailType.None;
+ }
+
+ @Override
+ public EventType getEventType()
+ {
+ return EventType.Start;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public SequenceFlow getOutFlow()
+ {
+ List<Transition> leavingTransitions = oldStart.getLeavingTransitions();
+ if (leavingTransitions == null)
+ throw new IllegalStateException ("No leaving transitions on: " + oldStart);
+ if (leavingTransitions.size() > 1)
+ throw new NotImplementedException ("Multiple leaving transitions on: " + oldStart);
+
+ Transition to = leavingTransitions.get(0);
+ return new SequenceFlowImpl(to);
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/StartEventImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/TaskImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/TaskImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/TaskImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,82 @@
+/*
+ * 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.integration.model;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.Task;
+import org.jbpm.graph.def.Node;
+import org.jbpm.graph.def.Transition;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class TaskImpl extends NodeImpl implements Task
+{
+ private static final long serialVersionUID = 1L;
+
+ public TaskImpl(ProcessDefinition procDef, org.jbpm.graph.def.Node oldNode)
+ {
+ super(procDef, oldNode);
+ }
+
+ @Override
+ public TaskType getTaskType()
+ {
+ return TaskType.None;
+ }
+
+ @Override
+ public SequenceFlow getInFlow()
+ {
+ Node oldNode = getOldNode();
+ Set<Transition> arrivingTransitions = oldNode.getArrivingTransitions();
+ if (arrivingTransitions == null)
+ throw new IllegalStateException("No leaving transitions on: " + oldNode);
+ if (arrivingTransitions.size() > 1)
+ throw new NotImplementedException("Multiple leaving transitions on: " + oldNode);
+
+ Transition from = arrivingTransitions.iterator().next();
+ return new SequenceFlowImpl(from);
+ }
+
+ @Override
+ public SequenceFlow getOutFlow()
+ {
+ Node oldNode = getOldNode();
+ List<Transition> leavingTransitions = oldNode.getLeavingTransitions();
+ if (leavingTransitions == null)
+ throw new IllegalStateException("No leaving transitions on: " + oldNode);
+ if (leavingTransitions.size() > 1)
+ throw new NotImplementedException("Multiple leaving transitions on: " + oldNode);
+
+ Transition to = leavingTransitions.get(0);
+ return new SequenceFlowImpl(to);
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/TaskImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/WaitStateImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/WaitStateImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/WaitStateImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,48 @@
+/*
+ * 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.integration.model;
+
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.WaitState;
+import org.jbpm.graph.node.State;
+
+/**
+ * An integration wrapper
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class WaitStateImpl extends TaskImpl implements WaitState
+{
+ private static final long serialVersionUID = 1L;
+
+ public WaitStateImpl(ProcessDefinition procDef, State oldState)
+ {
+ super(procDef, oldState);
+ }
+
+ @Override
+ public TaskType getTaskType()
+ {
+ return TaskType.Wait;
+ }
+}
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/WaitStateImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/ProcessBuilderImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/ProcessBuilderImpl.java (rev 0)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/ProcessBuilderImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -0,0 +1,195 @@
+/*
+ * 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.integration.model.builder;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.ProcessDefinition;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.api.model.Task.TaskType;
+import org.jbpm.api.model.builder.GatewayBuilder;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.graph.node.EndState;
+import org.jbpm.graph.node.StartState;
+import org.jbpm.graph.node.State;
+import org.jbpm.integration.model.EndEventImpl;
+import org.jbpm.integration.model.NodeImpl;
+import org.jbpm.integration.model.ProcessDefinitionImpl;
+import org.jbpm.integration.model.StartEventImpl;
+import org.jbpm.integration.model.TaskImpl;
+import org.jbpm.integration.model.WaitStateImpl;
+
+/**
+ * The ProcessBuilder can be used to dynamically build a {@link Process}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 15-Nov-2008
+ */
+public class ProcessBuilderImpl implements ProcessBuilder
+{
+ protected ProcessEngine engine;
+ protected ProcessDefinitionImpl procDefImpl;
+ protected NodeImpl nodeImpl;
+
+ private List<FlowTuple> flows = new ArrayList<FlowTuple>();
+
+ public ProcessBuilderImpl(ProcessEngine engine)
+ {
+ this.engine = engine;
+ }
+
+ protected ProcessBuilderImpl(ProcessBuilderImpl procBuilder)
+ {
+ this.engine = procBuilder.engine;
+ this.procDefImpl = procBuilder.procDefImpl;
+ this.nodeImpl = procBuilder.nodeImpl;
+ this.flows = procBuilder.flows;
+ }
+
+ @Override
+ public ProcessBuilder addProcess(String name)
+ {
+ procDefImpl = new ProcessDefinitionImpl(engine, name);
+ return this;
+ }
+
+ @Override
+ public ProcessDefinition getProcessDefinition()
+ {
+ // Initialize the flows
+ for (FlowTuple flow : flows)
+ {
+ NodeImpl srcNode = (NodeImpl)procDefImpl.getNode(flow.source);
+ if (srcNode == null)
+ throw new InvalidProcessException("Cannot obtain source node: " + flow.source);
+
+ srcNode.addSequenceFlow(flow.target);
+ }
+
+ // Verify that there is a start event
+ List<StartEvent> startEvents = procDefImpl.getNodes(StartEvent.class);
+ if (startEvents.size() == 0)
+ throw new InvalidProcessException("Cannot obtain a start event");
+
+ // Verify that there is an end event
+ List<EndEvent> endEvents = procDefImpl.getNodes(EndEvent.class);
+ if (endEvents.size() == 0)
+ throw new InvalidProcessException("Cannot obtain an end event");
+
+ // Detect unreachable nodes
+ for (Node node : procDefImpl.getNodes())
+ {
+ NodeImpl nodeImpl = (NodeImpl)node;
+ Set arriving = nodeImpl.getOldNode().getArrivingTransitions();
+ if (!(node instanceof StartEvent) && arriving == null)
+ throw new InvalidProcessException("Unreachable node: " + node);
+ }
+
+ // Detect dead end nodes
+ for (Node node : procDefImpl.getNodes())
+ {
+ NodeImpl nodeImpl = (NodeImpl)node;
+ List leaving = nodeImpl.getOldNode().getLeavingTransitions();
+ if (!(node instanceof EndEvent) && leaving == null)
+ throw new InvalidProcessException("Dead end node: " + node);
+ }
+ return procDefImpl;
+ }
+
+ @Override
+ public ProcessBuilder addStartEvent(String name)
+ {
+ nodeImpl = new StartEventImpl(procDefImpl, new StartState(name));
+ procDefImpl.addNode(nodeImpl);
+ return this;
+ }
+
+ @Override
+ public GatewayBuilder addGateway(String name, GatewayType type)
+ {
+ return null;
+ }
+
+ @Override
+ public ProcessBuilder addTask(String name)
+ {
+ return addTask(name, TaskType.None);
+ }
+
+ @Override
+ public ProcessBuilder addTask(String name, TaskType type)
+ {
+ if (type == TaskType.None)
+ {
+ nodeImpl = new TaskImpl(procDefImpl, new org.jbpm.graph.def.Node(name));
+ procDefImpl.addNode(nodeImpl);
+ }
+ else if (type == TaskType.Wait)
+ {
+ nodeImpl = new WaitStateImpl(procDefImpl, new State(name));
+ procDefImpl.addNode(nodeImpl);
+ }
+ else
+ {
+ throw new NotImplementedException("Unsupported task type: " + type);
+ }
+ return this;
+ }
+
+ @Override
+ public ProcessBuilder addEndEvent(String name)
+ {
+ nodeImpl = new EndEventImpl(procDefImpl, new EndState(name));
+ procDefImpl.addNode(nodeImpl);
+ return this;
+ }
+
+ @Override
+ public ProcessBuilder addSequenceFlow(String targetName)
+ {
+ flows.add(new FlowTuple(nodeImpl.getName(), targetName));
+ return this;
+ }
+
+ private class FlowTuple
+ {
+ String source;
+ String target;
+
+ public FlowTuple(String source, String target)
+ {
+ this.source = source;
+ this.target = target;
+ }
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/model/builder/ProcessBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/service/ProcessBuilderServiceImpl.java
===================================================================
--- jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/service/ProcessBuilderServiceImpl.java 2008-11-15 11:16:48 UTC (rev 2939)
+++ jbpm3/branches/tdiesler/modules/integration/src/main/java/org/jbpm/integration/service/ProcessBuilderServiceImpl.java 2008-11-15 11:17:46 UTC (rev 2940)
@@ -27,7 +27,7 @@
import org.jbpm.api.model.Process;
import org.jbpm.api.service.ProcessBuilderService;
import org.jbpm.api.model.builder.ProcessBuilder;
-
+import org.jbpm.integration.model.builder.ProcessBuilderImpl;
/**
* The ProcessBuilder can be used to build a {@link Process} dynamically.
*
@@ -45,6 +45,6 @@
@Override
public ProcessBuilder getProcessBuilder()
{
- return null;
+ return new ProcessBuilderImpl(getProcessEngine());
}
}
\ No newline at end of file
Modified: jbpm3/branches/tdiesler/pom.xml
===================================================================
--- jbpm3/branches/tdiesler/pom.xml 2008-11-15 11:16:48 UTC (rev 2939)
+++ jbpm3/branches/tdiesler/pom.xml 2008-11-15 11:17:46 UTC (rev 2940)
@@ -96,6 +96,11 @@
</dependency>
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-spec-dialect-api10</artifactId>
+ <version>${jbpm.api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-spec-cts</artifactId>
<version>${jbpm.api.version}</version>
<type>zip</type>
More information about the jbpm-commits
mailing list