[jbpm-commits] JBoss JBPM SVN: r5160 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/model and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jun 29 12:52:05 EDT 2009


Author: jbarrez
Date: 2009-06-29 12:52:04 -0400 (Mon, 29 Jun 2009)
New Revision: 5160

Added:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskPropertiesTest.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.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/task/TaskImpl.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
Log:
JBPM-2309: support for retrieval of current activity of a task (eg to display in an image): added executionId/activityName to Task interface.

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-06-29 15:24:27 UTC (rev 5159)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/Task.java	2009-06-29 16:52:04 UTC (rev 5160)
@@ -52,6 +52,10 @@
 
   int getPriority();
   void setPriority(int priority);
-
+  
+  String getExecutionId();
+  
+  String getActivityName();
+  
   String getFormResourceName();
 }
\ No newline at end of file

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-06-29 15:24:27 UTC (rev 5159)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-06-29 16:52:04 UTC (rev 5160)
@@ -715,6 +715,7 @@
     task.setExecution(this);
     task.setProcessInstance(processInstance);
     task.setSignalling(true);
+    task.setActivityName(getActivityName());
     
     // initialize the name
     if (taskDefinition.getName()!=null) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-06-29 15:24:27 UTC (rev 5159)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java	2009-06-29 16:52:04 UTC (rev 5160)
@@ -50,7 +50,6 @@
 import org.jbpm.pvm.internal.session.DbSession;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.pvm.internal.wire.WireContext;
 
 /**
  * is one task instance that can be assigned to an actor (read: put in someone's task list) and that
@@ -88,6 +87,13 @@
 
   protected ExecutionImpl execution;
   protected ExecutionImpl processInstance;
+  
+  // local storage of the execution id such that it
+  // can be lazily loaded when not needed.
+  protected String executionId;
+  
+  protected String activityName;
+  
   protected SwimlaneImpl swimlane;
 
   protected TaskImpl superTask;
@@ -485,8 +491,21 @@
 
   public void setExecution(ExecutionImpl execution) {
     this.execution = execution;
+    this.executionId = execution.getId();
   }
+  
+  public String getExecutionId() {
+    return executionId;
+  }
+  
+  public String getActivityName() {
+    return activityName;
+  }
 
+  public void setActivityName(String activityName) {
+    this.activityName = activityName;
+  }
+
   public void setSubTasks(Set<TaskImpl> subTasks) {
     this.subTasks = subTasks;
   }
@@ -514,4 +533,6 @@
   public void setFormResourceName(String form) {
     this.formResourceName = form;
   }
+
+  
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-06-29 15:24:27 UTC (rev 5159)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml	2009-06-29 16:52:04 UTC (rev 5160)
@@ -32,6 +32,9 @@
     <property name="progress" column="PROGRESS_"/>
     <property name="isSignalling" column="SIGNALLING_"/>
     
+    <property name="executionId" column="EXECUTION_ID_"/>
+    <property name="activityName" column="ACTIVITY_NAME_"/>
+    
     <property name="hasVariables" column="HASVARS_" />
     <map name="variables"
          cascade="all-delete-orphan">

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskPropertiesTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskPropertiesTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskPropertiesTest.java	2009-06-29 16:52:04 UTC (rev 5160)
@@ -0,0 +1,80 @@
+/*
+ * 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.task;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class TaskPropertiesTest extends JbpmTestCase {
+  
+  private static final String ACTOR = "johnDoe";
+  
+  private static final String ACTOR2 = "johnSmoe";
+  
+  private static final String PROCESS =
+    "<process name='VacationTrip'>" +
+    "  <start>" +
+    "    <transition to='f' />" +
+    "  </start>" +
+    "  <fork name='f'>" +
+    "    <transition to='select destination' />" +
+    "    <transition to='work hard for the money' />" +
+    "  </fork>" +
+    "  <task name='select destination' assignee='" + ACTOR + "'>" +
+    "    <transition to='wait' />" +
+    "  </task>" +
+    "  <task name='work hard for the money' assignee='" + ACTOR2 + "_not_the_same'>" +
+    "    <transition to='wait' />" +
+    "  </task>" +
+    "  <state name='wait'/>" +
+    "</process>";
+  
+  public void testGetActivityName() {
+    Task task = startProcessInstanceAndReturnTaskFor(ACTOR);
+    assertEquals("select destination", task.getActivityName()); 
+  }
+  
+  public void testGetProcessDefinitionThroughTask() {
+    Task task = startProcessInstanceAndReturnTaskFor(ACTOR);
+    
+    String pdId = executionService.findExecutionById(task.getExecutionId()).getProcessDefinitionId();
+    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
+                                                           .processDefinitionId(pdId)
+                                                           .uniqueResult();
+    assertEquals("VacationTrip", processDefinition.getName());   
+  }
+  
+  private Task startProcessInstanceAndReturnTaskFor(String actor) {
+    deployJpdlXmlString(PROCESS);
+    executionService.startProcessInstanceByKey("VacationTrip");
+    return taskService.findPersonalTasks(actor).get(0);
+  }
+
+}




More information about the jbpm-commits mailing list