JBoss JBPM SVN: r3849 - in projects/gwt-console/trunk: plugin-api and 13 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-12 08:19:13 -0500 (Thu, 12 Feb 2009)
New Revision: 3849
Modified:
projects/gwt-console/trunk/plugin-api/plugin.iml
projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
projects/gwt-console/trunk/pom.xml
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java
projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstanceRef.java
projects/gwt-console/trunk/server-integration/src/main/java/org/jboss/bpm/console/server/integration/ProcessManagement.java
projects/gwt-console/trunk/server/gwt-server.iml
projects/gwt-console/trunk/server/pom.xml
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java
projects/gwt-console/trunk/server/src/main/webapp/index.html
projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/BaseTC.java
projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
projects/gwt-console/trunk/war/gwt-war.iml
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageComponent.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceDetailForm.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceView.java
projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/report/ReportEditor.java
projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json
projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java
Log:
Migrate to string based entity ID's
Modified: projects/gwt-console/trunk/plugin-api/plugin.iml
===================================================================
--- projects/gwt-console/trunk/plugin-api/plugin.iml 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/plugin-api/plugin.iml 2009-02-12 13:19:13 UTC (rev 3849)
@@ -10,6 +10,7 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="gwt-parent" />
+ <orderEntry type="module" module-name="gwt-rpc" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: com.gwtext:gwtext:jar:2.0.5:compile">
<CLASSES>
Modified: projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
--- projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -48,9 +48,10 @@
return getConsoleServerUrl() + "/rs/process/definitions";
}
- public String getProcessInstancesURL(long processId)
+ public String getProcessInstancesURL(String processId)
{
- return getConsoleServerUrl() + "/rs/process/definitions/" + processId + "/instances";
+ String encodedId = URL.encode(processId);
+ return getConsoleServerUrl() + "/rs/process/definitions/" + encodedId + "/instances";
}
public String getUserInRoleURL(String[] possibleRoles)
@@ -66,34 +67,33 @@
}
@Deprecated
- public String getRemoveDefinitionURL(long processId)
+ public String getRemoveDefinitionURL(String processId)
{
- return getConsoleServerUrl() + "/rs/process/definitions/" + processId + "/remove";
+ String encodedId = URL.encode(processId);
+ return getConsoleServerUrl() + "/rs/process/definitions/" + encodedId+ "/remove";
}
- public String getProcessImageURL(long processId)
+ public String getProcessImageURL(String processId)
{
- return getConsoleServerUrl() + "/rs/jbpm3/definitions/" + processId + "/image";
+ String encodedId = URL.encode(processId);
+ return getConsoleServerUrl() + "/rs/jbpm3/definitions/" + encodedId+ "/image";
}
- public String getDiagramInfoURL(long processId)
+ public String getActiveNodeInfoURL(String instanceId)
{
- return getConsoleServerUrl() + "/rs/jbpm3/definitions/" + processId + "/diagramInfo";
- }
-
- public String getActiveNodeInfoURL(long instanceId)
- {
return getConsoleServerUrl() + "/rs/jbpm3/instances/" + instanceId + "/activeNodeInfo";
}
- public String getStateChangeURL(long instanceId, ProcessInstanceRef.STATE state)
+ public String getStateChangeURL(String instanceId, ProcessInstanceRef.STATE state)
{
- return getConsoleServerUrl() + "/rs/process/instances/" + instanceId + "/state/" + state;
+ String encodedId = URL.encode(instanceId);
+ return getConsoleServerUrl() + "/rs/process/instances/" + encodedId + "/state/" + state;
}
- public String getStartNewInstanceURL(long processId)
+ public String getStartNewInstanceURL(String processId)
{
- return getConsoleServerUrl() + "/rs/process/definitions/" + processId + "/instances/new";
+ String encodedID = URL.encode(processId);
+ return getConsoleServerUrl() + "/rs/process/definitions/" + encodedID + "/instances/new";
}
public String getUploadDefinitionURL()
Modified: projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java
===================================================================
--- projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/plugin-api/src/main/java/org/jboss/bpm/console/client/model/DTOParser.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -43,7 +43,7 @@
public static ProcessDefinitionRef parseProcessDefinition(String json)
{
JSONValue root = JSONParser.parse(json);
- long id = JSONWalk.on(root).next("processId").asLong();
+ String id = JSONWalk.on(root).next("id").asString();
Long version = JSONWalk.on(root).next("version").asLong();
String name = JSONWalk.on(root).next("name").asString();
@@ -197,8 +197,8 @@
{
ConsoleLog.debug("parse " + root);
- long id = JSONWalk.on(root).next("instanceId").asLong();
- long parentId = JSONWalk.on(root).next("parentId").asLong();
+ String id = JSONWalk.on(root).next("id").asString();
+ String definitionId = JSONWalk.on(root).next("definitionId").asString();
Date start = JSONWalk.on(root).next("startDate").asDate();
JSONWalk.JSONWrapper endDateJSON = JSONWalk.on(root).next("endDate");
@@ -209,7 +209,7 @@
boolean suspended = JSONWalk.on(root).next("suspended").asBool();
ProcessInstanceRef processInstance = new ProcessInstanceRef(
- id, parentId,
+ id, definitionId,
start, end,
suspended
);
Modified: projects/gwt-console/trunk/pom.xml
===================================================================
--- projects/gwt-console/trunk/pom.xml 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/pom.xml 2009-02-12 13:19:13 UTC (rev 3849)
@@ -38,7 +38,7 @@
<module>server-integration</module>
<module>server</module>
<module>war</module>
- <module>plugin-api/</module>
+ <module>plugin-api</module>
<module>plugin-example</module>
</modules>
Modified: projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java
===================================================================
--- projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessDefinitionRef.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -21,8 +21,6 @@
*/
package org.jboss.bpm.console.client.model;
-import com.google.gwt.user.client.rpc.IsSerializable;
-
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -32,7 +30,8 @@
@XmlRootElement(name="processDefinition")
public class ProcessDefinitionRef
{
- private long processId;
+ private String id;
+
private String name;
private long version;
private String key;
@@ -43,22 +42,22 @@
{
}
- public ProcessDefinitionRef(long id, String name, long version)
+ public ProcessDefinitionRef(String id, String name, long version)
{
- this.processId = id;
+ this.id = id;
this.name = name;
this.version = version;
}
@XmlElement(name = "processId")
- public long getProcessId()
+ public String getId()
{
- return processId;
+ return id;
}
- public void setProcessId(long processId)
+ public void setId(String id)
{
- this.processId = processId;
+ this.id = id;
}
@XmlElement(name = "name")
@@ -84,7 +83,7 @@
public String toString()
{
- return "ProcessDefinitionRef{id="+this.processId +", name="+this.name+", version="+this.version+"}";
+ return "ProcessDefinitionRef{id="+this.id +", name="+this.name+", version="+this.version+"}";
}
public String getKey()
@@ -117,6 +116,7 @@
this.packageName = packageName;
}
+
public boolean equals(Object o)
{
if (this == o) return true;
@@ -124,8 +124,9 @@
ProcessDefinitionRef that = (ProcessDefinitionRef) o;
- if (processId != that.processId) return false;
if (version != that.version) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ if (key != null ? !key.equals(that.key) : that.key != null) return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
return true;
@@ -134,9 +135,10 @@
public int hashCode()
{
int result;
- result = (int) (processId ^ (processId >>> 32));
+ result = (id != null ? id.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (int) (version ^ (version >>> 32));
+ result = 31 * result + (key != null ? key.hashCode() : 0);
return result;
}
}
Modified: projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstanceRef.java
===================================================================
--- projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstanceRef.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/rpc/src/main/java/org/jboss/bpm/console/client/model/ProcessInstanceRef.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -34,283 +34,274 @@
@XmlRootElement(name="processInstance")
public class ProcessInstanceRef
{
- private long instanceId;
- private long definitionId;
+ private String id;
+ private String definitionId;
- private String key;
- public enum STATE {RUNNING, SUSPENDED, ENDED};
+ private String key;
+ public enum STATE {RUNNING, SUSPENDED, ENDED};
- private Date startDate;
- private Date endDate;
+ private Date startDate;
+ private Date endDate;
- private boolean suspended;
+ private boolean suspended;
- private transient Lifecycle lifecycle;
+ private transient Lifecycle lifecycle;
- private TokenReference rootToken;
+ private TokenReference rootToken;
- public ProcessInstanceRef()
- {
- initLifecycle();
- }
+ public ProcessInstanceRef()
+ {
+ initLifecycle();
+ }
- public ProcessInstanceRef(long id, long parentId, Date startDate, Date endDate, boolean suspended)
- {
+ public ProcessInstanceRef(String id, String processDefinitionId, Date startDate, Date endDate, boolean suspended)
+ {
- if(null==startDate)
- throw new IllegalArgumentException("An instance requires a start date");
-
- if(endDate!=null && suspended)
- throw new IllegalArgumentException("An instance cannot be ended and suspended at the same time");
+ if(null==startDate)
+ throw new IllegalArgumentException("An instance requires a start date");
- this.instanceId = id;
- this.definitionId = parentId;
- this.startDate = startDate;
- this.endDate = endDate;
- this.suspended = suspended;
- initLifecycle();
- }
+ if(endDate!=null && suspended)
+ throw new IllegalArgumentException("An instance cannot be ended and suspended at the same time");
- /**
- * If not ENDED or SUSPENDED the instance is RUNNING
- */
- private void initLifecycle()
- {
- if(hasEnded())
- this.lifecycle = new Lifecycle(this, STATE.ENDED);
- else if(isSuspended())
- this.lifecycle = new Lifecycle(this, STATE.SUSPENDED);
- else
- this.lifecycle = new Lifecycle(this, STATE.RUNNING);
- }
+ this.id = id;
+ this.definitionId = processDefinitionId;
+ this.startDate = startDate;
+ this.endDate = endDate;
+ this.suspended = suspended;
+ initLifecycle();
+ }
- @XmlElement(name = "instanceId")
- public long getInstanceId()
- {
- return instanceId;
- }
+ /**
+ * If not ENDED or SUSPENDED the instance is RUNNING
+ */
+ private void initLifecycle()
+ {
+ if(hasEnded())
+ this.lifecycle = new Lifecycle(this, STATE.ENDED);
+ else if(isSuspended())
+ this.lifecycle = new Lifecycle(this, STATE.SUSPENDED);
+ else
+ this.lifecycle = new Lifecycle(this, STATE.RUNNING);
+ }
- public void setInstanceId(long instanceId)
- {
- this.instanceId = instanceId;
- }
+ @XmlElement(name = "instanceId")
+ public String getId()
+ {
+ return id;
+ }
- @XmlElement(name = "parentId")
- public long getDefinitionId()
- {
- return definitionId;
- }
+ public void setId(String id)
+ {
+ this.id = id;
+ }
- public void setDefinitionId(long definitionId)
- {
- this.definitionId = definitionId;
- }
+ @XmlElement(name = "definitionId")
+ public String getDefinitionId()
+ {
+ return definitionId;
+ }
- @XmlElement(name = "key")
- public String getKey()
- {
- return key !=null ? key : "";
- }
+ public void setDefinitionId(String definitionId)
+ {
+ this.definitionId = definitionId;
+ }
- public void setKey(String key)
- {
- this.key = key;
- }
+ @XmlElement(name = "key")
+ public String getKey()
+ {
+ return key !=null ? key : "";
+ }
- @XmlElement(name = "status")
- public STATE getState()
- {
- return this.lifecycle.getState();
- }
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
- public void setState(String nextState)
- {
- setState(STATE.valueOf(nextState));
- }
+ @XmlElement(name = "status")
+ public STATE getState()
+ {
+ return this.lifecycle.getState();
+ }
- public void setState(STATE nextState)
- {
- this.lifecycle = this.lifecycle.transitionTo(nextState);
- }
+ public void setState(String nextState)
+ {
+ setState(STATE.valueOf(nextState));
+ }
- @XmlElement(name = "start")
- public Date getStartDate()
- {
- return startDate;
- }
+ public void setState(STATE nextState)
+ {
+ this.lifecycle = this.lifecycle.transitionTo(nextState);
+ }
- public void setStartDate(Date startDate)
- {
- this.startDate = startDate;
- }
+ @XmlElement(name = "start")
+ public Date getStartDate()
+ {
+ return startDate;
+ }
- @XmlElement(name = "end")
- public Date getEndDate()
- {
- return endDate;
- }
+ public void setStartDate(Date startDate)
+ {
+ this.startDate = startDate;
+ }
- public void setEndDate(Date endDate)
- {
- this.endDate = endDate;
- }
+ @XmlElement(name = "end")
+ public Date getEndDate()
+ {
+ return endDate;
+ }
- public boolean isRunning()
- {
- return this.startDate!=null && !isSuspended();
- }
+ public void setEndDate(Date endDate)
+ {
+ this.endDate = endDate;
+ }
- public boolean hasEnded()
- {
- return this.startDate!=null
+ public boolean isRunning()
+ {
+ return this.startDate!=null && !isSuspended();
+ }
+
+ public boolean hasEnded()
+ {
+ return this.startDate!=null
&& this.endDate!=null;
- }
+ }
- public boolean isSuspended()
- {
- return null==this.endDate && suspended;
- }
-
- private class Lifecycle
- {
- private STATE current;
- private ProcessInstanceRef instance;
+ public boolean isSuspended()
+ {
+ return null==this.endDate && suspended;
+ }
- public Lifecycle(ProcessInstanceRef instance, STATE current)
- {
- this.instance = instance;
- this.current = current;
- }
+ private class Lifecycle
+ {
+ private STATE current;
+ private ProcessInstanceRef instance;
- public Lifecycle transitionTo(STATE next)
- {
- Lifecycle nextLifecycle = null;
+ public Lifecycle(ProcessInstanceRef instance, STATE current)
+ {
+ this.instance = instance;
+ this.current = current;
+ }
- switch(next)
- {
- case SUSPENDED: // only RUNNING instances can be SUSPENDED
- if(STATE.RUNNING.equals(current))
- {
- nextLifecycle = new Lifecycle(instance, next);
- instance.suspended = true;
- break;
- }
- else
- {
- throw new IllegalTransitionException(current, next);
- }
- case ENDED: // both RUNNING and SUSPENDED instances can be ENDED
- if(STATE.RUNNING.equals(current) || STATE.SUSPENDED.equals(current))
- {
- nextLifecycle = new Lifecycle(instance, next);
- instance.suspended = false;
- instance.endDate = new Date();
- break;
- }
- else
- {
- throw new IllegalTransitionException(current, next);
- }
- case RUNNING: // only SUSPENDED instances can become RUNNING
- if(STATE.SUSPENDED.equals(current))
- {
- nextLifecycle = new Lifecycle(instance, next);
- instance.suspended = false;
- break;
- }
- else
- {
- throw new IllegalTransitionException(current, next);
- }
- default:
- throw new IllegalTransitionException(current, next);
- }
+ public Lifecycle transitionTo(STATE next)
+ {
+ Lifecycle nextLifecycle = null;
- return nextLifecycle;
- }
-
- public STATE getState()
+ switch(next)
{
- return current;
+ case SUSPENDED: // only RUNNING instances can be SUSPENDED
+ if(STATE.RUNNING.equals(current))
+ {
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = true;
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ case ENDED: // both RUNNING and SUSPENDED instances can be ENDED
+ if(STATE.RUNNING.equals(current) || STATE.SUSPENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = false;
+ instance.endDate = new Date();
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ case RUNNING: // only SUSPENDED instances can become RUNNING
+ if(STATE.SUSPENDED.equals(current))
+ {
+ nextLifecycle = new Lifecycle(instance, next);
+ instance.suspended = false;
+ break;
+ }
+ else
+ {
+ throw new IllegalTransitionException(current, next);
+ }
+ default:
+ throw new IllegalTransitionException(current, next);
}
+ return nextLifecycle;
+ }
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ public STATE getState()
+ {
+ return current;
+ }
- Lifecycle lifecycle = (Lifecycle) o;
- if (current != lifecycle.current) return false;
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
- return true;
- }
+ Lifecycle lifecycle = (Lifecycle) o;
- public int hashCode()
- {
- int result;
- result = (current != null ? current.hashCode() : 0);
- return result;
- }
- }
+ if (current != lifecycle.current) return false;
- private class IllegalTransitionException extends IllegalArgumentException
- {
+ return true;
+ }
- public IllegalTransitionException(STATE current, STATE next)
- {
- super("Illegal transition current " + current + " next " + next);
- }
- }
+ public int hashCode()
+ {
+ int result;
+ result = (current != null ? current.hashCode() : 0);
+ return result;
+ }
+ }
- public TokenReference getRootToken()
- {
- return rootToken;
- }
+ private class IllegalTransitionException extends IllegalArgumentException
+ {
- public void setRootToken(TokenReference rootToken)
- {
- this.rootToken = rootToken;
- }
+ public IllegalTransitionException(STATE current, STATE next)
+ {
+ super("Illegal transition current " + current + " next " + next);
+ }
+ }
- // it's actually just used for unmarshalling, TODO: fix it
- public void setSuspended(boolean suspended)
- {
- this.suspended = suspended;
- initLifecycle();
- }
+ public TokenReference getRootToken()
+ {
+ return rootToken;
+ }
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ public void setRootToken(TokenReference rootToken)
+ {
+ this.rootToken = rootToken;
+ }
- ProcessInstanceRef that = (ProcessInstanceRef) o;
+ // it's actually just used for unmarshalling, TODO: fix it
+ public void setSuspended(boolean suspended)
+ {
+ this.suspended = suspended;
+ initLifecycle();
+ }
- if (instanceId != that.instanceId) return false;
- if (definitionId != that.definitionId) return false;
- if (suspended != that.suspended) return false;
- if (endDate != null ? !endDate.equals(that.endDate) : that.endDate != null) return false;
- if (key != null ? !key.equals(that.key) : that.key != null) return false;
- if (lifecycle != null ? !lifecycle.equals(that.lifecycle) : that.lifecycle != null) return false;
- if (rootToken != null ? !rootToken.equals(that.rootToken) : that.rootToken != null) return false;
- if (startDate != null ? !startDate.toString().equals(that.startDate.toString()) : that.startDate != null) return false;
- return true;
- }
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
- public int hashCode()
- {
- int result;
- result = (int) (instanceId ^ (instanceId >>> 32));
- result = 31 * result + (int) (definitionId ^ (definitionId >>> 32));
- result = 31 * result + (key != null ? key.hashCode() : 0);
- result = 31 * result + (startDate != null ? startDate.hashCode() : 0);
- result = 31 * result + (endDate != null ? endDate.hashCode() : 0);
- result = 31 * result + (suspended ? 1 : 0);
- result = 31 * result + (lifecycle != null ? lifecycle.hashCode() : 0);
- result = 31 * result + (rootToken != null ? rootToken.hashCode() : 0);
- return result;
- }
+ ProcessInstanceRef that = (ProcessInstanceRef) o;
+
+ if (definitionId != null ? !definitionId.equals(that.definitionId) : that.definitionId != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ if (key != null ? !key.equals(that.key) : that.key != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (id != null ? id.hashCode() : 0);
+ result = 31 * result + (definitionId != null ? definitionId.hashCode() : 0);
+ result = 31 * result + (key != null ? key.hashCode() : 0);
+ return result;
+ }
}
Modified: projects/gwt-console/trunk/server/gwt-server.iml
===================================================================
--- projects/gwt-console/trunk/server/gwt-server.iml 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/gwt-server.iml 2009-02-12 13:19:13 UTC (rev 3849)
@@ -11,6 +11,8 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="gwt-parent" />
+ <orderEntry type="module" module-name="gwt-rpc" />
+ <orderEntry type="module" module-name="gwt-server-integration" />
<orderEntry type="module-library" exported="">
<library name="M2 Dep: org.slf4j:slf4j-simple:jar:1.5.2:compile">
<CLASSES>
Modified: projects/gwt-console/trunk/server/pom.xml
===================================================================
--- projects/gwt-console/trunk/server/pom.xml 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/pom.xml 2009-02-12 13:19:13 UTC (rev 3849)
@@ -24,12 +24,6 @@
<!-- Module -->
<dependency>
<groupId>org.jboss.bpm</groupId>
- <artifactId>gwt-console-rpc</artifactId>
- <version>${version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.bpm</groupId>
<artifactId>gwt-console-server-integration</artifactId>
<version>${version}</version>
<scope>provided</scope>
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -21,11 +21,7 @@
*/
package org.jboss.bpm.console.server;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
+import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.commons.logging.Log;
@@ -77,7 +73,7 @@
@Produces("application/json")
public Response removeDefinitionsJSON(
@PathParam("id")
- long processId
+ String processId
)
{
ProcessDefinitionRefWrapper wrapper =
@@ -90,7 +86,7 @@
@Produces("application/json")
public Response getInstancesJSON(
@PathParam("id")
- long processId
+ String processId
)
{
@@ -104,11 +100,20 @@
@Produces("application/json")
public Response newInstance(
@PathParam("id")
- long processId)
+ String processId)
{
- ProcessInstanceRef instance = getProcessManagement().newInstance(processId);
- return createJsonResponse(instance);
+ ProcessInstanceRef instance = null;
+ try
+ {
+ instance = getProcessManagement().newInstance(processId);
+ return createJsonResponse(instance);
+ }
+ catch (Throwable t)
+ {
+ throw new WebApplicationException(t, 500);
+ }
+
}
@POST
@@ -116,7 +121,7 @@
@Produces("application/json")
public Response changeState(
@PathParam("id")
- long instanceId,
+ String instanceId,
@PathParam("next")
String next)
{
Modified: projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java
===================================================================
--- projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/src/main/java/org/jboss/bpm/console/server/TestFacade.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -83,7 +83,7 @@
if(pd.getName().equals("GWT_Test_Harness"))
{
log.info("Remove test harness " +pd);
- getProcessManagement().removeProcessDefinition(pd.getProcessId());
+ getProcessManagement().removeProcessDefinition(pd.getId());
}
}
return Response.ok().build();
Modified: projects/gwt-console/trunk/server/src/main/webapp/index.html
===================================================================
--- projects/gwt-console/trunk/server/src/main/webapp/index.html 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/src/main/webapp/index.html 2009-02-12 13:19:13 UTC (rev 3849)
@@ -58,7 +58,7 @@
<tr>
<td>GET</td>
- <td><a href="/gwt-console-server/rs/user/roles?roleCheck=admin,user">/rs/user/roles?roleCheck=a,b,c</a></td>
+ <td><a href="/gwt-console-server/rs/identity/user/roles?roleCheck=admin,user">/rs/identity/user/roles?roleCheck=a,b,c</a></td>
<td>A list of assigned roles matching the query parameter (Comma seperated list)</td>
<td>application/json</td>
</tr>
Modified: projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/BaseTC.java
===================================================================
--- projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/BaseTC.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/BaseTC.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -150,7 +150,7 @@
protected ProcessInstanceRef createNewProcessInstance()
throws Exception
{
- String resource = "/process/definitions/"+testDeploymentRef.getProcessId()+"/instances/new";
+ String resource = "/process/definitions/"+testDeploymentRef.getId()+"/instances/new";
String response = HTTP.post(SERVER_URL + resource, EMPTY, DEFAULT_CREDENTIALS);
// ------- New instance
@@ -163,7 +163,7 @@
protected ProcessInstanceRefWrapper getInstanceList(ProcessDefinitionRef def)
{
String listResponse = HTTP.get(
- SERVER_URL + "/process/definitions/"+def.getProcessId()+"/instances",
+ SERVER_URL + "/process/definitions/"+def.getId()+"/instances",
DEFAULT_CREDENTIALS
);
@@ -171,14 +171,14 @@
return instanceList;
}
- protected ProcessInstanceRef getInstance(ProcessDefinitionRef definitionRef, long instanceId)
+ protected ProcessInstanceRef getInstance(ProcessDefinitionRef definitionRef, String instanceId)
{
ProcessInstanceRef match = null;
ProcessInstanceRefWrapper list = getInstanceList(definitionRef);
for(ProcessInstanceRef i : list.getInstances())
{
- if(i.getInstanceId() == instanceId)
+ if(i.getId().equals(instanceId))
{
match = i;
break;
Modified: projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
===================================================================
--- projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -69,7 +69,7 @@
// ------- Suspend it
newInstanceRef.setState(ProcessInstanceRef.STATE.SUSPENDED);
- HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+ HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
// ------- Verify
@@ -92,7 +92,7 @@
// end and verify
newInstanceRef.setState(ProcessInstanceRef.STATE.ENDED);
- HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+ HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
// refresh instance list
instanceList = getInstanceList(testDeploymentRef);
Modified: projects/gwt-console/trunk/server-integration/src/main/java/org/jboss/bpm/console/server/integration/ProcessManagement.java
===================================================================
--- projects/gwt-console/trunk/server-integration/src/main/java/org/jboss/bpm/console/server/integration/ProcessManagement.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/server-integration/src/main/java/org/jboss/bpm/console/server/integration/ProcessManagement.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -36,17 +36,17 @@
{
List<ProcessDefinitionRef> getProcessDefinitions();
- ProcessDefinitionRef getProcessDefinition(long procDefId);
+ ProcessDefinitionRef getProcessDefinition(String definitionId);
- List<ProcessDefinitionRef> removeProcessDefinition(long procDefId);
+ List<ProcessDefinitionRef> removeProcessDefinition(String definitionId);
- List<ProcessInstanceRef> getProcessInstances(long procDefId);
+ List<ProcessInstanceRef> getProcessInstances(String definitionId);
- ProcessInstanceRef getProcessInstance(long procId);
+ ProcessInstanceRef getProcessInstance(String instanceId);
- ProcessInstanceRef newInstance(long procDefId);
+ ProcessInstanceRef newInstance(String instanceId);
- void setProcessState(long procId, STATE nextState);
+ void setProcessState(String instanceId, STATE nextState);
void signalToken(long tokenId, String signal);
Modified: projects/gwt-console/trunk/war/gwt-war.iml
===================================================================
--- projects/gwt-console/trunk/war/gwt-war.iml 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/gwt-war.iml 2009-02-12 13:19:13 UTC (rev 3849)
@@ -104,6 +104,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="gwt-rpc" />
<orderEntryProperties />
</component>
</module>
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessDefinitionList.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -63,7 +63,7 @@
final ColumnModel columnModel = new ColumnModel(
new ColumnConfig[]
{
- new ColumnConfig("Process ID", "processId", 75, true),
+ new ColumnConfig("Process ID", "id", 75, true),
new ColumnConfig("Name", "name", 300, true, null, "expand"),
new ColumnConfig("Version", "version", 75, true)
}
@@ -75,7 +75,7 @@
{
final RecordDef recordDef = new RecordDef(
new FieldDef[]{
- new IntegerFieldDef("processId"),
+ new StringFieldDef("id"),
new StringFieldDef("name"),
new StringFieldDef("version")
}
@@ -84,7 +84,7 @@
final JsonReader reader = new JsonReader(recordDef);
reader.setRoot("definitions");
reader.setTotalProperty("totalCount");
- reader.setId("processId");
+ reader.setId("id");
return reader;
}
@@ -121,7 +121,7 @@
if ("yes".equals(btnID))
{
ProcessDefinitionRef proc = (ProcessDefinitionRef) row2ProcessMap.get(row);
- String url = view.getUrlBuilder().getRemoveDefinitionURL(proc.getProcessId());
+ String url = view.getUrlBuilder().getRemoveDefinitionURL(proc.getId());
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
try
@@ -166,7 +166,7 @@
int i = 0;
for (Record r : records)
{
- Long id = Long.valueOf(r.getAsString("processId"));
+ String id = r.getAsString("id");
ProcessDefinitionRef pd = new ProcessDefinitionRef(
id,
r.getAsString("name"),
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageComponent.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageComponent.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessImageComponent.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -90,7 +90,7 @@
private void loadActiveNodeInfo()
{
- String url = view.getUrlBuilder().getActiveNodeInfoURL(this.instance.getInstanceId());
+ String url = view.getUrlBuilder().getActiveNodeInfoURL(this.instance.getId());
ConsoleLog.debug("Loading activeNodeInfo: " + url);
JSONRequest.get(url,
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceDetailForm.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceDetailForm.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceDetailForm.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -119,7 +119,7 @@
private void persistStateChange()
{
String url = mainView.getUrlBuilder().getStateChangeURL(
- selectedInstance.getInstanceId(), selectedInstance.getState()
+ selectedInstance.getId(), selectedInstance.getState()
);
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceList.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -57,7 +57,7 @@
public ProcessInstanceList(ModelModificationCallback callback, ProcessDefinitionRef procDef, String titleName, ApplicationContext view)
{
- super(callback, titleName, view, getResourceUrl(view, procDef.getProcessId()));
+ super(callback, titleName, view, getResourceUrl(view, procDef.getId()));
this.parent = procDef;
}
@@ -69,7 +69,7 @@
public void onExamine(final int row)
{
ProcessInstanceRef instance = row2InstanceMap.get(row);
- String id = ProcessInstanceView.ID + "." + instance.getInstanceId();
+ String id = ProcessInstanceView.ID + "." + instance.getId();
Editor editor = (Editor) ComponentMgr.getComponent(ProcessEditor.ID);
if (editor.hasView(id))
editor.showView(id);
@@ -93,11 +93,11 @@
{
ProcessInstanceRef instance = row2InstanceMap.get(row);
instance.setState(ProcessInstanceRef.STATE.ENDED);
- String url = view.getUrlBuilder().getStateChangeURL(instance.getInstanceId(), instance.getState());
+ String url = view.getUrlBuilder().getStateChangeURL(instance.getId(), instance.getState());
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
try
- {
+ {
rb.sendRequest("",
new RequestCallback()
{
@@ -140,7 +140,7 @@
{
if ("yes".equals(btnID))
{
- String url = view.getUrlBuilder().getStartNewInstanceURL(parent.getProcessId());
+ String url = view.getUrlBuilder().getStartNewInstanceURL(parent.getId());
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, url);
try
@@ -240,8 +240,8 @@
{
final RecordDef recordDef = new RecordDef(
new FieldDef[]{
- new IntegerFieldDef("instanceId"),
- new IntegerFieldDef("parentId"),
+ new StringFieldDef("instanceId"),
+ new StringFieldDef("definitionId"),
new StringFieldDef("key"),
new StringFieldDef("state"),
new DateFieldDef("startDate", UIConstants.DATE_FORMAT),
@@ -258,7 +258,7 @@
return reader;
}
- private static String getResourceUrl(ApplicationContext view, long parentId)
+ private static String getResourceUrl(ApplicationContext view, String parentId)
{
return view.getUrlBuilder().getProcessInstancesURL(parentId);
}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceView.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceView.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/process/ProcessInstanceView.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -47,13 +47,13 @@
public ProcessInstanceView(final ProcessDefinitionRef proc, final ProcessInstanceRef instance, final ApplicationContext view)
{
super(view);
- this.setId(ID + "." + instance.getInstanceId());
+ this.setId(ID + "." + instance.getId());
this.processDefinition = proc;
this.processInstance = instance;
this.mainView = view;
- this.setTitle("# " + instance.getInstanceId());
+ this.setTitle("# " + instance.getId());
// ----------------------------------
@@ -101,12 +101,12 @@
public String getViewId()
{
- return ID + "." + processInstance.getInstanceId();
+ return ID + "." + processInstance.getId();
}
public String getTitle()
{
- return "#" + processInstance.getInstanceId() + " (" + processDefinition.getName() + ")";
+ return "#" + processInstance.getId() + " (" + processDefinition.getName() + ")";
}
Modified: projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/report/ReportEditor.java
===================================================================
--- projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/report/ReportEditor.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/java/org/jboss/bpm/console/client/report/ReportEditor.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -134,7 +134,7 @@
final RecordDef recordDef = new RecordDef(
new FieldDef[]{
- new IntegerFieldDef("processId"),
+ new IntegerFieldDef("id"),
new StringFieldDef("name"),
new StringFieldDef("version")
}
@@ -143,7 +143,7 @@
final JsonReader reader = new JsonReader(recordDef);
reader.setRoot("definitions");
reader.setTotalProperty("totalCount");
- reader.setId("processId");
+ reader.setId("id");
DataProxy dataProxy = new ScriptTagProxy(
appContext.getUrlBuilder().getProcessDefinitionsURL(), 1000 * 10);
Modified: projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json
===================================================================
--- projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/main/resources/jmaki/xhp/xhp.json 2009-02-12 13:19:13 UTC (rev 3849)
@@ -4,8 +4,8 @@
{"id": "default",
"url":"http://localhost:8080/gwt-console-server",
"passthrough":true,
- "username":"manager",
- "password":"manager"
+ "username":"admin",
+ "password":"admin"
},
{"id": "birt",
"url":"http://localhost:8080/report",
Modified: projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java
===================================================================
--- projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java 2009-02-12 09:19:18 UTC (rev 3848)
+++ projects/gwt-console/trunk/war/src/test/java/org/jboss/bpm/console/client/GwtTestDTOParser.java 2009-02-12 13:19:13 UTC (rev 3849)
@@ -46,7 +46,7 @@
public void testTaskRefParsing()
{
- String json = "{\"tasks\":[{\"id\":14,\"tokenId\":6,\"processInstanceId\":4,\"processId\":2,\"name\":\"manager evaluation\",\"actor\":\"manager\",\"isBlocking\":false,\"isSignalling\":true,\"transitionNames\":[\"reject\",\"approve\"],\"pooledActors\":[\"hr\",\"sales\"]}]}";
+ String json = "{\"tasks\":[{\"id\":14,\"tokenId\":6,\"processInstanceId\":4,\"id\":2,\"name\":\"manager evaluation\",\"actor\":\"manager\",\"isBlocking\":false,\"isSignalling\":true,\"transitionNames\":[\"reject\",\"approve\"],\"pooledActors\":[\"hr\",\"sales\"]}]}";
List<TaskRef> result = DTOParser.parseTaskReferenceList(json);
assertTrue("Failed to parse TaskReferenceList", result.size()==1);
assertTrue("Failed to parse transitionNames", result.get(0).getTransitionNames().size()==2);
17 years, 2 months
JBoss JBPM SVN: r3848 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-12 04:19:18 -0500 (Thu, 12 Feb 2009)
New Revision: 3848
Modified:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
Log:
clean up TaskVariablesDbTest
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-02-12 07:33:12 UTC (rev 3847)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/taskmgmt/exe/TaskVariablesDbTest.java 2009-02-12 09:19:18 UTC (rev 3848)
@@ -22,25 +22,30 @@
package org.jbpm.taskmgmt.exe;
import java.util.HashMap;
+import java.util.Map;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
-public class TaskVariablesDbTest extends AbstractDbTestCase {
-
- public void testDefaultVariablePersistence() {
+public class TaskVariablesDbTest extends AbstractDbTestCase
+{
+ public void testDefaultVariablePersistence()
+ {
ProcessDefinition processDefinition = ProcessDefinition.createNewProcessDefinition();
- processDefinition = saveAndReload(processDefinition);
+ processDefinition.setName("default variable persistence");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createTaskInstance(processInstance.getRootToken());
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createTaskInstance(
+ processInstance.getRootToken());
taskInstance.setVariable("key", "value");
taskInstance = saveAndReload(taskInstance);
-
assertNotNull(taskInstance);
assertEquals("value", taskInstance.getVariable("key"));
}
@@ -49,46 +54,44 @@
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
-
- public void testSetOnTaskInstanceGetOnProcess() {
-
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask' />" +
- " </task-node>" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+
+ public void testSetOnTaskInstanceGetOnProcess()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set on task get on process'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask' />"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
+
processInstance = saveAndReload(processInstance);
ContextInstance contextInstance = processInstance.getContextInstance();
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
-
- HashMap expectedVariables = new HashMap();
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
+
+ Map<String, Object> expectedVariables = new HashMap<String, Object>();
assertEquals(expectedVariables, taskInstance.getVariables());
+
assertFalse(taskInstance.hasVariable("a"));
assertNull(taskInstance.getVariable("a"));
-
assertNull(contextInstance.getVariable("a"));
-
+
taskInstance.setVariable("a", "1");
- jbpmContext.save(taskInstance);
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
- taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
-
+
+ taskInstance = saveAndReload(taskInstance);
+ contextInstance = taskInstance.getContextInstance();
+
expectedVariables.put("a", "1");
assertEquals(expectedVariables, taskInstance.getVariables());
@@ -100,58 +103,41 @@
{
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
- public void testSetOnProcessGetOnTaskInstance() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask' />" +
- " </task-node>" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+ public void testSetOnProcessGetOnTaskInstance()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set on process get on task'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask' />"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- ContextInstance contextInstance = processInstance.getContextInstance();
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
processInstance.signal();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
- HashMap expectedVariables = new HashMap();
- jbpmContext.save(processInstance);
-
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- long taskInstanceId = taskInstance.getId();
- taskInstance = jbpmContext.loadTaskInstance(taskInstanceId);
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
-
+
+ processInstance = saveAndReload(processInstance);
+ ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("a", "1");
- jbpmContext.save(processInstance);
-
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstanceId);
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
-
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
+
+ taskInstance = saveAndReload(taskInstance);
+ Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("a", "1");
assertEquals(expectedVariables, taskInstance.getVariables());
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstanceId);
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
+ contextInstance = taskInstance.getContextInstance();
assertTrue(taskInstance.hasVariable("a"));
assertEquals("1", taskInstance.getVariable("a"));
@@ -161,54 +147,43 @@
{
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
- public void testSetLocally() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask' />" +
- " </task-node>" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+ public void testSetLocally()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='set locally'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask' />"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- ContextInstance contextInstance = processInstance.getContextInstance();
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
processInstance.signal();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
- jbpmContext.save(processInstance);
-
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
+ ContextInstance contextInstance = taskInstance.getContextInstance();
- HashMap expectedVariables = new HashMap();
+ Map<String, Object> expectedVariables = new HashMap<String, Object>();
assertEquals(expectedVariables, taskInstance.getVariables());
assertFalse(taskInstance.hasVariable("a"));
assertNull(taskInstance.getVariable("a"));
assertNull(contextInstance.getVariable("a"));
-
+
taskInstance.setVariableLocally("a", "1");
-
- jbpmContext.save(taskInstance);
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
+ contextInstance = taskInstance.getContextInstance();
expectedVariables.put("a", "1");
assertEquals(expectedVariables, taskInstance.getVariables());
@@ -222,79 +197,63 @@
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
}
-
- public void testCopyWithController() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask'>" +
- " <controller>" +
- " <variable name='a' />" +
- " <variable name='b' />" +
- " </controller>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+
+ public void testCopyWithController()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='copy with controller'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask'>"
+ + " <controller>"
+ + " <variable name='a' />"
+ + " <variable name='b' />"
+ + " </controller>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
ContextInstance contextInstance = processInstance.getContextInstance();
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
-
contextInstance.setVariable("a", "1");
contextInstance.setVariable("b", "2");
contextInstance.setVariable("c", "3");
-
+
processInstance.signal();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
- jbpmContext.save(processInstance);
-
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
- HashMap expectedVariables = new HashMap();
+ Map<String, Object> expectedVariables = new HashMap<String, Object>();
expectedVariables.put("a", "1");
expectedVariables.put("b", "2");
expectedVariables.put("c", "3");
assertEquals(expectedVariables, taskInstance.getVariables());
-
+
taskInstance.setVariable("a", "1 modified");
taskInstance.setVariable("b", "2 modified");
taskInstance.setVariable("c", "3 modified");
-
- jbpmContext.save(processInstance);
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
- expectedVariables = new HashMap();
+ expectedVariables.clear();
expectedVariables.put("a", "1 modified");
expectedVariables.put("b", "2 modified");
expectedVariables.put("c", "3 modified");
assertEquals(expectedVariables, taskInstance.getVariables());
- newTransaction();
-
- processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
- contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
+ taskInstance = saveAndReload(taskInstance);
+ contextInstance = taskInstance.getContextInstance();
- expectedVariables = new HashMap();
+ expectedVariables.clear();
expectedVariables.put("a", "1"); // task instance had local copy for var a
expectedVariables.put("b", "2"); // task instance had local copy for var b
expectedVariables.put("c", "3 modified");
@@ -306,94 +265,90 @@
}
}
- public void testOverwriteNullValue() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask'>" +
- " <controller>" +
- " <variable name='v' />" +
- " </controller>" +
- " </task>" +
- " </task-node>" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+ public void testOverwriteNullValue()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='overwrite-null-value'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask'>"
+ + " <controller>"
+ + " <variable name='v' />"
+ + " </controller>"
+ + " </task>"
+ + " </task-node>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
processInstance.signal();
-
+
processInstance = saveAndReload(processInstance);
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
-
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
+
assertNull(taskInstance.getVariable("v"));
taskInstance.setVariable("v", "facelets is great");
- jbpmContext.save(taskInstance);
-
- newTransaction();
-
- taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
+
+ taskInstance = saveAndReload(taskInstance);
assertEquals("facelets is great", taskInstance.getVariable("v"));
}
finally
{
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
- public void testNewTaskInstanceVariablesWithoutController() {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition>" +
- " <start-state>" +
- " <transition to='t' />" +
- " </start-state>" +
- " <task-node name='t'>" +
- " <task name='vartask'>" +
- " </task>" +
- " <transition to='u' />" +
- " </task-node>" +
- " <state name='u' />" +
- "</process-definition>"
- );
- processDefinition = saveAndReload(processDefinition);
+ public void testNewTaskInstanceVariablesWithoutController()
+ {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString("<process-definition name='task variables without controller'>"
+ + " <start-state>"
+ + " <transition to='t' />"
+ + " </start-state>"
+ + " <task-node name='t'>"
+ + " <task name='vartask' />"
+ + " <transition to='u' />"
+ + " </task-node>"
+ + " <state name='u' />"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ newTransaction();
try
{
ProcessInstance processInstance = new ProcessInstance(processDefinition);
- TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
processInstance.signal();
- TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
-
+ TaskInstance taskInstance = processInstance.getTaskMgmtInstance()
+ .getTaskInstances()
+ .iterator()
+ .next();
taskInstance.setVariableLocally("a", "value-a");
taskInstance.setVariableLocally("b", "value-b");
-
- jbpmContext.save(processInstance);
-
- processInstance = saveAndReload(processInstance);
- ContextInstance contextInstance = processInstance.getContextInstance();
- taskMgmtInstance = processInstance.getTaskMgmtInstance();
- taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
-
- assertFalse( contextInstance.hasVariable("a") );
- assertFalse( contextInstance.hasVariable("b") );
-
+
+ taskInstance = saveAndReload(taskInstance);
+ ContextInstance contextInstance = taskInstance.getContextInstance();
+
+ assertFalse(contextInstance.hasVariable("a"));
+ assertFalse(contextInstance.hasVariable("b"));
+
assertEquals("value-a", taskInstance.getVariable("a"));
assertEquals("value-b", taskInstance.getVariable("b"));
-
+
taskInstance.end();
-
+
assertEquals("value-a", contextInstance.getVariable("a"));
assertEquals("value-b", contextInstance.getVariable("b"));
-
- processInstance = saveAndReload(processInstance);
- contextInstance = processInstance.getContextInstance();
-
+
+ taskInstance = saveAndReload(taskInstance);
+ contextInstance = taskInstance.getContextInstance();
+
assertEquals("value-a", contextInstance.getVariable("a"));
assertEquals("value-b", contextInstance.getVariable("b"));
}
@@ -401,6 +356,5 @@
{
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
}
-
}
}
17 years, 2 months
JBoss JBPM SVN: r3847 - in jbpm3/trunk/modules/core: scripts and 4 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-12 02:33:12 -0500 (Thu, 12 Feb 2009)
New Revision: 3847
Added:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
Modified:
jbpm3/trunk/modules/core/pom.xml
jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
Log:
[JBPM-1686] NPE when reading a process definition with a decision name which contains the / character
Modified: jbpm3/trunk/modules/core/pom.xml
===================================================================
--- jbpm3/trunk/modules/core/pom.xml 2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/pom.xml 2009-02-12 07:33:12 UTC (rev 3847)
@@ -182,7 +182,7 @@
<configuration>
<tasks>
<property name="database" value="${database}" />
- <ant antfile="scripts/antrun-jbpm-config.xml" target="concat" />
+ <ant antfile="scripts/antrun-jbpm-config.xml" target="generate-hibernate-cfg" />
</tasks>
</configuration>
</execution>
@@ -225,8 +225,7 @@
<configuration>
<tasks>
<property name="database" value="${database}" />
- <ant antfile="scripts/antrun-jbpm-config.xml" target="concat" />
- <ant antfile="scripts/antrun-jbpm-config.xml" target="jbpm-cfg-xml-soa" />
+ <ant antfile="scripts/antrun-jbpm-config.xml" target="generate-jbpm-cfg-soa" />
</tasks>
</configuration>
</execution>
Modified: jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml
===================================================================
--- jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml 2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/scripts/antrun-jbpm-config.xml 2009-02-12 07:33:12 UTC (rev 3847)
@@ -11,7 +11,7 @@
<!-- $Id$ -->
-<project default="concat">
+<project>
<property name="project.build.directory" value="${basedir}/target"/>
<property name="build.resources.directory" value="${basedir}/target/classes"/>
@@ -80,7 +80,7 @@
</macrodef>
<!-- Concatenates the hibernate config scripts -->
- <target name="concat" >
+ <target name="generate-hibernate-cfg" >
<macro-database-cfg database="db2" />
<macro-database-cfg database="derby" />
<macro-database-cfg database="firebird" />
@@ -105,7 +105,7 @@
</target>
<!-- Generate the custom jbpm.cfg.xml for the SOA platform -->
- <target name="jbpm-cfg-xml-soa" >
+ <target name="generate-jbpm-cfg-soa" depends="generate-hibernate-cfg">
<echo message="Generate the custom jbpm.cfg.xml for the SOA platform" />
<macro-disable section="Logging Service" file="${project.build.directory}/classes/org/jbpm/default.jbpm.cfg.xml"/>
</target>
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Node.java 2009-02-12 07:33:12 UTC (rev 3847)
@@ -500,6 +500,9 @@
*/
public void setName(String name)
{
+ if (name == null || name.contains("/"))
+ throw new IllegalArgumentException("Invalid node name: " + name);
+
if (isDifferent(this.name, name))
{
String oldName = this.name;
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2009-02-12 06:54:41 UTC (rev 3846)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java 2009-02-12 07:33:12 UTC (rev 3847)
@@ -59,8 +59,9 @@
import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
import org.xml.sax.InputSource;
-public class JpdlXmlReader implements ProblemListener {
-
+public class JpdlXmlReader implements ProblemListener
+{
+
private static final long serialVersionUID = 1L;
protected InputSource inputSource = null;
@@ -71,32 +72,37 @@
protected Collection<Object[]> unresolvedTransitionDestinations = null;
protected Collection<Object[]> unresolvedActionReferences = null;
- /**
+ /*
* the parsed process definition as DOM tree (available after readProcessDefinition)
*/
protected Document document;
- /** for autonumbering anonymous timers. */
+ /* for autonumbering anonymous timers. */
private int timerNumber;
- public JpdlXmlReader(InputSource inputSource) {
+ public JpdlXmlReader(InputSource inputSource)
+ {
this.inputSource = inputSource;
}
-
- public JpdlXmlReader(InputSource inputSource, ProblemListener problemListener) {
+
+ public JpdlXmlReader(InputSource inputSource, ProblemListener problemListener)
+ {
this.inputSource = inputSource;
this.problemListener = problemListener;
}
-
- public JpdlXmlReader(Reader reader) {
+
+ public JpdlXmlReader(Reader reader)
+ {
this(new InputSource(reader));
}
- public void close() throws IOException {
+ public void close() throws IOException
+ {
InputStream byteStream = inputSource.getByteStream();
- if (byteStream != null)
+ if (byteStream != null)
byteStream.close();
- else {
+ else
+ {
Reader charStream = inputSource.getCharacterStream();
if (charStream != null)
charStream.close();
@@ -104,31 +110,38 @@
document = null;
}
- public ProcessDefinition getProcessDefinition() {
+ public ProcessDefinition getProcessDefinition()
+ {
return processDefinition;
}
- public void addProblem(Problem problem) {
+ public void addProblem(Problem problem)
+ {
problems.add(problem);
- if (problemListener!=null) problemListener.addProblem(problem);
+ if (problemListener != null)
+ problemListener.addProblem(problem);
}
-
- public void addError(String description) {
- log.error("invalid process xml: "+description);
+
+ public void addError(String description)
+ {
+ log.error("invalid process xml: " + description);
addProblem(new Problem(Problem.LEVEL_ERROR, description));
}
- public void addError(String description, Throwable exception) {
- log.error("invalid process xml: "+description, exception);
+ public void addError(String description, Throwable exception)
+ {
+ log.error("invalid process xml: " + description, exception);
addProblem(new Problem(Problem.LEVEL_ERROR, description, exception));
}
- public void addWarning(String description) {
- log.warn("process xml warning: "+description);
+ public void addWarning(String description)
+ {
+ log.warn("process xml warning: " + description);
addProblem(new Problem(Problem.LEVEL_WARNING, description));
}
- public ProcessDefinition readProcessDefinition() {
+ public ProcessDefinition readProcessDefinition()
+ {
// create a new definition
processDefinition = ProcessDefinition.createNewProcessDefinition();
@@ -136,18 +149,20 @@
problems = new ArrayList<Problem>();
unresolvedTransitionDestinations = new ArrayList<Object[]>();
unresolvedActionReferences = new ArrayList<Object[]>();
-
- try {
+
+ try
+ {
// parse the document into a dom tree
document = JpdlParser.parse(inputSource, this);
Element root = document.getRootElement();
-
+
// read the process name
parseProcessDefinitionAttributes(root);
-
- // get the process description
+
+ // get the process description
String description = root.elementTextTrim("description");
- if (description!=null) {
+ if (description != null)
+ {
processDefinition.setDescription(description);
}
@@ -164,59 +179,73 @@
resolveActionReferences();
verifySwimlaneAssignments();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
log.error("couldn't parse process definition", e);
addProblem(new Problem(Problem.LEVEL_ERROR, "couldn't parse process definition", e));
}
-
- if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR)) {
+
+ if (Problem.containsProblemsOfLevel(problems, Problem.LEVEL_ERROR))
+ {
throw new JpdlException(problems);
}
-
- if (problems!=null) {
- for (Problem problem : problems) {
- log.warn("process parse warning: "+problem.getDescription());
+
+ if (problems != null)
+ {
+ for (Problem problem : problems)
+ {
+ log.warn("process parse warning: " + problem.getDescription());
}
}
-
+
return processDefinition;
}
- protected void parseProcessDefinitionAttributes(Element root) {
+ protected void parseProcessDefinitionAttributes(Element root)
+ {
processDefinition.setName(root.attributeValue("name"));
initialNodeName = root.attributeValue("initial");
}
-
- protected void readSwimlanes(Element processDefinitionElement) {
+
+ protected void readSwimlanes(Element processDefinitionElement)
+ {
Iterator<?> iter = processDefinitionElement.elementIterator("swimlane");
TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
- while (iter.hasNext()) {
- Element swimlaneElement = (Element) iter.next();
+ while (iter.hasNext())
+ {
+ Element swimlaneElement = (Element)iter.next();
String swimlaneName = swimlaneElement.attributeValue("name");
- if (swimlaneName==null) {
+ if (swimlaneName == null)
+ {
addWarning("there's a swimlane without a name");
- } else {
+ }
+ else
+ {
Swimlane swimlane = new Swimlane(swimlaneName);
Element assignmentElement = swimlaneElement.element("assignment");
- if (assignmentElement!=null) {
-
- if ( (assignmentElement.attribute("actor-id")!=null)
- || (assignmentElement.attribute("pooled-actors")!=null)
- ) {
+ if (assignmentElement != null)
+ {
+
+ if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null))
+ {
swimlane.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
swimlane.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-
- } else {
+
+ }
+ else
+ {
Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
swimlane.setAssignmentDelegation(assignmentDelegation);
}
- } else {
+ }
+ else
+ {
Task startTask = taskMgmtDefinition.getStartTask();
- if ( (startTask==null)
- || (startTask.getSwimlane()!=swimlane)
- ) {
- addWarning("swimlane '"+swimlaneName+"' does not have an assignment");
+ if ((startTask == null) || (startTask.getSwimlane() != swimlane))
+ {
+ addWarning("swimlane '" + swimlaneName + "' does not have an assignment");
}
}
taskMgmtDefinition.addSwimlane(swimlane);
@@ -224,90 +253,111 @@
}
}
- public void readNodes(Element element, NodeCollection nodeCollection) {
+ public void readNodes(Element element, NodeCollection nodeCollection)
+ {
Iterator<?> nodeElementIter = element.elementIterator();
- while (nodeElementIter.hasNext()) {
- Element nodeElement = (Element) nodeElementIter.next();
+ while (nodeElementIter.hasNext())
+ {
+ Element nodeElement = (Element)nodeElementIter.next();
String nodeName = nodeElement.getName();
// get the node type
Class<?> nodeType = NodeTypes.getNodeType(nodeName);
- if (nodeType!=null) {
+ if (nodeType != null)
+ {
Node node = null;
- try {
+ try
+ {
// create a new instance
- node = (Node) nodeType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate node '"+nodeName+"', of type '"+nodeType.getName()+"'", e);
+ node = (Node)nodeType.newInstance();
+ }
+ catch (Exception e)
+ {
+ log.error("couldn't instantiate node '" + nodeName + "', of type '" + nodeType.getName() + "'", e);
continue;
}
-
+
node.setProcessDefinition(processDefinition);
-
+
// check for duplicate start-states
- if ( (node instanceof StartState)
- && (processDefinition.getStartState()!=null)
- ) {
+ if ((node instanceof StartState) && (processDefinition.getStartState() != null))
+ {
addError("max one start-state allowed in a process");
-
- } else {
+
+ }
+ else
+ {
// read the common node parts of the element
readNode(nodeElement, node, nodeCollection);
-
- // if the node is parsable
- // (meaning: if the node has special configuration to parse, other then the
- // common node data)
+
+ // if the node is parsable
+ // (meaning: if the node has special configuration to parse, other then the
+ // common node data)
node.read(nodeElement, this);
}
}
}
}
- public void readTasks(Element element, TaskNode taskNode) {
+ public void readTasks(Element element, TaskNode taskNode)
+ {
List<?> elements = element.elements("task");
- TaskMgmtDefinition tmd = processDefinition.getTaskMgmtDefinition();
- if (elements.size()>0) {
- if (tmd==null) {
+ TaskMgmtDefinition tmd = processDefinition.getTaskMgmtDefinition();
+ if (elements.size() > 0)
+ {
+ if (tmd == null)
+ {
tmd = new TaskMgmtDefinition();
}
processDefinition.addDefinition(tmd);
- for (Object taskElement : elements) {
- readTask((Element) taskElement, tmd, taskNode);
+ for (Object taskElement : elements)
+ {
+ readTask((Element)taskElement, tmd, taskNode);
}
}
}
- public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode) {
+ public Task readTask(Element taskElement, TaskMgmtDefinition taskMgmtDefinition, TaskNode taskNode)
+ {
Task task = new Task();
task.setProcessDefinition(processDefinition);
-
+
// get the task name
String name = taskElement.attributeValue("name");
- if (name!=null) {
+ if (name != null)
+ {
task.setName(name);
taskMgmtDefinition.addTask(task);
- } else if (taskNode!=null) {
+ }
+ else if (taskNode != null)
+ {
task.setName(taskNode.getName());
taskMgmtDefinition.addTask(task);
}
-
- // get the task description
+
+ // get the task description
String description = taskElement.elementTextTrim("description");
- if (description!=null) {
+ if (description != null)
+ {
task.setDescription(description);
- } else {
+ }
+ else
+ {
task.setDescription(taskElement.attributeValue("description"));
}
-
- // get the condition
+
+ // get the condition
String condition = taskElement.elementTextTrim("condition");
- if (condition!=null) {
+ if (condition != null)
+ {
task.setCondition(condition);
- } else {
+ }
+ else
+ {
task.setCondition(taskElement.attributeValue("condition"));
}
-
+
// parse common subelements
readTaskTimers(taskElement, task);
readEvents(taskElement, task);
@@ -315,83 +365,93 @@
// duedate and priority
String duedateText = taskElement.attributeValue("duedate");
- if (duedateText==null) {
+ if (duedateText == null)
+ {
duedateText = taskElement.attributeValue("dueDate");
}
task.setDueDate(duedateText);
String priorityText = taskElement.attributeValue("priority");
- if (priorityText!=null) {
+ if (priorityText != null)
+ {
task.setPriority(Task.parsePriority(priorityText));
}
-
+
// if this task is in the context of a taskNode, associate them
- if (taskNode!=null) {
+ if (taskNode != null)
+ {
taskNode.addTask(task);
}
// blocking
String blockingText = taskElement.attributeValue("blocking");
- if (blockingText!=null) {
- if ( ("true".equalsIgnoreCase(blockingText))
- || ("yes".equalsIgnoreCase(blockingText))
- || ("on".equalsIgnoreCase(blockingText)) ) {
+ if (blockingText != null)
+ {
+ if (("true".equalsIgnoreCase(blockingText)) || ("yes".equalsIgnoreCase(blockingText)) || ("on".equalsIgnoreCase(blockingText)))
+ {
task.setBlocking(true);
}
}
-
+
// signalling
String signallingText = taskElement.attributeValue("signalling");
- if (signallingText!=null) {
- if ( ("false".equalsIgnoreCase(signallingText))
- || ("no".equalsIgnoreCase(signallingText))
- || ("off".equalsIgnoreCase(signallingText)) ) {
+ if (signallingText != null)
+ {
+ if (("false".equalsIgnoreCase(signallingText)) || ("no".equalsIgnoreCase(signallingText)) || ("off".equalsIgnoreCase(signallingText)))
+ {
task.setSignalling(false);
}
}
-
+
// assignment
String swimlaneName = taskElement.attributeValue("swimlane");
Element assignmentElement = taskElement.element("assignment");
// if there is a swimlane attribute specified
- if (swimlaneName!=null) {
+ if (swimlaneName != null)
+ {
Swimlane swimlane = taskMgmtDefinition.getSwimlane(swimlaneName);
- if (swimlane==null) {
- addWarning("task references unknown swimlane '"+swimlaneName+"':"+taskElement.asXML());
- } else {
+ if (swimlane == null)
+ {
+ addWarning("task references unknown swimlane '" + swimlaneName + "':" + taskElement.asXML());
+ }
+ else
+ {
task.setSwimlane(swimlane);
}
- // else if there is a direct assignment specified
- } else if (assignmentElement!=null) {
- if ( (assignmentElement.attribute("actor-id")!=null)
- || (assignmentElement.attribute("pooled-actors")!=null)
- ) {
+ // else if there is a direct assignment specified
+ }
+ else if (assignmentElement != null)
+ {
+ if ((assignmentElement.attribute("actor-id") != null) || (assignmentElement.attribute("pooled-actors") != null))
+ {
task.setActorIdExpression(assignmentElement.attributeValue("actor-id"));
task.setPooledActorsExpression(assignmentElement.attributeValue("pooled-actors"));
-
- } else {
+
+ }
+ else
+ {
Delegation assignmentDelegation = readAssignmentDelegation(assignmentElement);
task.setAssignmentDelegation(assignmentDelegation);
}
- // if no assignment or swimlane is specified
- } else {
- // the user has to manage assignment manually, so we better inform him/her.
- log.info("process xml information: no swimlane or assignment specified for task '"+taskElement.asXML()+"'");
+ // if no assignment or swimlane is specified
}
+ else
+ {
+ // the user has to manage assignment manually, so we better inform him/her.
+ log.info("process xml information: no swimlane or assignment specified for task '" + taskElement.asXML() + "'");
+ }
// notify
String notificationsText = taskElement.attributeValue("notify");
- if ( notificationsText!=null
- && ("true".equalsIgnoreCase(notificationsText)
- || "on".equalsIgnoreCase(notificationsText)
- || "yes".equalsIgnoreCase(notificationsText)
- )
- ) {
+ if (notificationsText != null
+ && ("true".equalsIgnoreCase(notificationsText) || "on".equalsIgnoreCase(notificationsText) || "yes".equalsIgnoreCase(notificationsText)))
+ {
String notificationEvent = Event.EVENTTYPE_TASK_ASSIGN;
Event event = task.getEvent(notificationEvent);
- if (event==null) {
+ if (event == null)
+ {
event = new Event(notificationEvent);
task.addEvent(event);
}
@@ -404,119 +464,140 @@
// task controller
Element taskControllerElement = taskElement.element("controller");
- if (taskControllerElement!=null) {
+ if (taskControllerElement != null)
+ {
task.setTaskController(readTaskController(taskControllerElement));
}
-
+
return task;
}
- protected Delegation readAssignmentDelegation(Element assignmentElement) {
+ protected Delegation readAssignmentDelegation(Element assignmentElement)
+ {
Delegation assignmentDelegation = new Delegation();
String expression = assignmentElement.attributeValue("expression");
String actorId = assignmentElement.attributeValue("actor-id");
String pooledActors = assignmentElement.attributeValue("pooled-actors");
-
- if (expression!=null){
+
+ if (expression != null)
+ {
assignmentDelegation.setProcessDefinition(processDefinition);
assignmentDelegation.setClassName("org.jbpm.identity.assignment.ExpressionAssignmentHandler");
- assignmentDelegation.setConfiguration("<expression>"+expression+"</expression>");
-
- } else if ( (actorId!=null)
- || (pooledActors!=null)
- ) {
+ assignmentDelegation.setConfiguration("<expression>" + expression + "</expression>");
+
+ }
+ else if ((actorId != null) || (pooledActors != null))
+ {
assignmentDelegation.setProcessDefinition(processDefinition);
assignmentDelegation.setClassName("org.jbpm.taskmgmt.assignment.ActorAssignmentHandler");
String configuration = "";
- if (actorId!=null) {
- configuration += "<actorId>"+actorId+"</actorId>";
+ if (actorId != null)
+ {
+ configuration += "<actorId>" + actorId + "</actorId>";
}
- if (pooledActors!=null) {
- configuration += "<pooledActors>"+pooledActors+"</pooledActors>";
+ if (pooledActors != null)
+ {
+ configuration += "<pooledActors>" + pooledActors + "</pooledActors>";
}
assignmentDelegation.setConfiguration(configuration);
-
- } else {
+
+ }
+ else
+ {
assignmentDelegation = new Delegation();
assignmentDelegation.read(assignmentElement, this);
}
-
+
return assignmentDelegation;
}
- protected TaskController readTaskController(Element taskControllerElement) {
+ protected TaskController readTaskController(Element taskControllerElement)
+ {
TaskController taskController = new TaskController();
- if (taskControllerElement.attributeValue("class")!=null) {
+ if (taskControllerElement.attributeValue("class") != null)
+ {
Delegation taskControllerDelegation = new Delegation();
taskControllerDelegation.read(taskControllerElement, this);
taskController.setTaskControllerDelegation(taskControllerDelegation);
- } else {
+ }
+ else
+ {
List<VariableAccess> variableAccesses = readVariableAccesses(taskControllerElement);
taskController.setVariableAccesses(variableAccesses);
}
return taskController;
}
-
- public List<VariableAccess> readVariableAccesses(Element element) {
+
+ public List<VariableAccess> readVariableAccesses(Element element)
+ {
List<VariableAccess> variableAccesses = new ArrayList<VariableAccess>();
Iterator<?> iter = element.elementIterator("variable");
- while (iter.hasNext()) {
- Element variableElement = (Element) iter.next();
-
+ while (iter.hasNext())
+ {
+ Element variableElement = (Element)iter.next();
+
String variableName = variableElement.attributeValue("name");
- if (variableName==null) {
- addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: "+variableElement.asXML()));
+ if (variableName == null)
+ {
+ addProblem(new Problem(Problem.LEVEL_WARNING, "the name attribute of a variable element is required: " + variableElement.asXML()));
}
String access = variableElement.attributeValue("access", "read,write");
String mappedName = variableElement.attributeValue("mapped-name");
-
+
variableAccesses.add(new VariableAccess(variableName, access, mappedName));
}
return variableAccesses;
}
- public void readStartStateTask(Element startTaskElement, StartState startState) {
+ public void readStartStateTask(Element startTaskElement, StartState startState)
+ {
TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
Task startTask = readTask(startTaskElement, taskMgmtDefinition, null);
startTask.setStartState(startState);
- if (startTask.getName()==null) {
+ if (startTask.getName() == null)
+ {
startTask.setName(startState.getName());
}
taskMgmtDefinition.setStartTask(startTask);
}
- public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection) {
+ public void readNode(Element nodeElement, Node node, NodeCollection nodeCollection)
+ {
- // first put the node in its collection. this is done so that the
- // setName later on will be able to differentiate between nodes contained in
+ // first put the node in its collection. this is done so that the
+ // setName later on will be able to differentiate between nodes contained in
// processDefinitions and nodes contained in superstates
nodeCollection.addNode(node);
// get the node name
String name = nodeElement.attributeValue("name");
- if (name!=null) {
+ if (name != null)
+ {
node.setName(name);
// check if this is the initial node
- if ( (initialNodeName!=null)
- && (initialNodeName.equals(node.getFullyQualifiedName()))
- ) {
+ if ((initialNodeName != null) && (initialNodeName.equals(node.getFullyQualifiedName())))
+ {
processDefinition.setStartState(node);
}
}
- // get the node description
+ // get the node description
String description = nodeElement.elementTextTrim("description");
- if (description!=null) {
+ if (description != null)
+ {
node.setDescription(description);
}
String asyncText = nodeElement.attributeValue("async");
- if ("true".equalsIgnoreCase(asyncText)) {
+ if ("true".equalsIgnoreCase(asyncText))
+ {
node.setAsync(true);
- } else if ("exclusive".equalsIgnoreCase(asyncText)) {
+ }
+ else if ("exclusive".equalsIgnoreCase(asyncText))
+ {
node.setAsync(true);
node.setAsyncExclusive(true);
}
@@ -530,94 +611,109 @@
addUnresolvedTransitionDestination(nodeElement, node);
}
- protected void readNodeTimers(Element nodeElement, Node node) {
+ protected void readNodeTimers(Element nodeElement, Node node)
+ {
Iterator<?> iter = nodeElement.elementIterator("timer");
- while (iter.hasNext()) {
- Element timerElement = (Element) iter.next();
+ while (iter.hasNext())
+ {
+ Element timerElement = (Element)iter.next();
readNodeTimer(timerElement, node);
}
}
- protected void readNodeTimer(Element timerElement, Node node) {
+ protected void readNodeTimer(Element timerElement, Node node)
+ {
String name = timerElement.attributeValue("name", node.getName());
- if (name == null) name = generateTimerName();
-
+ if (name == null)
+ name = generateTimerName();
+
CreateTimerAction createTimerAction = instantiateCreateTimerAction();
createTimerAction.read(timerElement, this);
createTimerAction.setTimerName(name);
createTimerAction.setTimerAction(readSingleAction(timerElement));
addAction(node, Event.EVENTTYPE_NODE_ENTER, createTimerAction);
-
+
CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
cancelTimerAction.setTimerName(name);
addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
}
- /**
- * instantiate {@link CreateTimerAction} object from configured
- * class in action.types.xml (if configured). If not the default
- * jbpm class is used.
+ /*
+ * instantiate {@link CreateTimerAction} object from configured class in action.types.xml (if configured). If not the default jbpm class is used.
*/
private CreateTimerAction instantiateCreateTimerAction()
{
- if (ActionTypes.hasActionName("create-timer")) {
+ if (ActionTypes.hasActionName("create-timer"))
+ {
Class actionType = ActionTypes.getActionType("create-timer");
- try {
+ try
+ {
return (CreateTimerAction)actionType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate 'create-timer' action of type '"+actionType.getName()+"'. Using default CreateTimerAction.", e);
}
+ catch (Exception e)
+ {
+ log.error("couldn't instantiate 'create-timer' action of type '" + actionType.getName() + "'. Using default CreateTimerAction.", e);
+ }
}
// default
- return new CreateTimerAction();
+ return new CreateTimerAction();
}
- /**
- * instantiate {@link CancelTimerAction} object from configured
- * class in action.types.xml (if configured). If not the default
- * jbpm class is used.
+ /*
+ * instantiate {@link CancelTimerAction} object from configured class in action.types.xml (if configured). If not the default jbpm class is used.
*/
private CancelTimerAction instantiateCancelTimerAction()
{
- if (ActionTypes.hasActionName("cancel-timer")) {
+ if (ActionTypes.hasActionName("cancel-timer"))
+ {
Class actionType = ActionTypes.getActionType("cancel-timer");
- try {
+ try
+ {
return (CancelTimerAction)actionType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate 'cancel-timer' action of type '"+actionType.getName()+"'. Using default CancelTimerAction.", e);
}
+ catch (Exception e)
+ {
+ log.error("couldn't instantiate 'cancel-timer' action of type '" + actionType.getName() + "'. Using default CancelTimerAction.", e);
+ }
}
// default
- return new CancelTimerAction();
+ return new CancelTimerAction();
}
- private String generateTimerName() {
- return "timer-" + (timerNumber++);
+ private String generateTimerName()
+ {
+ return "timer-" + (timerNumber++);
}
- protected void readTaskTimers(Element taskElement, Task task) {
+ protected void readTaskTimers(Element taskElement, Task task)
+ {
Iterator<?> iter = taskElement.elementIterator();
- while (iter.hasNext()) {
- Element element = (Element) iter.next();
- if ( ("timer".equals(element.getName()))
- || ("reminder".equals(element.getName()))
- ) {
+ while (iter.hasNext())
+ {
+ Element element = (Element)iter.next();
+ if (("timer".equals(element.getName())) || ("reminder".equals(element.getName())))
+ {
readTaskTimer(element, task);
}
}
}
- protected void readTaskTimer(Element timerElement, Task task) {
+ protected void readTaskTimer(Element timerElement, Task task)
+ {
String name = timerElement.attributeValue("name", task.getName());
- if (name==null) name = generateTimerName();
+ if (name == null)
+ name = generateTimerName();
CreateTimerAction createTimerAction = instantiateCreateTimerAction();
createTimerAction.read(timerElement, this);
createTimerAction.setTimerName(name);
Action action = null;
- if ("timer".equals(timerElement.getName())) {
+ if ("timer".equals(timerElement.getName()))
+ {
action = readSingleAction(timerElement);
- } else {
+ }
+ else
+ {
Delegation delegation = createMailDelegation("task-reminder", null, null, null, null);
action = new Action(delegation);
}
@@ -628,47 +724,57 @@
Collection<String> cancelEventTypes = new ArrayList<String>();
String cancelEventTypeText = timerElement.attributeValue("cancel-event");
- if (cancelEventTypeText!=null) {
+ if (cancelEventTypeText != null)
+ {
// cancel-event is a comma separated list of events
StringTokenizer tokenizer = new StringTokenizer(cancelEventTypeText, ",");
- while (tokenizer.hasMoreTokens()) {
+ while (tokenizer.hasMoreTokens())
+ {
cancelEventTypes.add(tokenizer.nextToken().trim());
}
- } else {
+ }
+ else
+ {
// set the default
cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
}
- for (String cancelEventType : cancelEventTypes) {
+ for (String cancelEventType : cancelEventTypes)
+ {
CancelTimerAction cancelTimerAction = instantiateCancelTimerAction();
cancelTimerAction.setTimerName(name);
addAction(task, cancelEventType, cancelTimerAction);
}
}
-
- protected void readEvents(Element parentElement, GraphElement graphElement) {
+
+ protected void readEvents(Element parentElement, GraphElement graphElement)
+ {
Iterator<?> iter = parentElement.elementIterator("event");
- while (iter.hasNext()) {
- Element eventElement = (Element) iter.next();
+ while (iter.hasNext())
+ {
+ Element eventElement = (Element)iter.next();
String eventType = eventElement.attributeValue("type");
- if (!graphElement.hasEvent(eventType)) {
+ if (!graphElement.hasEvent(eventType))
+ {
graphElement.addEvent(new Event(eventType));
}
readActions(eventElement, graphElement, eventType);
}
}
- public void readActions(Element eventElement, GraphElement graphElement, String eventType) {
+ public void readActions(Element eventElement, GraphElement graphElement, String eventType)
+ {
// for all the elements in the event element
Iterator<?> nodeElementIter = eventElement.elementIterator();
- while (nodeElementIter.hasNext()) {
- Element actionElement = (Element) nodeElementIter.next();
+ while (nodeElementIter.hasNext())
+ {
+ Element actionElement = (Element)nodeElementIter.next();
String actionName = actionElement.getName();
- if (ActionTypes.hasActionName(actionName)) {
+ if (ActionTypes.hasActionName(actionName))
+ {
Action action = createAction(actionElement);
- if ( (graphElement!=null)
- && (eventType!=null)
- ) {
+ if ((graphElement != null) && (eventType != null))
+ {
// add the action to the event
addAction(graphElement, eventType, action);
}
@@ -676,22 +782,27 @@
}
}
- protected void addAction(GraphElement graphElement, String eventType, Action action) {
+ protected void addAction(GraphElement graphElement, String eventType, Action action)
+ {
Event event = graphElement.getEvent(eventType);
- if (event==null) {
- event = new Event(eventType);
+ if (event == null)
+ {
+ event = new Event(eventType);
graphElement.addEvent(event);
}
event.addAction(action);
}
-
- public Action readSingleAction(Element nodeElement) {
+
+ public Action readSingleAction(Element nodeElement)
+ {
Action action = null;
// search for the first action element in the node
Iterator<?> iter = nodeElement.elementIterator();
- while (iter.hasNext() && (action==null)) {
- Element candidate = (Element) iter.next();
- if (ActionTypes.hasActionName(candidate.getName())) {
+ while (iter.hasNext() && (action == null))
+ {
+ Element candidate = (Element)iter.next();
+ if (ActionTypes.hasActionName(candidate.getName()))
+ {
// parse the action and assign it to this node
action = createAction(candidate);
}
@@ -699,46 +810,55 @@
return action;
}
- public Action createAction(Element actionElement) {
+ public Action createAction(Element actionElement)
+ {
// create a new instance of the action
Action action = null;
String actionName = actionElement.getName();
Class<? extends Action> actionType = ActionTypes.getActionType(actionName);
- try {
+ try
+ {
action = actionType.newInstance();
- } catch (Exception e) {
- log.error("couldn't instantiate action '"+actionName+"', of type '"+actionType.getName()+"'", e);
}
+ catch (Exception e)
+ {
+ log.error("couldn't instantiate action '" + actionName + "', of type '" + actionType.getName() + "'", e);
+ }
// read the common node parts of the action
readAction(actionElement, action);
-
+
return action;
}
- public void readAction(Element element, Action action) {
+ public void readAction(Element element, Action action)
+ {
// if a name is specified for this action
String actionName = element.attributeValue("name");
- if (actionName!=null) {
+ if (actionName != null)
+ {
action.setName(actionName);
- // add the action to the named process action repository
+ // add the action to the named process action repository
processDefinition.addAction(action);
}
- // if the action is parsable
+ // if the action is parsable
// (meaning: if the action has special configuration to parse, other then the common node data)
action.read(element, this);
}
- protected void readExceptionHandlers(Element graphElementElement, GraphElement graphElement) {
+ protected void readExceptionHandlers(Element graphElementElement, GraphElement graphElement)
+ {
Iterator<?> iter = graphElementElement.elementIterator("exception-handler");
- while (iter.hasNext()) {
- Element exceptionHandlerElement = (Element) iter.next();
+ while (iter.hasNext())
+ {
+ Element exceptionHandlerElement = (Element)iter.next();
readExceptionHandler(exceptionHandlerElement, graphElement);
}
}
- protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement) {
+ protected void readExceptionHandler(Element exceptionHandlerElement, GraphElement graphElement)
+ {
// create the exception handler
ExceptionHandler exceptionHandler = new ExceptionHandler();
exceptionHandler.setExceptionClassName(exceptionHandlerElement.attributeValue("exception-class"));
@@ -747,9 +867,11 @@
// read the actions in the body of the exception-handler element
Iterator<?> iter = exceptionHandlerElement.elementIterator();
- while (iter.hasNext()) {
- Element childElement = (Element) iter.next();
- if (ActionTypes.hasActionName(childElement.getName())) {
+ while (iter.hasNext())
+ {
+ Element childElement = (Element)iter.next();
+ if (ActionTypes.hasActionName(childElement.getName()))
+ {
Action action = createAction(childElement);
exceptionHandler.addAction(action);
}
@@ -757,32 +879,36 @@
}
// transition destinations are parsed in a second pass //////////////////////
-
- public void addUnresolvedTransitionDestination(Element nodeElement, Node node) {
- unresolvedTransitionDestinations.add(new Object[]{nodeElement, node});
+
+ public void addUnresolvedTransitionDestination(Element nodeElement, Node node)
+ {
+ unresolvedTransitionDestinations.add(new Object[] { nodeElement, node });
}
- public void resolveTransitionDestinations() {
- for (Object[] unresolvedTransition : unresolvedTransitionDestinations) {
- Element nodeElement = (Element) unresolvedTransition[0];
- Node node = (Node) unresolvedTransition[1];
+ public void resolveTransitionDestinations()
+ {
+ for (Object[] unresolvedTransition : unresolvedTransitionDestinations)
+ {
+ Element nodeElement = (Element)unresolvedTransition[0];
+ Node node = (Node)unresolvedTransition[1];
resolveTransitionDestinations(nodeElement.elements("transition"), node);
}
}
- public void resolveTransitionDestinations(List<?> transitionElements, Node node) {
- for (Object transitionElement : transitionElements) {
- resolveTransitionDestination((Element) transitionElement, node);
+ public void resolveTransitionDestinations(List<?> transitionElements, Node node)
+ {
+ for (Object transitionElement : transitionElements)
+ {
+ resolveTransitionDestination((Element)transitionElement, node);
}
}
- /**
+ /*
* creates the transition object and configures it by the read attributes
- * @return the created <code>org.jbpm.graph.def.Transition</code> object
- * (useful, if you want to override this method
- * to read additional configuration properties)
+ * @return the created <code>org.jbpm.graph.def.Transition</code> object (useful, if you want to override this method to read additional configuration properties)
*/
- public Transition resolveTransitionDestination(Element transitionElement, Node node) {
+ public Transition resolveTransitionDestination(Element transitionElement, Node node)
+ {
Transition transition = new Transition();
transition.setProcessDefinition(processDefinition);
@@ -790,14 +916,15 @@
transition.setDescription(transitionElement.elementTextTrim("description"));
String condition = transitionElement.attributeValue("condition");
- if (condition==null) {
+ if (condition == null)
+ {
Element conditionElement = transitionElement.element("condition");
- if (conditionElement!=null) {
+ if (conditionElement != null)
+ {
condition = conditionElement.getTextTrim();
// for backwards compatibility
- if ( (condition==null)
- || (condition.length()==0)
- ) {
+ if ((condition == null) || (condition.length() == 0))
+ {
condition = conditionElement.attributeValue("expression");
}
}
@@ -809,58 +936,68 @@
// set destinationNode of the transition
String toName = transitionElement.attributeValue("to");
- if (toName==null) {
- addWarning("node '"+node.getFullyQualifiedName()+"' has a transition without a 'to'-attribute to specify its destinationNode");
- } else {
+ if (toName == null)
+ {
+ addWarning("node '" + node.getFullyQualifiedName() + "' has a transition without a 'to'-attribute to specify its destinationNode");
+ }
+ else
+ {
Node to = ((NodeCollection)node.getParent()).findNode(toName);
- if (to==null) {
- addWarning("transition to='"+toName+"' on node '"+node.getFullyQualifiedName()+"' cannot be resolved");
- } else {
+ if (to == null)
+ {
+ addWarning("transition to='" + toName + "' on node '" + node.getFullyQualifiedName() + "' cannot be resolved");
+ }
+ else
+ {
to.addArrivingTransition(transition);
}
}
-
+
// read the actions
readActions(transitionElement, transition, Event.EVENTTYPE_TRANSITION);
-
+
readExceptionHandlers(transitionElement, transition);
-
+
return transition;
}
-
+
// action references are parsed in a second pass ////////////////////////////
- public void addUnresolvedActionReference(Element actionElement, Action action) {
- unresolvedActionReferences.add(new Object[]{actionElement, action});
+ public void addUnresolvedActionReference(Element actionElement, Action action)
+ {
+ unresolvedActionReferences.add(new Object[] { actionElement, action });
}
- public void resolveActionReferences() {
- for (Object[] unresolvedActionReference : unresolvedActionReferences) {
- Element actionElement = (Element) unresolvedActionReference[0];
- Action action = (Action) unresolvedActionReference[1];
+ public void resolveActionReferences()
+ {
+ for (Object[] unresolvedActionReference : unresolvedActionReferences)
+ {
+ Element actionElement = (Element)unresolvedActionReference[0];
+ Action action = (Action)unresolvedActionReference[1];
String referencedActionName = actionElement.attributeValue("ref-name");
Action referencedAction = processDefinition.getAction(referencedActionName);
- if (referencedAction==null) {
- addWarning("couldn't resolve action reference in "+actionElement.asXML());
+ if (referencedAction == null)
+ {
+ addWarning("couldn't resolve action reference in " + actionElement.asXML());
}
action.setReferencedAction(referencedAction);
}
}
// verify swimlane assignments in second pass ///////////////////////////////
- public void verifySwimlaneAssignments() {
+ public void verifySwimlaneAssignments()
+ {
TaskMgmtDefinition taskMgmtDefinition = processDefinition.getTaskMgmtDefinition();
- if ( (taskMgmtDefinition!=null)
- && (taskMgmtDefinition.getSwimlanes()!=null)
- ) {
- for (Swimlane swimlane : taskMgmtDefinition.getSwimlanes().values()) {
+ if ((taskMgmtDefinition != null) && (taskMgmtDefinition.getSwimlanes() != null))
+ {
+ for (Swimlane swimlane : taskMgmtDefinition.getSwimlanes().values())
+ {
Task startTask = taskMgmtDefinition.getStartTask();
- Swimlane startTaskSwimlane = (startTask!=null ? startTask.getSwimlane() : null);
-
- if ( (swimlane.getAssignmentDelegation()==null)
- && (swimlane!=startTaskSwimlane)
- ) {
- addWarning("swimlane '"+swimlane.getName()+"' does not have an assignment");
+ Swimlane startTaskSwimlane = (startTask != null ? startTask.getSwimlane() : null);
+
+ if ((swimlane.getAssignmentDelegation() == null) && (swimlane != startTaskSwimlane))
+ {
+ addWarning("swimlane '" + swimlane.getName() + "' does not have an assignment");
}
}
}
@@ -868,42 +1005,47 @@
// mail delegations /////////////////////////////////////////////////////////
- public Delegation createMailDelegation(String template,
- String actors,
- String to,
- String subject,
- String text) {
+ public Delegation createMailDelegation(String template, String actors, String to, String subject, String text)
+ {
StringBuffer config = new StringBuffer();
- if (template!=null) {
+ if (template != null)
+ {
config.append("<template>");
config.append(template);
config.append("</template>");
}
- if (actors!=null) {
+ if (actors != null)
+ {
config.append("<actors>");
config.append(actors);
config.append("</actors>");
}
- if (to!=null) {
+ if (to != null)
+ {
config.append("<to>");
config.append(to);
config.append("</to>");
}
- if (subject!=null) {
+ if (subject != null)
+ {
config.append("<subject>");
config.append(subject);
config.append("</subject>");
}
- if (text!=null) {
+ if (text != null)
+ {
config.append("<text>");
config.append(text);
config.append("</text>");
}
String mailClassName = Mail.class.getName();
- if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name")) {
+ if (JbpmConfiguration.Configs.hasObject("jbpm.mail.class.name"))
+ {
mailClassName = JbpmConfiguration.Configs.getString("jbpm.mail.class.name");
- } else if (JbpmConfiguration.Configs.hasObject("mail.class.name")) {
+ }
+ else if (JbpmConfiguration.Configs.hasObject("mail.class.name"))
+ {
mailClassName = JbpmConfiguration.Configs.getString("mail.class.name");
}
@@ -913,11 +1055,14 @@
return delegation;
}
- public String getProperty(String property, Element element) {
+ public String getProperty(String property, Element element)
+ {
String value = element.attributeValue(property);
- if (value==null) {
+ if (value == null)
+ {
Element propertyElement = element.element(property);
- if (propertyElement!=null) {
+ if (propertyElement != null)
+ {
value = propertyElement.getText();
}
}
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java 2009-02-12 07:33:12 UTC (rev 3847)
@@ -0,0 +1,45 @@
+package org.jbpm.jbpm1686;
+
+import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.jpdl.JpdlException;
+
+/**
+ * NPE when reading a process definition with a decision name which contains the "/" character
+ *
+ * https://jira.jboss.org/jira/browse/JBPM-1686
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 12-Feb-2009
+ */
+public class JBPM1686Test extends AbstractJbpmTestCase
+{
+ public void testProcessDefinition()
+ {
+ try
+ {
+ ProcessDefinition.parseXmlString(
+ "<process-definition>" +
+ " <start-state>" +
+ " <transition to='d/e' />" +
+ " </start-state>" +
+ " <decision name='d/e'>" +
+ " <transition name='one' to='a'>" +
+ " <condition>#{a == 1}</condition>" +
+ " </transition>" +
+ " <transition name='three' to='c'>" +
+ " <condition>#{a == 3}</condition>" +
+ " </transition>" +
+ " </decision>" +
+ " <state name='a' />" +
+ " <state name='c' />" +
+ "</process-definition>");
+
+ fail("JpdlException expected");
+ }
+ catch (JpdlException ex)
+ {
+ // expected
+ }
+ }
+}
Property changes on: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm1686/JBPM1686Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
17 years, 2 months
JBoss JBPM SVN: r3846 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/db.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-12 01:54:41 -0500 (Thu, 12 Feb 2009)
New Revision: 3846
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
Log:
JBPM-2036: save action before saving job, fixes failure on postgresql
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-02-12 02:19:59 UTC (rev 3845)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-02-12 06:54:41 UTC (rev 3846)
@@ -114,15 +114,15 @@
public void saveJob(Job job) {
try {
- session.saveOrUpdate(job);
if (job instanceof Timer) {
Timer timer = (Timer) job;
Action action = timer.getAction();
if (action != null && !session.contains(action)) {
- log.debug("cascading save from " + job + " to " + action);
+ log.debug("cascading save from " + timer + " to " + action);
session.save(action);
}
}
+ session.saveOrUpdate(job);
}
catch (HibernateException e) {
throw new JbpmException("could not save " + job, e);
17 years, 2 months
JBoss JBPM SVN: r3845 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/job/executor and 4 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-11 21:19:59 -0500 (Wed, 11 Feb 2009)
New Revision: 3845
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/DeleteProcessInstanceDbTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java
Log:
JBPM-2036: prevent SOSE when repeating timer signals the token
supply missing findJobsWithOverdueLockTime query for LockMonitorThread
have deleteProcessInstance delete tasks as it is supposed to
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -24,8 +24,6 @@
// $Id$
import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -45,7 +43,6 @@
import org.jbpm.taskmgmt.exe.TaskInstance;
public abstract class AbstractDbTestCase extends AbstractJbpmTestCase {
- private static final Log log = LogFactory.getLog(AbstractDbTestCase.class);
protected JbpmConfiguration jbpmConfiguration;
@@ -61,6 +58,8 @@
protected JobExecutor jobExecutor;
+ private static final Log log = LogFactory.getLog(AbstractDbTestCase.class);
+
protected void setUp() throws Exception {
super.setUp();
beginSessionTransaction();
@@ -185,31 +184,19 @@
}
protected void waitForJobs(long timeout) {
- // install a timer that will interrupt if it takes too long
- // if that happens, it will lead to an interrupted exception and the test will fail
- TimerTask interruptTask = new TimerTask() {
- Thread testThread = Thread.currentThread();
-
- public void run() {
- log.debug("test " + getName() + " took too long. going to interrupt...");
- testThread.interrupt();
+ long startTime = System.currentTimeMillis();
+ while (getNbrOfJobsAvailable() > 0) {
+ if (System.currentTimeMillis() - startTime > timeout) {
+ fail("test execution exceeded treshold of " + timeout + " milliseconds");
}
- };
- Timer timer = new Timer();
- timer.schedule(interruptTask, timeout);
-
- try {
- while (getNbrOfJobsAvailable() > 0) {
- log.debug("going to sleep for 200 millis, waiting for the job executor to process more jobs");
- Thread.sleep(200);
+ log.debug("waiting for the job executor to process more jobs");
+ try {
+ Thread.sleep(500);
}
+ catch (InterruptedException e) {
+ // keep going
+ }
}
- catch (InterruptedException e) {
- fail("test execution exceeded treshold of " + timeout + " milliseconds");
- }
- finally {
- timer.cancel();
- }
}
protected int getNbrOfJobsAvailable() {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -28,10 +28,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
-import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.jbpm.JbpmException;
@@ -96,7 +94,7 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't save process definition '" + processDefinition + "'", e);
+ throw new JbpmException("could not save " + processDefinition, e);
}
}
@@ -107,11 +105,12 @@
*/
public ProcessDefinition loadProcessDefinition(long processDefinitionId) {
try {
- return (ProcessDefinition) session.load(ProcessDefinition.class, new Long(processDefinitionId));
+ return (ProcessDefinition) session.load(ProcessDefinition.class,
+ new Long(processDefinitionId));
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't load process definition '" + processDefinitionId + "'", e);
+ throw new JbpmException("could not load process definition " + processDefinitionId, e);
}
}
@@ -126,7 +125,7 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't get process definition '" + processDefinitionId + "'", e);
+ throw new JbpmException("could not get process definition " + processDefinitionId, e);
}
}
@@ -134,40 +133,35 @@
* queries the database for a process definition with the given name and version.
*/
public ProcessDefinition findProcessDefinition(String name, int version) {
- ProcessDefinition processDefinition = null;
try {
- Query query = session.getNamedQuery("GraphSession.findProcessDefinitionByNameAndVersion");
- query.setString("name", name);
- query.setInteger("version", version);
- processDefinition = (ProcessDefinition) query.uniqueResult();
+ return (ProcessDefinition) session.getNamedQuery("GraphSession.findProcessDefinitionByNameAndVersion")
+ .setString("name", name)
+ .setInteger("version", version)
+ .uniqueResult();
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't get process definition with name '"
+ throw new JbpmException("could not find process definition '"
+ name
- + "' and version '"
- + version
- + "'", e);
+ + "' at version "
+ + version, e);
}
- return processDefinition;
}
/**
* queries the database for the latest version of a process definition with the given name.
*/
public ProcessDefinition findLatestProcessDefinition(String name) {
- ProcessDefinition processDefinition = null;
try {
- Query query = session.getNamedQuery("GraphSession.findLatestProcessDefinitionQuery");
- query.setString("name", name);
- query.setMaxResults(1);
- processDefinition = (ProcessDefinition) query.uniqueResult();
+ return (ProcessDefinition) session.getNamedQuery("GraphSession.findLatestProcessDefinitionQuery")
+ .setString("name", name)
+ .setMaxResults(1)
+ .uniqueResult();
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't find process definition '" + name + "'", e);
+ throw new JbpmException("could not find process definition '" + name + "'", e);
}
- return processDefinition;
}
/**
@@ -176,11 +170,10 @@
*/
public List<ProcessDefinition> findLatestProcessDefinitions() {
try {
- Query query = session.getNamedQuery("GraphSession.findLatestProcessDefinitions");
- List<Object[]> tuples = CollectionUtil.checkList(query.list(), Object[].class);
-
+ List<?> tuples = session.getNamedQuery("GraphSession.findLatestProcessDefinitions")
+ .list();
List<ProcessDefinition> result = new ArrayList<ProcessDefinition>();
- for (Object[] tuple : tuples) {
+ for (Object[] tuple : CollectionUtil.checkList(tuples, Object[].class)) {
String name = (String) tuple[0];
Integer version = (Integer) tuple[1];
result.add(findProcessDefinition(name, version));
@@ -189,14 +182,15 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't find latest versions of process definitions", e);
+ throw new JbpmException("could not find latest versions of process definitions", e);
}
}
public List<ProcessDefinition> findProcessDefinitions(Collection<Long> processDefinitionIds) {
- Criteria criteria = session.createCriteria(ProcessDefinition.class)
- .add(Restrictions.in("id", processDefinitionIds));
- return CollectionUtil.checkList(criteria.list(), ProcessDefinition.class);
+ List<?> processDefinitions = session.createCriteria(ProcessDefinition.class)
+ .add(Restrictions.in("id", processDefinitionIds))
+ .list();
+ return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
}
/**
@@ -205,12 +199,13 @@
*/
public List<ProcessDefinition> findAllProcessDefinitions() {
try {
- Query query = session.getNamedQuery("GraphSession.findAllProcessDefinitions");
- return CollectionUtil.checkList(query.list(), ProcessDefinition.class);
+ List<?> processDefinitions = session.getNamedQuery("GraphSession.findAllProcessDefinitions")
+ .list();
+ return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't find all process definitions", e);
+ throw new JbpmException("could not find all process definitions", e);
}
}
@@ -220,13 +215,14 @@
*/
public List<ProcessDefinition> findAllProcessDefinitionVersions(String name) {
try {
- Query query = session.getNamedQuery("GraphSession.findAllProcessDefinitionVersions");
- query.setString("name", name);
- return CollectionUtil.checkList(query.list(), ProcessDefinition.class);
+ List<?> processDefinitions = session.getNamedQuery("GraphSession.findAllProcessDefinitionVersions")
+ .setString("name", name)
+ .list();
+ return CollectionUtil.checkList(processDefinitions, ProcessDefinition.class);
}
catch (HibernateException e) {
log.error(e);
- throw new JbpmException("couldn't find all versions of process definition '" + name + "'", e);
+ throw new JbpmException("could not find all versions of process definition '" + name + "'", e);
}
}
@@ -236,12 +232,22 @@
public void deleteProcessDefinition(ProcessDefinition processDefinition) {
if (processDefinition == null) {
- throw new JbpmException("processDefinition is null");
+ throw new IllegalArgumentException("processDefinition cannot be null");
}
+
try {
// delete all the process instances of this definition
- for (ProcessInstance processInstance; ((processInstance = findNextProcessInstance(processDefinition)) != null);) {
- deleteProcessInstance(processInstance);
+ List<?> processInstanceIds = session.getNamedQuery("GraphSession.findAllProcessInstanceIdsForDefinition")
+ .setLong("processDefinitionId", processDefinition.getId())
+ .list();
+ for (Long processInstanceId : CollectionUtil.checkList(processInstanceIds, Long.class)) {
+ ProcessInstance processInstance = getProcessInstance(processInstanceId);
+ if (processInstance != null) {
+ deleteProcessInstance(processInstance);
+ }
+ else {
+ log.debug("process instance " + processInstanceId + " has been deleted already");
+ }
}
List<ProcessState> referencingProcessStates = findReferencingProcessStates(processDefinition);
@@ -254,25 +260,17 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't delete process definition '"
- + processDefinition.getId()
- + "'", e);
+ throw new JbpmException("could not delete " + processDefinition, e);
}
}
- protected ProcessInstance findNextProcessInstance(ProcessDefinition processDefinition) {
- return (ProcessInstance) session.createCriteria(ProcessInstance.class)
- .add(Restrictions.eq("processDefinition", processDefinition))
- .setMaxResults(1)
- .uniqueResult();
+ List<ProcessState> findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
+ List<?> processStates = session.getNamedQuery("GraphSession.findReferencingProcessStates")
+ .setEntity("subProcessDefinition", subProcessDefinition)
+ .list();
+ return CollectionUtil.checkList(processStates, ProcessState.class);
}
- protected List<ProcessState> findReferencingProcessStates(ProcessDefinition subProcessDefinition) {
- Query query = session.getNamedQuery("GraphSession.findReferencingProcessStates");
- query.setEntity("subProcessDefinition", subProcessDefinition);
- return CollectionUtil.checkList(query.list(), ProcessState.class);
- }
-
// process instances ////////////////////////////////////////////////////////
/**
@@ -292,13 +290,11 @@
*/
public ProcessInstance loadProcessInstance(long processInstanceId) {
try {
- ProcessInstance processInstance = (ProcessInstance) session.load(ProcessInstance.class, new Long(
- processInstanceId));
- return processInstance;
+ return (ProcessInstance) session.load(ProcessInstance.class, new Long(processInstanceId));
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't load process instance '" + processInstanceId + "'", e);
+ throw new JbpmException("could not load process instance " + processInstanceId, e);
}
}
@@ -308,13 +304,11 @@
*/
public ProcessInstance getProcessInstance(long processInstanceId) {
try {
- ProcessInstance processInstance = (ProcessInstance) session.get(ProcessInstance.class, new Long(
- processInstanceId));
- return processInstance;
+ return (ProcessInstance) session.get(ProcessInstance.class, new Long(processInstanceId));
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't get process instance '" + processInstanceId + "'", e);
+ throw new JbpmException("could not get process instance " + processInstanceId, e);
}
}
@@ -326,12 +320,11 @@
*/
public Token loadToken(long tokenId) {
try {
- Token token = (Token) session.load(Token.class, new Long(tokenId));
- return token;
+ return (Token) session.load(Token.class, new Long(tokenId));
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't load token '" + tokenId + "'", e);
+ throw new JbpmException("could not load token " + tokenId, e);
}
}
@@ -342,12 +335,11 @@
*/
public Token getToken(long tokenId) {
try {
- Token token = (Token) session.get(Token.class, new Long(tokenId));
- return token;
+ return (Token) session.get(Token.class, new Long(tokenId));
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't get token '" + tokenId + "'", e);
+ throw new JbpmException("could not get token " + tokenId, e);
}
}
@@ -355,7 +347,13 @@
* locks a process instance in the database.
*/
public void lockProcessInstance(long processInstanceId) {
- lockProcessInstance(loadProcessInstance(processInstanceId));
+ try {
+ session.load(ProcessInstance.class, processInstanceId, LockMode.UPGRADE);
+ }
+ catch (Exception e) {
+ handle(e);
+ throw new JbpmException("could not lock process instance " + processInstanceId, e);
+ }
}
/**
@@ -367,7 +365,7 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't lock process instance '" + processInstance.getId() + "'", e);
+ throw new JbpmException("could not lock " + processInstance, e);
}
}
@@ -377,15 +375,15 @@
*/
public List<ProcessInstance> findProcessInstances(long processDefinitionId) {
try {
- Query query = session.getNamedQuery("GraphSession.findAllProcessInstancesForADefinition");
- query.setLong("processDefinitionId", processDefinitionId);
- return CollectionUtil.checkList(query.list(), ProcessInstance.class);
+ List<?> processInstances = session.getNamedQuery("GraphSession.findAllProcessInstancesForDefinition")
+ .setLong("processDefinitionId", processDefinitionId)
+ .list();
+ return CollectionUtil.checkList(processInstances, ProcessInstance.class);
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't load process instances for process definition '"
- + processDefinitionId
- + "'", e);
+ throw new JbpmException("could not find process instances for process definition "
+ + processDefinitionId, e);
}
}
@@ -399,89 +397,82 @@
public void deleteProcessInstance(ProcessInstance processInstance, boolean includeTasks,
boolean includeJobs) {
- if (processInstance == null)
- throw new JbpmException("processInstance is null in JbpmSession.deleteProcessInstance()");
- log.debug("deleting process instance " + processInstance.getId());
+ if (processInstance == null) {
+ throw new IllegalArgumentException("processInstance cannot be null");
+ }
try {
- // jobs
+ // delete outstanding jobs
if (includeJobs) {
- log.debug("deleting jobs for process instance " + processInstance.getId());
- Query query = session.getNamedQuery("GraphSession.deleteJobsForProcessInstance");
- query.setEntity("processInstance", processInstance);
- query.executeUpdate();
+ log.debug("deleting jobs for " + processInstance);
+ int entityCount = session.getNamedQuery("GraphSession.deleteJobsForProcessInstance")
+ .setEntity("processInstance", processInstance)
+ .executeUpdate();
+ log.debug("deleted " + entityCount + " jobs for " + processInstance);
}
- // tasks
- if (includeTasks) {
- Query query = session.getNamedQuery("GraphSession.findTaskInstanceIdsForProcessInstance");
- query.setEntity("processInstance", processInstance);
- List<Long> taskInstanceIds = CollectionUtil.checkList(query.list(), Long.class);
-
- if (!taskInstanceIds.isEmpty()) {
- log.debug("deleting tasks "
- + taskInstanceIds
- + " for process instance "
- + processInstance.getId());
- query = session.getNamedQuery("GraphSession.deleteTaskInstancesById");
- query.setParameterList("taskInstanceIds", taskInstanceIds);
- }
- }
-
- // delete the logs
- log.debug("deleting logs for process instance " + processInstance.getId());
+ // delete logs
+ log.debug("deleting logs for " + processInstance);
deleteLogs(processInstance);
- // delete the tokens and subprocess instances
- log.debug("deleting subprocesses for process instance " + processInstance.getId());
- deleteSubProcesses(processInstance.getRootToken());
-
- // null out the parent process token
+ // detach from parent process token
Token superProcessToken = processInstance.getSuperProcessToken();
if (superProcessToken != null) {
- log.debug("nulling property subProcessInstance in superProcessToken "
- + superProcessToken.getId()
- + " which is referencing the process instance "
- + processInstance.getId()
- + " which is being deleted");
+ log.debug("detaching "
+ + processInstance
+ + " from super process token "
+ + superProcessToken.getId());
+ processInstance.setSuperProcessToken(null);
superProcessToken.setSubProcessInstance(null);
}
- // add the process instance
- log.debug("hibernate session delete for process instance " + processInstance.getId());
+ // delete tokens and subprocess instances
+ log.debug("deleting subprocesses for " + processInstance);
+ deleteSubProcesses(processInstance);
+
+ // delete tasks (TaskLogs reference tasks, so tasks must be deleted after logs)
+ if (includeTasks) {
+ log.debug("deleting tasks for " + processInstance);
+ List<?> tasks = session.getNamedQuery("GraphSession.findTaskInstancesForProcessInstance")
+ .setEntity("processInstance", processInstance)
+ .list();
+ for (Object task : tasks) {
+ session.delete(task);
+ }
+ }
+
+ // delete the process instance
+ log.debug("deleting " + processInstance);
session.delete(processInstance);
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't delete process instance '" + processInstance.getId() + "'",
- e);
+ throw new JbpmException("could not delete " + processInstance, e);
}
}
void deleteLogs(ProcessInstance processInstance) {
- Query query = session.getNamedQuery("GraphSession.findLogsForProcessInstance");
- query.setEntity("processInstance", processInstance);
- List<ProcessLog> logs = CollectionUtil.checkList(query.list(), ProcessLog.class);
- for (ProcessLog processLog : logs) {
+ List<?> logs = session.getNamedQuery("GraphSession.findLogsForProcessInstance")
+ .setEntity("processInstance", processInstance)
+ .list();
+ for (ProcessLog processLog : CollectionUtil.checkList(logs, ProcessLog.class)) {
session.delete(processLog);
}
}
- void deleteSubProcesses(Token token) {
- if (token != null) {
- Query query = session.getNamedQuery("GraphSession.findSubProcessInstances");
- query.setEntity("processInstance", token.getProcessInstance());
- List<ProcessInstance> subProcessInstances = CollectionUtil.checkList(query.list(), ProcessInstance.class);
+ void deleteSubProcesses(ProcessInstance processInstance) {
+ if (processInstance != null) {
+ List<?> subProcessInstances = session.getNamedQuery("GraphSession.findSubProcessInstances")
+ .setEntity("processInstance", processInstance)
+ .list();
if (subProcessInstances.isEmpty()) {
- log.debug("no subprocesses to delete for token " + token.getId());
+ log.debug("no subprocesses to delete for " + processInstance);
return;
}
- for (ProcessInstance subProcessInstance : subProcessInstances) {
- log.debug("deleting sub process " + subProcessInstance.getId());
- subProcessInstance.setSuperProcessToken(null);
- token.setSubProcessInstance(null);
+ for (ProcessInstance subProcessInstance : CollectionUtil.checkList(subProcessInstances, ProcessInstance.class)) {
+ log.debug("preparing to delete sub process instance " + subProcessInstance.getId());
deleteProcessInstance(subProcessInstance);
}
}
@@ -545,19 +536,19 @@
}
}
- public List<AverageNodeTimeEntry> calculateAverageTimeByNode(final long processDefinitionId,
- final long minumumDurationMillis) {
+ public List<AverageNodeTimeEntry> calculateAverageTimeByNode(long processDefinitionId,
+ long minumumDurationMillis) {
try {
- Query query = session.getNamedQuery("GraphSession.calculateAverageTimeByNode");
- query.setLong("processDefinitionId", processDefinitionId);
- query.setDouble("minimumDuration", minumumDurationMillis);
- List<Object[]> listResults = CollectionUtil.checkList(query.list(), Object[].class);
+ List<?> tuples = session.getNamedQuery("GraphSession.calculateAverageTimeByNode")
+ .setLong("processDefinitionId", processDefinitionId)
+ .setDouble("minimumDuration", minumumDurationMillis)
+ .list();
List<AverageNodeTimeEntry> results;
- if (!listResults.isEmpty()) {
+ if (!tuples.isEmpty()) {
results = new ArrayList<AverageNodeTimeEntry>();
- for (Object[] values : listResults) {
+ for (Object[] values : CollectionUtil.checkList(tuples, Object[].class)) {
AverageNodeTimeEntry averageNodeTimeEntry = new AverageNodeTimeEntry();
averageNodeTimeEntry.setNodeId(((Number) values[0]).longValue());
averageNodeTimeEntry.setNodeName((String) values[1]);
@@ -576,63 +567,48 @@
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't load process instances for process definition '"
- + processDefinitionId
- + "'", e);
+ throw new JbpmException("could not calculate average time by node for process definition "
+ + processDefinitionId, e);
}
}
public List<Node> findActiveNodesByProcessInstance(ProcessInstance processInstance) {
try {
- Query query = session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance");
- query.setEntity("processInstance", processInstance);
- return CollectionUtil.checkList(query.list(), Node.class);
+ List<?> nodes = session.getNamedQuery("GraphSession.findActiveNodesByProcessInstance")
+ .setEntity("processInstance", processInstance)
+ .list();
+ return CollectionUtil.checkList(nodes, Node.class);
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't active nodes for process instance '"
- + processInstance
- + "'", e);
+ throw new JbpmException("could not find active nodes for " + processInstance, e);
}
}
public ProcessInstance getProcessInstance(ProcessDefinition processDefinition, String key) {
- ProcessInstance processInstance = null;
try {
- Query query = session.getNamedQuery("GraphSession.findProcessInstanceByKey");
- query.setEntity("processDefinition", processDefinition);
- query.setString("key", key);
- processInstance = (ProcessInstance) query.uniqueResult();
+ return (ProcessInstance) session.getNamedQuery("GraphSession.findProcessInstanceByKey")
+ .setEntity("processDefinition", processDefinition)
+ .setString("key", key)
+ .uniqueResult();
}
catch (Exception e) {
handle(e);
- throw new JbpmException("couldn't get process instance with key '" + key + "'", e);
+ throw new JbpmException("could not get process instance with key '" + key + "'", e);
}
- return processInstance;
}
public ProcessInstance loadProcessInstance(ProcessDefinition processDefinition, String key) {
- ProcessInstance processInstance = null;
- try {
- Query query = session.getNamedQuery("GraphSession.findProcessInstanceByKey");
- query.setEntity("processDefinition", processDefinition);
- query.setString("key", key);
- processInstance = (ProcessInstance) query.uniqueResult();
- if (processInstance == null) {
- throw new JbpmException("no process instance was found with key " + key);
- }
+ ProcessInstance processInstance = getProcessInstance(processDefinition, key);
+ if (processInstance == null) {
+ throw new JbpmException("no process instance was found with key '" + key + "'");
}
- catch (Exception e) {
- handle(e);
- throw new JbpmException("couldn't load process instance with key '" + key + "'", e);
- }
return processInstance;
}
private void handle(Exception e) {
log.error(e);
- if (jbpmSession != null)
- jbpmSession.handleException();
+ if (jbpmSession != null) jbpmSession.handleException();
}
private static final Log log = LogFactory.getLog(GraphSession.class);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -21,13 +21,14 @@
*/
package org.jbpm.db;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
@@ -48,187 +49,227 @@
}
public Job getFirstAcquirableJob(String lockOwner) {
- Job job = null;
try {
- Query query = session.getNamedQuery("JobSession.getFirstAcquirableJob");
- query.setString("lockOwner", lockOwner);
- query.setTimestamp("now", new Date());
- query.setMaxResults(1);
- job = (Job) query.uniqueResult();
-
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't get acquirable jobs", e);
+ return (Job) session.getNamedQuery("JobSession.getFirstAcquirableJob")
+ .setString("lockOwner", lockOwner)
+ .setTimestamp("now", new Date())
+ .setMaxResults(1)
+ .uniqueResult();
}
- return job;
+ catch (HibernateException e) {
+ throw new JbpmException("could not get first acquirable job", e);
+ }
}
public List<Job> findExclusiveJobs(String lockOwner, ProcessInstance processInstance) {
try {
- Query query = session.getNamedQuery("JobSession.findExclusiveJobs");
- query.setString("lockOwner", lockOwner);
- query.setTimestamp("now", new Date());
- query.setParameter("processInstance", processInstance);
- return CollectionUtil.checkList(query.list(), Job.class);
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't find exclusive jobs for thread '"+lockOwner+"' and process instance '"+processInstance+"'", e);
+ List<?> jobs = session.getNamedQuery("JobSession.findExclusiveJobs")
+ .setString("lockOwner", lockOwner)
+ .setTimestamp("now", new Date())
+ .setParameter("processInstance", processInstance)
+ .list();
+ return CollectionUtil.checkList(jobs, Job.class);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not find exclusive jobs owned by '"
+ + lockOwner
+ + "' for "
+ + processInstance, e);
+ }
}
-
- /**
- * find all jobs
- */
+
public List<Job> findJobsByToken(Token token) {
try {
- Query query = session.getNamedQuery("JobSession.findJobsByToken");
- query.setParameter("token", token);
- return CollectionUtil.checkList(query.list(), Job.class);
- } catch (Exception e) {
- throw new JbpmException("couldn't find jobs for token '"+token+"'", e);
+ List<?> jobs = session.getNamedQuery("JobSession.findJobsByToken")
+ .setParameter("token", token)
+ .list();
+ return CollectionUtil.checkList(jobs, Job.class);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not find jobs for " + token, e);
+ }
}
- public Job getFirstDueJob(String lockOwner, Collection<Long> jobIdsToIgnore) {
- Job job = null;
+ public Job getFirstDueJob(String lockOwner, Collection<Long> monitoredJobs) {
try {
- Query query = null;
- if ( (jobIdsToIgnore==null)
- || (jobIdsToIgnore.isEmpty() )
- ) {
+ Query query;
+ if (monitoredJobs == null || monitoredJobs.isEmpty()) {
query = session.getNamedQuery("JobSession.getFirstDueJob");
- query.setString("lockOwner", lockOwner);
-
- } else {
- query = session.getNamedQuery("JobSession.getFirstDueJobExlcMonitoredJobs");
- query.setString("lockOwner", lockOwner);
- query.setParameterList("jobIdsToIgnore", jobIdsToIgnore);
-
}
- query.setMaxResults(1);
- job = (Job) query.uniqueResult();
-
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't get acquirable jobs", e);
+ else {
+ query = session.getNamedQuery("JobSession.getFirstDueJobExcludingMonitoredJobs");
+ query.setParameterList("monitoredJobIds", monitoredJobs);
+ }
+ return (Job) query.setString("lockOwner", lockOwner)
+ .setMaxResults(1)
+ .uniqueResult();
}
- return job;
+ catch (HibernateException e) {
+ throw new JbpmException("could not get first due job owned by '"
+ + lockOwner
+ + "' ignoring jobs "
+ + monitoredJobs, e);
+ }
}
public void saveJob(Job job) {
- session.saveOrUpdate(job);
- if (job instanceof Timer) {
- Timer timer = (Timer) job;
- Action action = timer.getAction();
- if (action != null && !session.contains(action)) {
- log.debug("cascading timer save to action");
- session.save(action);
+ try {
+ session.saveOrUpdate(job);
+ if (job instanceof Timer) {
+ Timer timer = (Timer) job;
+ Action action = timer.getAction();
+ if (action != null && !session.contains(action)) {
+ log.debug("cascading save from " + job + " to " + action);
+ session.save(action);
+ }
}
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not save " + job, e);
+ }
}
public void deleteJob(Job job) {
- session.delete(job);
+ try {
+ session.delete(job);
+ log.debug("deleted " + job);
+ }
+ catch (HibernateException e) {
+ throw new JbpmException("could not delete " + job, e);
+ }
}
public Job loadJob(long jobId) {
try {
return (Job) session.load(Job.class, new Long(jobId));
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't load job '"+jobId+"'", e);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not load job " + jobId, e);
+ }
}
public Timer loadTimer(long timerId) {
try {
return (Timer) session.load(Timer.class, new Long(timerId));
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't load timer " + timerId, e);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not load timer " + timerId, e);
+ }
}
public List<Job> loadJobs(long... jobIds) {
- Criteria criteria = session.createCriteria(Job.class)
- .add(Restrictions.in("id", toObjectArray(jobIds)));
- return CollectionUtil.checkList(criteria.list(), Job.class);
+ try {
+ List<?> jobs = session.createCriteria(Job.class)
+ .add(Restrictions.in("id", toObjectArray(jobIds)))
+ .list();
+ return CollectionUtil.checkList(jobs, Job.class);
+ }
+ catch (HibernateException e) {
+ throw new JbpmException("could not load jobs " + Arrays.toString(jobIds), e);
+ }
}
+ private static Long[] toObjectArray(long[] primitives) {
+ final int length = primitives.length;
+ Long[] objects = new Long[length];
+ for (int i = 0; i < length; i++) {
+ objects[i] = primitives[i];
+ }
+ return objects;
+ }
+
public Job getJob(long jobId) {
try {
return (Job) session.get(Job.class, new Long(jobId));
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't get job '"+jobId+"'", e);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not get job " + jobId, e);
+ }
}
public void suspendJobs(Token token) {
try {
- Query query = session.getNamedQuery("JobSession.suspendJobs");
- query.setParameter("token", token);
- query.executeUpdate();
-
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't suspend jobs for "+token, e);
+ session.getNamedQuery("JobSession.suspendJobs").setParameter("token", token).executeUpdate();
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not suspend jobs for " + token, e);
+ }
}
public void resumeJobs(Token token) {
try {
- Query query = session.getNamedQuery("JobSession.resumeJobs");
- query.setParameter("token", token);
- query.executeUpdate();
-
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't resume jobs for "+token, e);
+ session.getNamedQuery("JobSession.resumeJobs").setParameter("token", token).executeUpdate();
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not resume jobs for " + token, e);
+ }
}
public void deleteTimersByName(String name, Token token) {
try {
- log.debug("deleting timers by name '" + name + "' for " + token);
- Query query = session.getNamedQuery("JobSession.deleteTimersByName");
- query.setString("name", name);
- query.setParameter("token", token);
- int entityCount = query.executeUpdate();
- log.debug(entityCount + " timers by name '" + name + "' for " + token + " were deleted");
- } catch (Exception e) {
- log.error(e);
- throw new JbpmException("couldn't delete timers by name '" + name + "' for " + token, e);
+ // delete unowned timers
+ int entityCount = session.getNamedQuery("JobSession.deleteTimersByName")
+ .setString("name", name)
+ .setParameter("token", token)
+ .executeUpdate();
+ log.debug("deleted " + entityCount + " timers by name '" + name + "' for " + token);
+
+ // prevent further repetitions
+ List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersByName")
+ .setString("name", name)
+ .setParameter("token", token)
+ .list();
+ preventFurtherRepetitions(timers);
}
+ catch (HibernateException e) {
+ throw new JbpmException("could not delete timers by name '" + name + "' for " + token, e);
+ }
}
public void deleteJobsForProcessInstance(ProcessInstance processInstance) {
- log.debug("deleting timers for "+processInstance);
- Query query = session.getNamedQuery("JobSession.deleteTimersForProcessInstance");
- query.setParameter("processInstance", processInstance);
- int entityCount = query.executeUpdate();
- log.debug(entityCount+" remaining timers for "+processInstance+" were deleted");
+ try {
+ // delete node execution jobs
+ int entityCount = session.getNamedQuery("JobSession.deleteExecuteNodeJobsForProcessInstance")
+ .setParameter("processInstance", processInstance)
+ .executeUpdate();
+ log.debug("deleted " + entityCount + " execute-node-jobs for " + processInstance);
- log.debug("deleting execute-node-jobs for "+processInstance);
- query = session.getNamedQuery("JobSession.deleteExecuteNodeJobsForProcessInstance");
- query.setParameter("processInstance", processInstance);
- entityCount = query.executeUpdate();
- log.debug(entityCount+" remaining execute-node-jobs for "+processInstance+" were deleted");
+ // delete unowned timers
+ entityCount = session.getNamedQuery("JobSession.deleteTimersForProcessInstance")
+ .setParameter("processInstance", processInstance)
+ .executeUpdate();
+ log.debug("deleted " + entityCount + " timers for " + processInstance);
+
+ // prevent further repetitions
+ List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersForProcessInstance")
+ .setParameter("processInstance", processInstance)
+ .list();
+ preventFurtherRepetitions(timers);
+ }
+ catch (HibernateException e) {
+ throw new JbpmException("could not delete jobs for " + processInstance, e);
+ }
}
- public List<Job> findJobsWithOverdueLockTime(Date treshold) {
- Query query = session.getNamedQuery("JobSession.findJobsWithOverdueLockTime");
- query.setDate("now", treshold);
- return CollectionUtil.checkList(query.list(), Job.class);
+ private static void preventFurtherRepetitions(List<?> timers) {
+ if (!timers.isEmpty()) {
+ for (Timer timer : CollectionUtil.checkList(timers, Timer.class)) {
+ timer.setRepeat(null);
+ }
+ log.debug("prevented further repetitions of " + timers);
+ }
}
- private static Long[] toObjectArray(long[] array) {
- final int length = array.length;
- Long[] objects = new Long[length];
- for (int i = 0; i < length; i++) {
- objects[i] = array[i];
+ public List<Job> findJobsWithOverdueLockTime(Date threshold) {
+ try {
+ List<?> jobs = session.getNamedQuery("JobSession.findJobsWithOverdueLockTime")
+ .setDate("threshold", threshold)
+ .list();
+ return CollectionUtil.checkList(jobs, Job.class);
}
- return objects;
+ catch (HibernateException e) {
+ throw new JbpmException("could not find jobs with lock time over " + threshold, e);
+ }
}
private static Log log = LogFactory.getLog(JobSession.class);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/executor/LockMonitorThread.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -20,7 +20,7 @@
int maxLockTime;
int lockBufferTime;
- boolean isActive = true;
+ volatile boolean isActive = true;
public LockMonitorThread(JbpmConfiguration jbpmConfiguration, int lockMonitorInterval,
int maxLockTime, int lockBufferTime) {
@@ -67,9 +67,9 @@
List<Job> overdueJobs = null;
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try {
- Date treshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
+ Date threshold = new Date(System.currentTimeMillis() - maxLockTime - lockBufferTime);
JobSession jobSession = jbpmContext.getJobSession();
- overdueJobs = jobSession.findJobsWithOverdueLockTime(treshold);
+ overdueJobs = jobSession.findJobsWithOverdueLockTime(threshold);
for (Job job : overdueJobs) {
log.debug("unlocking " + job + " owned by thread " + job.getLockOwner());
job.setLockOwner(null);
Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-02-12 02:19:59 UTC (rev 3845)
@@ -1,8 +1,7 @@
<?xml version="1.0"?>
-
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
@@ -15,14 +14,14 @@
from org.jbpm.graph.def.ProcessDefinition pd
]]>
</query>
-
+
<query name="GraphSession.NumberOfDeployedProcesses">
<![CDATA[
select count (distinct pd.name)
from org.jbpm.graph.def.ProcessDefinition pd
]]>
</query>
-
+
<query name="GraphSession.NumberOfActiveProcessInstances">
<![CDATA[
select count (pi.id)
@@ -30,7 +29,7 @@
where pi.end is null
]]>
</query>
-
+
<query name="GraphSession.findLatestProcessDefinitionQuery">
<![CDATA[
select pd
@@ -39,7 +38,7 @@
order by pd.version desc
]]>
</query>
-
+
<query name="GraphSession.findProcessDefinitionByNameAndVersion">
<![CDATA[
select pd
@@ -48,7 +47,7 @@
and pd.version = :version
]]>
</query>
-
+
<query name="GraphSession.findAllProcessDefinitions">
<![CDATA[
select pd
@@ -83,8 +82,8 @@
)
-->
</query>
-
- <query name="GraphSession.findAllProcessInstancesForADefinition">
+
+ <query name="GraphSession.findAllProcessInstancesForDefinition">
<![CDATA[
select pi
from org.jbpm.graph.exe.ProcessInstance as pi
@@ -92,7 +91,15 @@
order by pi.start desc
]]>
</query>
-
+
+ <query name="GraphSession.findAllProcessInstanceIdsForDefinition">
+ <![CDATA[
+ select pi.id
+ from org.jbpm.graph.exe.ProcessInstance as pi
+ where pi.processDefinition.id = :processDefinitionId
+ ]]>
+ </query>
+
<query name="GraphSession.findReferencingProcessStates">
<![CDATA[
select ps
@@ -139,7 +146,7 @@
order by pi.start desc
]]>
</query>
-
+
<query name="GraphSession.findSubProcessInstances">
<![CDATA[
select pi
@@ -149,7 +156,7 @@
order by pi.start desc
]]>
</query>
-
+
<query name="GraphSession.findTokensForProcessInNode">
<![CDATA[
select token
@@ -168,7 +175,7 @@
and token.node.name = :nodeName
]]>
</query>
-
+
<query name="GraphSession.findProcessInstanceByKey">
<![CDATA[
select pi
@@ -177,7 +184,7 @@
and pi.key = :key
]]>
</query>
-
+
<query name="GraphSession.findLogsForProcessInstance">
<![CDATA[
select pl
@@ -185,23 +192,14 @@
where pl.token.processInstance = :processInstance
]]>
</query>
-
-
- <query name="GraphSession.findTaskInstanceIdsForProcessInstance">
+
+ <query name="GraphSession.findTaskInstancesForProcessInstance">
<![CDATA[
- select ti.id
+ select ti
from org.jbpm.taskmgmt.exe.TaskInstance ti
- where ti.taskMgmtInstance.processInstance = :processInstance
+ where ti.processInstance = :processInstance
]]>
</query>
-
- <query name="GraphSession.deleteTaskInstancesById">
- <![CDATA[
- delete
- from org.jbpm.taskmgmt.exe.TaskInstance ti
- where ti.id in (:taskInstanceIds)
- ]]>
- </query>
<query name="GraphSession.deleteJobsForProcessInstance">
<![CDATA[
@@ -247,7 +245,7 @@
from org.jbpm.taskmgmt.def.Swimlane as swimlane
]]>
</query>
-
+
<!-- Logging -->
<!-- ########################### -->
@@ -259,7 +257,7 @@
order by pl.index
]]>
</query>
-
+
<!-- JobSession -->
<!-- ########################### -->
@@ -300,12 +298,12 @@
]]>
</query>
- <query name="JobSession.getFirstDueJobExlcMonitoredJobs">
+ <query name="JobSession.getFirstDueJobExcludingMonitoredJobs">
<![CDATA[
select job
from org.jbpm.job.Job as job
where ( (job.lockOwner is null) or (job.lockOwner = :lockOwner) )
- and job.id not in ( :jobIdsToIgnore )
+ and job.id not in ( :monitoredJobIds )
and job.retries > 0
and job.isSuspended = false
order by job.dueDate asc
@@ -333,20 +331,37 @@
delete from org.jbpm.job.Timer timer
where timer.token = :token
and timer.name = :name
- and (timer.lockOwner is null
- or timer.repeat is not null)
+ and timer.lockOwner is null
]]>
</query>
+ <query name="JobSession.findRepeatingTimersByName">
+ <![CDATA[
+ select timer
+ from org.jbpm.job.Timer timer
+ where timer.token = :token
+ and timer.name = :name
+ and timer.repeat is not null
+ ]]>
+ </query>
+
<query name="JobSession.deleteTimersForProcessInstance">
<![CDATA[
delete from org.jbpm.job.Timer timer
where timer.processInstance = :processInstance
- and (timer.lockOwner is null
- or timer.repeat is not null)
+ and timer.lockOwner is null
]]>
</query>
+ <query name="JobSession.findRepeatingTimersForProcessInstance">
+ <![CDATA[
+ select timer
+ from org.jbpm.job.Timer timer
+ where timer.processInstance = :processInstance
+ and timer.repeat is not null
+ ]]>
+ </query>
+
<query name="JobSession.deleteExecuteNodeJobsForProcessInstance">
<![CDATA[
delete from org.jbpm.job.ExecuteNodeJob job
@@ -354,7 +369,7 @@
and job.lockOwner is null
]]>
</query>
-
+
<query name="JobSession.findJobsByToken">
<![CDATA[
select job
@@ -363,10 +378,17 @@
]]>
</query>
+ <query name="JobSession.findJobsWithOverdueLockTime">
+ <![CDATA[
+ select job
+ from org.jbpm.job.Job as job
+ where job.lockTime > :threshold
+ ]]>
+ </query>
+
<!-- related to Tasks -->
<!-- ########################### -->
-
<query name="TaskMgmtSession.findTaskInstancesByActorId">
<![CDATA[
select ti
@@ -438,8 +460,7 @@
where ti.id in ( :taskInstanceIds )
]]>
</query>
-
-
+
<query name="TaskMgmtSession.findOpenTasksOfProcessInstance">
<![CDATA[
select ti
@@ -457,5 +478,5 @@
and task.taskNode.id = :taskNodeId
]]>
</query>
-
+
</hibernate-mapping>
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/DeleteProcessInstanceDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/DeleteProcessInstanceDbTest.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/DeleteProcessInstanceDbTest.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -15,18 +15,15 @@
+ " <state name='buy cheese' />"
+ "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
+ newTransaction();
try {
- newTransaction();
-
ProcessInstance processInstance = jbpmContext.newProcessInstance("make fondue");
processInstance.signal();
processInstance = saveAndReload(processInstance);
-
jbpmContext.getGraphSession().deleteProcessInstance(processInstance);
newTransaction();
-
assertDeleted(processInstance);
}
finally {
@@ -44,18 +41,15 @@
+ " </task-node>"
+ "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
+ newTransaction();
try {
- newTransaction();
-
ProcessInstance processInstance = jbpmContext.newProcessInstance("make fondue");
processInstance.signal();
processInstance = saveAndReload(processInstance);
-
jbpmContext.getGraphSession().deleteProcessInstance(processInstance);
newTransaction();
-
assertDeleted(processInstance);
}
finally {
@@ -81,18 +75,16 @@
+ " </process-state>"
+ "</process-definition>");
jbpmContext.deployProcessDefinition(makeFondue);
- try {
- newTransaction();
+ newTransaction();
+ try {
ProcessInstance processInstance = jbpmContext.newProcessInstance("make fondue");
processInstance.signal();
processInstance = saveAndReload(processInstance);
-
jbpmContext.getGraphSession().deleteProcessInstance(processInstance);
newTransaction();
-
assertDeleted(processInstance.getRootToken().getProcessInstance());
assertDeleted(processInstance);
}
@@ -115,9 +107,8 @@
+ " <state name='bake bread' />"
+ "</process-definition>");
jbpmContext.deployProcessDefinition(makeFondue);
+ newTransaction();
try {
- newTransaction();
-
ProcessInstance processInstance = jbpmContext.newProcessInstance("make fondue");
ContextInstance contextInstance = processInstance.getContextInstance();
contextInstance.setVariable("a", "asterix");
@@ -134,11 +125,9 @@
contextInstance.setVariable("b", "janneke", bread);
processInstance = saveAndReload(processInstance);
-
jbpmContext.getGraphSession().deleteProcessInstance(processInstance);
newTransaction();
-
assertDeleted(processInstance);
}
finally {
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/graph/exe/SubProcessCancellationTest.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -1,76 +1,67 @@
package org.jbpm.graph.exe;
-import java.util.Iterator;
-
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class SubProcessCancellationTest extends AbstractDbTestCase
+public class SubProcessCancellationTest extends AbstractDbTestCase
{
- public void testWithSubProcess()
+ public void testWithSubProcess()
{
- ProcessDefinition subProcess = ProcessDefinition.parseXmlString(
- "<process-definition name='sub'>" +
- " <start-state>" +
- " <transition to='wait' />" +
- " </start-state>" +
- " <task-node name='wait'>" +
- " <task>" +
- " <timer duedate='2 seconds' class='MyTimerClass' />" +
- " </task>" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
+ ProcessDefinition subProcess = ProcessDefinition.parseXmlString("<process-definition name='sub'>"
+ + " <start-state>"
+ + " <transition to='wait' />"
+ + " </start-state>"
+ + " <task-node name='wait'>"
+ + " <task>"
+ + " <timer duedate='2 seconds' class='MyTimerClass' />"
+ + " </task>"
+ + " <transition to='end' />"
+ + " </task-node>"
+ + " <end-state name='end' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(subProcess);
-
- ProcessDefinition superProcess = ProcessDefinition.parseXmlString(
- "<process-definition name='super'>" +
- " <start-state>" +
- " <transition to='subprocess' />" +
- " </start-state>" +
- " <process-state name='subprocess'>" +
- " <sub-process name='sub' />" +
- " <transition to='s'/>" +
- " </process-state>" +
- " <state name='s' />" +
- "</process-definition>"
- );
+
+ ProcessDefinition superProcess = ProcessDefinition.parseXmlString("<process-definition name='super'>"
+ + " <start-state>"
+ + " <transition to='subprocess' />"
+ + " </start-state>"
+ + " <process-state name='subprocess'>"
+ + " <sub-process name='sub' />"
+ + " <transition to='s'/>"
+ + " </process-state>"
+ + " <state name='s' />"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(superProcess);
-
+
+ newTransaction();
try
{
- newTransaction();
-
ProcessInstance pi = jbpmContext.newProcessInstanceForUpdate("super");
pi.signal();
-
+
ProcessInstance subPi = pi.getRootToken().getSubProcessInstance();
assertEquals("wait", subPi.getRootToken().getNode().getName());
-
- newTransaction();
- pi = jbpmContext.loadProcessInstance(pi.getId());
- subPi = pi.getRootToken().getSubProcessInstance();
+ pi = saveAndReload(pi);
pi.end();
pi.getTaskMgmtInstance().endAll();
- jbpmContext.save(pi);
+ pi = saveAndReload(pi);
assertTrue(pi.hasEnded());
+ subPi = pi.getRootToken().getSubProcessInstance();
assertTrue(subPi.hasEnded());
- Iterator iter = subPi.getTaskMgmtInstance().getTaskInstances().iterator();
- while (iter.hasNext()) {
- TaskInstance taskInstance = (TaskInstance) iter.next();
+
+ for (TaskInstance taskInstance : subPi.getTaskMgmtInstance().getTaskInstances())
+ {
assertFalse(taskInstance.isSignalling());
assertFalse(taskInstance.hasEnded());
}
}
finally
{
- jbpmContext.getGraphSession().deleteProcessDefinition(superProcess.getId());
- jbpmContext.getGraphSession().deleteProcessDefinition(subProcess.getId());
+ graphSession.deleteProcessDefinition(superProcess.getId());
+ graphSession.deleteProcessDefinition(subProcess.getId());
}
}
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java 2009-02-11 22:36:06 UTC (rev 3844)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/jbpm2036/JBPM2036Test.java 2009-02-12 02:19:59 UTC (rev 3845)
@@ -5,65 +5,75 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
/**
- * StaleObjectStateException when timer ends process
+ * StaleObjectStateException when repeating timer signals the token.
*
- * https://jira.jboss.org/jira/browse/JBPM-2036
- *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-2036">JBPM-2036</a>
* @author Thomas.Diesler(a)jboss.com
* @since 11-Feb-2009
*/
-public class JBPM2036Test extends AbstractDbTestCase
+public class JBPM2036Test extends AbstractDbTestCase
{
- public void testTimerAction()
+ public void testTimerAction()
{
- if (true)
- {
- System.out.println("FIXME: [JBPM-2036] StaleObjectStateException when timer ends process");
- return;
- }
-
ProcessDefinition pd = getProcessDefinition();
jbpmContext.deployProcessDefinition(pd);
+
newTransaction();
- try
+ try
{
- ProcessInstance pi = pd.createProcessInstance();
- Token tok = pi.getRootToken();
- tok.signal();
+ ProcessInstance pi = new ProcessInstance(pd);
+ pi.signal();
+ jbpmContext.save(pi);
+
+ processJobs(30000);
+
+ long piId = pi.getId();
+ assertTrue("expected process instance " + piId + " to have ended",
+ jbpmContext.loadProcessInstance(piId).hasEnded());
+ assertEquals(1, TimerAction.getExecutionCount());
}
- finally {
- graphSession.deleteProcessDefinition(pd.getId());
+ finally
+ {
+ // TODO Timer -> Action -> Delegation cascade is broken somewhere
+ // graphSession.deleteProcessDefinition(pd.getId());
}
}
- private ProcessDefinition getProcessDefinition()
+ private ProcessDefinition getProcessDefinition()
{
- ProcessDefinition pd = ProcessDefinition.parseXmlString("<process-definition name='jbpm2036' initial='start'>"
- + " <node name='start'>"
- + " <transition to='state1'/>"
- + " </node>"
- + " <state name='state1'>"
- + " <timer name='timer-to-end-with-repeat' duedate='1 second' repeat='5 seconds'>"
- + " <action class='" + TimerAction.class.getName() + "' />"
+ return ProcessDefinition.parseXmlString("<process-definition name='jbpm2036'>"
+ + " <start-state name='start'>"
+ + " <transition to='midway'/>"
+ + " </start-state>"
+ + " <state name='midway'>"
+ + " <timer name='chaos' duedate='1 second' repeat='5 seconds'>"
+ + " <action class='"
+ + TimerAction.class.getName()
+ + "' />"
+ " </timer>"
+ " <transition to='end'/>"
+ " </state>"
+ " <end-state name='end' />"
+ "</process-definition>");
- return pd;
}
- public static class TimerAction implements ActionHandler
+ public static class TimerAction implements ActionHandler
{
+ private static int executionCount = 0;
+
private static final long serialVersionUID = 1L;
- public void execute(ExecutionContext executionContext) throws Exception
+ public void execute(ExecutionContext executionContext) throws Exception
{
- System.out.println("leaveNode");
- executionContext.leaveNode();
+ executionContext.leaveNode();
+ executionCount++;
}
+
+ public static int getExecutionCount()
+ {
+ return executionCount;
+ }
}
}
17 years, 2 months
JBoss JBPM SVN: r3844 - in jbpm3/trunk/modules/core/src/main/java/org/jbpm: graph/exe and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-11 17:36:06 -0500 (Wed, 11 Feb 2009)
New Revision: 3844
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Job.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Timer.java
Log:
review toString() in a few select classes
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -57,17 +57,14 @@
public String toString() {
String toString = null;
- if (name!=null) {
- toString = "action["+name+"]";
- } else if (actionExpression!=null) {
- toString = "action["+actionExpression+"]";
+ if (actionExpression!=null) {
+ toString = "Action("+actionExpression+')';
} else {
- String className = getClass().getName();
- className = className.substring(className.lastIndexOf('.')+1);
+ String className = getClass().getSimpleName();
if (name!=null) {
- toString = className+"("+name+")";
+ toString = className+'('+name+')';
} else {
- toString = className+"("+Integer.toHexString(System.identityHashCode(this))+")";
+ toString = className+'@'+Integer.toHexString(hashCode());
}
}
return toString;
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -176,7 +176,7 @@
// event handling ///////////////////////////////////////////////////////////
public void fireEvent(String eventType, ExecutionContext executionContext) {
- log.debug("event '" + eventType + "' on '" + this + "' for '" + executionContext.getToken() + "'");
+ log.debug("event '" + eventType + "' on " + this + " for " + executionContext.getToken());
try {
executionContext.setEventSource(this);
@@ -268,7 +268,7 @@
executionContext.setAction(action);
// execute the action
- log.debug("executing action '" + action + "'");
+ log.debug("executing " + action);
String lockOwnerId = "token[" + token.getId() + "]";
try {
if (actionMustBeLocked) {
@@ -465,14 +465,8 @@
}
public String toString() {
- String className = getClass().getName();
- className = className.substring(className.lastIndexOf('.') + 1);
- if (name != null) {
- className = className + "(" + name + ")";
- } else {
- className = className + "(" + Integer.toHexString(System.identityHashCode(this)) + ")";
- }
- return className;
+ return getClass().getSimpleName() + (name != null ? '(' + name + ')'
+ : '@' + Integer.toHexString(hashCode()));
}
// equals ///////////////////////////////////////////////////////////////////
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -511,7 +511,8 @@
public String toString()
{
- return "ProcessInstance" + (key != null ? '(' + key + ')' : "@" + Integer.toHexString(hashCode()));
+ return "ProcessInstance" + (key != null ? '(' + key + ')'
+ : id != 0 ? "(" + id + ')' : '@' + Integer.toHexString(hashCode()));
}
// getters and setters //////////////////////////////////////////////////////
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/exe/Token.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -456,8 +456,7 @@
public String toString()
{
- getNode();
- return "Token[name=" + getFullName() + ",node=" + getNode() + "]";
+ return "Token(" + getFullName() + ')';
}
public boolean hasEnded()
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Job.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Job.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Job.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -58,7 +58,7 @@
public abstract boolean execute(JbpmContext jbpmContext) throws Exception;
public String toString() {
- return "job["+id+"]";
+ return "Job("+id+')';
}
public String toStringLongFormat() {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-02-11 21:42:58 UTC (rev 3843)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-02-11 22:36:06 UTC (rev 3844)
@@ -107,25 +107,25 @@
}
public String toString() {
- StringBuffer buffer = new StringBuffer("Timer");
+ StringBuilder text = new StringBuilder("Timer");
if (name != null || dueDate != null) {
- buffer.append("(");
- if (name!=null) {
- buffer.append(name).append(",");
- }
- if (dueDate!=null) {
- buffer.append(formatDueDate(dueDate)).append(",");
- }
+ text.append('(');
+
+ if (name!=null)
+ text.append(name).append(",");
+ if (dueDate!=null)
+ text.append(formatDueDate(dueDate)).append(",");
if (taskInstance!=null)
- buffer.append(taskInstance).append(",");
+ text.append(taskInstance).append(",");
+
if (token!=null)
- buffer.append(token);
+ text.append(token);
else if (processInstance!=null)
- buffer.append(processInstance);
+ text.append(processInstance);
- buffer.append(")");
+ text.append(')');
}
- return buffer.toString();
+ return text.toString();
}
public static String formatDueDate(Date date) {
17 years, 2 months
JBoss JBPM SVN: r3843 - jbpm4/trunk/modules/test-load.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-11 16:42:58 -0500 (Wed, 11 Feb 2009)
New Revision: 3843
Modified:
jbpm4/trunk/modules/test-load/pom.xml
Log:
Remove dependency on jbpm-db in test-load module
Modified: jbpm4/trunk/modules/test-load/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-load/pom.xml 2009-02-11 21:16:41 UTC (rev 3842)
+++ jbpm4/trunk/modules/test-load/pom.xml 2009-02-11 21:42:58 UTC (rev 3843)
@@ -44,12 +44,6 @@
<artifactId>jbpm-jpdl</artifactId>
<version>${version}</version>
</dependency>
-
- <dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-db</artifactId>
- <version>${version}</version>
- </dependency>
<!-- TODO remove PVM dependency for compilation (keep it for test)-->
<dependency>
@@ -120,4 +114,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
17 years, 2 months
JBoss JBPM SVN: r3842 - jbpm4/trunk/hudson.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-11 16:16:41 -0500 (Wed, 11 Feb 2009)
New Revision: 3842
Modified:
jbpm4/trunk/hudson/jbpm4-base.sh
jbpm4/trunk/hudson/jbpm4-db.sh
jbpm4/trunk/hudson/jbpm4-load.sh
Log:
force dependency update (mvn -U)
Modified: jbpm4/trunk/hudson/jbpm4-base.sh
===================================================================
--- jbpm4/trunk/hudson/jbpm4-base.sh 2009-02-11 21:02:22 UTC (rev 3841)
+++ jbpm4/trunk/hudson/jbpm4-base.sh 2009-02-11 21:16:41 UTC (rev 3842)
@@ -21,7 +21,7 @@
# build the tests
#
cd $JBPMDIR
-MVN_CMD="mvn -DskipTests clean install"
+MVN_CMD="mvn -U -DskipTests clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
Modified: jbpm4/trunk/hudson/jbpm4-db.sh
===================================================================
--- jbpm4/trunk/hudson/jbpm4-db.sh 2009-02-11 21:02:22 UTC (rev 3841)
+++ jbpm4/trunk/hudson/jbpm4-db.sh 2009-02-11 21:16:41 UTC (rev 3842)
@@ -22,7 +22,7 @@
# build the tests
#
cd $JBPMDIR
-MVN_CMD="mvn -DskipTests clean install"
+MVN_CMD="mvn -U -DskipTests clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
Modified: jbpm4/trunk/hudson/jbpm4-load.sh
===================================================================
--- jbpm4/trunk/hudson/jbpm4-load.sh 2009-02-11 21:02:22 UTC (rev 3841)
+++ jbpm4/trunk/hudson/jbpm4-load.sh 2009-02-11 21:16:41 UTC (rev 3842)
@@ -21,7 +21,7 @@
# build the tests
#
cd $JBPMDIR
-MVN_CMD="mvn -DskipTests clean install"
+MVN_CMD="mvn -U -DskipTests clean install"
echo $MVN_CMD; $MVN_CMD 2>&1; MVN_STATUS=$?
if [ $MVN_STATUS -ne 0 ]; then
echo maven exit status $MVN_STATUS
17 years, 2 months
JBoss JBPM SVN: r3841 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/session and 15 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-02-11 16:02:22 -0500 (Wed, 11 Feb 2009)
New Revision: 3841
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.cfg.xml
jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.common.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
Log:
first history test
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ProcessService.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -51,11 +51,11 @@
ProcessDefinitionQuery createProcessDefinitionQuery();
/** deletes process definition if there are no existing executions.
- * @throws JbpmException if there are existing executions. */
+ * @throws JbpmException if there are existing executions or history. */
void deleteProcessDefinition(String processDefinitionId);
- /** deletes process definition and the existing executions. */
- void deleteProcessDefinitionAndInstances(String processDefinitionId);
+ /** deletes process definition, the existing executions and the history. */
+ void deleteProcessDefinitionCascade(String processDefinitionId);
/** retrieves an attachment of a process definition */
byte[] getAttachment(String processDefinitionId, String name);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -59,7 +59,7 @@
String findProcessDefinitionNameByKey(String processDefinitionKey);
/** delete process definition */
- void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances);
+ void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory);
// process execution queries ////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ProcessManagementImpl.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -77,7 +77,7 @@
public List<ProcessDefinitionRef> removeProcessDefinition(long procDefId)
{
ProcessService processService = this.processEngine.getProcessService();
- processService.deleteProcessDefinitionAndInstances(String.valueOf(procDefId));
+ processService.deleteProcessDefinitionCascade(String.valueOf(procDefId));
return getProcessDefinitions();
}
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.cfg.xml 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.cfg.xml 2009-02-11 21:02:22 UTC (rev 3841)
@@ -13,6 +13,7 @@
<mapping resource="jbpm.pvm.execution.hbm.xml" />
<mapping resource="jbpm.pvm.variable.hbm.xml" />
<mapping resource="jbpm.pvm.job.hbm.xml" />
+ <mapping resource="jbpm.pvm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.jpdl.hbm.xml" />
</session-factory>
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.common.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.common.xml 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.common.xml 2009-02-11 21:02:22 UTC (rev 3841)
@@ -37,5 +37,6 @@
<mapping resource="jbpm.pvm.execution.hbm.xml" />
<mapping resource="jbpm.pvm.variable.hbm.xml" />
<mapping resource="jbpm.pvm.job.hbm.xml" />
+ <mapping resource="jbpm.pvm.history.hbm.xml" />
<mapping resource="jbpm.task.hbm.xml" />
<mapping resource="jbpm.jpdl.hbm.xml" />
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/DeleteProcessDefinitionCmd.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -37,14 +37,16 @@
String processDefinitionId;
boolean deleteProcessInstances;
+ boolean deleteHistory;
public DeleteProcessDefinitionCmd(String processDefinitionId) {
- this(processDefinitionId, false);
+ this(processDefinitionId, false, false);
}
- public DeleteProcessDefinitionCmd(String processDefinitionId, boolean deleteProcessInstances) {
+ public DeleteProcessDefinitionCmd(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory) {
this.processDefinitionId = processDefinitionId;
this.deleteProcessInstances = deleteProcessInstances;
+ this.deleteHistory = deleteHistory;
}
public Void execute(Environment environment) {
@@ -52,7 +54,7 @@
if (pvmDbSession==null) {
throw new JbpmException("no "+PvmDbSessionBinding.TAG+" configured");
}
- pvmDbSession.deleteProcessDefinition(processDefinitionId, deleteProcessInstances);
+ pvmDbSession.deleteProcessDefinition(processDefinitionId, deleteProcessInstances, deleteHistory);
return null;
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -33,6 +33,8 @@
import org.jbpm.job.Message;
import org.jbpm.job.Timer;
import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstance;
import org.jbpm.session.PvmDbSession;
/**
@@ -93,7 +95,7 @@
return (String) query.uniqueResult();
}
- public void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances) {
+ public void deleteProcessDefinition(String processDefinitionId, boolean deleteProcessInstances, boolean deleteHistory) {
List<String> processInstanceIds = findProcessInstanceIds(processDefinitionId);
if (deleteProcessInstances) {
@@ -106,6 +108,17 @@
}
}
+ List<String> historyProcessInstanceIds = findHistoryProcessInstanceIds(processDefinitionId);
+ if (deleteHistory) {
+ for (String historyProcessInstanceId: historyProcessInstanceIds) {
+ deleteHistoryProcessInstance(historyProcessInstanceId);
+ }
+ } else {
+ if (historyProcessInstanceIds.size()>0) {
+ throw new JbpmException("still "+historyProcessInstanceIds.size()+" history process instances for process definition "+processDefinitionId);
+ }
+ }
+
ProcessDefinition processDefinition = findProcessDefinitionById(processDefinitionId);
session.delete(processDefinition);
}
@@ -190,4 +203,15 @@
log.debug("deleting process instance "+processInstanceId);
session.delete(processInstance);
}
+
+ public List<String> findHistoryProcessInstanceIds(String processDefinitionId) {
+ Query query = session.getNamedQuery("findHistoryProcessInstanceIds");
+ query.setString("processDefinitionId", processDefinitionId);
+ return query.list();
+ }
+
+ public void deleteHistoryProcessInstance(String historyProcessInstanceId) {
+ HistoryProcessInstance historyProcessInstance = (HistoryProcessInstance) session.load(HistoryProcessInstance.class, historyProcessInstanceId);
+ session.delete(historyProcessInstance);
+ }
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -0,0 +1,33 @@
+/*
+ * 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.pvm.internal.history;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionImpl implements HistorySession {
+
+ public void process(HistoryEvent historyEvent) {
+ historyEvent.process();
+ }
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -35,9 +35,11 @@
private static final long serialVersionUID = 1L;
public void process() {
- long dbid = execution.getDbid();
- Session session = Environment.getFromCurrent(Session.class);
- HistoryProcessInstance historyProcessInstance = (HistoryProcessInstance) session.load(HistoryProcessInstance.class, dbid);
- historyProcessInstance.setEndTime(Clock.getCurrentTime());
+ String executionId = execution.getId();
+ if (executionId!=null) {
+ Session session = Environment.getFromCurrent(Session.class);
+ HistoryProcessInstance historyProcessInstance = (HistoryProcessInstance) session.load(HistoryProcessInstance.class, executionId);
+ historyProcessInstance.setEndTime(Clock.getCurrentTime());
+ }
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -37,9 +37,11 @@
private static final long serialVersionUID = 1L;
public void process() {
- HistoryProcessInstance historyProcessInstance = new HistoryProcessInstance(execution);
+ if (execution.getId()!=null) {
+ HistoryProcessInstance historyProcessInstance = new HistoryProcessInstance(execution);
- Session session = Environment.getFromCurrent(Session.class);
- session.save(historyProcessInstance);
+ Session session = Environment.getFromCurrent(Session.class);
+ session.save(historyProcessInstance);
+ }
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -53,6 +53,7 @@
import org.jbpm.model.Transition;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;
import org.jbpm.pvm.internal.history.events.ProcessInstanceStart;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.model.op.AtomicOperation;
@@ -193,7 +194,6 @@
this.state = STATE_ACTIVE;
ExecutionImpl scopedExecution = initializeScopes();
-
fireHistoryEvent(new ProcessInstanceStart());
fire(Event.START, processDefinition);
if (activity!=null) {
@@ -319,6 +319,7 @@
parent.removeExecution(this);
} else { // this is a process instance
+ fireHistoryEvent(new ProcessInstanceEnd());
fire(Event.END, processDefinition);
if (superProcessExecution!=null) {
log.trace(toString()+" signals super process execution");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ProcessServiceImpl.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -71,8 +71,8 @@
commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId));
}
- public void deleteProcessDefinitionAndInstances(String processDefinitionId) {
- commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId, true));
+ public void deleteProcessDefinitionCascade(String processDefinitionId) {
+ commandService.execute(new DeleteProcessDefinitionCmd(processDefinitionId, true, true));
}
public byte[] getAttachment(String processDefinitionId, String name) {
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.history.HistorySessionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionBinding extends WireDescriptorBinding {
+
+ public HistorySessionBinding() {
+ super("history-session");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ return new ObjectDescriptor(HistorySessionImpl.class);
+ }
+
+}
Added: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml 2009-02-11 21:02:22 UTC (rev 3841)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.internal.history.model" default-access="field">
+
+ <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+ <class name="HistoryProcessInstance" table="JBPM_HIST_PROC_INST">
+ <id name="id" column="ID_">
+ <generator class="assigned" />
+ </id>
+ <version name="dbversion" column="DBVERSION_" />
+
+ <property name="key" column="KEY_" />
+ <property name="startTime" column="START_" type="timestamp" />
+ <property name="endTime" column="END_" type="timestamp" />
+ <property name="duration" column="DURATION_" />
+
+ <many-to-one name="processDefinition"
+ class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl"
+ column="PROCDEF_"
+ foreign-key="FK_HPI_PROCDEF"
+ index="IDX_HPI_PROCDEF" />
+ </class>
+
+ <query name="findHistoryProcessInstanceIds">
+ <![CDATA[
+ select historyExecution.id
+ from org.jbpm.pvm.internal.history.model.HistoryProcessInstance historyExecution
+ where historyExecution.processDefinition.id = :processDefinitionId
+ ]]>
+ </query>
+
+
+</hibernate-mapping>
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.wire.bindings.xml 2009-02-11 21:02:22 UTC (rev 3841)
@@ -46,6 +46,7 @@
<!-- sessions -->
<binding class="org.jbpm.pvm.internal.wire.binding.MessageSessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.TimerSessionBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionFactoryBinding" />
<!-- db sessions -->
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -87,7 +87,7 @@
protected void tearDown() throws Exception {
if (registeredProcessDefinitions!=null) {
for (ProcessDefinition processDefinition : registeredProcessDefinitions) {
- processService.deleteProcessDefinitionAndInstances(processDefinition.getId());
+ processService.deleteProcessDefinitionCascade(processDefinition.getId());
}
}
Added: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -0,0 +1,49 @@
+/*
+ * 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.history;
+
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceHistoryTest extends DbTestCase {
+
+ public void testSignalExecutionByKey() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <flow to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ executionService.startExecutionByKey("ICL");
+ executionService.startExecutionByKey("ICL");
+ executionService.startExecutionByKey("ICL");
+
+
+ }
+
+}
Modified: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/process/ProcessServiceTest.java 2009-02-11 21:02:22 UTC (rev 3841)
@@ -170,7 +170,7 @@
executionService.startExecutionByKey("deleteme");
// delete it all
- processService.deleteProcessDefinitionAndInstances("deleteme:33");
+ processService.deleteProcessDefinitionCascade("deleteme:33");
// check if the db is empty
assertEquals(0, processService.createProcessDefinitionQuery().execute().size());
Modified: jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml 2009-02-11 20:37:56 UTC (rev 3840)
+++ jbpm4/trunk/modules/test-db/src/main/resources/jbpm.cfg.xml 2009-02-11 21:02:22 UTC (rev 3841)
@@ -64,6 +64,7 @@
<task-db-session />
<message-session />
<timer-session />
+ <history-session />
</environment>
</jbpm-configuration>
17 years, 2 months
JBoss JBPM SVN: r3840 - jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-02-11 15:37:56 -0500 (Wed, 11 Feb 2009)
New Revision: 3840
Modified:
jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java
Log:
The compilation error should be fixed. A dependend module wasn't published
Modified: jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java 2009-02-11 18:28:51 UTC (rev 3839)
+++ jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/mgmt/ModelAdaptor.java 2009-02-11 20:37:56 UTC (rev 3840)
@@ -57,7 +57,7 @@
ProcessInstanceRef ref = new ProcessInstanceRef();
ref.setInstanceId( e0.getDbid() );
ref.setKey(e0.getKey());
- // ref.setDefinitionId(e0.getProcessDefinition().getDbid());
+ ref.setDefinitionId(e0.getProcessDefinition().getDbid());
ref.setState( ProcessInstanceRef.STATE.RUNNING); // TODO: FIXME
17 years, 2 months