Author: tom.baeyens(a)jboss.com
Date: 2009-02-12 09:14:00 -0500 (Thu, 12 Feb 2009)
New Revision: 3853
Added:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryProcessInstanceQuery.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/
jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
Removed:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/CreateTimerActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstance.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstance.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceStoppedSynchronization.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveConditionActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveExpressionActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ScriptActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml
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/HistorySessionImpl.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/model/op/ExecuteActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
Log:
first cut of history
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-02-12
13:51:43 UTC (rev 3852)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/ExecutionService.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -120,6 +120,9 @@
/** search for process instances with criteria */
ExecutionQuery createProcessInstanceQuery();
+ /** search for process instances in the history */
+ HistoryProcessInstanceQuery createHistoryProcessInstanceQuery();
+
/** creates or overwrites a variable value on the referenced execution */
Execution setVariable(String executionId, String name, Object value);
Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryProcessInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryProcessInstanceQuery.java
(rev 0)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryProcessInstanceQuery.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.jbpm.history.HistoryProcessInstance;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryProcessInstanceQuery {
+
+ String PROPERTY_STARTTIME = "startTime";
+ String PROPERTY_ENDTIME = "endTime";
+ String PROPERTY_ID = "id";
+
+ HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId);
+
+ HistoryProcessInstanceQuery orderAsc(String property);
+ HistoryProcessInstanceQuery orderDesc(String property);
+
+ HistoryProcessInstanceQuery page(int firstResult, int maxResults);
+
+ List<HistoryProcessInstance> execute();
+}
Property changes on:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/HistoryProcessInstanceQuery.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
===================================================================
---
jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -266,4 +266,26 @@
/** returns the previously taken transition only if {@link
Activity#isPreviousNeeded()}
* is set to true. */
Transition getPreviousTransition();
+
+ /** record history event that specifies for an exclusive activity which transition
+ * has been taken. */
+ void historyExclusive(String transitionName);
+
+ /** records the end of an automatic event. This should be called at the end of
+ * the activity. Before the activity's execute method is invoked, the start time
+ * is automatically recorded. And invocation of this historyAutomatic will
+ * capture the end time. */
+ void historyAutomatic();
+
+ /** marks the start of an activity for history purposes. */
+ void historyActivityStart();
+
+ /** marks the end of an activity for history purposes. */
+ void historyActivityEnd();
+
+ /** marks the start of a user task for history purposes. */
+ void historyTaskStart(String assignee);
+
+ /** marks the end of a user task for history purposes. */
+ void historyTaskEnd(String outcome);
}
Copied: jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
(from rev 3843,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java)
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
(rev 0)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,42 @@
+/*
+ * 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.history;
+
+import java.util.Date;
+
+/**
+ * @author Tom Baeyens
+ */
+public interface HistoryProcessInstance {
+
+ String getId();
+
+ String getKey();
+
+ String getState();
+
+ Date getStartTime();
+
+ Date getEndTime();
+
+ long getDuration();
+}
\ No newline at end of file
Property changes on:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/history/HistoryProcessInstance.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java
===================================================================
---
jbpm4/trunk/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/api/src/main/java/org/jbpm/listener/EventListenerExecution.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -59,9 +59,6 @@
* registered to parent's of the given eventSource. */
void fire(String eventName, ObservableElement eventSource);
- /** the exception in case an exception handler is handling an exception. */
- Exception getException();
-
// extensions //////////////////////////////////////////////////////////////
/** way to access process language extensions in the execution without
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-12
13:51:43 UTC (rev 3852)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/PvmDbSession.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -73,9 +73,12 @@
/* find ids for all process instances for a given process definition. */
List<String> findProcessInstanceIds(String processDefinitionId);
- /** delete the process instance */
+ /** delete the process instance including the history. */
void deleteProcessInstance(String processInstanceId);
+ /** delete the process instance and optionally deletes the history. */
+ void deleteProcessInstance(String processInstanceId, boolean deleteHistory);
+
// job queries //////////////////////////////////////////////////////////////
/** timers */
@@ -87,4 +90,5 @@
/** the jobs for which all the retries have failed and which will not be
* picked up any more by the jobImpl executor */
public List<Job> findJobsWithException(int firstResult, int maxResults);
+
}
Deleted:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/CreateTimerActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/CreateTimerActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/CreateTimerActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.jpdl.activity;
-
-import org.jbpm.activity.ActivityExecution;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CreateTimerActivity extends JpdlActivity {
-
- private static final long serialVersionUID = 1L;
-
-
-
- public void execute(ActivityExecution execution) {
- }
-}
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveConditionActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveConditionActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveConditionActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -42,6 +42,9 @@
if (transition==null) {
throw new JpdlException("no outgoing transition condition evaluated to true
for exclusive "+execution.getActivity());
}
+ if (transition.getName()!=null) {
+ execution.historyExclusive(transition.getName());
+ }
execution.take(transition);
}
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveExpressionActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveExpressionActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveExpressionActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -55,6 +55,8 @@
if (transition==null) {
throw new JbpmException("expression '"+expr+"' in exclusive
'"+activity.getName()+"' returned unexisting outgoing transition name:
"+transitionName);
}
+
+ execution.historyExclusive(transitionName);
execution.take(transition);
}
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ExclusiveHandlerActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -66,6 +66,8 @@
if (transition==null) {
throw new JbpmException("handler in exclusive
'"+activity.getName()+"' returned unexisting outgoing transition name:
"+transitionName);
}
+
+ execution.historyExclusive(transitionName);
execution.take(transition);
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/HqlActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -71,6 +71,8 @@
}
execution.setVariable(resultVariableName, result);
+
+ execution.historyAutomatic();
}
protected Query createQuery(Session session) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/JavaActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -69,6 +69,9 @@
if (variableName!=null) {
execution.setVariable(variableName, returnValue);
}
+
+ execution.historyAutomatic();
+
} catch (WireException e) {
throw e;
} catch (Exception e) {
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ScriptActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ScriptActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/ScriptActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -44,6 +44,8 @@
if (variableName!=null) {
execution.setVariable(variableName, returnValue);
}
+
+ execution.historyAutomatic();
}
public void setScript(String script) {
Modified:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/StateActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -35,6 +35,8 @@
private static final long serialVersionUID = 1L;
public void execute(ActivityExecution execution) {
+ execution.historyActivityStart();
+
execution.waitForSignal();
}
@@ -49,6 +51,7 @@
Transition transition = activity.findOutgoingTransition(signalName);
if (transition!=null) {
+ execution.historyActivityEnd();
execution.take(transition);
} else {
execution.waitForSignal();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java
===================================================================
---
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/TaskActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -21,8 +21,13 @@
*/
package org.jbpm.jpdl.activity;
+import java.util.Map;
+
+import org.jbpm.JbpmException;
import org.jbpm.activity.ActivityExecution;
import org.jbpm.env.Environment;
+import org.jbpm.model.Activity;
+import org.jbpm.model.Transition;
import org.jbpm.task.internal.model.TaskImpl;
import org.jbpm.task.session.TaskDbSession;
@@ -30,7 +35,7 @@
/**
* @author Tom Baeyens
*/
-public class TaskActivity extends StateActivity {
+public class TaskActivity extends JpdlExternalActivity {
private static final long serialVersionUID = 1L;
@@ -43,8 +48,27 @@
task.setAssignee(assignee);
taskDbSession.saveTask(task);
+ execution.historyTaskStart(assignee);
execution.waitForSignal();
}
+
+ public void signal(ActivityExecution execution, String signalName, Map<String,
Object> parameters) {
+ Activity activity = execution.getActivity();
+
+ if (parameters!=null) {
+ execution.setVariables(parameters);
+ }
+
+ execution.fire(signalName, activity);
+
+ Transition transition = activity.findOutgoingTransition(signalName);
+ if (transition!=null) {
+ execution.historyTaskEnd(signalName);
+ execution.take(transition);
+ } else {
+ throw new JbpmException("task outcome '"+signalName+"'
doesn't match with the an outgoing transition
"+activity.getOutgoingTransitions());
+ }
+ }
public void setAssignee(String assignee) {
this.assignee = assignee;
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml 2009-02-12
13:51:43 UTC (rev 3852)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/hibernate.properties.hsqldb.xml 2009-02-12
14:14:00 UTC (rev 3853)
@@ -4,7 +4,7 @@
<!-- JDBC connection properties (begin) -->
<property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
- <property
name="hibernate.connection.url">jdbc:hsqldb:mem:jbpm</property>
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<!-- JDBC connection properties (end) -->
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-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -29,12 +29,14 @@
import org.jbpm.ProcessDefinition;
import org.jbpm.client.ClientExecution;
import org.jbpm.client.ClientProcessDefinition;
+import org.jbpm.history.HistoryProcessInstance;
import org.jbpm.job.Job;
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.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
+import org.jbpm.pvm.internal.svc.DefaultCommandService;
import org.jbpm.session.PvmDbSession;
/**
@@ -98,6 +100,19 @@
public void deleteProcessDefinition(String processDefinitionId, boolean
deleteProcessInstances, boolean deleteHistory) {
List<String> processInstanceIds = findProcessInstanceIds(processDefinitionId);
+ if ( deleteHistory
+ // and if hibernate knows about the history class
+ &&
(session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class)!=null)
+ ) {
+ List<HistoryProcessInstance> historyProcessInstances = new
HistoryProcessInstanceQueryImpl(new DefaultCommandService())
+ .processDefinitionId(processDefinitionId)
+ .execute();
+
+ for (HistoryProcessInstance historyProcessInstance : historyProcessInstances) {
+ session.delete(historyProcessInstance);
+ }
+ }
+
if (deleteProcessInstances) {
for (String processInstanceId : processInstanceIds) {
deleteProcessInstance(processInstanceId);
@@ -108,17 +123,6 @@
}
}
- 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);
}
@@ -199,9 +203,39 @@
}
public void deleteProcessInstance(String processInstanceId) {
+ deleteProcessInstance(processInstanceId, true);
+ }
+
+ public void deleteProcessInstance(String processInstanceId, boolean deleteHistory) {
+ if (processInstanceId==null) {
+ throw new JbpmException("processInstanceId is null");
+ }
+
Execution processInstance = findExecutionById(processInstanceId);
- log.debug("deleting process instance "+processInstanceId);
- session.delete(processInstance);
+
+ // if history should be deleted
+ if ( deleteHistory
+ // and if hibernate knows about the history class
+ &&
(session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class)!=null)
+ ) {
+ HistoryProcessInstanceImpl historyProcessInstance = (HistoryProcessInstanceImpl)
+ session.get(HistoryProcessInstanceImpl.class, processInstance.getId());
+
+ // if there is a history process instance in the db
+ if (historyProcessInstance!=null) {
+ if (log.isDebugEnabled()) {
+ log.debug("deleting history process instance "+processInstanceId);
+ }
+ session.delete(historyProcessInstance);
+ }
+ }
+
+ if (processInstance!=null) {
+ if (log.isDebugEnabled()) {
+ log.debug("deleting process instance "+processInstanceId);
+ }
+ session.delete(processInstance);
+ }
}
public List<String> findHistoryProcessInstanceIds(String processDefinitionId) {
@@ -209,9 +243,4 @@
query.setString("processDefinitionId", processDefinitionId);
return query.list();
}
-
- public void deleteHistoryProcessInstance(String historyProcessInstanceId) {
- HistoryProcessInstance historyProcessInstance = (HistoryProcessInstance)
session.load(HistoryProcessInstance.class, historyProcessInstanceId);
- session.delete(historyProcessInstance);
- }
}
Modified:
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 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -28,6 +28,8 @@
public class HistorySessionImpl implements HistorySession {
public void process(HistoryEvent historyEvent) {
- historyEvent.process();
+ if (historyEvent.execution.getId()!=null) {
+ historyEvent.process();
+ }
}
}
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,54 @@
+/*
+ * 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.events;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityEnd extends HistoryEvent {
+
+ private static final long serialVersionUID = 1L;
+
+ public void process() {
+ Session session = Environment.getFromCurrent(Session.class);
+ Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
+ HistoryActivityInstanceImpl historyActivityInstanceImpl =
(HistoryActivityInstanceImpl)
+ session.load(getHistoryActivityInstanceClass(), historyActivityInstanceDbId);
+ historyActivityInstanceImpl.setEndTime(Clock.getCurrentTime());
+ updateActivitySpecificProperties(historyActivityInstanceImpl);
+ session.update(historyActivityInstanceImpl);
+ }
+
+ protected Class<? extends HistoryActivityInstanceImpl>
getHistoryActivityInstanceClass() {
+ return HistoryActivityInstanceImpl.class;
+ }
+
+ protected void updateActivitySpecificProperties(HistoryActivityInstanceImpl
historyActivityInstanceImpl) {
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,56 @@
+/*
+ * 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.events;
+
+import org.hibernate.Session;
+import org.jbpm.env.Environment;
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ActivityStart extends HistoryEvent {
+
+ private static final long serialVersionUID = 1L;
+
+ public void process() {
+ Session session = Environment.getFromCurrent(Session.class);
+
+ HistoryProcessInstance historyProcessInstanceImpl = (HistoryProcessInstance)
+ session.load(HistoryProcessInstanceImpl.class, execution.getId());
+
+ HistoryActivityInstanceImpl historyActivityInstanceImpl =
+ createHistoryActivityInstance(historyProcessInstanceImpl);
+
+ session.save(historyActivityInstanceImpl);
+
+ execution.setHistoryActivityInstanceDbid(historyActivityInstanceImpl.getDbid());
+ }
+
+ protected HistoryActivityInstanceImpl
createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+ return new HistoryActivityInstanceImpl(historyProcessInstanceImpl, execution);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityStart.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,40 @@
+/*
+ * 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.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryAutomaticInstanceImpl;
+
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticEnd extends ActivityStart {
+
+ private static final long serialVersionUID = 1L;
+
+ protected HistoryActivityInstanceImpl
createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+ return new HistoryAutomaticInstanceImpl(historyProcessInstanceImpl, execution);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/AutomaticEnd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryExclusiveInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveEnd extends AutomaticEnd {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String transitionName;
+
+ public ExclusiveEnd(String transitionName) {
+ this.transitionName = transitionName;
+ }
+
+ protected HistoryActivityInstanceImpl
createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+ return new HistoryExclusiveInstanceImpl(historyProcessInstanceImpl, execution,
transitionName);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ExclusiveEnd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -24,7 +24,7 @@
import org.hibernate.Session;
import org.jbpm.env.Environment;
import org.jbpm.pvm.internal.history.HistoryEvent;
-import org.jbpm.pvm.internal.history.model.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
import org.jbpm.pvm.internal.util.Clock;
/**
@@ -35,11 +35,9 @@
private static final long serialVersionUID = 1L;
public void process() {
- 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());
- }
+ Session session = Environment.getFromCurrent(Session.class);
+ HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
+ session.load(HistoryProcessInstanceImpl.class, execution.getId());
+ historyProcessInstanceImpl.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-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceStart.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -25,8 +25,9 @@
import org.hibernate.Session;
import org.jbpm.env.Environment;
+import org.jbpm.history.HistoryProcessInstance;
import org.jbpm.pvm.internal.history.HistoryEvent;
-import org.jbpm.pvm.internal.history.model.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
/**
@@ -37,11 +38,8 @@
private static final long serialVersionUID = 1L;
public void process() {
- if (execution.getId()!=null) {
- HistoryProcessInstance historyProcessInstance = new
HistoryProcessInstance(execution);
-
- Session session = Environment.getFromCurrent(Session.class);
- session.save(historyProcessInstance);
- }
+ HistoryProcessInstance historyProcessInstanceImpl = new
HistoryProcessInstanceImpl(execution);
+ Session session = Environment.getFromCurrent(Session.class);
+ session.save(historyProcessInstanceImpl);
}
}
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -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.pvm.internal.history.events;
+
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskEnd extends ActivityEnd {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String outcome;
+
+ public TaskEnd(String outcome) {
+ this.outcome = outcome;
+ }
+
+ protected Class<? extends HistoryActivityInstanceImpl>
getHistoryActivityInstanceClass() {
+ return HistoryTaskInstanceImpl.class;
+ }
+
+ protected void updateActivitySpecificProperties(HistoryActivityInstanceImpl
historyActivityInstanceImpl) {
+ HistoryTaskInstanceImpl historyTaskInstanceImpl = (HistoryTaskInstanceImpl)
historyActivityInstanceImpl;
+ historyTaskInstanceImpl.setOutcome(outcome);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskEnd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.events;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
+import org.jbpm.pvm.internal.history.model.HistoryTaskInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskStart extends ActivityStart {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String assignee;
+
+ public TaskStart(String assignee) {
+ this.assignee = assignee;
+ }
+
+ protected HistoryActivityInstanceImpl
createHistoryActivityInstance(HistoryProcessInstance historyProcessInstanceImpl) {
+ return new HistoryTaskInstanceImpl(historyProcessInstanceImpl, execution, assignee);
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskStart.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstance.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstance.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstance.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.history.model;
-
-import java.util.Date;
-
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.util.Clock;
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryActivityInstance {
-
- protected long dbid;
- protected int dbversion;
-
- protected ActivityImpl activity;
- protected String activityName;
-
- protected Date createTime;
- protected Date endTime;
- protected long duration;
-
- public HistoryActivityInstance() {
- }
-
- public HistoryActivityInstance(ActivityImpl activity) {
- this.activity = activity;
- this.createTime = Clock.getCurrentTime();
- }
-
- public void setEndTime(Date endTime) {
- this.endTime = endTime;
- this.duration = endTime.getTime() - createTime.getTime();
- }
-
-
- public long getDbid() {
- return dbid;
- }
- public ActivityImpl getActivity() {
- return activity;
- }
- public String getActivityName() {
- return activityName;
- }
- public Date getCreateTime() {
- return createTime;
- }
- public Date getEndTime() {
- return endTime;
- }
- public long getDuration() {
- return duration;
- }
-}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
(from rev 3843,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstance.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.history.model;
+
+import java.util.Date;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/** base activity instance class.
+ *
+ * @author Tom Baeyens
+ */
+public class HistoryActivityInstanceImpl {
+
+ protected long dbid;
+ protected int dbversion;
+
+ protected HistoryProcessInstance historyProcessInstance;
+ protected String executionId;
+ protected ActivityImpl activity;
+ protected String activityName;
+
+ protected Date startTime;
+ protected Date endTime;
+ protected long duration;
+
+ public HistoryActivityInstanceImpl() {
+ }
+
+ public HistoryActivityInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl,
ExecutionImpl execution) {
+ this.historyProcessInstance = historyProcessInstanceImpl;
+ this.activity = execution.getActivity();
+ this.executionId = execution.getId();
+ this.activityName = activity.getName();
+ this.startTime = execution.getHistoryActivityStart();
+ }
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ this.duration = endTime.getTime() - startTime.getTime();
+ }
+
+ public long getDbid() {
+ return dbid;
+ }
+ public ActivityImpl getActivity() {
+ return activity;
+ }
+ public String getActivityName() {
+ return activityName;
+ }
+ public Date getStartTime() {
+ return startTime;
+ }
+ public Date getEndTime() {
+ return endTime;
+ }
+ public long getDuration() {
+ return duration;
+ }
+ public HistoryProcessInstance getHistoryProcessInstance() {
+ return historyProcessInstance;
+ }
+ public String getExecutionId() {
+ return executionId;
+ }
+ public void setExecutionId(String executionId) {
+ this.executionId = executionId;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,41 @@
+/*
+ * 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.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryAutomaticInstanceImpl extends HistoryActivityInstanceImpl {
+
+ public HistoryAutomaticInstanceImpl() {
+ }
+
+ public HistoryAutomaticInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl,
ExecutionImpl execution) {
+ super(historyProcessInstanceImpl, execution);
+ setEndTime(Clock.getCurrentTime());
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,46 @@
+/*
+ * 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.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryExclusiveInstanceImpl extends HistoryAutomaticInstanceImpl {
+
+ protected String transitionName;
+
+ public HistoryExclusiveInstanceImpl() {
+ }
+
+ public HistoryExclusiveInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl,
ExecutionImpl execution, String transitionName) {
+ super(historyProcessInstanceImpl, execution);
+ this.transitionName = transitionName;
+ }
+
+ public String getTransitionName() {
+ return transitionName;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryExclusiveInstanceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.history.model;
-
-import java.util.Date;
-
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.util.Clock;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryProcessInstance {
-
- protected long dbid;
- protected int dbversion;
-
- protected ProcessDefinitionImpl processDefinition;
- protected String id;
- protected String key;
- protected Date startTime;
- protected Date endTime;
- protected long duration;
-
- public HistoryProcessInstance() {
- }
-
- public HistoryProcessInstance(ExecutionImpl processInstance) {
- this.processDefinition = processInstance.getProcessDefinition();
- this.dbid = processInstance.getDbid();
- this.id = processInstance.getId();
- this.key = processInstance.getKey();
- this.startTime = Clock.getCurrentTime();
- }
-
- public void setEndTime(Date endTime) {
- this.endTime = endTime;
- this.duration = endTime.getTime() - startTime.getTime();
- }
-
- public Date getEndTime() {
- return endTime;
- }
- public long getDbid() {
- return dbid;
- }
- public ProcessDefinitionImpl getProcessDefinition() {
- return processDefinition;
- }
- public Date getStartTime() {
- return startTime;
- }
- public long getDuration() {
- return duration;
- }
- public String getId() {
- return id;
- }
-}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
(from rev 3843,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstance.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,94 @@
+/*
+ * 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.model;
+
+import java.util.Date;
+import java.util.Set;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.util.Clock;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryProcessInstanceImpl implements HistoryProcessInstance {
+
+ protected long dbid;
+ protected int dbversion;
+
+ protected ProcessDefinitionImpl processDefinition;
+ protected String id;
+ protected String key;
+ protected String state;
+ protected Date startTime;
+ protected Date endTime;
+ protected long duration;
+
+ /** only here to get hibernate cascade deletes */
+ protected Set<HistoryActivityInstanceImpl> historyActivityInstances;
+
+ public HistoryProcessInstanceImpl() {
+ }
+
+ public HistoryProcessInstanceImpl(ExecutionImpl processInstance) {
+ this.processDefinition = processInstance.getProcessDefinition();
+ this.dbid = processInstance.getDbid();
+ this.id = processInstance.getId();
+ this.key = processInstance.getKey();
+ this.state = "active";
+ this.startTime = Clock.getCurrentTime();
+ }
+
+ public void setEndTime(Date endTime) {
+ this.endTime = endTime;
+ this.duration = endTime.getTime() - startTime.getTime();
+ this.state = "ended";
+ }
+
+ public Date getEndTime() {
+ return endTime;
+ }
+ public long getDbid() {
+ return dbid;
+ }
+ public ProcessDefinitionImpl getProcessDefinition() {
+ return processDefinition;
+ }
+ public Date getStartTime() {
+ return startTime;
+ }
+ public long getDuration() {
+ return duration;
+ }
+ public String getId() {
+ return id;
+ }
+ public String getKey() {
+ return key;
+ }
+ public String getState() {
+ return state;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstance.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstance.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstance.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.history.model;
-
-import org.jbpm.pvm.internal.model.ActivityImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistoryTaskInstance extends HistoryActivityInstance {
-
- protected String assignee;
-
- public HistoryTaskInstance() {
- }
-
- public HistoryTaskInstance(ActivityImpl activity, String assignee) {
- super(activity);
- this.assignee = assignee;
- }
-}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
(from rev 3843,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstance.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,47 @@
+/*
+ * 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.model;
+
+import org.jbpm.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryTaskInstanceImpl extends HistoryActivityInstanceImpl {
+
+ protected String assignee;
+ protected String outcome;
+
+ public HistoryTaskInstanceImpl() {
+ }
+
+ public HistoryTaskInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl,
ExecutionImpl execution, String assignee) {
+ super(historyProcessInstanceImpl, execution);
+ this.assignee = assignee;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskInstanceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
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-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -34,11 +35,11 @@
import java.util.Set;
import org.jbpm.Execution;
-import org.jbpm.ExecutionService;
import org.jbpm.JbpmException;
import org.jbpm.activity.ActivityExecution;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.cmd.CommandService;
import org.jbpm.env.Environment;
import org.jbpm.env.Transaction;
import org.jbpm.listener.EventListener;
@@ -53,8 +54,14 @@
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.ActivityEnd;
+import org.jbpm.pvm.internal.history.events.ActivityStart;
+import org.jbpm.pvm.internal.history.events.AutomaticEnd;
+import org.jbpm.pvm.internal.history.events.ExclusiveEnd;
import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;
import org.jbpm.pvm.internal.history.events.ProcessInstanceStart;
+import org.jbpm.pvm.internal.history.events.TaskEnd;
+import org.jbpm.pvm.internal.history.events.TaskStart;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.model.op.AtomicOperation;
import org.jbpm.pvm.internal.model.op.ExecuteActivity;
@@ -100,8 +107,6 @@
protected ProcessDefinitionImpl processDefinition;
- // current position /////////////////////////////////////////////////////////
-
/** current activity */
protected ActivityImpl activity;
@@ -134,14 +139,15 @@
/** the free text comments users make on this execution */
protected Set<CommentImpl> comments;
+
+ /** reference to the current activity instance history record */
+ protected Long historyActivityInstanceDbid;
+
+ /** start time of the activity for history purposes (not persisted) */
+ protected Date historyActivityStart;
protected int priority = Priority.NORMAL;
- /** maintains the index of the next log record. That way, the logs don't
- * have to be loaded to add one. Instead, for each log that is added to
- * this execution, the nextLogIndex is used and incremented. */
- protected int nextLogIndex;
-
/** caches the child executions by execution name. This member might be
* null and is only created from the executions in case its needed. Note
* that not all executions are forced to have a name and duplicates are allowed.
@@ -161,15 +167,7 @@
protected Activity previousActivity;
protected Transition previousTransition;
- protected Exception exception;
- // It's important that this refers to a separate entity. This
- // execution must do nullpointercheck before accessing the
- // process modifications. That way, good performance is guaranteed
- // for the most common scenario: a persistent execution without
- // process modifications.
- protected ProcessModificationsImpl processModifications;
-
// construction /////////////////////////////////////////////////////////////
public void initializeProcessInstance(ProcessDefinitionImpl processDefinition, String
key) {
@@ -329,11 +327,11 @@
Environment environment = Environment.getCurrent();
if (environment!=null) {
Transaction transaction = environment.get(Transaction.class);
- ExecutionService executionService = environment.get(ExecutionService.class);
+ CommandService commandService = environment.get(CommandService.class);
if ( (transaction!=null)
- && (executionService!=null)
+ && (commandService!=null)
) {
- transaction.registerSynchronization(new
ProcessInstanceStoppedSynchronization(this.getId(), executionService));
+ transaction.registerSynchronization(new
ProcessInstanceEndedSynchronization(this.getId(), commandService));
}
}
}
@@ -934,10 +932,6 @@
}
}
- public int nextLogIndex() {
- return nextLogIndex++;
- }
-
// overriding the ScopeInstanceImpl methods /////////////////////////////////
public ScopeInstanceImpl getParentVariableScope() {
@@ -961,8 +955,33 @@
protected TransitionImpl findDefaultTransition() {
return activity.findDefaultTransition();
}
+
+ // history //////////////////////////////////////////////////////////////////
+ public void historyAutomatic() {
+ fireHistoryEvent(new AutomaticEnd());
+ }
+
+ public void historyExclusive(String transitionName) {
+ fireHistoryEvent(new ExclusiveEnd(transitionName));
+ }
+ public void historyActivityStart() {
+ fireHistoryEvent(new ActivityStart());
+ }
+
+ public void historyActivityEnd() {
+ fireHistoryEvent(new ActivityEnd());
+ }
+
+ public void historyTaskStart(String assignee) {
+ fireHistoryEvent(new TaskStart(assignee));
+ }
+
+ public void historyTaskEnd(String outcome) {
+ fireHistoryEvent(new TaskEnd(outcome));
+ }
+
// extensions ///////////////////////////////////////////////////////////////
public <T> T getExtension(Class<T> extensionClass) {
@@ -1049,18 +1068,6 @@
public void setTransitionOrigin(ActivityImpl transitionOrigin) {
this.transitionOrigin = transitionOrigin;
}
- public Exception getException() {
- return exception;
- }
- public void setException(Exception exception) {
- this.exception = exception;
- }
- public ProcessModificationsImpl getProcessModifications() {
- return processModifications;
- }
- public void setProcessModifications(ProcessModificationsImpl processModifications) {
- this.processModifications = processModifications;
- }
public String getKey() {
return key;
}
@@ -1118,4 +1125,16 @@
public void setId(String id) {
this.id = id;
}
+ public Long getHistoryActivityInstanceDbid() {
+ return historyActivityInstanceDbid;
+ }
+ public void setHistoryActivityInstanceDbid(Long historyActivityInstanceDbid) {
+ this.historyActivityInstanceDbid = historyActivityInstanceDbid;
+ }
+ public Date getHistoryActivityStart() {
+ return historyActivityStart;
+ }
+ public void setHistoryActivityStart(Date historyActivityStart) {
+ this.historyActivityStart = historyActivityStart;
+ }
}
Copied:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
(from rev 3816,
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceStoppedSynchronization.java)
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,64 @@
+/*
+ * 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.model;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+import org.hibernate.Session;
+import org.jbpm.ExecutionService;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.session.PvmDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessInstanceEndedSynchronization implements Synchronization,
Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ String processInstanceId;
+ CommandService commandService;
+
+ public ProcessInstanceEndedSynchronization(String processInstanceId, CommandService
commandService) {
+ this.processInstanceId = processInstanceId;
+ this.commandService = commandService;
+ }
+
+ public void afterCompletion(int status) {
+ if (status==Status.STATUS_COMMITTED) {
+ commandService.execute(this);
+ }
+ }
+
+ public void beforeCompletion() {
+ }
+
+ public Void execute(Environment environment) {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ pvmDbSession.deleteProcessInstance(processInstanceId, false);
+ return null;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceEndedSynchronization.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceStoppedSynchronization.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceStoppedSynchronization.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessInstanceStoppedSynchronization.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.model;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-import org.jbpm.ExecutionService;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ProcessInstanceStoppedSynchronization implements Synchronization {
-
- String processInstanceId;
- ExecutionService executionService;
-
- public ProcessInstanceStoppedSynchronization(String processInstanceId, ExecutionService
executionService) {
- this.processInstanceId = processInstanceId;
- this.executionService = executionService;
- }
-
- public void afterCompletion(int status) {
- if (status==Status.STATUS_COMMITTED) {
- executionService.deleteProcessInstance(processInstanceId);
- }
- }
-
- public void beforeCompletion() {
- }
-}
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -27,6 +27,7 @@
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl.Propagation;
+import org.jbpm.pvm.internal.util.Clock;
public class ExecuteActivity implements AtomicOperation {
@@ -51,7 +52,8 @@
try {
execution.setPropagation(Propagation.UNSPECIFIED);
-
+ execution.setHistoryActivityStart(Clock.getCurrentTime());
+
activityBehaviour.execute(execution);
} catch (Exception e) {
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
(rev 0)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -0,0 +1,85 @@
+/*
+ * 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.query;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.jbpm.HistoryProcessInstanceQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryProcessInstanceQueryImpl extends AbstractQuery implements
HistoryProcessInstanceQuery {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionId;
+
+ public HistoryProcessInstanceQueryImpl(CommandService commandService) {
+ super(commandService);
+ }
+
+ public String hql() {
+ StringBuffer hql = new StringBuffer();
+ hql.append("select hpi ");
+ hql.append("from ");
+ hql.append(HistoryProcessInstanceImpl.class.getName());
+ hql.append(" as hpi ");
+
+ if (processDefinitionId!=null) {
+ appendWhereClause(" hpi.processDefinition.id =
'"+processDefinitionId+"' ", hql);
+ }
+
+ return hql.toString();
+ }
+
+ protected void applyParameters(Query query) {
+ }
+
+ public List<org.jbpm.history.HistoryProcessInstance> execute() {
+ return (List) commandService.execute(this);
+ }
+
+ public HistoryProcessInstanceQuery orderAsc(String property) {
+ addOrderByClause("hpi."+property+" asc");
+ return this;
+ }
+
+ public HistoryProcessInstanceQuery orderDesc(String property) {
+ addOrderByClause("hpi."+property+" asc");
+ return this;
+ }
+
+ public HistoryProcessInstanceQuery page(int firstResult, int maxResults) {
+ this.page = new Page(firstResult, maxResults);
+ return this;
+ }
+
+ public HistoryProcessInstanceQuery processDefinitionId(String processDefinitionId) {
+ this.processDefinitionId = processDefinitionId;
+ return this;
+ }
+}
Property changes on:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/query/HistoryProcessInstanceQueryImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
---
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -29,6 +29,7 @@
import org.jbpm.Execution;
import org.jbpm.ExecutionQuery;
import org.jbpm.ExecutionService;
+import org.jbpm.HistoryProcessInstanceQuery;
import org.jbpm.cmd.CommandService;
import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
@@ -40,6 +41,7 @@
import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
import org.jbpm.pvm.internal.cmd.StartExecutionInLatestCmd;
import org.jbpm.pvm.internal.query.ExecutionQueryImpl;
+import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
/**
@@ -170,4 +172,8 @@
cmd.setVariables(variables);
return commandService.execute(cmd);
}
+
+ public HistoryProcessInstanceQuery createHistoryProcessInstanceQuery() {
+ return new HistoryProcessInstanceQueryImpl(commandService);
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml 2009-02-12
13:51:43 UTC (rev 3852)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.execution.hbm.xml 2009-02-12
14:14:00 UTC (rev 3853)
@@ -44,7 +44,7 @@
<property name="state" column="STATE_" />
<property name="priority" column="PRIORITY_" />
- <property name="nextLogIndex" column="NEXTLOGIDX_" />
+ <property name="historyActivityInstanceDbid"
column="HISACTINST_" />
<many-to-one name="processDefinition"
class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl"
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml 2009-02-12
13:51:43 UTC (rev 3852)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.pvm.history.hbm.xml 2009-02-12
14:14:00 UTC (rev 3853)
@@ -4,7 +4,7 @@
<hibernate-mapping package="org.jbpm.pvm.internal.history.model"
default-access="field">
<!-- ### HISTORY PROCESS INSTANCE ####################################### -->
- <class name="HistoryProcessInstance"
table="JBPM_HIST_PROC_INST">
+ <class name="HistoryProcessInstanceImpl"
table="JBPM_HIST_PROCINST">
<id name="id" column="ID_">
<generator class="assigned" />
</id>
@@ -17,18 +17,56 @@
<many-to-one name="processDefinition"
class="org.jbpm.pvm.internal.model.ProcessDefinitionImpl"
- column="PROCDEF_"
- foreign-key="FK_HPI_PROCDEF"
- index="IDX_HPI_PROCDEF" />
+ column="PROCESS_"
+ foreign-key="FK_HISTPI_PROCDEF"
+ index="IDX_HISTPI_PROCDEF" />
+
+ <set name="historyActivityInstances"
+ cascade="all">
+ <key>
+ <column name="HPI_" />
+ </key>
+ <one-to-many class="HistoryActivityInstanceImpl" />
+ </set>
+
</class>
- <query name="findHistoryProcessInstanceIds">
- <![CDATA[
- select historyExecution.id
- from org.jbpm.pvm.internal.history.model.HistoryProcessInstance historyExecution
- where historyExecution.processDefinition.id = :processDefinitionId
- ]]>
- </query>
-
+ <!-- ### HISTORY PROCESS INSTANCE ####################################### -->
+ <class name="HistoryActivityInstanceImpl"
table="JBPM_HIST_ACTINST" discriminator-value="ACT">
+ <id name="dbid" column="DBID_">
+ <generator class="native" />
+ </id>
+ <discriminator column="CLASS_" />
+ <version name="dbversion" column="DBVERSION_" />
+ <many-to-one name="historyProcessInstance"
+ class="HistoryProcessInstanceImpl"
+ column="HPI_"
+ foreign-key="FK_HAI_HPI"
+ index="IDX_HAI_HPI" />
+
+ <many-to-one name="activity"
+ class="org.jbpm.pvm.internal.model.ActivityImpl"
+ column="ACTIVITY_"
+ foreign-key="FK_HISTAI_ACT"
+ index="IDX_HISTAI_ACT" />
+
+ <property name="executionId" column="EXECUTION_" />
+ <property name="activityName" column="ACTIVITY_NAME_" />
+ <property name="startTime" column="START_"
type="timestamp" />
+ <property name="endTime" column="END_"
type="timestamp" />
+ <property name="duration" column="DURATION_" />
+
+ <subclass name="HistoryAutomaticInstanceImpl"
discriminator-value="AUT">
+ <subclass name="HistoryExclusiveInstanceImpl"
discriminator-value="EXCL">
+ <property name="transitionName" column="TRANSITION_"
/>
+ </subclass>
+ </subclass>
+
+ <subclass name="HistoryTaskInstanceImpl"
discriminator-value="TASK">
+ <property name="assignee" column="ASSIGNEE_" />
+ <property name="outcome" column="TRANSITION_" />
+ </subclass>
+ </class>
+
</hibernate-mapping>
\ No newline at end of file
Modified:
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 2009-02-12
13:51:43 UTC (rev 3852)
+++
jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java 2009-02-12
14:14:00 UTC (rev 3853)
@@ -21,6 +21,10 @@
*/
package org.jbpm.test.history;
+import java.util.List;
+
+import org.jbpm.HistoryProcessInstanceQuery;
+import org.jbpm.history.HistoryProcessInstance;
import org.jbpm.test.DbTestCase;
@@ -42,8 +46,14 @@
executionService.startExecutionByKey("ICL");
executionService.startExecutionByKey("ICL");
executionService.startExecutionByKey("ICL");
+
+ List<HistoryProcessInstance> historyProcessInstances = executionService
+ .createHistoryProcessInstanceQuery()
+ .processDefinitionId("ICL:1")
+ .orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME)
+ .execute();
-
+ assertEquals(3, historyProcessInstances.size());
}
}