[jbpm-commits] JBoss JBPM SVN: r2412 - in jbpm4/branches/tdiesler/modules: cts/src/test/java/org/jbpm/test/cts/persistence and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Sep 28 05:52:30 EDT 2008


Author: thomas.diesler at 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 at 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 at 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 at jboss.com
+ * @since 08-Jul-2008
+ */
+ at 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 at 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")
+ at 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 at jboss.com
  * @since 08-Jul-2008
  */
+ at Entity
+ at 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)




More information about the jbpm-commits mailing list