[jbpm-commits] JBoss JBPM SVN: r1576 - in api/trunk: modules/api and 7 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jul 10 13:10:40 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-07-10 13:10:40 -0400 (Thu, 10 Jul 2008)
New Revision: 1576

Modified:
   api/trunk/modules/api/pom.xml
   api/trunk/modules/api/scripts/antrun-schemagen.xml
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Activity.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Flow.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageFlow.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/NamedFlowObject.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessMarshaller.java
   api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java
   api/trunk/modules/api/src/main/resources/org/jboss/bpm/model/jaxb.index
   api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java
   api/trunk/modules/testsuite/pom.xml
   api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java
   api/trunk/pom.xml
Log:
Add JAXB Flow

Modified: api/trunk/modules/api/pom.xml
===================================================================
--- api/trunk/modules/api/pom.xml	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/pom.xml	2008-07-10 17:10:40 UTC (rev 1576)
@@ -41,14 +41,14 @@
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
     </dependency>
-
+    
     <!-- Provided Dependencies -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>provided</scope>
     </dependency>
-    
+
     <!-- Runtime/System Dependencies -->
     <dependency>
       <groupId>com.sun.xml.bind</groupId>
@@ -81,12 +81,15 @@
             <include>Event.java</include>
             <include>ExclusiveGateway.java</include>
             <include>FlowObject.java</include>
+            <include>Flow.java</include>
             <include>Gateway.java</include>
             <include>InclusiveGateway.java</include>
             <include>ItermediateEvent.java</include>
+            <include>MessageFlow.java</include>
             <include>NamedFlowObject.java</include>
             <include>ParallelGateway.java</include>
             <include>Process.java</include>
+            <include>SequenceFlow.java</include>
             <include>Signal.java</include>
             <include>StartEvent.java</include>
             <include>SubProcess.java</include>

Modified: api/trunk/modules/api/scripts/antrun-schemagen.xml
===================================================================
--- api/trunk/modules/api/scripts/antrun-schemagen.xml	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/scripts/antrun-schemagen.xml	2008-07-10 17:10:40 UTC (rev 1576)
@@ -30,13 +30,16 @@
       <include name="EndEvent.java"/>
       <include name="Event.java"/>
       <include name="ExclusiveGateway.java"/>
+      <include name="Flow.java"/>
       <include name="FlowObject.java"/>
       <include name="Gateway.java"/>
       <include name="InclusiveGateway.java"/>
       <include name="ItermediateEvent.java"/>
+      <include name="MessageFlow.java"/>
       <include name="NamedFlowObject.java"/>
       <include name="ParallelGateway.java"/>
       <include name="Process.java"/>
+      <include name="SequenceFlow.java"/>
       <include name="Signal.java"/>
       <include name="StartEvent.java"/>
       <include name="SubProcess.java"/>

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Activity.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Activity.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Activity.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -50,18 +50,4 @@
   {
     super(name);
   }
-  
-  /** 
-   * Call to initialize fully
-   * Note, this MUST NOT leak into the public API. 
-   */
-  protected void init(String name)
-  {
-    if (name == null)
-    {
-      Process proc = getProcess();
-      name = "AnonymousActivity#" + proc.getFlowObjects().size();
-      setName(name);
-    }
-  }
 }
\ No newline at end of file

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/EndEvent.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -21,6 +21,7 @@
  */
 package org.jboss.bpm.model;
 
+import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
@@ -43,10 +44,43 @@
 @XmlType(name="EndEvent")
 public class EndEvent extends Event
 {
-  @XmlTransient
+  private String name;
   private Result result;
   
-  /** Get the result */
+  public EndEvent()
+  {
+  }
+  
+  public EndEvent(String name)
+  {
+    this.name = name;
+  }
+
+  /**
+   * Get the name
+   */
+  public String getName()
+  {
+    return name;
+  }
+
+  /**
+   * Set the name.
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlAttribute(required = true)
+  protected void setName(String name)
+  {
+    if (this.name != null)
+      throw new IllegalStateException("Cannot rename: " + name);
+
+    this.name = name;
+  }
+  
+  /** 
+   * Get the result 
+   */
+  @XmlTransient
   public Result getResult()
   {
     return result;

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Flow.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Flow.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Flow.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -21,7 +21,12 @@
  */
 package org.jboss.bpm.model;
 
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
 
+
+
 // $Id$
 
 /**
@@ -34,14 +39,81 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
-public interface Flow
+ at XmlType(name="Flow")
+public abstract class Flow
 {
-  /** Get the name */
-  String getName();
+  private FlowObject source;
+  private String name;
+  private String targetName;
   
-  /** Get the source of this Flow */
-  FlowObject getSource();
+  /**
+   * JAXB Constructer
+   */
+  public Flow()
+  {
+  }
   
-  /** Get the target for this Flow */
-  FlowObject getTarget();
+  /**
+   * Construct a flow with a given target
+   */
+  public Flow(String targetName)
+  {
+    this.targetName = targetName;
+  }
+
+  /**
+   * Get the source flow object
+   */
+  public FlowObject getSource()
+  {
+    return source;
+  }
+
+  /**
+   * Set the source flow object
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlTransient
+  protected void setSource(FlowObject source)
+  {
+    this.source = source;
+  }
+
+  /**
+   * Get the optional name
+   */
+  public String getName()
+  {
+    return name;
+  }
+  
+  /**
+   * Set the optional name
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlAttribute(required = false)
+  protected void setName(String name)
+  {
+    this.name = name;
+  }
+
+  /**
+   * Get the target name
+   * Note, this MUST NOT leak into the public API.
+   */
+  public String getTargetName()
+  {
+    return targetName;
+  }
+
+  /**
+   * Set the target name
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlAttribute(required = true)
+  protected void setTargetName(String targetName)
+  {
+    this.targetName = targetName;
+  }
+
 }
\ No newline at end of file

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/FlowObject.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -39,7 +39,7 @@
 public abstract class FlowObject
 {
   @XmlTransient
-  protected Process process;
+  private Process process;
   @XmlTransient
   private Object implObject;
   
@@ -71,7 +71,7 @@
   // TODO
   public void setProcess(Process process)
   {
-    if (this.process != null)
+    if (this.process != null && this.process != process)
       throw new IllegalStateException("Cannot reassign task to process");
     
     this.process = process;

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageFlow.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageFlow.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageFlow.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -21,8 +21,9 @@
  */
 package org.jboss.bpm.model;
 
+//$Id$
 
-// $Id$
+import javax.xml.bind.annotation.XmlType;
 
 /**
  * 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. 
@@ -31,6 +32,21 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
-public interface MessageFlow extends Flow
+ at XmlType(name="MessageFlow")
+public class MessageFlow extends Flow
 {
+  /**
+   * JAXB Constructer
+   */
+  public MessageFlow()
+  {
+  }
+  
+  /**
+   * Construct a flow with a given target
+   */
+  public MessageFlow(String targetName)
+  {
+    super(targetName);
+  }
 }
\ No newline at end of file

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/NamedFlowObject.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/NamedFlowObject.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/NamedFlowObject.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -22,7 +22,6 @@
 package org.jboss.bpm.model;
 
 import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 
 //$Id$
@@ -36,7 +35,6 @@
 @XmlType(name = "NamedFlowObject")
 public abstract class NamedFlowObject extends FlowObject
 {
-  @XmlAttribute(required = true)
   private String name;
 
   /**
@@ -63,10 +61,11 @@
   }
 
   /**
-   * Set the name Note, this MUST NOT leak into the public API.
+   * Set the name.
+   * Note, this MUST NOT leak into the public API.
    */
   // TODO
-  @XmlTransient
+  @XmlAttribute(required = true)
   public void setName(String name)
   {
     if (this.name != null)

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Process.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -48,12 +48,13 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
- at XmlType(name = "Process")
+ at XmlType(name = "Process", propOrder = { "startEvent", "tasks", "endEvents" })
 @XmlRootElement(name = "process")
 public class Process extends Activity
 {
-  @XmlElement(name = "flowObject")
-  protected List<FlowObject> flowObjects = new ArrayList<FlowObject>();
+  private StartEvent startEvent;
+  private List<Task> tasks = new ArrayList<Task>();
+  private List<EndEvent> endEvents = new ArrayList<EndEvent>();
 
   /**
    * Construct an anonymous process
@@ -71,7 +72,7 @@
   }
 
   /**
-   * Call to initialize fully Note, this MUST NOT leak into the public API.
+   * Call to initialize fully. Note, this MUST NOT leak into the public API.
    */
   protected void init(String name)
   {
@@ -84,13 +85,10 @@
   }
 
   /**
-   * Add a flow object Note, this MUST NOT leak into the public API.
+   * Add a flow object. Note, this MUST NOT leak into the public API.
    */
   protected void addFlowObject(FlowObject flowObject)
   {
-    if (flowObject instanceof StartEvent && getStartEventInternal() != null)
-      throw new InvalidProcessException("Process cannot have multiple start events: " + flowObject);
-
     if (flowObject instanceof NamedFlowObject)
     {
       String name = ((NamedFlowObject)flowObject).getName();
@@ -98,64 +96,95 @@
         throw new NameNotUniqueException("NamedFlowObject: " + name);
     }
 
-    flowObjects.add(flowObject);
+    if (flowObject instanceof StartEvent)
+    {
+      setStartEvent((StartEvent)flowObject);
+    }
+    else if (flowObject instanceof EndEvent)
+    {
+      endEvents.add((EndEvent)flowObject);
+      flowObject.setProcess(this);
+    }
+    else if (flowObject instanceof Task)
+    {
+      if (tasks == null)
+        tasks = new ArrayList<Task>();
+
+      tasks.add((Task)flowObject);
+      flowObject.setProcess(this);
+    }
+    else
+    {
+      throw new InvalidProcessException("Unsupported type: " + flowObject);
+    }
   }
 
   /**
    * Get the start event
    */
-  @XmlTransient
   public StartEvent getStartEvent()
   {
-    StartEvent start = getStartEventInternal();
-    if (start == null)
+    if (startEvent == null)
       throw new InvalidProcessException("Process does not have a start event");
 
-    return start;
+    return startEvent;
   }
 
-  private StartEvent getStartEventInternal()
+  /**
+   * Set the start event Note, this MUST NOT leak into the public API.
+   */
+  @XmlElement(name = "start-event")
+  protected void setStartEvent(StartEvent startEvent)
   {
-    StartEvent start = null;
-    for (FlowObject aux : flowObjects)
+    if (this.startEvent != null)
+      throw new InvalidProcessException("Process cannot have multiple start events: " + startEvent);
+
+    startEvent.setProcess(this);
+    this.startEvent = startEvent;
+  }
+
+  /**
+   * Get the set of end events
+   */
+  public List<EndEvent> getEndEvents()
+  {
+    // Lock end events
+    if (endEvents.size() > 0)
     {
-      if (aux instanceof StartEvent)
-      {
-        start = (StartEvent)aux;
-        break;
-      }
+      endEvents = Collections.unmodifiableList(endEvents);
     }
-    return start;
+    return endEvents;
   }
 
-  /** Get the set of end events */
-  @XmlTransient
-  public List<EndEvent> getEndEvents()
+  /**
+   * Set the start event Note, this MUST NOT leak into the public API.
+   */
+  @XmlElement(name = "end-event")
+  protected void setEndEvents(List<EndEvent> endEvents)
   {
-    List<EndEvent> ends = getEndEventsInternal();
-    if (ends.size() == 0)
-      throw new InvalidProcessException("Process does not have end events");
-
-    return ends;
+    this.endEvents = endEvents;
   }
 
-  private List<EndEvent> getEndEventsInternal()
+  /**
+   * Get the list of tasks
+   */
+  public List<Task> getTasks()
   {
-    List<EndEvent> ends = new ArrayList<EndEvent>();
-    for (FlowObject aux : flowObjects)
+    // Lock tasks
+    if (tasks.size() > 0)
     {
-      if (aux instanceof EndEvent)
-      {
-        ends.add((EndEvent)aux);
-      }
+      tasks = Collections.unmodifiableList(tasks);
     }
-    return ends;
+    return tasks;
   }
 
-  /** Get the set of flow objects */
-  public List<FlowObject> getFlowObjects()
+  /**
+   * Set the tasks Note, this MUST NOT leak into the public API.
+   */
+  @XmlElement(name = "task")
+  protected void setTasks(List<Task> tasks)
   {
-    return Collections.unmodifiableList(flowObjects);
+    this.tasks = tasks;
   }
 
   /** Start the process */
@@ -179,7 +208,7 @@
   public NamedFlowObject findFlowObject(String name)
   {
     NamedFlowObject nfo = null;
-    for (FlowObject aux : flowObjects)
+    for (FlowObject aux : getFlowObjects())
     {
       if (aux instanceof NamedFlowObject && ((NamedFlowObject)aux).getName().equals(name))
       {
@@ -190,6 +219,15 @@
     return nfo;
   }
 
+  public List<FlowObject> getFlowObjects()
+  {
+    List<FlowObject> flowObjects = new ArrayList<FlowObject>();
+    flowObjects.add(startEvent);
+    flowObjects.addAll(tasks);
+    flowObjects.addAll(endEvents);
+    return flowObjects;
+  }
+
   /**
    * Get signal for enter
    */
@@ -242,8 +280,7 @@
     {
       if (result == null)
       {
-        List<EndEvent> ends = getEndEventsInternal();
-        for (EndEvent aux : ends)
+        for (EndEvent aux : endEvents)
         {
           result = aux.getResult();
           if (result != null)

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/SequenceFlow.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -21,8 +21,9 @@
  */
 package org.jboss.bpm.model;
 
+//$Id$
 
-// $Id$
+import javax.xml.bind.annotation.XmlType;
 
 /**
  * A Sequence Flow is a solid graphical line that is used to show the order that Activities will be performed in a Process. 
@@ -31,6 +32,21 @@
  * @author thomas.diesler at jboss.com
  * @since 08-Jul-2008
  */
-public interface SequenceFlow extends Flow
+ at XmlType(name="SequenceFlow")
+public class SequenceFlow extends Flow
 {
+  /**
+   * JAXB Constructer
+   */
+  public SequenceFlow()
+  {
+  }
+  
+  /**
+   * Construct a flow with a given target
+   */
+  public SequenceFlow(String targetName)
+  {
+    super(targetName);
+  }
 }
\ No newline at end of file

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/StartEvent.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -23,8 +23,10 @@
 
 //$Id$
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlType;
 
+
 /**
  * A Start Event indicates where a particular Process will start. 
  * 
@@ -37,6 +39,8 @@
 @XmlType(name="StartEvent")
 public class StartEvent extends Event
 {
+  private Flow outFlow;
+  
   /** 
    * Get signal for enter 
    */
@@ -52,4 +56,23 @@
   {
     return new Signal(getProcess(), Signal.Type.EXIT_START_EVENT);
   }
+
+  /**
+   * Get the out flow
+   */
+  public Flow getOutFlow()
+  {
+    return outFlow;
+  }
+
+  /**
+   * Set the out flow
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlElement(name = "flow", required = true)
+  protected void setOutFlow(Flow outFlow)
+  {
+    this.outFlow = outFlow;
+  }
+
 }
\ No newline at end of file

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/model/Task.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -21,6 +21,7 @@
  */
 package org.jboss.bpm.model;
 
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlType;
 
 //$Id$
@@ -37,6 +38,8 @@
 @XmlType(name="Task")
 public class Task extends Activity
 {
+  private Flow outFlow;
+  
   /**
    * Construct an anonymous Task
    */
@@ -52,6 +55,24 @@
     super(name);
   }
   
+  /**
+   * Get the out flow
+   */
+  public Flow getOutFlow()
+  {
+    return outFlow;
+  }
+
+  /**
+   * Set the out flow
+   * Note, this MUST NOT leak into the public API.
+   */
+  @XmlElement(name = "flow", required = true)
+  protected void setOutFlow(Flow outFlow)
+  {
+    this.outFlow = outFlow;
+  }
+  
   /** Get signal for enter */
   public Signal getEnterSignal()
   {

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessMarshaller.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessMarshaller.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessMarshaller.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -43,20 +43,17 @@
 {
   public void marshallProcess(Process proc, Writer out) throws JAXBException, IOException
   {
-    StringWriter strwr = new StringWriter();
     JAXBContext jaxbContext = JAXBContext.newInstance(Process.class.getPackage().getName());
     Marshaller marshaller = jaxbContext.createMarshaller();
     marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
     marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
 
-    marshaller.marshal(proc, strwr);
-
     // Add xmlns:xsi to the top level element and remove it from all others
+    StringWriter strwr = new StringWriter();
+    marshaller.marshal(proc, strwr);
     String str = strwr.toString();
     String xsi = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
     str = new StringBuilder(str.replace(xsi, "")).insert(str.indexOf(">"), xsi).toString();
-
-    // Write the xml string
     out.write(str);
   }
 }

Modified: api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java
===================================================================
--- api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/java/org/jboss/bpm/util/ProcessUnmarshaller.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -28,8 +28,9 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
-import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.EndEvent;
 import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Task;
 
 /**
  * A JAXB unmarshaller for a Process 
@@ -45,10 +46,12 @@
     Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
     Process proc = (Process)unmarshaller.unmarshal(xml);
     
-    // Set the process reference
-    for (FlowObject fo : proc.getFlowObjects())
-      fo.setProcess(proc);
+    for (EndEvent aux : proc.getEndEvents())
+      aux.setProcess(proc);
     
+    for (Task aux : proc.getTasks())
+      aux.setProcess(proc);
+    
     return proc;
   }
 }

Modified: api/trunk/modules/api/src/main/resources/org/jboss/bpm/model/jaxb.index
===================================================================
--- api/trunk/modules/api/src/main/resources/org/jboss/bpm/model/jaxb.index	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/main/resources/org/jboss/bpm/model/jaxb.index	2008-07-10 17:10:40 UTC (rev 1576)
@@ -3,13 +3,16 @@
 EndEvent
 Event
 ExclusiveGateway
+Flow
 FlowObject
 Gateway
 InclusiveGateway
 ItermediateEvent
+MessageFlow
 NamedFlowObject
 ParallelGateway
 Process
+SequenceFlow
 Signal
 StartEvent
 SubProcess

Modified: api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java
===================================================================
--- api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/api/src/test/java/org/jboss/bpm/model/ProcessMarshallerTest.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -42,27 +42,35 @@
   public void testProcess() throws Exception
   {
     Process inProc = new Process("myproc");
-    inProc.addFlowObject(new StartEvent());
-    inProc.addFlowObject(new Task("mytask"));
-    inProc.addFlowObject(new EndEvent());
+    StartEvent start = new StartEvent();
+    start.setOutFlow(new SequenceFlow("taskA"));
+    inProc.addFlowObject(start);
+    Task taskA = new Task("taskA");
+    taskA.setOutFlow(new SequenceFlow("end"));
+    inProc.addFlowObject(taskA);
+    EndEvent end = new EndEvent("end");
+    inProc.addFlowObject(end);
     
     StringWriter strwr = new StringWriter();
     ProcessMarshaller marshaller = new ProcessMarshaller();
     marshaller.marshallProcess(inProc, strwr);
     String xml = strwr.toString();
     
-    //System.out.println(xml);
+    System.out.println(xml);
     
     ProcessUnmarshaller unmarshaller = new ProcessUnmarshaller();
     Process outProc = unmarshaller.unmarshallProcess(new StringReader(xml));
+    start = outProc.getStartEvent();
+    taskA = (Task)outProc.findFlowObject("taskA");
+    end = outProc.getEndEvents().get(0);
     
     assertEquals(inProc.getName(), outProc.getName());
-    assertNotNull(outProc.getStartEvent());
-    assertEquals(outProc, outProc.getStartEvent().getProcess());
-    assertNotNull(outProc.findFlowObject("mytask"));
-    assertEquals(outProc, outProc.findFlowObject("mytask").getProcess());
+    assertNotNull(start);
+    assertEquals(outProc, start.getProcess());
+    assertNotNull(taskA);
+    assertEquals(outProc, taskA.getProcess());
     assertEquals(1, outProc.getEndEvents().size());
-    assertNotNull(outProc.getEndEvents().get(0));
-    assertEquals(outProc, outProc.getEndEvents().get(0).getProcess());
+    assertNotNull(end);
+    assertEquals(outProc, end.getProcess());
   }
 }

Modified: api/trunk/modules/testsuite/pom.xml
===================================================================
--- api/trunk/modules/testsuite/pom.xml	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/testsuite/pom.xml	2008-07-10 17:10:40 UTC (rev 1576)
@@ -117,23 +117,5 @@
         </dependency>
       </dependencies>
     </profile>
-    
-    <!--
-      Name: skiptests
-      Desc: Skips the tests 
-    -->
-    <profile>
-      <id>skiptests</id>
-      <build>
-        <plugins>
-          <plugin>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <skipTests>true</skipTests>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
   </profiles>
 </project>
\ No newline at end of file

Modified: api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java
===================================================================
--- api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/modules/testsuite/src/test/java/org/jboss/bpm/model/ProcessTest.java	2008-07-10 17:10:40 UTC (rev 1576)
@@ -52,9 +52,6 @@
     StartEvent start = proc.getStartEvent();
     assertNotNull("Start expected", start);
 
-    List<FlowObject> fos = proc.getFlowObjects();
-    assertEquals(3, fos.size());
-    
     NamedFlowObject nfo = proc.findFlowObject("stateA");
     assertNotNull("FlowObject expected", nfo);
     assertTrue("Task expected", nfo instanceof Task);

Modified: api/trunk/pom.xml
===================================================================
--- api/trunk/pom.xml	2008-07-10 17:10:18 UTC (rev 1575)
+++ api/trunk/pom.xml	2008-07-10 17:10:40 UTC (rev 1576)
@@ -87,5 +87,26 @@
       <url>scp://jbpm.dyndns.org/var/www/html/jbpm-site</url>
     </site>
   </distributionManagement>
+  
+  <!-- Profiles -->
+  <profiles>
+    <!--
+      Name: skiptests
+      Desc: Skips the tests 
+    -->
+    <profile>
+      <id>skiptests</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <skipTests>true</skipTests>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 
 </project>
\ No newline at end of file




More information about the jbpm-commits mailing list