JBoss JBPM SVN: r2415 - jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-28 17:46:37 -0400 (Sun, 28 Sep 2008)
New Revision: 2415
Modified:
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java 2008-09-28 21:26:02 UTC (rev 2414)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java 2008-09-28 21:46:37 UTC (rev 2415)
@@ -1,92 +1,16 @@
-/**
- *
- */
package org.jbpm.test.cts.persistence;
-import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-
-import org.hibernate.annotations.IndexColumn;
-
-@Entity
-public class Node
+public interface Node
{
- @Id
- @GeneratedValue
- public Integer id;
- @Basic
- private String name;
- @ManyToOne
- private Process process;
- @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "target")
- @IndexColumn(name = "targetIndex")
- private List<Flow> inFlows = new ArrayList<Flow>();
- @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "source")
- @IndexColumn(name = "sourceIndex")
- private List<Flow> outFlows = new ArrayList<Flow>();
- public Node()
- {
- }
+ public abstract Process getProcess();
- public Node(String name)
- {
- this.name = name;
- }
+ public abstract String getName();
- public Process getProcess()
- {
- return process;
- }
+ public abstract List<SequenceFlow> getInFlows();
- public void setProcess(Process process)
- {
- this.process = process;
- }
+ public abstract List<SequenceFlow> getOutFlows();
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public List<Flow> getInFlows()
- {
- return inFlows;
- }
-
- public void setInFlows(List<Flow> inFlows)
- {
- this.inFlows = inFlows;
- }
-
- public List<Flow> getOutFlows()
- {
- return outFlows;
- }
-
- public void setOutFlows(List<Flow> flows)
- {
- this.outFlows = flows;
- }
-
- @Override
- public String toString()
- {
- return "[name=" + name + ",in=" + inFlows + ",out=" + outFlows + "]";
- }
-
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java 2008-09-28 21:26:02 UTC (rev 2414)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java 2008-09-28 21:46:37 UTC (rev 2415)
@@ -48,17 +48,17 @@
*/
public void testSaveLoadDelete() throws Exception
{
- Node na = new Node("A");
- Node nb = new Node("B");
- Node nc = new Node("C");
+ NodeImpl na = new NodeImpl("A");
+ NodeImpl nb = new NodeImpl("B");
+ NodeImpl nc = new NodeImpl("C");
- Process proc = new Process("P");
+ ProcessImpl proc = new ProcessImpl("P");
proc.addNode(na);
proc.addNode(nb);
proc.addNode(nc);
- new Flow(na, nb);
- new Flow(nb, nc);
+ new SequenceFlowImpl(na, nb);
+ new SequenceFlowImpl(nb, nc);
System.out.println(proc);
@@ -89,7 +89,7 @@
Session session = getSessionFactory().openSession();
try
{
- proc = (Process)session.load(Process.class, id);
+ proc = (Process)session.load(ProcessImpl.class, id);
Hibernate.initialize(proc);
}
catch (ObjectNotFoundException ex)
@@ -132,9 +132,9 @@
if (sessionFactory == null)
{
AnnotationConfiguration anConfig = new AnnotationConfiguration();
- anConfig.addAnnotatedClass(Process.class);
- anConfig.addAnnotatedClass(Node.class);
- anConfig.addAnnotatedClass(Flow.class);
+ anConfig.addAnnotatedClass(ProcessImpl.class);
+ anConfig.addAnnotatedClass(NodeImpl.class);
+ anConfig.addAnnotatedClass(SequenceFlowImpl.class);
sessionFactory = anConfig.configure(hibernateConfig).buildSessionFactory();
}
return sessionFactory;
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java 2008-09-28 21:26:02 UTC (rev 2414)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java 2008-09-28 21:46:37 UTC (rev 2415)
@@ -1,69 +1,12 @@
-/**
- *
- */
package org.jbpm.test.cts.persistence;
-import java.util.ArrayList;
import java.util.List;
-import javax.persistence.Basic;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.OneToMany;
-
-@Entity
-public class Process
+public interface Process
{
- @Id
- @GeneratedValue
- public Integer id;
- @Basic
- private String name;
- @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "process")
- private List<Node> nodes = new ArrayList<Node>();
- public Process()
- {
- }
+ public abstract String getName();
- public Process(String name)
- {
- this.name = name;
- }
+ public abstract List<Node> getNodes();
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public List<Node> getNodes()
- {
- return nodes;
- }
-
- public void setNodes(List<Node> nodes)
- {
- this.nodes = nodes;
- }
-
- public void addNode(Node node)
- {
- node.setProcess(this);
- nodes.add(node);
- }
-
- @Override
- public String toString()
- {
- return "[name=" + name + ",nodes=" + nodes + "]";
- }
-
}
\ No newline at end of file
17 years, 6 months
JBoss JBPM SVN: r2414 - jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-28 17:26:02 -0400 (Sun, 28 Sep 2008)
New Revision: 2414
Modified:
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java 2008-09-28 20:58:03 UTC (rev 2413)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java 2008-09-28 21:26:02 UTC (rev 2414)
@@ -18,6 +18,10 @@
public Integer id;
@Basic
private String targetName;
+ @Basic
+ private int sourceIndex;
+ @Basic
+ private int targetIndex;
@ManyToOne(cascade = CascadeType.ALL)
private Node source;
@ManyToOne(cascade = CascadeType.ALL)
@@ -32,10 +36,32 @@
this.source = source;
this.target = target;
this.targetName = target.getName();
+ this.sourceIndex = source.getOutFlows().size();
+ this.targetIndex = target.getInFlows().size();
source.getOutFlows().add(this);
target.getInFlows().add(this);
}
+ public int getSourceIndex()
+ {
+ return sourceIndex;
+ }
+
+ public void setSourceIndex(int sourceIndex)
+ {
+ this.sourceIndex = sourceIndex;
+ }
+
+ public int getTargetIndex()
+ {
+ return targetIndex;
+ }
+
+ public void setTargetIndex(int targetIndex)
+ {
+ this.targetIndex = targetIndex;
+ }
+
public String getTargetName()
{
return targetName;
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java 2008-09-28 20:58:03 UTC (rev 2413)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java 2008-09-28 21:26:02 UTC (rev 2414)
@@ -12,9 +12,11 @@
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
-import javax.persistence.Transient;
+import org.hibernate.annotations.IndexColumn;
+
@Entity
public class Node
{
@@ -23,12 +25,13 @@
public Integer id;
@Basic
private String name;
- @Transient
- // @ManyToOne
+ @ManyToOne
private Process process;
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "target")
+ @IndexColumn(name = "targetIndex")
private List<Flow> inFlows = new ArrayList<Flow>();
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "source")
+ @IndexColumn(name = "sourceIndex")
private List<Flow> outFlows = new ArrayList<Flow>();
public Node()
@@ -40,24 +43,24 @@
this.name = name;
}
- public String getName()
+ public Process getProcess()
{
- return name;
+ return process;
}
- public void setName(String name)
+ public void setProcess(Process process)
{
- this.name = name;
+ this.process = process;
}
- public Process getProcess()
+ public String getName()
{
- return process;
+ return name;
}
- public void setProcess(Process process)
+ public void setName(String name)
{
- this.process = process;
+ this.name = name;
}
public List<Flow> getInFlows()
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java 2008-09-28 20:58:03 UTC (rev 2413)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java 2008-09-28 21:26:02 UTC (rev 2414)
@@ -60,14 +60,13 @@
new Flow(na, nb);
new Flow(nb, nc);
- printNode(na);
+ System.out.println(proc);
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
try
{
session.save(proc);
- session.save(na);
tx.commit();
}
@@ -76,31 +75,22 @@
session.close();
}
- Node loadA = loadNode(na.id);
+ Process loadProc = loadProcess(proc.id);
System.out.println();
- printNode(loadA);
+ System.out.println(loadProc);
- deleteNode(na);
+ deleteProcess(proc);
}
- private void printNode(Node node)
+ public Process loadProcess(Integer id)
{
- System.out.println(node);
- for (Flow out : node.getOutFlows())
- {
- printNode(out.getTarget());
- }
- }
-
- public Node loadNode(Integer id)
- {
- Node node = null;
+ Process proc = null;
Session session = getSessionFactory().openSession();
try
{
- node = (Node)session.load(Node.class, id);
- Hibernate.initialize(node);
+ proc = (Process)session.load(Process.class, id);
+ Hibernate.initialize(proc);
}
catch (ObjectNotFoundException ex)
{
@@ -110,16 +100,16 @@
{
session.close();
}
- return node;
+ return proc;
}
- public void deleteNode(Node node)
+ public void deleteProcess(Process proc)
{
Session session = getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
try
{
- session.delete(node);
+ session.delete(proc);
tx.commit();
}
finally
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java 2008-09-28 20:58:03 UTC (rev 2413)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java 2008-09-28 21:26:02 UTC (rev 2414)
@@ -7,10 +7,12 @@
import java.util.List;
import javax.persistence.Basic;
+import javax.persistence.CascadeType;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
-import javax.persistence.Transient;
+import javax.persistence.OneToMany;
@Entity
public class Process
@@ -20,8 +22,7 @@
public Integer id;
@Basic
private String name;
- @Transient
- // @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
+ @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "process")
private List<Node> nodes = new ArrayList<Node>();
public Process()
17 years, 6 months
JBoss JBPM SVN: r2413 - in jbpm4/branches/tdiesler: modules/api/src/main/java/org/jbpm/api/model and 3 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-28 16:58:03 -0400 (Sun, 28 Sep 2008)
New Revision: 2413
Added:
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
Modified:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/AbstractElement.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
jbpm4/branches/tdiesler/pom.xml
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/AbstractElement.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/AbstractElement.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/AbstractElement.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -38,5 +38,5 @@
/**
* Get the ID of this element
*/
- ObjectName getID();
+ ObjectName getKey();
}
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -0,0 +1,74 @@
+/**
+ *
+ */
+package org.jbpm.test.cts.persistence;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Flow
+{
+ @Id
+ @GeneratedValue
+ public Integer id;
+ @Basic
+ private String targetName;
+ @ManyToOne(cascade = CascadeType.ALL)
+ private Node source;
+ @ManyToOne(cascade = CascadeType.ALL)
+ private Node target;
+
+ public Flow()
+ {
+ }
+
+ public Flow(Node source, Node target)
+ {
+ this.source = source;
+ this.target = target;
+ this.targetName = target.getName();
+ source.getOutFlows().add(this);
+ target.getInFlows().add(this);
+ }
+
+ public String getTargetName()
+ {
+ return targetName;
+ }
+
+ public void setTargetName(String targetName)
+ {
+ this.targetName = targetName;
+ }
+
+ public Node getSource()
+ {
+ return source;
+ }
+
+ public void setSource(Node source)
+ {
+ this.source = source;
+ }
+
+ public Node getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(Node target)
+ {
+ this.target = target;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[" + source.getName() + "->" + target.getName() + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Flow.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -0,0 +1,89 @@
+/**
+ *
+ */
+package org.jbpm.test.cts.persistence;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Transient;
+
+@Entity
+public class Node
+{
+ @Id
+ @GeneratedValue
+ public Integer id;
+ @Basic
+ private String name;
+ @Transient
+ // @ManyToOne
+ private Process process;
+ @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "target")
+ private List<Flow> inFlows = new ArrayList<Flow>();
+ @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "source")
+ private List<Flow> outFlows = new ArrayList<Flow>();
+
+ public Node()
+ {
+ }
+
+ public Node(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Process getProcess()
+ {
+ return process;
+ }
+
+ public void setProcess(Process process)
+ {
+ this.process = process;
+ }
+
+ public List<Flow> getInFlows()
+ {
+ return inFlows;
+ }
+
+ public void setInFlows(List<Flow> inFlows)
+ {
+ this.inFlows = inFlows;
+ }
+
+ public List<Flow> getOutFlows()
+ {
+ return outFlows;
+ }
+
+ public void setOutFlows(List<Flow> flows)
+ {
+ this.outFlows = flows;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[name=" + name + ",in=" + inFlows + ",out=" + outFlows + "]";
+ }
+
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Node.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -53,7 +53,7 @@
service.saveProcess(proc);
// Load the process
- ObjectName procID = proc.getID();
+ ObjectName procID = proc.getKey();
Process procLoad = service.loadProcess(procID);
TestProcessBuilder.validateTrivialProcess(procLoad);
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -0,0 +1,152 @@
+/*
+ * 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.test.cts.persistence;
+
+// $Id$
+
+import org.hibernate.Hibernate;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.classic.Session;
+import org.jbpm.api.ProcessNotFoundException;
+import org.jbpm.api.test.CTSTestCase;
+
+/**
+ * Test the ExecutionManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class PersistenceTest extends CTSTestCase
+{
+ private String hibernateConfig;
+ private SessionFactory sessionFactory;
+
+ /**
+ * Test save, load, delete of a trivial process
+ */
+ public void testSaveLoadDelete() throws Exception
+ {
+ Node na = new Node("A");
+ Node nb = new Node("B");
+ Node nc = new Node("C");
+
+ Process proc = new Process("P");
+ proc.addNode(na);
+ proc.addNode(nb);
+ proc.addNode(nc);
+
+ new Flow(na, nb);
+ new Flow(nb, nc);
+
+ printNode(na);
+
+ Session session = getSessionFactory().openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ session.save(proc);
+ session.save(na);
+
+ tx.commit();
+ }
+ finally
+ {
+ session.close();
+ }
+
+ Node loadA = loadNode(na.id);
+
+ System.out.println();
+ printNode(loadA);
+
+ deleteNode(na);
+ }
+
+ private void printNode(Node node)
+ {
+ System.out.println(node);
+ for (Flow out : node.getOutFlows())
+ {
+ printNode(out.getTarget());
+ }
+ }
+
+ public Node loadNode(Integer id)
+ {
+ Node node = null;
+ Session session = getSessionFactory().openSession();
+ try
+ {
+ node = (Node)session.load(Node.class, id);
+ Hibernate.initialize(node);
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ throw new ProcessNotFoundException("Cannot find process: " + id);
+ }
+ finally
+ {
+ session.close();
+ }
+ return node;
+ }
+
+ public void deleteNode(Node node)
+ {
+ Session session = getSessionFactory().openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ session.delete(node);
+ tx.commit();
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ private SessionFactory getSessionFactory()
+ {
+ // If this property is not explicitly set in the beans config
+ // fall back to the -Ddatabase property that also activates
+ // the corresponding mvn profiles
+ if (hibernateConfig == null)
+ {
+ String database = System.getProperty("database", "mysql");
+ hibernateConfig = "hibernate.cfg." + database + ".xml";
+ }
+
+ if (sessionFactory == null)
+ {
+ AnnotationConfiguration anConfig = new AnnotationConfiguration();
+ anConfig.addAnnotatedClass(Process.class);
+ anConfig.addAnnotatedClass(Node.class);
+ anConfig.addAnnotatedClass(Flow.class);
+ sessionFactory = anConfig.configure(hibernateConfig).buildSessionFactory();
+ }
+ return sessionFactory;
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -0,0 +1,68 @@
+/**
+ *
+ */
+package org.jbpm.test.cts.persistence;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Transient;
+
+@Entity
+public class Process
+{
+ @Id
+ @GeneratedValue
+ public Integer id;
+ @Basic
+ private String name;
+ @Transient
+ // @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
+ private List<Node> nodes = new ArrayList<Node>();
+
+ public Process()
+ {
+ }
+
+ public Process(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public List<Node> getNodes()
+ {
+ return nodes;
+ }
+
+ public void setNodes(List<Node> nodes)
+ {
+ this.nodes = nodes;
+ }
+
+ public void addNode(Node node)
+ {
+ node.setProcess(this);
+ nodes.add(node);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "[name=" + name + ",nodes=" + nodes + "]";
+ }
+
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/Process.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -24,7 +24,6 @@
//$Id$
import javax.management.ObjectName;
-import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
@@ -42,35 +41,31 @@
@MappedSuperclass
public abstract class AbstractElementImpl implements AbstractElement
{
- // provide serial version UID
private static final long serialVersionUID = 1L;
- // The cached ID
- protected transient ObjectName id;
- // The persistent key
- private transient String key;
+ @Id
+ private String id;
+ @Transient
+ protected transient ObjectName key;
@Id
- @Column(name = "id")
- public String getKey()
+ public String getId()
{
- if (key == null)
- {
- key = new UID().toString();
- }
- return key;
+ if (id == null)
+ id = new UID().toString();
+
+ return id;
}
- public void setKey(String key)
+ public void setId(String id)
{
- this.key = key;
+ this.id = id;
}
/**
* Get the ID of this element
*/
- @Transient
- public abstract ObjectName getID();
+ public abstract ObjectName getKey();
/**
* Called when the process is created
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -58,11 +58,13 @@
// provide logging
final static Logger log = LoggerFactory.getLogger(EndEventImpl.class);
+ @Enumerated(EnumType.STRING)
private ResultType resultType = ResultType.None;
public EndEventImpl(String name)
{
super(name);
+ this.eventType = EventType.End;
}
// Persistence ctor
@@ -70,13 +72,6 @@
{
}
- @Enumerated(EnumType.STRING)
- public EventType getEventType()
- {
- return EventType.End;
- }
-
- @Enumerated(EnumType.STRING)
public ResultType getResultType()
{
return resultType;
@@ -90,15 +85,15 @@
@Override
@Transient
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=EndEvent,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=EndEvent,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
@Transient
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -24,55 +24,61 @@
//$Id$
import javax.management.ObjectName;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.MappedSuperclass;
import org.jbpm.api.Constants;
import org.jbpm.api.model.Event;
import org.jbpm.api.model.builder.ObjectNameFactory;
/**
- * An Event is something that “happens” during the course of a business process.
- * <p/>
- * These Events affect the flow of the Process and usually have a cause or an impact.
+ * An Event is something that “happens” during the course of a business process. <p/> These Events affect the flow of
+ * the Process and usually have a cause or an impact.
*
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
+@MappedSuperclass
public class EventImpl extends NodeImpl implements Event
{
// provide serial version UID
private static final long serialVersionUID = 1L;
-
+
+ @Enumerated(EnumType.STRING)
+ protected EventType eventType;
+
public EventImpl(String name)
{
super(name);
+ this.eventType = EventType.Intermediate;
}
-
+
// Persistence ctor
protected EventImpl()
{
}
@Override
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=Event,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=Event,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
public EventType getEventType()
{
- return EventType.Intermediate;
+ return eventType;
}
// Persistence method
protected void setEventType(EventType eventType)
{
- // nothing to do
+ this.eventType = eventType;
}
-
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -54,15 +54,15 @@
}
@Override
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=" + getGatewayType() + "Gateway,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=" + getGatewayType() + "Gateway,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
public List<SequenceFlow> getGates()
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -26,13 +26,11 @@
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.CascadeType;
+import javax.persistence.Basic;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -62,11 +60,13 @@
// provide serial version UID
private static final long serialVersionUID = 1L;
+ @Basic
private String name;
- private Process proc;
- // The list of incomming flows
+ @Transient // @ManyToOne(targetEntity = ProcessImpl.class)
+ private Process process;
+ @Transient // @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "targetRef", targetEntity = SequenceFlowImpl.class)
protected List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
- // The list of outgoing flows
+ @Transient // @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "sourceRef", targetEntity = SequenceFlowImpl.class)
protected List<SequenceFlow> outFlows = new ArrayList<SequenceFlow>();
public NodeImpl(String name)
@@ -79,16 +79,15 @@
{
}
- @ManyToOne(targetEntity = ProcessImpl.class)
public Process getProcess()
{
- return proc;
+ return process;
}
// Persistence method
protected void setProcess(Process proc)
{
- this.proc = proc;
+ this.process = proc;
}
public String getName()
@@ -101,7 +100,6 @@
this.name = name;
}
- @Transient
public List<SequenceFlow> getInFlows()
{
return inFlows;
@@ -113,7 +111,6 @@
this.inFlows = inFlows;
}
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
public List<SequenceFlow> getOutFlows()
{
return outFlows;
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -28,6 +28,7 @@
import java.util.List;
import javax.management.ObjectName;
+import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -59,19 +60,22 @@
@Table(name = "JBPM_PROCESS")
public class ProcessImpl extends AbstractElementImpl implements Process
{
+ private static final long serialVersionUID = 1L;
+
// Provide logging
final static Logger log = LoggerFactory.getLogger(ProcessImpl.class);
- // provide serial version UID
- private static final long serialVersionUID = 1L;
- // The required process name
+ @Basic
private String name;
- // The list of associated flow objects
+
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
private List<Node> nodes = new ArrayList<Node>();
- // the status of the process
+
+ @Enumerated(EnumType.STRING)
private ProcessStatus status = ProcessStatus.None;
- // The possible exception that caused the process to abort
- private transient RuntimeException runtimeException;
+
+ @Transient
+ private transient RuntimeException runtimeException;
public ProcessImpl(String name)
{
@@ -85,15 +89,15 @@
@Override
@Transient
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=Process,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=Process,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
public String getName()
@@ -106,13 +110,12 @@
this.name = name;
}
- @Enumerated(EnumType.STRING)
- public synchronized ProcessStatus getProcessStatus()
+ public ProcessStatus getProcessStatus()
{
return status;
}
- public synchronized void setProcessStatus(ProcessStatus status)
+ public void setProcessStatus(ProcessStatus status)
{
this.status = status;
}
@@ -122,13 +125,9 @@
nodes.add(node);
}
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
public List<Node> getNodes()
{
- if (status == ProcessStatus.None)
- return nodes;
-
- return Collections.unmodifiableList(nodes);
+ return nodes;
}
// Persistence method
@@ -211,7 +210,6 @@
// Runtime Aspects ====================================================================================================
- @Transient
public RuntimeException getRuntimeException()
{
return runtimeException;
@@ -235,7 +233,7 @@
private ObjectName startProcessInternal(Attachments att)
{
- return getID();
+ return getKey();
}
public ProcessStatus waitForEnd()
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -23,12 +23,15 @@
//$Id$
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -54,12 +57,19 @@
@GeneratedValue
@SuppressWarnings("unused")
private Integer id;
-
+
+ @Enumerated(EnumType.STRING)
private ConditionType conditionType = ConditionType.None;
+
+ @Basic
private String targetName;
+
+ @Transient // @ManyToOne(cascade = CascadeType.ALL, targetEntity = NodeImpl.class)
private Node sourceRef;
+
+ @Transient // @ManyToOne(cascade = CascadeType.ALL, targetEntity = NodeImpl.class)
private Node targetRef;
-
+
@Embedded
private ExpressionImpl conditionExpression;
@@ -80,7 +90,6 @@
{
}
- @Transient
public Node getSourceRef()
{
return sourceRef;
@@ -91,12 +100,11 @@
this.sourceRef = source;
}
- @Transient
public Node getTargetRef()
{
return targetRef;
}
-
+
protected void setTargetRef(Node target)
{
this.targetRef = target;
@@ -112,8 +120,7 @@
{
this.targetName = targetName;
}
-
- @Enumerated(EnumType.STRING)
+
public ConditionType getConditionType()
{
return conditionType;
@@ -137,11 +144,11 @@
String srcName = null;
if (sourceRef != null)
- srcName = (sourceRef.getName() != null ? sourceRef.getName() : sourceRef.getID().getCanonicalName());
+ srcName = (sourceRef.getName() != null ? sourceRef.getName() : sourceRef.getKey().getCanonicalName());
String tarName = null;
if (targetRef != null)
- tarName = (targetRef.getName() != null ? targetRef.getName() : targetRef.getID().getCanonicalName());
+ tarName = (targetRef.getName() != null ? targetRef.getName() : targetRef.getKey().getCanonicalName());
return "SequenceFlow[" + srcName + "->" + tarName + "]";
}
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -25,6 +25,8 @@
import javax.management.ObjectName;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -49,16 +51,18 @@
@Table(name = "JBPM_START_EVENT")
public class StartEventImpl extends EventImpl implements StartEvent, SingleOutFlowSupport
{
+ private static final long serialVersionUID = 1L;
+
// Provide logging
final static Logger log = LoggerFactory.getLogger(StartEventImpl.class);
- // provide serial version UID
- private static final long serialVersionUID = 1L;
+ @Enumerated(EnumType.STRING)
private TriggerType triggerType = TriggerType.None;
public StartEventImpl(String name)
{
super(name);
+ this.eventType = EventType.Start;
}
// Persistence ctor
@@ -66,16 +70,11 @@
{
}
- public EventType getEventType()
- {
- return EventType.Start;
- }
-
public TriggerType getTriggerType()
{
return triggerType;
}
-
+
// Persistence method
protected void setTriggerType(TriggerType triggerType)
{
@@ -83,16 +82,15 @@
}
@Override
- @Transient
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=StartEvent,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=StartEvent,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
@Transient
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -80,15 +80,15 @@
@Override
@Transient
- public ObjectName getID()
+ public ObjectName getKey()
{
- if (id == null)
+ if (key == null)
{
StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
- str.append("type=" + getTaskType() + "Task,name=" + getName() + ",id=" + getKey());
- id = ObjectNameFactory.create(str.toString());
+ str.append("type=" + getTaskType() + "Task,name=" + getName() + ",id=" + getId());
+ key = ObjectNameFactory.create(str.toString());
}
- return id;
+ return key;
}
@Transient
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java 2008-09-28 20:58:03 UTC (rev 2413)
@@ -71,7 +71,7 @@
{
session.close();
}
- return proc.getID();
+ return proc.getKey();
}
public Process loadProcess(ObjectName procID)
Modified: jbpm4/branches/tdiesler/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/pom.xml 2008-09-28 09:52:28 UTC (rev 2412)
+++ jbpm4/branches/tdiesler/pom.xml 2008-09-28 20:58:03 UTC (rev 2413)
@@ -40,7 +40,7 @@
<!-- Properties -->
<properties>
- <hibernate.version>3.2.5.ga</hibernate.version>
+ <hibernate.version>3.2.6.ga</hibernate.version>
<log4j.version>1.2.14</log4j.version>
<slf4j.version>1.5.3</slf4j.version>
</properties>
17 years, 6 months
JBoss JBPM SVN: r2412 - in jbpm4/branches/tdiesler/modules: cts/src/test/java/org/jbpm/test/cts/persistence and 3 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-28 05:52:28 -0400 (Sun, 28 Sep 2008)
New Revision: 2412
Added:
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/TestProcessBuilder.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ExpressionImpl.java
Removed:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
Modified:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Expression.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Expression.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Expression.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Expression.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -32,7 +32,7 @@
*/
public interface Expression
{
- public enum ExpressionLanguage
+ enum ExpressionLanguage
{
MVEL
}
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -1,67 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-
-/**
- * There MAY be zero or more Gates (except where noted below). Zero Gates are
- * allowed if the Gateway is last object in a Process flow and there are no Start or
- * End Events for the Process. If there are zero or only one incoming Sequence
- * Flow, then there MUST be at least two Gates.
- *
- * For Exclusive Data-Based Gateways
- * When two Gates are required, one of them MAY be the DefaultGate.
- *
- * For Exclusive Event-Based Gateways
- * There MUST be two or more Gates. (Note that this type of Gateway does not act
- * only as a Merge--it is always a Decision, at least.)
- *
- * For Inclusive Gateways
- * When two Gates are required, one of them MAY be the DefaultGate.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface Gate
-{
- /**
- * Each Gate MUST have an associated (outgoing) Sequence Flow.
- *
- * For Exclusive Event-Based, Complex, and Parallel Gateways:
- * The Sequence Flow MUST have its Condition attribute set to None (there is not an
- * evaluation of a condition expression).
- *
- * For Exclusive Data-Based, and Inclusive Gateways:
- * The Sequence Flow MUST have its Condition attribute set to Expression and
- * MUST have a valid ConditionExpression. The ConditionExpression MUST be
- * unique for all the Gates within the Gateway. If there is only one Gate (i.e., the
- * Gateway is acting only as a Merge), then Sequence Flow MUST have its Condition
- * set to None.
- *
- * For DefaultGates:
- * The Sequence Flow MUST have its Condition attribute set to Default
- */
- SequenceFlow getOutgoingSequenceFlow();
-
-}
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -66,17 +66,17 @@
* For Inclusive Gateways.
* When two Gates are required, one of them MAY be the DefaultGate.
*/
- List<Gate> getGates();
+ List<SequenceFlow> getGates();
/**
* Get the optional default gate
* @return null if there is none
*/
- Gate getDefaultGate();
+ SequenceFlow getDefaultGate();
/**
* Get the gate for the given target name
* @return null if there is none
*/
- Gate getGateByName(String targetName);
+ SequenceFlow getGateByName(String targetName);
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -88,6 +88,6 @@
* Token will be generated and will traverse the Sequence--Subject to any constraints imposed by a Source that is a
* Gateway.
*/
- //Expression getConditionExpression();
+ Expression getConditionExpression();
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -28,9 +28,9 @@
import org.jbpm.api.ProcessNotFoundException;
import org.jbpm.api.client.ProcessEngine;
import org.jbpm.api.model.Process;
-import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.service.PersistenceService;
import org.jbpm.api.test.CTSTestCase;
+import org.jbpm.test.cts.processbuilder.TestProcessBuilder;
/**
* Test the ExecutionManager
@@ -49,13 +49,13 @@
PersistenceService service = engine.getService(PersistenceService.class);
// Save the process
- Process proc = getProcess();
+ Process proc = TestProcessBuilder.getTrivalProcess();
service.saveProcess(proc);
// Load the process
ObjectName procID = proc.getID();
Process procLoad = service.loadProcess(procID);
- assertEquals("Loaded process name equals", proc.getName(), procLoad.getName());
+ TestProcessBuilder.validateTrivialProcess(procLoad);
// Delete the process
service.deleteProcess(proc);
@@ -69,13 +69,4 @@
// expected
}
}
-
- private Process getProcess()
- {
- ProcessEngine engine = ProcessEngine.getProcessEngine();
- ProcessBuilder builder = engine.getService(ProcessBuilder.class);
- builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
- builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
- return builder.getProcess();
- }
}
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -25,11 +25,7 @@
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.client.ProcessEngine;
-import org.jbpm.api.model.EndEvent;
import org.jbpm.api.model.Process;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.model.StartEvent;
-import org.jbpm.api.model.Task;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.test.CTSTestCase;
@@ -43,43 +39,8 @@
{
public void testBasicProcess() throws Exception
{
- ProcessEngine engine = ProcessEngine.getProcessEngine();
- ProcessBuilder builder = engine.getService(ProcessBuilder.class);
- assertNotNull("ProcessBuilder not null", builder);
-
- builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
- builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
- Process proc = builder.getProcess();
- assertNotNull("Process not null", proc);
- assertEquals("Proc", proc.getName());
-
- StartEvent start = (StartEvent)proc.getNode("Start");
- Task task = (Task)proc.getNode("Task");
- EndEvent end = (EndEvent)proc.getNode("End");
-
- assertNotNull("Start not null", start);
- assertNotNull("Task not null", task);
- assertNotNull("End not null", end);
-
- assertSame(proc, start.getProcess());
- assertSame(proc, task.getProcess());
- assertSame(proc, end.getProcess());
-
- assertSame(start, proc.getNode(StartEvent.class, "Start"));
- assertSame(task, proc.getNode(Task.class, "Task"));
- assertSame(end, proc.getNode(EndEvent.class, "End"));
-
- SequenceFlow startFlow = start.getOutFlow();
- assertNotNull("Start flow not null", startFlow);
- assertEquals("Task", startFlow.getTargetName());
- assertSame(start, startFlow.getSourceRef());
- assertSame(task, startFlow.getTargetRef());
-
- SequenceFlow taskFlow = task.getOutFlow();
- assertNotNull("Task flow not null", taskFlow);
- assertEquals("End", taskFlow.getTargetName());
- assertSame(task, taskFlow.getSourceRef());
- assertSame(end, taskFlow.getTargetRef());
+ Process proc = TestProcessBuilder.getTrivalProcess();
+ TestProcessBuilder.validateTrivialProcess(proc);
}
public void testNoProcessName() throws Exception
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/TestProcessBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/TestProcessBuilder.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/TestProcessBuilder.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -0,0 +1,87 @@
+/*
+ * 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.test.cts.processbuilder;
+
+// $Id$
+
+import junit.framework.TestCase;
+
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.Task;
+import org.jbpm.api.model.builder.ProcessBuilder;
+
+/**
+ * A catalog of CTS test processes
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Sep-2008
+ */
+public abstract class TestProcessBuilder
+{
+ public static Process getTrivalProcess()
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ Process proc = builder.getProcess();
+ return proc;
+ }
+
+ public static void validateTrivialProcess(Process wasProc)
+ {
+ TestCase.assertNotNull("Process not null", wasProc);
+ TestCase.assertEquals("Proc", wasProc.getName());
+
+ StartEvent start = (StartEvent)wasProc.getNode("Start");
+ Task task = (Task)wasProc.getNode("Task");
+ EndEvent end = (EndEvent)wasProc.getNode("End");
+
+ TestCase.assertNotNull("Start not null", start);
+ TestCase.assertNotNull("Task not null", task);
+ TestCase.assertNotNull("End not null", end);
+
+ TestCase.assertSame(wasProc, start.getProcess());
+ TestCase.assertSame(wasProc, task.getProcess());
+ TestCase.assertSame(wasProc, end.getProcess());
+
+ TestCase.assertSame(start, wasProc.getNode(StartEvent.class, "Start"));
+ TestCase.assertSame(task, wasProc.getNode(Task.class, "Task"));
+ TestCase.assertSame(end, wasProc.getNode(EndEvent.class, "End"));
+
+ SequenceFlow startFlow = start.getOutFlow();
+ TestCase.assertNotNull("Start flow not null", startFlow);
+ TestCase.assertEquals("Task", startFlow.getTargetName());
+ TestCase.assertSame(start, startFlow.getSourceRef());
+ TestCase.assertSame(task, startFlow.getTargetRef());
+
+ SequenceFlow taskFlow = task.getOutFlow();
+ TestCase.assertNotNull("Task flow not null", taskFlow);
+ TestCase.assertEquals("End", taskFlow.getTargetName());
+ TestCase.assertSame(task, taskFlow.getSourceRef());
+ TestCase.assertSame(end, taskFlow.getTargetRef());
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/TestProcessBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -31,6 +31,7 @@
import javax.persistence.Transient;
import org.jbpm.api.Constants;
+import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.model.EndEvent;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.builder.ObjectNameFactory;
@@ -57,7 +58,6 @@
// provide logging
final static Logger log = LoggerFactory.getLogger(EndEventImpl.class);
- private SequenceFlow inFlow;
private ResultType resultType = ResultType.None;
public EndEventImpl(String name)
@@ -104,12 +104,14 @@
@Transient
public SequenceFlow getInFlow()
{
- return inFlow;
+ if (inFlows.size() != 1)
+ throw new InvalidProcessException("EndEvent must have one incomming flow: " + inFlows);
+ return inFlows.get(0);
}
public void setInFlow(SequenceFlow inFlow)
{
- this.inFlow = inFlow;
+ inFlows.add(inFlow);
}
public String toString()
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ExpressionImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ExpressionImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ExpressionImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -0,0 +1,68 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.persistence.Embeddable;
+
+import org.jbpm.api.model.Expression;
+
+/**
+ * An Expression, which is used in the definition of attributes for @{link StartEvent},
+ * @{link IntermediateEvent}, @{link Activity}, @{link ComplexGateway}, and @{link SequenceFlow}
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@Embeddable
+public class ExpressionImpl implements Expression
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private String body;
+ private ExpressionLanguage lang;
+
+ public ExpressionImpl(String body)
+ {
+ this.body = body;
+ this.lang = ExpressionLanguage.MVEL;
+ }
+
+ public ExpressionImpl(ExpressionLanguage lang, String body)
+ {
+ this.body = body;
+ this.lang = lang;
+ }
+
+
+ public ExpressionLanguage getExpressionLanguage()
+ {
+ return lang;
+ }
+
+ public String getExpressionBody()
+ {
+ return body;
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ExpressionImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -1,65 +0,0 @@
-/*
- * 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.ri.model;
-
-//$Id$
-
-import org.jbpm.api.model.Expression;
-import org.jbpm.api.model.Gate;
-import org.jbpm.api.model.Gateway;
-import org.jbpm.api.model.SequenceFlow;
-import org.jbpm.api.model.SequenceFlow.ConditionType;
-
-/**
- * A {@link Gate} associated with a {@link Gateway}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public class GateImpl implements Gate
-{
- // provide serial version UID
- private static final long serialVersionUID = 1L;
-
- private SequenceFlow seqFlow;
-
- public GateImpl(String targetName)
- {
- seqFlow = new SequenceFlowImpl(targetName);
- }
-
- public GateImpl(String targetName, ConditionType type, Expression expr)
- {
- seqFlow = new SequenceFlowImpl(targetName, type, expr);
- }
-
- public SequenceFlow getOutgoingSequenceFlow()
- {
- return seqFlow;
- }
-
- public String toString()
- {
- String flowStr = seqFlow.toString();
- return "Gate" + flowStr.substring(flowStr.indexOf('['));
- }
-}
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -23,16 +23,12 @@
//$Id$
-import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import javax.management.ObjectName;
import org.jbpm.api.Constants;
-import org.jbpm.api.model.Gate;
import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.SequenceFlow.ConditionType;
@@ -52,11 +48,6 @@
// provide serial version UID
private static final long serialVersionUID = 1L;
- // The list of incomming flows
- protected List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
- // The list of outgoing gates
- private Map<String, Gate> gates = new LinkedHashMap<String, Gate>();
-
public GatewayImpl(String name)
{
super(name);
@@ -74,34 +65,17 @@
return id;
}
- public List<Gate> getGates()
+ public List<SequenceFlow> getGates()
{
- return Collections.unmodifiableList(new ArrayList<Gate>(gates.values()));
+ return Collections.unmodifiableList(outFlows);
}
- public void addGate(Gate gate)
+ public SequenceFlow getDefaultGate()
{
- String targetName = gate.getOutgoingSequenceFlow().getTargetName();
- gates.put(targetName, gate);
- }
-
- public List<SequenceFlow> getInFlows()
- {
- return Collections.unmodifiableList(inFlows);
- }
-
- public void addInFlow(SequenceFlow inFlow)
- {
- this.inFlows.add(inFlow);
- }
-
- public Gate getDefaultGate()
- {
- Gate gate = null;
- for (Gate aux : gates.values())
+ SequenceFlow gate = null;
+ for (SequenceFlow aux : outFlows)
{
- SequenceFlow seqFlow = aux.getOutgoingSequenceFlow();
- if (seqFlow.getConditionType() == ConditionType.Default)
+ if (aux.getConditionType() == ConditionType.Default)
{
gate = aux;
break;
@@ -110,9 +84,17 @@
return gate;
}
- public Gate getGateByName(String targetName)
+ public SequenceFlow getGateByName(String targetName)
{
- Gate gate = gates.get(targetName);
+ SequenceFlow gate = null;
+ for (SequenceFlow aux : outFlows)
+ {
+ if (aux.getTargetName().equals(targetName))
+ {
+ gate = aux;
+ break;
+ }
+ }
return gate;
}
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -23,15 +23,22 @@
//$Id$
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
+import javax.persistence.Transient;
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.NameNotUniqueException;
import org.jbpm.api.model.EndEvent;
-import org.jbpm.api.model.Gate;
-import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.SequenceFlow;
@@ -49,6 +56,7 @@
*/
@Entity
@Table(name = "JBPM_NODE")
+@Inheritance(strategy = InheritanceType.JOINED)
public abstract class NodeImpl extends AbstractElementImpl implements Node
{
// provide serial version UID
@@ -56,6 +64,10 @@
private String name;
private Process proc;
+ // The list of incomming flows
+ protected List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
+ // The list of outgoing flows
+ protected List<SequenceFlow> outFlows = new ArrayList<SequenceFlow>();
public NodeImpl(String name)
{
@@ -89,11 +101,35 @@
this.name = name;
}
+ @Transient
+ public List<SequenceFlow> getInFlows()
+ {
+ return inFlows;
+ }
+
+ // Persistence method
+ protected void setInFlows(List<SequenceFlow> inFlows)
+ {
+ this.inFlows = inFlows;
+ }
+
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
+ public List<SequenceFlow> getOutFlows()
+ {
+ return outFlows;
+ }
+
+ // Persistence method
+ protected void setOutFlows(List<SequenceFlow> outFlows)
+ {
+ this.outFlows = outFlows;
+ }
+
@Override
protected void initialize(Process proc)
{
super.initialize(proc);
-
+
// Set the associated process
setProcess(proc);
@@ -126,15 +162,6 @@
initFlow(proc, (SequenceFlowImpl)outFlow);
}
}
- else if (this instanceof Gateway)
- {
- Gateway gateway = (Gateway)this;
- for (Gate gate : gateway.getGates())
- {
- outFlow = gate.getOutgoingSequenceFlow();
- initFlow(proc, (SequenceFlowImpl)outFlow);
- }
- }
SequenceFlow inFlow = null;
if (this instanceof SingleInFlowSupport)
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -122,7 +122,7 @@
nodes.add(node);
}
- @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
public List<Node> getNodes()
{
if (status == ProcessStatus.None)
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -23,6 +23,7 @@
//$Id$
+import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -55,12 +56,12 @@
private Integer id;
private ConditionType conditionType = ConditionType.None;
- //private Expression conditionExpression;
private String targetName;
- @Transient
private Node sourceRef;
- @Transient
private Node targetRef;
+
+ @Embedded
+ private ExpressionImpl conditionExpression;
public SequenceFlowImpl(String targetName)
{
@@ -71,7 +72,7 @@
{
this.targetName = targetName;
this.conditionType = type;
- //this.conditionExpression = expr;
+ this.conditionExpression = (ExpressionImpl)expr;
}
// Persistence ctor
@@ -124,11 +125,10 @@
this.conditionType = conditionType;
}
- @Transient
-// public Expression getConditionExpression()
-// {
-// return conditionExpression;
-// }
+ public Expression getConditionExpression()
+ {
+ return conditionExpression;
+ }
public String toString()
{
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -24,15 +24,12 @@
//$Id$
import javax.management.ObjectName;
-import javax.persistence.CascadeType;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.jbpm.api.Constants;
+import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.StartEvent;
import org.jbpm.api.model.builder.ObjectNameFactory;
@@ -57,7 +54,6 @@
// provide serial version UID
private static final long serialVersionUID = 1L;
- private SequenceFlow outFlow;
private TriggerType triggerType = TriggerType.None;
public StartEventImpl(String name)
@@ -99,16 +95,17 @@
return id;
}
- @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
- @JoinColumn
+ @Transient
public SequenceFlow getOutFlow()
{
- return outFlow;
+ if (outFlows.size() != 1)
+ throw new InvalidProcessException("StartEvent must have one outgoing flow: " + outFlows);
+ return outFlows.get(0);
}
- public void setOutFlow(SequenceFlow flow)
+ public void setOutFlow(SequenceFlow outFlow)
{
- this.outFlow = flow;
+ outFlows.add(outFlow);
}
public String toString()
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -24,9 +24,14 @@
//$Id$
import javax.management.ObjectName;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Table;
import javax.persistence.Transient;
import org.jbpm.api.Constants;
+import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.Task;
import org.jbpm.api.model.builder.ObjectNameFactory;
@@ -42,13 +47,14 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
+@Entity
+@Table(name = "JBPM_TASK")
public class TaskImpl extends NodeImpl implements Task, SingleOutFlowSupport, SingleInFlowSupport
{
// provide serial version UID
private static final long serialVersionUID = 1L;
- private SequenceFlow inFlow;
- private SequenceFlow outFlow;
+ private TaskType taskType = TaskType.None;
public TaskImpl(String name)
{
@@ -60,10 +66,17 @@
{
}
+ @Enumerated(EnumType.STRING)
public TaskType getTaskType()
{
- return TaskType.None;
+ return taskType;
}
+
+ // Persistence method
+ protected void setTaskType(TaskType taskType)
+ {
+ this.taskType = taskType;
+ }
@Override
@Transient
@@ -78,24 +91,30 @@
return id;
}
+ @Transient
public SequenceFlow getInFlow()
{
- return inFlow;
+ if (inFlows.size() != 1)
+ throw new InvalidProcessException("Task must have one incomming flow: " + inFlows);
+ return inFlows.get(0);
}
public void setInFlow(SequenceFlow inFlow)
{
- this.inFlow = inFlow;
+ inFlows.add(inFlow);
}
+ @Transient
public SequenceFlow getOutFlow()
{
- return outFlow;
+ if (outFlows.size() != 1)
+ throw new InvalidProcessException("Task must have one outgoing flow: " + outFlows);
+ return outFlows.get(0);
}
public void setOutFlow(SequenceFlow outFlow)
{
- this.outFlow = outFlow;
+ outFlows.add(outFlow);
}
public String toString()
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java 2008-09-28 04:50:38 UTC (rev 2411)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java 2008-09-28 09:52:28 UTC (rev 2412)
@@ -76,13 +76,14 @@
public Process loadProcess(ObjectName procID)
{
- Process proc = null;
+ ProcessImpl procImpl = null;
Session session = getSessionFactory().openSession();
try
{
String key = procID.getKeyProperty("id");
- proc = (Process)session.load(ProcessImpl.class, key);
- Hibernate.initialize(proc);
+ procImpl = (ProcessImpl)session.load(ProcessImpl.class, key);
+ Hibernate.initialize(procImpl);
+ procImpl.initialize(procImpl);
}
catch (ObjectNotFoundException ex)
{
@@ -92,7 +93,7 @@
{
session.close();
}
- return proc;
+ return procImpl;
}
public void deleteProcess(Process proc)
17 years, 6 months
JBoss JBPM SVN: r2411 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-28 00:50:38 -0400 (Sun, 28 Sep 2008)
New Revision: 2411
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/JobSession.java
Log:
removing pessimistic locks on jobs, it does not help
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/JobSession.java 2008-09-27 20:52:42 UTC (rev 2410)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/db/JobSession.java 2008-09-28 04:50:38 UTC (rev 2411)
@@ -6,7 +6,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.jbpm.JbpmContext;
@@ -33,7 +32,6 @@
query.setString("lockOwner", lockOwner);
query.setTimestamp("now", new Date());
query.setMaxResults(1);
- query.setLockMode("job", LockMode.UPGRADE);
job = (Job) query.uniqueResult();
} catch (Exception e) {
@@ -50,7 +48,6 @@
query.setString("lockOwner", lockOwner);
query.setTimestamp("now", new Date());
query.setParameter("processInstance", processInstance);
- query.setLockMode("job", LockMode.UPGRADE);
jobs = query.list();
} catch (Exception e) {
@@ -104,7 +101,7 @@
public Job loadJob(long jobId) {
try {
- return (Job) session.load(Job.class, new Long(jobId), LockMode.UPGRADE);
+ return (Job) session.load(Job.class, new Long(jobId));
} catch (Exception e) {
log.error(e);
throw new JbpmException("couldn't load job '"+jobId+"'", e);
17 years, 6 months
JBoss JBPM SVN: r2410 - in jbpm4/branches/tdiesler: modules/api/src/main/java/org/jbpm/api/client and 11 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-27 16:52:42 -0400 (Sat, 27 Sep 2008)
New Revision: 2410
Added:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/PersistenceService.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
Removed:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
Modified:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
jbpm4/branches/tdiesler/modules/cts/pom.xml
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
jbpm4/branches/tdiesler/modules/impl/pom.xml
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
jbpm4/branches/tdiesler/pom.xml
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -89,7 +89,9 @@
}
/**
- * Get the registered default ProcessEngine <p/> If there is no ProcessEngine registered, a call to this method will
+ * Get the registered default ProcessEngine
+ * <p/>
+ * If there is no ProcessEngine registered, a call to this method will
* register the default engine automatically.
*
* @return The configured instance of a process engine
@@ -135,13 +137,6 @@
this.name = name;
}
- /**
- * Do a shutdown of this
- */
- public void shutdownProcessEngine()
- {
- }
-
private static ProcessEngine loadDefaultEngine()
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -1,58 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-/**
- * Sequence Flow and Message Flow, to a certain extent, represent orthogonal aspects of the business processes depicted in a model,
- * although they both affect the performance of activities within a Process.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface Flow
-{
- /**
- * Name is an optional attribute that is text description of the Connecting Object.
- */
- String getName();
-
- /**
- * SourceRef is an attribute that identifies which Graphical Element the Connecting
- * Object is connected from. Note: there are restrictions as to what objects Sequence
- * Flow and Message Flow can connect.
- */
- Node getSourceRef();
-
- /**
- * TargetRef is an attribute that identifies which Graphical Element the Connecting
- * Object is connected to. Note: there are restrictions as to what objects Sequence
- * Flow and Message Flow can connect.
- */
- Node getTargetRef();
-
- /**
- * Get the required target name
- */
- String getTargetName();
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -21,7 +21,9 @@
*/
package org.jbpm.api.model;
+import java.io.Serializable;
+
//$Id$
/**
@@ -34,7 +36,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public interface SequenceFlow extends Flow
+public interface SequenceFlow extends Serializable
{
/**
* The ConditionType
@@ -45,6 +47,25 @@
}
/**
+ * SourceRef is an attribute that identifies which Graphical Element the Connecting
+ * Object is connected from. Note: there are restrictions as to what objects Sequence
+ * Flow and Message Flow can connect.
+ */
+ Node getSourceRef();
+
+ /**
+ * TargetRef is an attribute that identifies which Graphical Element the Connecting
+ * Object is connected to. Note: there are restrictions as to what objects Sequence
+ * Flow and Message Flow can connect.
+ */
+ Node getTargetRef();
+
+ /**
+ * Get the required target name
+ */
+ String getTargetName();
+
+ /**
* By default, the ConditionType of a Sequence Flow is None. This means that there is no evaluation at runtime to
* determine whether or not the Sequence Flow will be used. Once a Token is ready to traverse the Sequence Flow (i.e.,
* the Source is an activity that has completed), then the Token will do so. The normal, uncontrolled use of Sequence
@@ -67,6 +88,6 @@
* Token will be generated and will traverse the Sequence--Subject to any constraints imposed by a Source that is a
* Gateway.
*/
- Expression getConditionExpression();
+ //Expression getConditionExpression();
}
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/PersistenceService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/PersistenceService.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/PersistenceService.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -0,0 +1,44 @@
+/*
+ * 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.api.service;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Process;
+
+/**
+ * The persistence service for a process.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 17-Sep-2008
+ */
+public interface PersistenceService extends Service
+{
+ ObjectName saveProcess(Process proc);
+
+ Process loadProcess(ObjectName procID);
+
+ void deleteProcess(Process proc);
+
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/PersistenceService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/cts/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/pom.xml 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/cts/pom.xml 2008-09-27 20:52:42 UTC (rev 2410)
@@ -25,6 +25,11 @@
<relativePath>../../pom.xml</relativePath>
</parent>
+ <!-- Properties -->
+ <properties>
+ <mysql.connector.version>5.1.6</mysql.connector.version>
+ </properties>
+
<!-- Dependencies -->
<dependencies>
<dependency>
@@ -46,6 +51,17 @@
</dependency>
</dependencies>
+ <!-- DependencyManagement -->
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>${mysql.connector.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<!-- Plugins -->
<build>
<plugins>
@@ -75,6 +91,29 @@
</dependencies>
</profile>
+ <!--
+ Name: no-database
+ Descr: Setup the default database
+ -->
+ <profile>
+ <id>no-database</id>
+ <activation>
+ <property>
+ <name>!database</name>
+ </property>
+ </activation>
+ <properties>
+ <database>mysql</database>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
</profiles>
</project>
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -0,0 +1,81 @@
+/*
+ * 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.test.cts.persistence;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.ProcessNotFoundException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.service.PersistenceService;
+import org.jbpm.api.test.CTSTestCase;
+
+/**
+ * Test the ExecutionManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class PersistenceServiceTest extends CTSTestCase
+{
+ /**
+ * Test save, load, delete of a trivial process
+ */
+ public void testSaveLoadDelete() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ PersistenceService service = engine.getService(PersistenceService.class);
+
+ // Save the process
+ Process proc = getProcess();
+ service.saveProcess(proc);
+
+ // Load the process
+ ObjectName procID = proc.getID();
+ Process procLoad = service.loadProcess(procID);
+ assertEquals("Loaded process name equals", proc.getName(), procLoad.getName());
+
+ // Delete the process
+ service.deleteProcess(proc);
+ try
+ {
+ service.loadProcess(procID);
+ fail("ProcessNotFoundException expected");
+ }
+ catch (ProcessNotFoundException ex)
+ {
+ // expected
+ }
+ }
+
+ private Process getProcess()
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ return builder.getProcess();
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/persistence/PersistenceServiceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -60,6 +60,10 @@
assertNotNull("Start not null", start);
assertNotNull("Task not null", task);
assertNotNull("End not null", end);
+
+ assertSame(proc, start.getProcess());
+ assertSame(proc, task.getProcess());
+ assertSame(proc, end.getProcess());
assertSame(start, proc.getNode(StartEvent.class, "Start"));
assertSame(task, proc.getNode(Task.class, "Task"));
Modified: jbpm4/branches/tdiesler/modules/impl/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/pom.xml 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/pom.xml 2008-09-27 20:52:42 UTC (rev 2410)
@@ -33,8 +33,6 @@
<hibernate.version>3.2.6.ga</hibernate.version>
<hibernate.annotations.version>3.3.1.GA</hibernate.annotations.version>
<hibernate.validator.version>3.0.0.ga</hibernate.validator.version>
- <hsqldb.version>1.8.0.7</hsqldb.version>
- <mysql.connector.version>5.1.6</mysql.connector.version>
</properties>
<!-- DependencyManagement -->
@@ -55,13 +53,6 @@
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.validator.version}</version>
</dependency>
-
- <!-- Database Driver Versions -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${mysql.connector.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -25,6 +25,8 @@
import javax.management.ObjectName;
import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Transient;
@@ -68,16 +70,24 @@
{
}
+ @Enumerated(EnumType.STRING)
public EventType getEventType()
{
return EventType.End;
}
+ @Enumerated(EnumType.STRING)
public ResultType getResultType()
{
return resultType;
}
+ // Persistence method
+ protected void setResultType(ResultType resultType)
+ {
+ this.resultType = resultType;
+ }
+
@Override
@Transient
public ObjectName getID()
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -68,4 +68,11 @@
{
return EventType.Intermediate;
}
+
+ // Persistence method
+ protected void setEventType(EventType eventType)
+ {
+ // nothing to do
+ }
+
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -23,6 +23,12 @@
//$Id$
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
import javax.persistence.Transient;
import org.jbpm.api.model.Expression;
@@ -36,17 +42,25 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
+@Entity
+@Table(name = "JBPM_SEQUENCE_FLOW")
public class SequenceFlowImpl implements SequenceFlow
{
// provide serial version UID
private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue
+ @SuppressWarnings("unused")
+ private Integer id;
+
private ConditionType conditionType = ConditionType.None;
- private Expression conditionExpression;
- private String name;
+ //private Expression conditionExpression;
private String targetName;
- private Node source;
- private Node target;
+ @Transient
+ private Node sourceRef;
+ @Transient
+ private Node targetRef;
public SequenceFlowImpl(String targetName)
{
@@ -57,7 +71,7 @@
{
this.targetName = targetName;
this.conditionType = type;
- this.conditionExpression = expr;
+ //this.conditionExpression = expr;
}
// Persistence ctor
@@ -65,36 +79,26 @@
{
}
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
@Transient
public Node getSourceRef()
{
- return source;
+ return sourceRef;
}
protected void setSourceRef(Node source)
{
- this.source = source;
+ this.sourceRef = source;
}
@Transient
public Node getTargetRef()
{
- return target;
+ return targetRef;
}
protected void setTargetRef(Node target)
{
- this.target = target;
+ this.targetRef = target;
}
public String getTargetName()
@@ -108,6 +112,7 @@
this.targetName = targetName;
}
+ @Enumerated(EnumType.STRING)
public ConditionType getConditionType()
{
return conditionType;
@@ -119,10 +124,11 @@
this.conditionType = conditionType;
}
- public Expression getConditionExpression()
- {
- return conditionExpression;
- }
+ @Transient
+// public Expression getConditionExpression()
+// {
+// return conditionExpression;
+// }
public String toString()
{
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -80,6 +80,12 @@
return triggerType;
}
+ // Persistence method
+ protected void setTriggerType(TriggerType triggerType)
+ {
+ this.triggerType = triggerType;
+ }
+
@Override
@Transient
public ObjectName getID()
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java 2008-09-27 20:52:42 UTC (rev 2410)
@@ -0,0 +1,138 @@
+/*
+ * 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.ri.service;
+
+// $Id$
+
+import javax.management.ObjectName;
+
+import org.hibernate.Hibernate;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.classic.Session;
+import org.jbpm.api.ProcessNotFoundException;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.service.PersistenceService;
+import org.jbpm.ri.model.AbstractElementImpl;
+import org.jbpm.ri.model.EndEventImpl;
+import org.jbpm.ri.model.NodeImpl;
+import org.jbpm.ri.model.ProcessImpl;
+import org.jbpm.ri.model.SequenceFlowImpl;
+import org.jbpm.ri.model.StartEventImpl;
+import org.jbpm.ri.model.TaskImpl;
+
+/**
+ * A Hibernate based persistence service for a process.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 17-Sep-2008
+ */
+public class HibernatePersistenceService implements PersistenceService
+{
+ private String hibernateConfig;
+ private SessionFactory sessionFactory;
+
+ public void setHibernateConfig(String hibernateConfig)
+ {
+ this.hibernateConfig = hibernateConfig;
+ }
+
+ public ObjectName saveProcess(Process proc)
+ {
+ Session session = getSessionFactory().openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ session.saveOrUpdate(proc);
+ tx.commit();
+ }
+ finally
+ {
+ session.close();
+ }
+ return proc.getID();
+ }
+
+ public Process loadProcess(ObjectName procID)
+ {
+ Process proc = null;
+ Session session = getSessionFactory().openSession();
+ try
+ {
+ String key = procID.getKeyProperty("id");
+ proc = (Process)session.load(ProcessImpl.class, key);
+ Hibernate.initialize(proc);
+ }
+ catch (ObjectNotFoundException ex)
+ {
+ throw new ProcessNotFoundException("Cannot find process: " + procID);
+ }
+ finally
+ {
+ session.close();
+ }
+ return proc;
+ }
+
+ public void deleteProcess(Process proc)
+ {
+ Session session = getSessionFactory().openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ session.delete(proc);
+ tx.commit();
+ }
+ finally
+ {
+ session.close();
+ }
+ }
+
+ private SessionFactory getSessionFactory()
+ {
+ // If this property is not explicitly set in the beans config
+ // fall back to the -Ddatabase property that also activates
+ // the corresponding mvn profiles
+ if (hibernateConfig == null)
+ {
+ String database = System.getProperty("database", "mysql");
+ hibernateConfig = "hibernate.cfg." + database + ".xml";
+ }
+
+ if (sessionFactory == null)
+ {
+ AnnotationConfiguration anConfig = new AnnotationConfiguration();
+ anConfig.addAnnotatedClass(AbstractElementImpl.class);
+ anConfig.addAnnotatedClass(EndEventImpl.class);
+ anConfig.addAnnotatedClass(NodeImpl.class);
+ anConfig.addAnnotatedClass(TaskImpl.class);
+ anConfig.addAnnotatedClass(ProcessImpl.class);
+ anConfig.addAnnotatedClass(SequenceFlowImpl.class);
+ anConfig.addAnnotatedClass(StartEventImpl.class);
+ sessionFactory = anConfig.configure(hibernateConfig).buildSessionFactory();
+ }
+ return sessionFactory;
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/service/HibernatePersistenceService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml 2008-09-27 20:52:42 UTC (rev 2410)
@@ -9,11 +9,13 @@
<property name="services">
<set elementClass="org.jbpm.api.service.Service">
<inject bean="jBPMProcessBuilder" />
+ <inject bean="jBPMPersistenceService" />
</set>
</property>
</bean>
<!-- The Services -->
<bean name="jBPMProcessBuilder" class="org.jbpm.ri.model.builder.ProcessBuilderImpl" />
+ <bean name="jBPMPersistenceService" class="org.jbpm.ri.service.HibernatePersistenceService" />
</deployment>
Modified: jbpm4/branches/tdiesler/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/pom.xml 2008-09-27 18:41:41 UTC (rev 2409)
+++ jbpm4/branches/tdiesler/pom.xml 2008-09-27 20:52:42 UTC (rev 2410)
@@ -40,19 +40,9 @@
<!-- Properties -->
<properties>
- <cactus.version>13-1.7.1</cactus.version>
- <clover.version>2.3.1</clover.version>
<hibernate.version>3.2.5.ga</hibernate.version>
- <hsqldb.version>1.8.0.7</hsqldb.version>
- <jboss.j2ee.version>4.2.1.GA</jboss.j2ee.version>
- <jboss.seam.version>2.0.1.GA</jboss.seam.version>
- <jbpm.api.version>1.0.0-SNAPSHOT</jbpm.api.version>
- <jsr233.version>2.0.3</jsr233.version>
- <juel.version>2.1.0</juel.version>
<log4j.version>1.2.14</log4j.version>
- <servlet-api.version>2.5</servlet-api.version>
<slf4j.version>1.5.3</slf4j.version>
- <spring.version>2.5.4</spring.version>
</properties>
<!-- DependencyManagement -->
@@ -66,71 +56,11 @@
<!-- Please sort by groupid -->
<dependency>
- <groupId>cactus</groupId>
- <artifactId>cactus</artifactId>
- <version>${cactus.version}</version>
- </dependency>
- <dependency>
- <groupId>com.cenqua.clover</groupId>
- <artifactId>clover</artifactId>
- <version>${clover.version}</version>
- </dependency>
- <dependency>
- <groupId>hsqldb</groupId>
- <artifactId>hsqldb</artifactId>
- <version>${hsqldb.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>${servlet-api.version}</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-j2ee</artifactId>
- <version>${jboss.j2ee.version}</version>
- </dependency>
- <dependency>
- <groupId>juel</groupId>
- <artifactId>juel</artifactId>
- <version>${juel.version}</version>
- </dependency>
- <dependency>
- <groupId>juel</groupId>
- <artifactId>juel-engine</artifactId>
- <version>${juel.version}</version>
- </dependency>
- <dependency>
- <groupId>juel</groupId>
- <artifactId>juel-impl</artifactId>
- <version>${juel.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j.version}</version>
- </dependency>
- <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
- <groupId>org.jboss.seam</groupId>
- <artifactId>jboss-seam</artifactId>
- <version>${jboss.seam.version}</version>
- </dependency>
- <dependency>
- <groupId>org.livetribe</groupId>
- <artifactId>livetribe-jsr223</artifactId>
- <version>${jsr233.version}</version>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
@@ -140,11 +70,6 @@
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- <version>${spring.version}</version>
- </dependency>
</dependencies>
</dependencyManagement>
17 years, 6 months
JBoss JBPM SVN: r2409 - in jbpm4/branches/tdiesler/modules: impl/src/main/java/org/jbpm/ri/model and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-27 14:41:41 -0400 (Sat, 27 Sep 2008)
New Revision: 2409
Modified:
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-27 18:27:51 UTC (rev 2408)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-27 18:41:41 UTC (rev 2409)
@@ -178,4 +178,38 @@
// expected
}
}
+
+ public void testUnreachableNode() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task1");
+ builder.addTask("Task1").addSequenceFlow("End").addTask("Task2").addSequenceFlow("End").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("Unreachable node Task2");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testDeadEndNode() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("Dead end Task");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
}
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-27 18:41:41 UTC (rev 2409)
@@ -29,11 +29,13 @@
import org.jbpm.api.InvalidProcessException;
import org.jbpm.api.NameNotUniqueException;
+import org.jbpm.api.model.EndEvent;
import org.jbpm.api.model.Gate;
import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.Node;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
import org.jbpm.api.model.builder.MultipleInFlowSupport;
import org.jbpm.api.model.builder.MultipleOutFlowSupport;
import org.jbpm.api.model.builder.SingleInFlowSupport;
@@ -149,8 +151,11 @@
}
}
- if (inFlow == null && outFlow == null)
- throw new InvalidProcessException("Unconnected flow object: " + this);
+ if (inFlow == null && (this instanceof StartEvent == false))
+ throw new InvalidProcessException("Unconnected node: " + this);
+
+ if (outFlow == null && (this instanceof EndEvent == false))
+ throw new InvalidProcessException("Dead end node: " + this);
}
private void initFlow(Process proc, SequenceFlowImpl flow)
17 years, 6 months
JBoss JBPM SVN: r2408 - in jbpm4/branches/tdiesler/modules: api/src/main/java/org/jbpm/api and 13 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-09-27 14:27:51 -0400 (Sat, 27 Sep 2008)
New Revision: 2408
Added:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/
jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
Removed:
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java
Modified:
jbpm4/branches/tdiesler/modules/api/pom.xml
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java
jbpm4/branches/tdiesler/modules/impl/pom.xml
jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java
jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
Log:
wip
Modified: jbpm4/branches/tdiesler/modules/api/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/api/pom.xml 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/pom.xml 2008-09-27 18:27:51 UTC (rev 2408)
@@ -27,7 +27,7 @@
<!-- Properties -->
<properties>
- <jboss.microcontainer.version>2.0.0.Beta15</jboss.microcontainer.version>
+ <jboss.microcontainer.version>2.0.0.CR1</jboss.microcontainer.version>
</properties>
<!-- DependencyManagement -->
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,36 @@
+/*
+ * 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.api;
+
+//$Id$
+
+
+/**
+ * Defines the constants used by the jBPM API
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Constants
+{
+ static final String ID_DOMAIN = "jboss.jbpm";
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/Constants.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/client/ProcessEngine.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -26,8 +26,7 @@
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.HashSet;
import java.util.Set;
import org.jbpm.api.config.Configuration;
@@ -60,7 +59,7 @@
final static Logger log = LoggerFactory.getLogger(ProcessEngine.class);
// The map of registered services
- private Map<Class<Service>, Service> services = new HashMap<Class<Service>, Service>();
+ protected Set<Service> services = new HashSet<Service>();
// The name of this engine
private String name;
@@ -77,7 +76,16 @@
@SuppressWarnings("unchecked")
public <T> T getService(Class<T> clazz)
{
- return (T)services.get(clazz);
+ Service service = null;
+ for (Service aux : services)
+ {
+ if (clazz.isAssignableFrom(aux.getClass()))
+ {
+ service = aux;
+ break;
+ }
+ }
+ return (T)service;
}
/**
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Builder.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,34 +0,0 @@
-/*
- * 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.api.model;
-
-// $Id$
-
-/**
- * The base of all builders.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface Builder
-{
-}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ConnectingObject.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,59 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-/**
- * There are two ways of Connecting Objects in BPMN: a Flow, either sequence or message, and an Association. Sequence
- * Flow and Message Flow, to a certain extent, represent orthogonal aspects of the business processes depicted in a model,
- * although they both affect the performance of activities within a Process.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface ConnectingObject
-{
- /**
- * Name is an optional attribute that is text description of the Connecting Object.
- */
- String getName();
-
- /**
- * SourceRef is an attribute that identifies which Graphical Element the Connecting
- * Object is connected from. Note: there are restrictions as to what objects Sequence
- * Flow and Message Flow can connect.
- */
- Node getSourceRef();
-
- /**
- * TargetRef is an attribute that identifies which Graphical Element the Connecting
- * Object is connected to. Note: there are restrictions as to what objects Sequence
- * Flow and Message Flow can connect.
- */
- Node getTargetRef();
-
- /**
- * Get the required target name
- */
- String getTargetName();
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/EndEvent.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -35,4 +35,16 @@
*/
public interface EndEvent extends Event
{
+ /**
+ * Defines the type of end result
+ */
+ enum ResultType
+ {
+ None, Message, Error, Compensation, Link, Multiple
+ }
+
+ /**
+ * Get the type od end result
+ */
+ ResultType getResultType();
}
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,58 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * Sequence Flow and Message Flow, to a certain extent, represent orthogonal aspects of the business processes depicted in a model,
+ * although they both affect the performance of activities within a Process.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface Flow
+{
+ /**
+ * Name is an optional attribute that is text description of the Connecting Object.
+ */
+ String getName();
+
+ /**
+ * SourceRef is an attribute that identifies which Graphical Element the Connecting
+ * Object is connected from. Note: there are restrictions as to what objects Sequence
+ * Flow and Message Flow can connect.
+ */
+ Node getSourceRef();
+
+ /**
+ * TargetRef is an attribute that identifies which Graphical Element the Connecting
+ * Object is connected to. Note: there are restrictions as to what objects Sequence
+ * Flow and Message Flow can connect.
+ */
+ Node getTargetRef();
+
+ /**
+ * Get the required target name
+ */
+ String getTargetName();
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Flow.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gate.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -60,7 +60,7 @@
* set to None.
*
* For DefaultGates:
- * The Sequence Flow MUST have its Condition attribute set to Otherwise
+ * The Sequence Flow MUST have its Condition attribute set to Default
*/
SequenceFlow getOutgoingSequenceFlow();
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Gateway.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,7 +21,7 @@
*/
package org.jbpm.api.model;
-//$Id:$
+//$Id$
import java.util.List;
@@ -78,5 +78,5 @@
* Get the gate for the given target name
* @return null if there is none
*/
- Gate getGateByTargetName(String targetName);
+ Gate getGateByName(String targetName);
}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Message.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -22,6 +22,7 @@
package org.jbpm.api.model;
+
//$Id$
/**
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageBuilder.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,66 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-import javax.management.ObjectName;
-
-
-/**
- * A MessageBuilder can be used to build a {@link Message} dynamically.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface MessageBuilder extends Builder
-{
- /**
- * Create a {@link Message} with a given name
- */
- MessageBuilder newMessage(String msgName);
-
- /**
- * Add a message destination
- */
- MessageBuilder addToRef(ObjectName toRef);
-
- /**
- * Add a message source
- */
- MessageBuilder addFromRef(ObjectName fromRef);
-
- /**
- * Add a message property
- */
- MessageBuilder addProperty(String name, Object value);
-
- /**
- * Add a message property
- */
- MessageBuilder addProperty(String name, Object value, boolean isCorrelation);
-
- /**
- * Get the Message
- */
- Message getMessage();
-}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/MessageFlow.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,42 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-/**
- * A Message Flow is a dashed line that is used to show the flow of messages between two entities that are prepared to
- * send and receive them. In BPMN, two separate Pools in the Diagram will represent the two entities.
- *
- * Message Flow MUST connect two Pools, either to the Pools themselves or to Flow Objects within the Pools. They cannot
- * connect two objects within the same Pool.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface MessageFlow extends ConnectingObject
-{
- /**
- * MessageRef is an optional attribute that identifies the Message that is being sent.
- */
- Message getMessageRef();
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Node.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -29,7 +29,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public interface Node extends AbstractElement
+public interface Node extends AbstractElement
{
/**
* Get the unique name.
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Participant.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -25,6 +25,8 @@
import javax.management.ObjectName;
+
+
/**
* A Participant, which is used in the definition of attributes for a Pool, {@link Message}, and WebService
*
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Process.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -56,17 +56,22 @@
ProcessStatus getProcessStatus();
/**
- * Get the list of flow objects
+ * Get the list of nodes
*/
List<Node> getNodes();
/**
- * Get a list of flow objects of a given type.
+ * Get a list of nodes of a given type.
*/
<T extends Node> List<T> getNodes(Class<T> clazz);
/**
- * Get a flow object by name.
+ * Get a node of a given type and name
+ */
+ <T extends Node> T getNode(Class<T> clazz, String name);
+
+ /**
+ * Get a node by name.
* @return null if not found
*/
Node getNode(String name);
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/ProcessBuilder.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,119 +0,0 @@
-/*
- * 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.api.model;
-
-// $Id$
-
-/**
- * The ProcessBuilder can be used to build a {@link Process} dynamically.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface ProcessBuilder extends Builder
-{
- /**
- * Add a {@link Process} with a given name
- */
- ProcessBuilder addProcess(String name);
-
- /**
- * Get the {@link Process}.
- * <p/>
- * This is the final call to the ProcessBuilder after all elements have been added.
- * The {@link Process} is initialized and put in state READY
- */
- Process getProcess();
-
- /**
- * Get the {@link Process} for inclusion in another.
- * <p/>
- * This is the final call to the ProcessBuilder after all elements have been added.
- * The {@link Process} is not initialized and stays in state CREATED
- */
- Process getProcessForInclude();
-
- /**
- * Add a SequenceFlow with a given name
- */
- ProcessBuilder addSequenceFlow(String targetName);
-
- /**
- * Add a MessageFlow with a given name
- */
- ProcessBuilder addMessageFlow(String targetName);
-
- /**
- * Add a SartEvent with a given name
- */
- ProcessBuilder addStartEvent(String name);
-
- /**
- * Add an IntermediateEvent with a given name
- */
- ProcessBuilder addEvent(String name);
-
- /**
- * Add an EndEvent with a given name
- */
- ProcessBuilder addEndEvent(String name);
-
- /**
- * Add a Task of {@link Task.TaskType} NONE with a given name
- */
- ProcessBuilder addTask(String name);
-
- /**
- * Add a Task with a given name and type
- */
- ProcessBuilder addTask(String name, Task.TaskType type);
-
- /**
- * Add a Gateway with a given name
- */
- ProcessBuilder addGateway(String name, Gateway.GatewayType type);
-
- /**
- * Add a {@link Message} with a given name.
- */
- MessageBuilder addMessage(String name);
-
- /**
- * Add a process property
- */
- ProcessBuilder addProperty(String name, String value);
-
- /**
- * Add an {@link ExecutionHandler} with a given Class
- */
- ProcessBuilder addExecutionHandler(Class<?> clazz);
-
- /**
- * Add an {@link FlowHandler} with a given Class
- */
- ProcessBuilder addFlowHandler(Class<?> clazz);
-
- /**
- * Add an {@link SignalHandler} with a given Class
- */
- ProcessBuilder addSignalHandler(Class<?> clazz);
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/SequenceFlow.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,6 +21,7 @@
*/
package org.jbpm.api.model;
+
//$Id$
/**
@@ -33,7 +34,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public interface SequenceFlow extends ConnectingObject
+public interface SequenceFlow extends Flow
{
/**
* The ConditionType
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StartEvent.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -33,4 +33,21 @@
*/
public interface StartEvent extends Event
{
+ /**
+ * Defines the start trigger type
+ */
+ enum TriggerType
+ {
+ None, Message, Timer, Rule, Signal
+ }
+
+ /**
+ * Get the outgoing SequenceFlow
+ */
+ SequenceFlow getOutFlow();
+
+ /**
+ * Get the start trigger type
+ */
+ TriggerType getTriggerType();
}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/StructuralProcess.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,51 +0,0 @@
-/*
- * 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.api.model;
-
-//$Id$
-
-import java.util.List;
-
-/**
- * A Process is any Activity performed within a company or organization.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface StructuralProcess extends Process
-{
- /**
- * Get the list of flow objects
- */
- List<Node> getNodes();
-
- /**
- * Get a list of flow objects of a given type.
- */
- <T extends Node> List<T> getNodes(Class<T> clazz);
-
- /**
- * Get a flow object by name.
- * @return null if not found
- */
- Node getNode(String name);
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -52,4 +52,9 @@
* The TaskType list MAY be extended to include new types.
*/
TaskType getTaskType();
+
+ /**
+ * Get the outgoing SequenceFlow
+ */
+ SequenceFlow getOutFlow();
}
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,68 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.model.Message;
+
+
+/**
+ * A MessageBuilder can be used to build a {@link Message} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MessageBuilder
+{
+ /**
+ * Create a {@link Message} with a given name
+ */
+ MessageBuilder newMessage(String msgName);
+
+ /**
+ * Add a message destination
+ */
+ MessageBuilder addToRef(ObjectName toRef);
+
+ /**
+ * Add a message source
+ */
+ MessageBuilder addFromRef(ObjectName fromRef);
+
+ /**
+ * Add a message property
+ */
+ MessageBuilder addProperty(String name, Object value);
+
+ /**
+ * Add a message property
+ */
+ MessageBuilder addProperty(String name, Object value, boolean isCorrelation);
+
+ /**
+ * Get the Message
+ */
+ Message getMessage();
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MessageBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.api.model.builder;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple incomming {@link SequenceFlow}s.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleInFlowSupport
+{
+ /**
+ * Gat the incomming SequenceFlows
+ */
+ List<SequenceFlow> getInFlows();
+
+ /**
+ * Add an incomming SequenceFlow
+ */
+ void addInFlow(SequenceFlow flow);
+
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.api.model.builder;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple outgoing {@link SequenceFlow}s.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleOutFlowSupport
+{
+ /**
+ * Gat the outgoing SequenceFlows
+ */
+ List<SequenceFlow> getOutFlows();
+
+ /**
+ * Add an outgoing SequenceFlow
+ */
+ void addOutFlow(SequenceFlow flow);
+
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/MultipleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,74 @@
+/*
+ * 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.api.model.builder;
+
+// $Id$
+
+import java.util.Hashtable;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+/**
+ * A simple factory for creating safe object names.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 08-May-2006
+ */
+public class ObjectNameFactory
+{
+ public static ObjectName create(String name)
+ {
+ try
+ {
+ return new ObjectName(name);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new Error("Invalid ObjectName: " + name + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, String key, String value)
+ {
+ try
+ {
+ return new ObjectName(domain, key, value);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
+ }
+ }
+
+ public static ObjectName create(String domain, Hashtable<String, String> table)
+ {
+ try
+ {
+ return new ObjectName(domain, table);
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
+ }
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ObjectNameFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,91 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.api.model.Task.TaskType;
+
+/**
+ * The ProcessBuilder can be used to build a {@link Process} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ProcessBuilder
+{
+ /**
+ * Add a {@link Process} with a given name
+ */
+ ProcessBuilder addProcess(String name);
+
+ /**
+ * Get the {@link Process}.
+ * <p/>
+ * This is the final call to the ProcessBuilder after all elements have been added.
+ * The {@link Process} is initialized and put in state READY
+ */
+ Process getProcess();
+
+ /**
+ * Add a SequenceFlow with a given name
+ */
+ ProcessBuilder addSequenceFlow(String targetName);
+
+ /**
+ * Add a SartEvent with a given name
+ */
+ ProcessBuilder addStartEvent(String name);
+
+ /**
+ * Add an IntermediateEvent with a given name
+ */
+ ProcessBuilder addEvent(String name);
+
+ /**
+ * Add an EndEvent with a given name
+ */
+ ProcessBuilder addEndEvent(String name);
+
+ /**
+ * Add a Task of {@link TaskType} NONE with a given name
+ */
+ ProcessBuilder addTask(String name);
+
+ /**
+ * Add a Task of {@link TaskType} with a given name
+ */
+ ProcessBuilder addTask(String name, TaskType type);
+
+ /**
+ * Add a Gateway with a given name
+ */
+ ProcessBuilder addGateway(String name, GatewayType type);
+
+ /**
+ * Add a user defined Node
+ */
+ ProcessBuilder addNode(Node node);
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/ProcessBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single incomming {@link SequenceFlow}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleInFlowSupport
+{
+ /**
+ * Get the incomming SequenceFlow
+ */
+ SequenceFlow getInFlow();
+
+ /**
+ * Set the incomming SequenceFlow
+ */
+ void setInFlow(SequenceFlow flow);
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * 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.api.model.builder;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single outgoing {@link SequenceFlow}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleOutFlowSupport
+{
+ /**
+ * Get the outgoing SequenceFlow
+ */
+ SequenceFlow getOutFlow();
+
+ /**
+ * Set the outgoing SequenceFlow
+ */
+ void setOutFlow(SequenceFlow flow);
+}
Property changes on: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/model/builder/SingleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/ExecutionHandler.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,41 +0,0 @@
-/*
- * 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.api.runtime;
-
-//$Id$
-
-
-/**
- * The ProcessEngine invokes the ExecutionHandler on a
- * Node to execute user provided business logic.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface ExecutionHandler extends Handler
-{
- /**
- * Execute the associated business logic.
- */
- void execute(Token token);
-
-}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/FlowHandler.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,45 +0,0 @@
-/*
- * 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.api.runtime;
-
-// $Id$
-
-import org.jbpm.api.client.ProcessEngine;
-
-/**
- * The {@link ProcessEngine} invokes the FlowHandler on an {@link HandlerSupport}
- * {@link Node} to move the {@link Token} to the next {@link Node}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface FlowHandler extends Handler
-{
- /**
- * Execute the FlowHandler.
- * <p/>
- * The FlowHandler typically invoves one of the {@link TokenExecutor}
- * methods to move the {@link Token} to the next {@link Node}.
- */
- void execute(TokenExecutor tokenExecutor, Token token);
-
-}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/Handler.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,37 +0,0 @@
-/*
- * 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.api.runtime;
-
-import java.io.Serializable;
-
-//$Id$
-
-/**
- * The generic base for handlers that can be associated with a Node.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface Handler extends Serializable
-{
-
-}
\ No newline at end of file
Deleted: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/runtime/SignalHandler.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,47 +0,0 @@
-/*
- * 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.api.runtime;
-
-// $Id$
-
-import org.jbpm.api.client.ProcessEngine;
-import org.jbpm.api.model.Signal;
-
-/**
- * The {@link ProcessEngine} invokes the SignalHandler on an {@link HandlerSupport}
- * {@link Node} to send {@link Signal}s.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-public interface SignalHandler extends Handler
-{
- /**
- * Get signal for enter
- */
- void throwEnterSignal(Token token);
-
- /**
- * Get signal for exit
- */
- void throwExitSignal(Token token);
-}
\ No newline at end of file
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/ProcessService.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -31,6 +31,7 @@
import javax.management.ObjectName;
+import org.jbpm.api.client.ProcessEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,6 +46,8 @@
// Provide logging
final static Logger log = LoggerFactory.getLogger(ProcessService.class);
+ // The associated ProcessEngine
+ private ProcessEngine processEngine;
// The set of registered processes
private Map<ObjectName, Process> procs = new HashMap<ObjectName, Process>();
@@ -53,10 +56,23 @@
{
}
+ /**
+ * Get the associated ProcessEngine
+ */
+ public ProcessEngine getProcessEngine()
+ {
+ return processEngine;
+ }
+
+ public void setProcessEngine(ProcessEngine processEngine)
+ {
+ this.processEngine = processEngine;
+ }
+
/**
* Deploy a new process to the process service.
*/
- ObjectName deploy(Deployment deployment)
+ public ObjectName deploy(Deployment deployment)
{
return null;
Modified: jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java
===================================================================
--- jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/api/src/main/java/org/jbpm/api/service/Service.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -21,7 +21,6 @@
*/
package org.jbpm.api.service;
-import org.jbpm.api.client.ProcessEngine;
//$Id$
@@ -33,8 +32,4 @@
*/
public interface Service
{
- /**
- * Get the associated ProcessEngine
- */
- ProcessEngine getProcessEngine();
}
\ No newline at end of file
Added: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
===================================================================
--- jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,181 @@
+/*
+ * 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.test.cts.processbuilder;
+
+// $Id$
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.Task;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.test.CTSTestCase;
+
+/**
+ * Test the ProcessBuilder
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Sep-2008
+ */
+public class ProcessBuilderTest extends CTSTestCase
+{
+ public void testBasicProcess() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ assertNotNull("ProcessBuilder not null", builder);
+
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ Process proc = builder.getProcess();
+ assertNotNull("Process not null", proc);
+ assertEquals("Proc", proc.getName());
+
+ StartEvent start = (StartEvent)proc.getNode("Start");
+ Task task = (Task)proc.getNode("Task");
+ EndEvent end = (EndEvent)proc.getNode("End");
+
+ assertNotNull("Start not null", start);
+ assertNotNull("Task not null", task);
+ assertNotNull("End not null", end);
+
+ assertSame(start, proc.getNode(StartEvent.class, "Start"));
+ assertSame(task, proc.getNode(Task.class, "Task"));
+ assertSame(end, proc.getNode(EndEvent.class, "End"));
+
+ SequenceFlow startFlow = start.getOutFlow();
+ assertNotNull("Start flow not null", startFlow);
+ assertEquals("Task", startFlow.getTargetName());
+ assertSame(start, startFlow.getSourceRef());
+ assertSame(task, startFlow.getTargetRef());
+
+ SequenceFlow taskFlow = task.getOutFlow();
+ assertNotNull("Task flow not null", taskFlow);
+ assertEquals("End", taskFlow.getTargetName());
+ assertSame(task, taskFlow.getSourceRef());
+ assertSame(end, taskFlow.getTargetRef());
+ }
+
+ public void testNoProcessName() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess(null).addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("Process name required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testNoStartName() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent(null).addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("StartEvent name required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testNoTaskName() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask(null).addSequenceFlow("End").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("Task name required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testNoEndName() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task").addSequenceFlow("End").addEndEvent(null);
+ try
+ {
+ builder.getProcess();
+ fail("EndEvent name required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testNoStartEvent() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addTask("Task").addSequenceFlow("End").addEndEvent("End");
+ try
+ {
+ builder.getProcess();
+ fail("StartEvent required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+
+ public void testNoEndEvent() throws Exception
+ {
+ ProcessEngine engine = ProcessEngine.getProcessEngine();
+ ProcessBuilder builder = engine.getService(ProcessBuilder.class);
+ builder.addProcess("Proc").addStartEvent("Start").addSequenceFlow("Task");
+ builder.addTask("Task");
+ try
+ {
+ builder.getProcess();
+ fail("EndEvent required");
+ }
+ catch (InvalidProcessException e)
+ {
+ // expected
+ }
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/cts/src/test/java/org/jbpm/test/cts/processbuilder/ProcessBuilderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/impl/pom.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/pom.xml 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/pom.xml 2008-09-27 18:27:51 UTC (rev 2408)
@@ -70,7 +70,7 @@
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-api</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/client/ProcessEngineImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -23,7 +23,10 @@
//$Id$
+import java.util.Set;
+
import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.service.Service;
/**
* A process engine with public access
@@ -33,5 +36,8 @@
*/
public class ProcessEngineImpl extends ProcessEngine
{
-
+ public void setServices(Set<Service> services)
+ {
+ this.services = services;
+ }
}
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Column;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.Transient;
+
+import org.jboss.util.id.UID;
+import org.jbpm.api.model.AbstractElement;
+import org.jbpm.api.model.Process;
+
+/**
+ * The parrent of all Elements
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@MappedSuperclass
+public abstract class AbstractElementImpl implements AbstractElement
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ // The cached ID
+ protected transient ObjectName id;
+ // The persistent key
+ private transient String key;
+
+ @Id
+ @Column(name = "id")
+ public String getKey()
+ {
+ if (key == null)
+ {
+ key = new UID().toString();
+ }
+ return key;
+ }
+
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ /**
+ * Get the ID of this element
+ */
+ @Transient
+ public abstract ObjectName getID();
+
+ /**
+ * Called when the process is created
+ */
+ protected void initialize(Process proc)
+ {
+ // nothing to do
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/AbstractElementImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,109 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * As the name implies, the End Event indicates where a Process will end.
+ *
+ * In terms of Sequence Flow, the End Event ends the flow of the Process, and thus, will not have any outgoing Sequence
+ * Flow. An End Event can have a specific Result that will appear as a marker within the center of the End Event shape.
+ * End Event Results are Message, Error, Compensation, Link, and Multiple.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@Entity
+@Table(name = "JBPM_END_EVENT")
+public class EndEventImpl extends EventImpl implements EndEvent, SingleInFlowSupport
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+ // provide logging
+ final static Logger log = LoggerFactory.getLogger(EndEventImpl.class);
+
+ private SequenceFlow inFlow;
+ private ResultType resultType = ResultType.None;
+
+ public EndEventImpl(String name)
+ {
+ super(name);
+ }
+
+ // Persistence ctor
+ protected EndEventImpl()
+ {
+ }
+
+ public EventType getEventType()
+ {
+ return EventType.End;
+ }
+
+ public ResultType getResultType()
+ {
+ return resultType;
+ }
+
+ @Override
+ @Transient
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=EndEvent,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ @Transient
+ public SequenceFlow getInFlow()
+ {
+ return inFlow;
+ }
+
+ public void setInFlow(SequenceFlow inFlow)
+ {
+ this.inFlow = inFlow;
+ }
+
+ public String toString()
+ {
+ return "EndEvent[" + getName() + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EndEventImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,71 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.Event;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+
+/**
+ * An Event is something that “happens” during the course of a business process.
+ * <p/>
+ * These Events affect the flow of the Process and usually have a cause or an impact.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class EventImpl extends NodeImpl implements Event
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ public EventImpl(String name)
+ {
+ super(name);
+ }
+
+ // Persistence ctor
+ protected EventImpl()
+ {
+ }
+
+ @Override
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=Event,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ public EventType getEventType()
+ {
+ return EventType.Intermediate;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/EventImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,65 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.SequenceFlow.ConditionType;
+
+/**
+ * A {@link Gate} associated with a {@link Gateway}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class GateImpl implements Gate
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private SequenceFlow seqFlow;
+
+ public GateImpl(String targetName)
+ {
+ seqFlow = new SequenceFlowImpl(targetName);
+ }
+
+ public GateImpl(String targetName, ConditionType type, Expression expr)
+ {
+ seqFlow = new SequenceFlowImpl(targetName, type, expr);
+ }
+
+ public SequenceFlow getOutgoingSequenceFlow()
+ {
+ return seqFlow;
+ }
+
+ public String toString()
+ {
+ String flowStr = seqFlow.toString();
+ return "Gate" + flowStr.substring(flowStr.indexOf('['));
+ }
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GateImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,118 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.SequenceFlow.ConditionType;
+import org.jbpm.api.model.builder.MultipleInFlowSupport;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+
+/**
+ * Gateways are modelling elements that are used to control how Sequence Flow interact as they converge and diverge
+ * within a Process. If the flow does not need to be controlled, then a Gateway is not needed.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public abstract class GatewayImpl extends NodeImpl implements Gateway, MultipleOutFlowSupport, MultipleInFlowSupport
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ // The list of incomming flows
+ protected List<SequenceFlow> inFlows = new ArrayList<SequenceFlow>();
+ // The list of outgoing gates
+ private Map<String, Gate> gates = new LinkedHashMap<String, Gate>();
+
+ public GatewayImpl(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=" + getGatewayType() + "Gateway,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ public List<Gate> getGates()
+ {
+ return Collections.unmodifiableList(new ArrayList<Gate>(gates.values()));
+ }
+
+ public void addGate(Gate gate)
+ {
+ String targetName = gate.getOutgoingSequenceFlow().getTargetName();
+ gates.put(targetName, gate);
+ }
+
+ public List<SequenceFlow> getInFlows()
+ {
+ return Collections.unmodifiableList(inFlows);
+ }
+
+ public void addInFlow(SequenceFlow inFlow)
+ {
+ this.inFlows.add(inFlow);
+ }
+
+ public Gate getDefaultGate()
+ {
+ Gate gate = null;
+ for (Gate aux : gates.values())
+ {
+ SequenceFlow seqFlow = aux.getOutgoingSequenceFlow();
+ if (seqFlow.getConditionType() == ConditionType.Default)
+ {
+ gate = aux;
+ break;
+ }
+ }
+ return gate;
+ }
+
+ public Gate getGateByName(String targetName)
+ {
+ Gate gate = gates.get(targetName);
+ return gate;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/GatewayImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.ri.model;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple incomming {@link SequenceFlow}s.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleInFlowSupport
+{
+ /**
+ * Gat the incomming SequenceFlows
+ */
+ List<SequenceFlow> getInFlows();
+
+ /**
+ * Add an incomming SequenceFlow
+ */
+ void addInFlow(SequenceFlow flow);
+
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -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.ri.model;
+
+//$Id$
+
+import java.util.List;
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node} support multiple outgoing {@link SequenceFlow}s.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface MultipleOutFlowSupport
+{
+ /**
+ * Gat the outgoing SequenceFlows
+ */
+ List<SequenceFlow> getOutFlows();
+
+ /**
+ * Add an outgoing SequenceFlow
+ */
+ void addOutFlow(SequenceFlow flow);
+
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/MultipleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,184 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NameNotUniqueException;
+import org.jbpm.api.model.Gate;
+import org.jbpm.api.model.Gateway;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.builder.MultipleInFlowSupport;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+
+/**
+ * A Flow Object is one of the set of following graphical objects: Event, Activity, and
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@Entity
+@Table(name = "JBPM_NODE")
+public abstract class NodeImpl extends AbstractElementImpl implements Node
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private Process proc;
+
+ public NodeImpl(String name)
+ {
+ this.name = name;
+ }
+
+ // Persistence ctor
+ protected NodeImpl()
+ {
+ }
+
+ @ManyToOne(targetEntity = ProcessImpl.class)
+ public Process getProcess()
+ {
+ return proc;
+ }
+
+ // Persistence method
+ protected void setProcess(Process proc)
+ {
+ this.proc = proc;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Override
+ protected void initialize(Process proc)
+ {
+ super.initialize(proc);
+
+ // Set the associated process
+ setProcess(proc);
+
+ // Check required name
+ if (name == null)
+ throw new InvalidProcessException("Name is required for: " + this);
+
+ // Check name uniqueness
+ for (Node aux : proc.getNodes())
+ {
+ String auxName = aux.getName();
+ if (aux != this && name.equals(auxName))
+ throw new NameNotUniqueException(toString());
+ }
+
+ // Initialize in/out flows
+ SequenceFlow outFlow = null;
+ if (this instanceof SingleOutFlowSupport)
+ {
+ SingleOutFlowSupport sof = (SingleOutFlowSupport)this;
+ outFlow = sof.getOutFlow();
+ initFlow(proc, (SequenceFlowImpl)outFlow);
+ }
+ else if (this instanceof MultipleOutFlowSupport)
+ {
+ MultipleOutFlowSupport mof = (MultipleOutFlowSupport)this;
+ for (SequenceFlow flow : mof.getOutFlows())
+ {
+ outFlow = flow;
+ initFlow(proc, (SequenceFlowImpl)outFlow);
+ }
+ }
+ else if (this instanceof Gateway)
+ {
+ Gateway gateway = (Gateway)this;
+ for (Gate gate : gateway.getGates())
+ {
+ outFlow = gate.getOutgoingSequenceFlow();
+ initFlow(proc, (SequenceFlowImpl)outFlow);
+ }
+ }
+
+ SequenceFlow inFlow = null;
+ if (this instanceof SingleInFlowSupport)
+ {
+ SingleInFlowSupport sif = (SingleInFlowSupport)this;
+ inFlow = sif.getInFlow();
+ }
+ else if (this instanceof MultipleInFlowSupport)
+ {
+ MultipleInFlowSupport mif = (MultipleInFlowSupport)this;
+ for (SequenceFlow flow : mif.getInFlows())
+ {
+ inFlow = flow;
+ }
+ }
+
+ if (inFlow == null && outFlow == null)
+ throw new InvalidProcessException("Unconnected flow object: " + this);
+ }
+
+ private void initFlow(Process proc, SequenceFlowImpl flow)
+ {
+ if (flow != null)
+ {
+ String name = flow.getTargetName();
+ Node target = proc.getNode(name);
+ if (target == null)
+ throw new InvalidProcessException("Cannot find target for out flow: " + name);
+
+ if (target instanceof SingleInFlowSupport)
+ {
+ SingleInFlowSupport sif = (SingleInFlowSupport)target;
+ sif.setInFlow(flow);
+ }
+ else if (target instanceof MultipleInFlowSupport)
+ {
+ MultipleInFlowSupport mif = (MultipleInFlowSupport)target;
+ mif.addInFlow(flow);
+ }
+ else
+ {
+ throw new InvalidProcessException("Target does not support in flow: " + target);
+ }
+
+ flow.setSourceRef(this);
+ flow.setTargetRef(target);
+ }
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/NodeImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,265 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.ObjectName;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.EndEvent;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.runtime.Attachments;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Process is any Activity performed within a company or organization.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@Entity
+@Table(name = "JBPM_PROCESS")
+public class ProcessImpl extends AbstractElementImpl implements Process
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(ProcessImpl.class);
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ // The required process name
+ private String name;
+ // The list of associated flow objects
+ private List<Node> nodes = new ArrayList<Node>();
+ // the status of the process
+ private ProcessStatus status = ProcessStatus.None;
+ // The possible exception that caused the process to abort
+ private transient RuntimeException runtimeException;
+
+ public ProcessImpl(String name)
+ {
+ this.name = name;
+ }
+
+ // Persistence ctor
+ protected ProcessImpl()
+ {
+ }
+
+ @Override
+ @Transient
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=Process,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Enumerated(EnumType.STRING)
+ public synchronized ProcessStatus getProcessStatus()
+ {
+ return status;
+ }
+
+ public synchronized void setProcessStatus(ProcessStatus status)
+ {
+ this.status = status;
+ }
+
+ public void addNode(Node node)
+ {
+ nodes.add(node);
+ }
+
+ @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "process", targetEntity = NodeImpl.class)
+ public List<Node> getNodes()
+ {
+ if (status == ProcessStatus.None)
+ return nodes;
+
+ return Collections.unmodifiableList(nodes);
+ }
+
+ // Persistence method
+ protected void setNodes(List<Node> Nodes)
+ {
+ this.nodes = Nodes;
+ }
+
+ public Node getNode(String name)
+ {
+ if (name == null)
+ throw new IllegalArgumentException("Cannot find node with name: null");
+
+ Node Node = null;
+ for (Node aux : nodes)
+ {
+ if (name.equals(aux.getName()))
+ {
+ Node = aux;
+ break;
+ }
+ }
+ return Node;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Node> List<T> getNodes(Class<T> clazz)
+ {
+ List<T> retNodes = new ArrayList<T>();
+ for (Node node : nodes)
+ {
+ if (clazz.isAssignableFrom(node.getClass()))
+ retNodes.add((T)node);
+ }
+ return retNodes;
+ }
+
+ public <T extends Node> T getNode(Class<T> clazz, String name)
+ {
+ T node = null;
+ for (T aux : getNodes(clazz))
+ {
+ if (aux.getName().equals(name))
+ {
+ node = aux;
+ break;
+ }
+ }
+ return node;
+ }
+
+ @Override
+ public void initialize(Process proc)
+ {
+ if (status != ProcessStatus.None)
+ throw new IllegalStateException("Cannot initialize process in state: " + status);
+
+ // Initialize the Element
+ super.initialize(this);
+
+ // Check required name
+ if (name == null)
+ throw new InvalidProcessException("Name is required for: " + this);
+
+ if (getNodes(StartEvent.class).size() == 0)
+ throw new InvalidProcessException("Process does not have a start event");
+
+ if (getNodes(EndEvent.class).size() == 0)
+ throw new InvalidProcessException("Process does not have end events");
+
+ // Initialize the nodes
+ for (Node node : nodes)
+ {
+ NodeImpl nodeImpl = (NodeImpl)node;
+ nodeImpl.initialize(this);
+ }
+
+ status = ProcessStatus.Ready;
+ }
+
+ // Runtime Aspects ====================================================================================================
+
+ @Transient
+ public RuntimeException getRuntimeException()
+ {
+ return runtimeException;
+ }
+
+ public void setRuntimeException(RuntimeException rte)
+ {
+ this.runtimeException = rte;
+ setProcessStatus(ProcessStatus.Aborted);
+ }
+
+ public ObjectName startProcess()
+ {
+ return startProcessInternal(null);
+ }
+
+ public ObjectName startProcess(Attachments att)
+ {
+ return startProcessInternal(att);
+ }
+
+ private ObjectName startProcessInternal(Attachments att)
+ {
+ return getID();
+ }
+
+ public ProcessStatus waitForEnd()
+ {
+ return waitForEndInternal(0);
+ }
+
+ public ProcessStatus waitForEnd(long timeout)
+ {
+ return waitForEndInternal(timeout);
+ }
+
+ /**
+ * Wait for the Process to end. All Tokens that are generated at the Start Event for that Process must eventually
+ * arrive at an End Event. The Process will be in a running state until all Tokens are consumed. If the process was
+ * aborted this method throws the causing RuntimeException if avaialable.
+ */
+ private ProcessStatus waitForEndInternal(long timeout)
+ {
+ throw new NotImplementedException();
+ }
+
+ public String toString()
+ {
+ return "Process[" + getName() + ",status=" + getProcessStatus() + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/ProcessImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,142 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * A Sequence Flow is a solid graphical line that is used to show the order that Activities will be performed in a
+ * Process. Each Flow has only one source and only one target.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class SequenceFlowImpl implements SequenceFlow
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private ConditionType conditionType = ConditionType.None;
+ private Expression conditionExpression;
+ private String name;
+ private String targetName;
+ private Node source;
+ private Node target;
+
+ public SequenceFlowImpl(String targetName)
+ {
+ this.targetName = targetName;
+ }
+
+ public SequenceFlowImpl(String targetName, ConditionType type, Expression expr)
+ {
+ this.targetName = targetName;
+ this.conditionType = type;
+ this.conditionExpression = expr;
+ }
+
+ // Persistence ctor
+ protected SequenceFlowImpl()
+ {
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ @Transient
+ public Node getSourceRef()
+ {
+ return source;
+ }
+
+ protected void setSourceRef(Node source)
+ {
+ this.source = source;
+ }
+
+ @Transient
+ public Node getTargetRef()
+ {
+ return target;
+ }
+
+ protected void setTargetRef(Node target)
+ {
+ this.target = target;
+ }
+
+ public String getTargetName()
+ {
+ return targetName;
+ }
+
+ // Persistence method
+ protected void setTargetName(String targetName)
+ {
+ this.targetName = targetName;
+ }
+
+ public ConditionType getConditionType()
+ {
+ return conditionType;
+ }
+
+ // Persistent method
+ protected void setConditionType(ConditionType conditionType)
+ {
+ this.conditionType = conditionType;
+ }
+
+ public Expression getConditionExpression()
+ {
+ return conditionExpression;
+ }
+
+ public String toString()
+ {
+ Node sourceRef = getSourceRef();
+ Node targetRef = getTargetRef();
+
+ String srcName = null;
+ if (sourceRef != null)
+ srcName = (sourceRef.getName() != null ? sourceRef.getName() : sourceRef.getID().getCanonicalName());
+
+ String tarName = null;
+ if (targetRef != null)
+ tarName = (targetRef.getName() != null ? targetRef.getName() : targetRef.getID().getCanonicalName());
+
+ return "SequenceFlow[" + srcName + "->" + tarName + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SequenceFlowImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single incomming {@link SequenceFlow}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleInFlowSupport
+{
+ /**
+ * Get the incomming SequenceFlow
+ */
+ SequenceFlow getInFlow();
+
+ /**
+ * Set the incomming SequenceFlow
+ */
+ void setInFlow(SequenceFlow flow);
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleInFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,45 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import org.jbpm.api.model.SequenceFlow;
+
+/**
+ * Implementing {@link Node}s support a single outgoing {@link SequenceFlow}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface SingleOutFlowSupport
+{
+ /**
+ * Get the outgoing SequenceFlow
+ */
+ SequenceFlow getOutFlow();
+
+ /**
+ * Set the outgoing SequenceFlow
+ */
+ void setOutFlow(SequenceFlow flow);
+}
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/SingleOutFlowSupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,112 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.StartEvent;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Start Event indicates where a particular Process will start. In terms of Sequence Flow, the Start Event starts the
+ * Flow of the Process, and thus, will not have any incoming Sequence Flow. A Start Event can have a Trigger that
+ * indicates how the Process starts: Message, Timer, Rule, Link, or Multiple.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+@Entity
+@Table(name = "JBPM_START_EVENT")
+public class StartEventImpl extends EventImpl implements StartEvent, SingleOutFlowSupport
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(StartEventImpl.class);
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private SequenceFlow outFlow;
+ private TriggerType triggerType = TriggerType.None;
+
+ public StartEventImpl(String name)
+ {
+ super(name);
+ }
+
+ // Persistence ctor
+ protected StartEventImpl()
+ {
+ }
+
+ public EventType getEventType()
+ {
+ return EventType.Start;
+ }
+
+ public TriggerType getTriggerType()
+ {
+ return triggerType;
+ }
+
+ @Override
+ @Transient
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=StartEvent,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = SequenceFlowImpl.class)
+ @JoinColumn
+ public SequenceFlow getOutFlow()
+ {
+ return outFlow;
+ }
+
+ public void setOutFlow(SequenceFlow flow)
+ {
+ this.outFlow = flow;
+ }
+
+ public String toString()
+ {
+ return "StartEvent[" + getName() + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/StartEventImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,105 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import javax.management.ObjectName;
+import javax.persistence.Transient;
+
+import org.jbpm.api.Constants;
+import org.jbpm.api.model.SequenceFlow;
+import org.jbpm.api.model.Task;
+import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.model.builder.SingleInFlowSupport;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+
+/**
+ * A Task is an Atomic Activity that is included within a Process.
+ *
+ * A Task is used when the work in the Process is not broken down to a finer level of Process Model detail. Generally,
+ * an end-user and/or an application are used to perform the Task when it is executed.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class TaskImpl extends NodeImpl implements Task, SingleOutFlowSupport, SingleInFlowSupport
+{
+ // provide serial version UID
+ private static final long serialVersionUID = 1L;
+
+ private SequenceFlow inFlow;
+ private SequenceFlow outFlow;
+
+ public TaskImpl(String name)
+ {
+ super(name);
+ }
+
+ // Persistence ctor
+ protected TaskImpl()
+ {
+ }
+
+ public TaskType getTaskType()
+ {
+ return TaskType.None;
+ }
+
+ @Override
+ @Transient
+ public ObjectName getID()
+ {
+ if (id == null)
+ {
+ StringBuilder str = new StringBuilder(Constants.ID_DOMAIN + ":");
+ str.append("type=" + getTaskType() + "Task,name=" + getName() + ",id=" + getKey());
+ id = ObjectNameFactory.create(str.toString());
+ }
+ return id;
+ }
+
+ public SequenceFlow getInFlow()
+ {
+ return inFlow;
+ }
+
+ public void setInFlow(SequenceFlow inFlow)
+ {
+ this.inFlow = inFlow;
+ }
+
+ public SequenceFlow getOutFlow()
+ {
+ return outFlow;
+ }
+
+ public void setOutFlow(SequenceFlow outFlow)
+ {
+ this.outFlow = outFlow;
+ }
+
+ public String toString()
+ {
+ return "Task[" + getTaskType() + "," + getName() + "]";
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java (rev 0)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java 2008-09-27 18:27:51 UTC (rev 2408)
@@ -0,0 +1,193 @@
+/*
+ * 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.ri.model.builder;
+
+//$Id$
+
+import org.jbpm.api.NotImplementedException;
+import org.jbpm.api.model.Node;
+import org.jbpm.api.model.Process;
+import org.jbpm.api.model.Gateway.GatewayType;
+import org.jbpm.api.model.Task.TaskType;
+import org.jbpm.api.model.builder.MultipleOutFlowSupport;
+import org.jbpm.api.model.builder.ProcessBuilder;
+import org.jbpm.api.model.builder.SingleOutFlowSupport;
+import org.jbpm.api.service.Service;
+import org.jbpm.ri.model.EndEventImpl;
+import org.jbpm.ri.model.EventImpl;
+import org.jbpm.ri.model.NodeImpl;
+import org.jbpm.ri.model.ProcessImpl;
+import org.jbpm.ri.model.SequenceFlowImpl;
+import org.jbpm.ri.model.StartEventImpl;
+import org.jbpm.ri.model.TaskImpl;
+
+/**
+ * The ProcessBuilder can be used to dynamically build a {@link Process}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class ProcessBuilderImpl implements ProcessBuilder, Service
+{
+ protected ProcessImpl proc;
+ protected NodeImpl node;
+
+ public ProcessBuilderImpl()
+ {
+ }
+
+ public ProcessBuilder addProcess(String procName)
+ {
+ proc = new ProcessImpl(procName);
+ return this;
+ }
+
+ public Process getProcess()
+ {
+ ProcessImpl procImpl = getProcessInternal();
+ procImpl.initialize(procImpl);
+ return procImpl;
+ }
+
+ public ProcessBuilder addSequenceFlow(String targetName)
+ {
+ if (node instanceof SingleOutFlowSupport)
+ {
+ SingleOutFlowSupport outFlow = (SingleOutFlowSupport)node;
+ outFlow.setOutFlow(new SequenceFlowImpl(targetName));
+ }
+ else if (node instanceof MultipleOutFlowSupport)
+ {
+ MultipleOutFlowSupport outFlow = (MultipleOutFlowSupport)node;
+ outFlow.addOutFlow(new SequenceFlowImpl(targetName));
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot add a sequence flow to: " + node);
+ }
+ return this;
+ }
+
+ public ProcessBuilder addStartEvent(String name)
+ {
+ node = new StartEventImpl(name);
+ return addNode(node);
+ }
+
+ public ProcessBuilder addEvent(String name)
+ {
+ node = new EventImpl(name);
+ return addNode(node);
+ }
+
+ public ProcessBuilder addEndEvent(String name)
+ {
+ node = new EndEventImpl(name);
+ return addNode(node);
+ }
+
+ public ProcessBuilder addTask(String name)
+ {
+ return addTask(name, TaskType.None);
+ }
+
+ public ProcessBuilder addTask(String name, TaskType type)
+ {
+ if (type == TaskType.None || type == null)
+ {
+ node = new TaskImpl(name);
+ }
+ else if (type == TaskType.Service)
+ {
+ throw new NotImplementedException("JBPM-1652", "Task Type Service");
+ }
+ else if (type == TaskType.Receive)
+ {
+ throw new NotImplementedException();
+ }
+ else if (type == TaskType.Send)
+ {
+ throw new NotImplementedException();
+ }
+ else if (type == TaskType.User)
+ {
+ throw new NotImplementedException("JBPM-1653", "Task Type User");
+ }
+ else if (type == TaskType.Script)
+ {
+ throw new NotImplementedException("JBPM-1654", "Task Type Script");
+ }
+ else if (type == TaskType.Manual)
+ {
+ throw new NotImplementedException("JBPM-1655", "Task Type Manual");
+ }
+ else if (type == TaskType.Reference)
+ {
+ throw new NotImplementedException("JBPM-1656", "Task Type Reference");
+ }
+ else
+ {
+ throw new IllegalStateException("Task type: " + type);
+ }
+ return addNode(node);
+ }
+
+ public ProcessBuilder addGateway(String name, GatewayType type)
+ {
+ node = (NodeImpl)getProcessInternal().getNode(name);
+ if (node == null)
+ {
+ if (GatewayType.Exclusive == type)
+ {
+ throw new NotImplementedException();
+ }
+ else if (GatewayType.Inclusive == type)
+ {
+ throw new NotImplementedException();
+ }
+ else if (GatewayType.Parallel == type)
+ {
+ throw new NotImplementedException();
+ }
+ else if (GatewayType.Complex == type)
+ {
+ throw new NotImplementedException();
+ }
+ addNode(node);
+ }
+ return this;
+ }
+
+ public ProcessBuilder addNode(Node node)
+ {
+ getProcessInternal().addNode(node);
+ return this;
+ }
+
+ private ProcessImpl getProcessInternal()
+ {
+ if (proc == null)
+ throw new IllegalStateException("No process available");
+
+ return proc;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/branches/tdiesler/modules/impl/src/main/java/org/jbpm/ri/model/builder/ProcessBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml 2008-09-27 06:40:16 UTC (rev 2407)
+++ jbpm4/branches/tdiesler/modules/impl/src/main/resources/jbpm-cfg-beans.xml 2008-09-27 18:27:51 UTC (rev 2408)
@@ -1,10 +1,19 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!-- The KernelLocator -->
- <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator"/>
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
- <!-- The ProcessEngine -->
- <bean name="jBPMProcessEngine" class="org.jbpm.ri.client.ProcessEngineImpl">
- </bean>
-
-</deployment>
+ <!-- The KernelLocator -->
+ <bean name="KernelLocator" class="org.jboss.kernel.plugins.util.KernelLocator" />
+
+ <!-- The ProcessEngine -->
+ <bean name="jBPMProcessEngine" class="org.jbpm.ri.client.ProcessEngineImpl">
+ <property name="services">
+ <set elementClass="org.jbpm.api.service.Service">
+ <inject bean="jBPMProcessBuilder" />
+ </set>
+ </property>
+ </bean>
+
+ <!-- The Services -->
+ <bean name="jBPMProcessBuilder" class="org.jbpm.ri.model.builder.ProcessBuilderImpl" />
+
+ </deployment>
17 years, 6 months
JBoss JBPM SVN: r2407 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-27 02:40:16 -0400 (Sat, 27 Sep 2008)
New Revision: 2407
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
Log:
have job executor thread rollback on persistence exception
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-09-27 06:37:01 UTC (rev 2406)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-09-27 06:40:16 UTC (rev 2407)
@@ -168,7 +168,7 @@
}
} catch (Exception e) {
log.debug("exception while executing " + job, e);
- if (isPersistenceException(e)) {
+ if (!isPersistenceException(e)) {
StringWriter memoryWriter = new StringWriter();
e.printStackTrace(new PrintWriter(memoryWriter));
job.setException(memoryWriter.toString());
17 years, 6 months
JBoss JBPM SVN: r2406 - jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-09-27 02:37:01 -0400 (Sat, 27 Sep 2008)
New Revision: 2406
Modified:
jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
Log:
have job executor thread rollback on persistence exception
Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-09-27 05:25:27 UTC (rev 2405)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2008-09-27 06:37:01 UTC (rev 2406)
@@ -166,17 +166,18 @@
if (job.execute(jbpmContext)) {
jobSession.deleteJob(job);
}
- } catch (HibernateException e) {
- log.debug("exception while executing " + job, e);
- // allowing a transaction to proceed after a persistence exception is unsafe
- // TODO rollback on *any* runtime exception?
- jbpmContext.setRollbackOnly();
} catch (Exception e) {
log.debug("exception while executing " + job, e);
- StringWriter memoryWriter = new StringWriter();
- e.printStackTrace(new PrintWriter(memoryWriter));
- job.setException(memoryWriter.toString());
- job.setRetries(job.getRetries()-1);
+ if (isPersistenceException(e)) {
+ StringWriter memoryWriter = new StringWriter();
+ e.printStackTrace(new PrintWriter(memoryWriter));
+ job.setException(memoryWriter.toString());
+ job.setRetries(job.getRetries()-1);
+ }
+ else {
+ // allowing a transaction to proceed after a persistence exception is unsafe
+ jbpmContext.setRollbackOnly();
+ }
}
// if this job is locked too long
@@ -188,7 +189,7 @@
try {
jbpmContext.close();
} catch (JbpmPersistenceException e) {
- // if this is a stale object exception, keep it quiet
+ // if this is a stale state exception, keep it quiet
if (Services.isCausedByStaleState(e)) {
log.debug("optimistic locking failed, couldn't complete job "+job);
} else {
@@ -197,6 +198,16 @@
}
}
}
+
+ private static boolean isPersistenceException(Throwable throwable) {
+ do {
+ if (throwable instanceof HibernateException)
+ return true;
+ throwable = throwable.getCause();
+ } while (throwable != null);
+ return false;
+ }
+
protected Date getNextDueDate() {
Date nextDueDate = null;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
17 years, 6 months