[jbpm-commits] JBoss JBPM SVN: r2413 - in jbpm4/branches/tdiesler: modules/api/src/main/java/org/jbpm/api/model and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sun Sep 28 16:58:04 EDT 2008
Author: thomas.diesler at 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;
+
+ at 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;
+
+ at 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 at 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;
+
+ at 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 at jboss.com
* @since 08-Jul-2008
*/
+ at 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>
More information about the jbpm-commits
mailing list