[jbpm-commits] JBoss JBPM SVN: r3519 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/session and 14 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 23 04:46:40 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-23 04:46:39 -0500 (Tue, 23 Dec 2008)
New Revision: 3519
Added:
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTaskCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTaskCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTaskCmd.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SubmitTaskCmd.java
jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
Removed:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/TaskBuilder.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskBuilder.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTask.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskBuilderImpl.java
jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/DbSession.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.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/ProcessDefinitionImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
Log:
prepared task component for task activity
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -25,7 +25,6 @@
import org.jbpm.task.Role;
import org.jbpm.task.Task;
-import org.jbpm.task.TaskBuilder;
/**
* Human task management facility.
@@ -58,15 +57,6 @@
/** Removes the task with the given identifier from persistent storage. */
void deleteTask(String taskId);
- /** Provides a fluent interface for task configuration. The usage model is:
- * <pre>Task task = taskService.buildTask()
- * .name("expenses")
- * .dueDate(asap)
- * .assignedUserId(me)
- * .priority(HIGH)
- * .done();</pre> */
- TaskBuilder buildTask();
-
List<String> getCandidates(String taskId);
List<Role> getRoles(String taskId);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/DbSession.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/session/DbSession.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -28,6 +28,7 @@
public interface DbSession {
void save(Object entity);
+ void merge(Object entity);
<T> T get(Class<T> entityClass, Object primaryKey);
void delete(Object entity);
Deleted: jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/TaskBuilder.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/TaskBuilder.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/task/TaskBuilder.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,28 +0,0 @@
-package org.jbpm.task;
-
-import java.util.Date;
-
-import org.jbpm.TaskService;
-
-/**
- * Task builders are useful to create and configure human tasks through
- * a fluent interface. Refer to {@link TaskService#buildTask()} for the
- * usage model.
- * @author Alejandro Guizar
- */
-public interface TaskBuilder {
-
- TaskBuilder id(String id);
-
- TaskBuilder name(String name);
-
- TaskBuilder description(String description);
-
- TaskBuilder assignedUserId(String assignedUserId);
-
- TaskBuilder priority(int priority);
-
- TaskBuilder dueDate(Date dueDate);
-
- Task done();
-}
\ No newline at end of file
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/esb/EsbTest.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -51,7 +51,7 @@
MockRegistry.register("orderProcessing", "bookSold", epr, courier);
}
- public void testJavaInstantiate() {
+ public void testEsb() {
deployJpdlResource("org/jbpm/examples/esb/process.jpdl.xml");
Map<String, Object> variables = new HashMap<String, Object>();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernateDbSession.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -55,9 +55,13 @@
}
public void save(Object entity) {
- session.persist(entity);
+ session.save(entity);
}
+ public void merge(Object entity) {
+ session.merge(entity);
+ }
+
public void delete(Object entity) {
session.delete(entity);
}
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 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -189,9 +189,9 @@
this.state = STATE_CREATED;
this.key = key;
- IdGenerator keyGenerator = Environment.getFromCurrent(IdGenerator.class, false);
- if (keyGenerator!=null) {
- this.id = keyGenerator.createId(processDefinition, null, this);
+ IdGenerator idGenerator = processDefinition.getIdGenerator();
+ if (idGenerator!=null) {
+ this.id = idGenerator.createId(processDefinition, null, this);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -30,7 +30,9 @@
import org.jbpm.Execution;
import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.env.Environment;
import org.jbpm.log.Log;
+import org.jbpm.model.IdGenerator;
import org.jbpm.model.OpenProcessDefinition;
import org.jbpm.pvm.internal.lob.Blob;
import org.jbpm.pvm.internal.util.IoUtil;
@@ -115,6 +117,15 @@
return new ExecutionImpl();
}
+ /** by default, during initialization, an id will be generated when
+ * an IdGenerator is present in the environment. By default,
+ * this makes the execution persistent. So in case the process definition
+ * is not persistent and there is an environment present (like in the case
+ * of task lifecycle for jpdl processes), this method needs to be overwritten. */
+ public IdGenerator getIdGenerator() {
+ return Environment.getFromCurrent(IdGenerator.class, false);
+ }
+
// attachments //////////////////////////////////////////////////////////////
public void addAttachment(String name, InputStream inputStream) {
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,87 +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.task.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.session.DbSession;
-import org.jbpm.task.Task;
-import org.jbpm.task.internal.model.TaskDefinitionImpl;
-import org.jbpm.task.internal.model.TaskImpl;
-import org.jbpm.task.session.TaskDbSession;
-
-/**
- * @author Tom Baeyens
- */
-public class CreateTask implements Command<Task> {
-
- private static final long serialVersionUID = 1L;
-
- protected String taskId;
- protected Long taskDefinitionDbid;
- protected Long executionDbid;
-
- public CreateTask() {
- }
-
- public CreateTask(String taskId) {
- this.taskId = taskId;
- }
-
- public CreateTask(String taskId, long taskDefinitionDbid) {
- this.taskId = taskId;
- this.taskDefinitionDbid = taskDefinitionDbid;
- }
-
- public CreateTask(String taskId, long taskDefinitionDbid, long executionDbid) {
- this.taskId = taskId;
- this.taskDefinitionDbid = taskDefinitionDbid;
- this.executionDbid = executionDbid;
- }
-
- public Task execute(Environment environment) throws Exception {
- TaskDefinitionImpl taskDefinition = null;
- ExecutionImpl execution = null;
-
- if (taskDefinitionDbid!=null) {
- TaskDbSession dbSession = environment.get(TaskDbSession.class);
- taskDefinition = dbSession.get(TaskDefinitionImpl.class, taskDefinitionDbid);
- }
-
- if (executionDbid!=null) {
- DbSession dbSession = environment.get(DbSession.class);
- execution = dbSession.get(ExecutionImpl.class, executionDbid);
- }
-
- Task task = null;
- if (taskDefinition==null) {
- task = TaskImpl.create(taskId);
- } else if (execution==null) {
- task = TaskImpl.create(taskId, taskDefinition);
- } else {
- task = TaskImpl.create(taskId, taskDefinition, execution);
- }
-
- return task;
- }
-}
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskBuilder.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskBuilder.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskBuilder.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -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.task.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.TaskBuilder;
-import org.jbpm.task.internal.model.TaskBuilderImpl;
-import org.jbpm.task.internal.model.TaskImpl;
-
-/**
- * @author Alejandro Guizar
- */
-public class CreateTaskBuilder implements Command<TaskBuilder> {
-
- private static final long serialVersionUID = 1L;
-
- public TaskBuilder execute(Environment environment) throws Exception {
- return new TaskBuilderImpl(TaskImpl.create());
- }
-
-}
Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskCmd.java (from rev 3439, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/CreateTaskCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -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.task.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.session.DbSession;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.model.TaskDefinitionImpl;
+import org.jbpm.task.internal.model.TaskImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class CreateTaskCmd implements Command<Task> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String taskId;
+ protected Long taskDefinitionDbid;
+ protected Long executionDbid;
+
+ public CreateTaskCmd() {
+ }
+
+ public CreateTaskCmd(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public CreateTaskCmd(String taskId, long taskDefinitionDbid) {
+ this.taskId = taskId;
+ this.taskDefinitionDbid = taskDefinitionDbid;
+ }
+
+ public CreateTaskCmd(String taskId, long taskDefinitionDbid, long executionDbid) {
+ this.taskId = taskId;
+ this.taskDefinitionDbid = taskDefinitionDbid;
+ this.executionDbid = executionDbid;
+ }
+
+ public Task execute(Environment environment) throws Exception {
+ TaskDefinitionImpl taskDefinition = null;
+ ExecutionImpl execution = null;
+
+ Session session = environment.get(Session.class);
+
+ if (taskDefinitionDbid!=null) {
+ taskDefinition = (TaskDefinitionImpl) session.load(TaskDefinitionImpl.class, taskDefinitionDbid);
+ }
+
+ if (executionDbid!=null) {
+ execution = (ExecutionImpl) session.load(ExecutionImpl.class, executionDbid);
+ }
+
+ Task task = TaskImpl.create(taskId, taskDefinition, execution);
+
+ return task;
+ }
+}
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,49 +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.task.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.Task;
-import org.jbpm.task.session.TaskDbSession;
-
-/**
- * @author Alejandro Guizar
- */
-public class DeleteTask implements Command<Void> {
-
- private static final long serialVersionUID = 1L;
-
- protected String taskId;
-
- public DeleteTask(String taskId) {
- this.taskId = taskId;
- }
-
- public Void execute(Environment environment) throws Exception {
- TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
- Task task = taskDbSession.getTask(taskId);
- taskDbSession.delete(task);
- return null;
- }
-
-}
Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTaskCmd.java (from rev 3439, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTaskCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/DeleteTaskCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -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.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.Task;
+import org.jbpm.task.session.TaskDbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class DeleteTaskCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String taskId;
+
+ public DeleteTaskCmd(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+ Task task = taskDbSession.findTaskById(taskId);
+ taskDbSession.delete(task);
+ return null;
+ }
+
+}
Added: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -0,0 +1,53 @@
+/*
+ * 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.task.internal.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.Task;
+import org.jbpm.task.session.TaskDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class GetPersonalTaskListCmd implements Command<List<Task>> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String userId;
+ protected int firstResult;
+ protected int maxResults;
+
+ public GetPersonalTaskListCmd(String userId, int firstResult, int maxResults) {
+ this.userId = userId;
+ this.firstResult = firstResult;
+ this.maxResults = maxResults;
+ }
+
+ public List<Task> execute(Environment environment) {
+ TaskDbSession taskDbession = environment.get(TaskDbSession.class);
+ return taskDbession.findPersonalTasks(userId, firstResult, maxResults);
+ }
+}
Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetPersonalTaskListCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,45 +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.task.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.Task;
-import org.jbpm.task.session.TaskDbSession;
-
-/**
- * @author Alejandro Guizar
- */
-public class GetTask implements Command<Task> {
-
- private static final long serialVersionUID = 1L;
-
- protected String taskId;
-
- public GetTask(String taskId) {
- this.taskId = taskId;
- }
-
- public Task execute(Environment environment) throws Exception {
- return environment.get(TaskDbSession.class).getTask(taskId);
- }
-}
Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTaskCmd.java (from rev 3439, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTaskCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/GetTaskCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -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.task.internal.cmd;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.Task;
+import org.jbpm.task.session.TaskDbSession;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class GetTaskCmd implements Command<Task> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String taskId;
+
+ public GetTaskCmd(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public Task execute(Environment environment) throws Exception {
+ TaskDbSession taskDbSession = environment.get(TaskDbSession.class);
+ return taskDbSession.findTaskById(taskId);
+ }
+}
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTask.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTask.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTask.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,47 +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.task.internal.cmd;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.task.Task;
-import org.jbpm.task.session.TaskDbSession;
-
-/**
- * @author Alejandro Guizar
- */
-public class SaveTask implements Command<Void> {
-
- private static final long serialVersionUID = 1L;
-
- protected Task task;
-
- public SaveTask(Task task) {
- this.task = task;
- }
-
- public Void execute(Environment environment) throws Exception {
- environment.get(TaskDbSession.class).saveTask(task);
- return null;
- }
-
-}
Copied: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTaskCmd.java (from rev 3439, jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTask.java)
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTaskCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SaveTaskCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -0,0 +1,59 @@
+/*
+ * 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.task.internal.cmd;
+
+import java.io.Serializable;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.internal.model.TaskImpl;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class SaveTaskCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected TaskImpl task;
+
+ public SaveTaskCmd(TaskImpl task) {
+ this.task = task;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+
+ if (! task.isPersisted()) {
+ Serializable dbid = session.save(task);
+ if (task.getId() == null) {
+ task.setId(dbid.toString());
+ }
+
+ } else {
+ session.update(task);
+ }
+
+ return null;
+ }
+}
Added: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SubmitTaskCmd.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SubmitTaskCmd.java (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SubmitTaskCmd.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -0,0 +1,60 @@
+/*
+ * 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.task.internal.cmd;
+
+import org.hibernate.Session;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.internal.model.TaskImpl;
+import org.jbpm.task.session.TaskDbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubmitTaskCmd implements Command<Void> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String taskId;
+ protected TaskImpl task;
+
+ public SubmitTaskCmd(TaskImpl task) {
+ this.task = task;
+ }
+
+ public SubmitTaskCmd(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ TaskDbSession taskDbession = environment.get(TaskDbSession.class);
+ if (task!=null) {
+ taskDbession.merge(task);
+ } else {
+ task = taskDbession.findTaskById(taskId);
+ }
+ task.submit();
+ taskDbession.delete(task);
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/SubmitTaskCmd.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/hibernate/HibernateTaskDbSession.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -22,6 +22,7 @@
package org.jbpm.task.internal.hibernate;
import java.io.Serializable;
+import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.jbpm.pvm.internal.hibernate.HibernateDbSession;
@@ -32,22 +33,23 @@
/**
* @author Alejandro Guizar
*/
-public class HibernateTaskDbSession extends HibernateDbSession implements
- TaskDbSession {
+public class HibernateTaskDbSession extends HibernateDbSession implements TaskDbSession {
- public Task getTask(String taskId) {
- return (Task) session.createCriteria(TaskImpl.class)
- .add(Restrictions.eq("id", taskId))
- .uniqueResult();
+ public TaskImpl findTaskById(String taskId) {
+ // TODO maybe we should move these criteria queries to hql queries in the
+ // hbm file so that users can easily customize.
+ return (TaskImpl) session.createCriteria(TaskImpl.class)
+ .add(Restrictions.eq("id", taskId))
+ .uniqueResult();
}
- public void saveTask(Task task) {
- if (task.getId() == null) {
- Serializable dbid = session.save(task);
- ((TaskImpl) task).setId(dbid.toString());
- }
- else {
- session.saveOrUpdate(task);
- }
+ public List<Task> findPersonalTasks(String userId, int firstResult, int maxResults) {
+ // TODO maybe we should move these criteria queries to hql queries in the
+ // hbm file so that users can easily customize.
+ return session.createCriteria(TaskImpl.class)
+ .add(Restrictions.eq("assignedUserId", userId))
+ .setFirstResult(firstResult)
+ .setMaxResults(maxResults)
+ .list();
}
}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycle.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -25,6 +25,7 @@
import java.util.Map;
import org.jbpm.client.ClientProcessInstance;
+import org.jbpm.model.IdGenerator;
import org.jbpm.model.Node;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.NodeImpl;
@@ -34,8 +35,9 @@
/**
* @author Tom Baeyens
*/
-public class LifeCycle {
+public class LifeCycle extends ProcessDefinitionImpl {
+ private static final long serialVersionUID = 1L;
private static LifeCycleParser lifeCycleParser = new LifeCycleParser();
private static Map<String, ProcessDefinitionImpl> lifeCycleProcesses = new HashMap<String, ProcessDefinitionImpl>();
@@ -73,7 +75,7 @@
return lifeCycleProcess;
}
- protected void fireLifeCycleEvent(String eventName, TaskImpl task) {
+ protected static void fireLifeCycleEvent(String eventName, TaskImpl task) {
ExecutionImpl lifeCycleExecution = new ExecutionImpl();
ProcessDefinitionImpl lifeCycleProcess = getLifeCycle(task);
lifeCycleExecution.setProcessDefinition(lifeCycleProcess);
@@ -84,4 +86,11 @@
task.state = lifeCycleExecution.getNode().getName();
}
+ public IdGenerator getIdGenerator() {
+ // overrides the default ProcessDefinitionImpl behaviour that will end up
+ // in the execution being persisted
+ return null;
+ }
+
+
}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/LifeCycleParser.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -36,7 +36,7 @@
public class LifeCycleParser extends Parser {
public Object parseDocumentElement(Element element, Parse parse) {
- ProcessDefinitionImpl lifeCycleProcess = new ProcessDefinitionImpl();
+ ProcessDefinitionImpl lifeCycleProcess = new LifeCycle();
List<Element> stateElements = XmlUtil.elements(element, "state");
for (Element stateElement: stateElements) {
Deleted: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskBuilderImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskBuilderImpl.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskBuilderImpl.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,73 +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.task.internal.model;
-
-import java.util.Date;
-
-import org.jbpm.task.Task;
-import org.jbpm.task.TaskBuilder;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskBuilderImpl implements TaskBuilder {
-
- private final TaskImpl task;
-
- public TaskBuilderImpl(TaskImpl task) {
- this.task = task;
- }
-
- public TaskBuilder id(String id) {
- task.setId(id);
- return this;
- }
-
- public TaskBuilder name(String name) {
- task.setName(name);
- return this;
- }
-
- public TaskBuilder description(String description) {
- task.setDescription(description);
- return this;
- }
-
- public TaskBuilder assignedUserId(String assignedUserId) {
- task.setAssignedUserId(assignedUserId);
- return this;
- }
-
- public TaskBuilder priority(int priority) {
- task.setPriority(priority);
- return this;
- }
-
- public TaskBuilder dueDate(Date dueDate) {
- task.setDueDate(dueDate);
- return this;
- }
-
- public Task done() {
- return task;
- }
-}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskImpl.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -27,11 +27,9 @@
import java.util.Date;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.jbpm.Execution;
-import org.jbpm.env.Environment;
import org.jbpm.model.Comment;
import org.jbpm.pvm.internal.cal.Duration;
import org.jbpm.pvm.internal.model.CommentImpl;
@@ -40,7 +38,6 @@
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.task.Role;
import org.jbpm.task.Swimlane;
import org.jbpm.task.Task;
@@ -57,12 +54,6 @@
private static final long serialVersionUID = 1L;
// private static final Logger log = Logger.getLogger(TaskImpl.class.getName());
- // could be made configurable:
- public static final String CONTEXTKEY_TASK_CLASS_NAME = "taskClassName";
- public static final String[] SEARCHORDER_TASK_CLASS_NAME = new String[]{
- // PvmEnvironment.CONTEXTNAME_APPLICATION
- };
-
protected String id;
protected String name;
protected String description;
@@ -109,8 +100,9 @@
}
public static TaskImpl create(String taskId, TaskDefinitionImpl taskDefinition, ExecutionImpl execution) {
- TaskImpl task = null;
+ TaskImpl task = new TaskImpl();
+ /*
// if a task class name is configured
Environment environment = Environment.getCurrent();
String taskClassName = environment!=null ? (String) environment.get(TaskImpl.CONTEXTKEY_TASK_CLASS_NAME, TaskImpl.SEARCHORDER_TASK_CLASS_NAME) : null;
@@ -124,6 +116,7 @@
else {
task = new TaskImpl();
}
+ */
task.setCreate(Clock.getCurrentTime());
@@ -212,10 +205,20 @@
// completion ///////////////////////////////////////////////////////////////
public void submit() {
- submit(null);
+ if (execution!=null) {
+ // the outcome is dynamically calculated based on e.g. a
+ // variable or a decision table on a variable. an
+ // interface OutcomeEvaluator for user defined outcome calculation
+ // could be envisioned.
+ String outcome = evaluateOutcome();
+ // the outcome serves as the signal given to the execution.
+ execution.signal(outcome);
+ }
}
- public void submit(Map<String, Object> variables) {
+ public String evaluateOutcome() {
+ // for now, only the default signal can be given.
+ return null;
}
// comments /////////////////////////////////////////////////////////////////
@@ -317,109 +320,97 @@
}
this.progress = progress;
}
-
+
+ public boolean isPersisted() {
+ return dbid!=0;
+ }
+
// getters and setters //////////////////////////////////////////////////////
public long getDbid() {
return dbid;
}
-
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
-
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
-
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
-
public boolean isBlocking() {
return isBlocking;
}
public void setBlocking(boolean isBlocking) {
this.isBlocking = isBlocking;
}
-
public boolean isSignalling() {
return isSignalling;
}
public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
-
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
-
public void setComments(List<CommentImpl> comments) {
this.comments = comments;
}
-
public Date getCreate() {
return create;
}
public void setCreate(Date create) {
this.create = create;
}
-
public Date getDueDate() {
return dueDate;
}
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
-
public ExecutionImpl getExecution() {
return execution;
}
public void setExecution(Execution execution) {
this.execution = (ExecutionImpl) execution;
}
-
public String getState() {
return state;
}
-
public String getAssignedUserId() {
return assignedUserId;
}
public void setAssignedUserId(String assignedUserId) {
this.assignedUserId = assignedUserId;
}
-
public Swimlane getSwimlane() {
return swimlane;
}
public void setSwimlane(SwimlaneImpl swimlane) {
this.swimlane = swimlane;
}
-
public TaskDefinition getTaskDefinition() {
return taskDefinition;
}
-
public TaskImpl getSuperTask() {
return superTask;
}
public void setSuperTask(TaskImpl superTask) {
this.superTask = superTask;
}
-
public Integer getProgress() {
return progress;
}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -27,82 +27,76 @@
import org.jbpm.cmd.CommandService;
import org.jbpm.task.Role;
import org.jbpm.task.Task;
-import org.jbpm.task.TaskBuilder;
-import org.jbpm.task.internal.cmd.CreateTask;
-import org.jbpm.task.internal.cmd.CreateTaskBuilder;
-import org.jbpm.task.internal.cmd.DeleteTask;
-import org.jbpm.task.internal.cmd.GetTask;
-import org.jbpm.task.internal.cmd.SaveTask;
+import org.jbpm.task.internal.cmd.CreateTaskCmd;
+import org.jbpm.task.internal.cmd.DeleteTaskCmd;
+import org.jbpm.task.internal.cmd.GetPersonalTaskListCmd;
+import org.jbpm.task.internal.cmd.GetTaskCmd;
+import org.jbpm.task.internal.cmd.SaveTaskCmd;
+import org.jbpm.task.internal.cmd.SubmitTaskCmd;
/**
* @author Alejandro Guizar
*/
public class TaskServiceImpl implements TaskService {
- protected CommandService commandService;
+ protected CommandService commandService;
- public TaskServiceImpl() {
- }
+ public TaskServiceImpl() {
+ }
- public TaskServiceImpl(CommandService commandService) {
- this.commandService = commandService;
- }
+ public TaskServiceImpl(CommandService commandService) {
+ this.commandService = commandService;
+ }
- public CommandService getCommandService() {
- return commandService;
- }
+ public CommandService getCommandService() {
+ return commandService;
+ }
- public void setCommandService(CommandService commandService) {
- this.commandService = commandService;
- }
+ public void setCommandService(CommandService commandService) {
+ this.commandService = commandService;
+ }
- public Task newTask() {
+ public Task newTask() {
return newTask(null);
}
public Task newTask(String taskId) {
- return commandService.execute(new CreateTask(taskId));
- }
+ return commandService.execute(new CreateTaskCmd(taskId));
+ }
- public Task getTask(String taskId) {
- return commandService.execute(new GetTask(taskId));
- }
+ public Task getTask(String taskId) {
+ return commandService.execute(new GetTaskCmd(taskId));
+ }
- public void saveTask(Task task) {
- commandService.execute(new SaveTask(task));
- }
+ public void saveTask(Task task) {
+ commandService.execute(new SaveTaskCmd((TaskImpl) task));
+ }
- public void submitTask(String taskId) {
- // TODO Auto-generated method stub
- }
+ public void deleteTask(String taskId) {
+ commandService.execute(new DeleteTaskCmd(taskId));
+ }
- public void deleteTask(String taskId) {
- commandService.execute(new DeleteTask(taskId));
- }
+ public void submitTask(String taskId) {
+ commandService.execute(new SubmitTaskCmd(taskId));
+ }
- public TaskBuilder buildTask() {
- return commandService.execute(new CreateTaskBuilder());
+ public void submitTask(Task task) {
+ commandService.execute(new SubmitTaskCmd((TaskImpl)task));
}
public List<String> getCandidates(String taskId) {
- // TODO Auto-generated method stub
- return null;
- }
+ return null;
+ }
- public List<Role> getRoles(String taskId) {
- // TODO Auto-generated method stub
- return null;
- }
+ public List<Role> getRoles(String taskId) {
+ return null;
+ }
- public List<Task> getPersonalTaskList(String userId, int firstResult,
- int maxResults) {
- // TODO Auto-generated method stub
- return null;
- }
+ public List<Task> getPersonalTaskList(String userId, int firstResult, int maxResults) {
+ return commandService.execute(new GetPersonalTaskListCmd(userId, firstResult, maxResults));
+ }
- public List<Task> getGroupTaskList(String userId, int firstResult,
- int maxResults) {
- // TODO Auto-generated method stub
- return null;
- }
+ public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
+ return null;
+ }
}
Modified: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/session/TaskDbSession.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -21,8 +21,11 @@
*/
package org.jbpm.task.session;
+import java.util.List;
+
import org.jbpm.session.DbSession;
import org.jbpm.task.Task;
+import org.jbpm.task.internal.model.TaskImpl;
/**
* Persistence interface for tasks.
@@ -30,7 +33,7 @@
*/
public interface TaskDbSession extends DbSession {
- Task getTask(String taskId);
+ TaskImpl findTaskById(String taskId);
- void saveTask(Task task);
+ List<Task> findPersonalTasks(String userId, int firstResult, int maxResults);
}
Deleted: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -1,105 +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.task;
-
-import java.util.Date;
-
-import org.jbpm.pvm.internal.util.Priority;
-import org.jbpm.test.DbTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskServiceTest extends DbTestCase {
-
- public void testNewTask() {
- String taskId = getName();
- Task task = taskService.newTask(taskId);
- assertEquals(taskId, task.getId());
- // new task is transient
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-
- public void testGenerateTaskId() {
- Task task = taskService.newTask();
- String taskId = task.getId();
- assertNull("expected null, but was " + taskId, taskId);
- // save task to generate identifier
- saveTask(task);
- assertNotNull("expected non-null task id", task.getId());
- }
-
- public void testSaveTask() {
- String taskId = getName();
- Task task = taskService.newTask(taskId);
- saveTask(task);
- // task was made persistent
- task = taskService.getTask(taskId);
- assertNotNull("expected non-null task", task);
- // make some change
- Date dueDate = new Date();
- task.setDueDate(dueDate);
- taskService.saveTask(task);
- // verify change is applied
- task = taskService.getTask(taskId);
- assertEquals(dueDate, task.getDueDate());
- }
-
- public void testGetTask() {
- String taskId = getName();
- // ensure task does not exist
- Task task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- // create task and verify it exists
- task = taskService.newTask(taskId);
- saveTask(task);
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- }
-
- public void testDeleteTask() {
- String taskId = getName();
- Task task = taskService.newTask(taskId);
- taskService.saveTask(task);
- // task was made persistent
- assertNotNull("expected non-null task", taskService.getTask(taskId));
- // delete task and verify it does not exist
- taskService.deleteTask(taskId);
- task = taskService.getTask(taskId);
- assertNull("expected null, but was " + task, task);
- }
-
- public void testBuildTask() {
- Date asap = new Date();
- String me = System.getProperty("user.name");
- Task task = taskService.buildTask()
- .name("expenses")
- .dueDate(asap)
- .assignedUserId(me)
- .priority(Priority.HIGH)
- .done();
- assertEquals("expenses", task.getName());
- assertEquals(asap, task.getDueDate());
- assertEquals(me, task.getAssignedUserId());
- assertEquals(Priority.HIGH, task.getPriority());
- }
-}
Added: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
===================================================================
--- jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java (rev 0)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -0,0 +1,57 @@
+/*
+ * 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.task.internal.model;
+
+import java.util.List;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskActivityScenarioTest extends DbTestCase {
+
+ public void testDefaultScenario() {
+ // execution arrives in task node
+ // the task id is generated from the executionId and the task name
+ String taskId = "t28346";
+ Task task = taskService.newTask(taskId);
+ task.setName("do laundry");
+ task.setAssignedUserId("johndoe");
+ taskService.saveTask(task);
+
+
+ List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+ assertEquals("expected 1 task for john doe: "+taskList, 1, taskList.size());
+
+ task = taskList.get(0);
+ assertEquals("johndoe", task.getAssignedUserId());
+ assertEquals("t28346", task.getId());
+ assertEquals("do laundry", task.getName());
+
+ taskService.submitTask("t28346");
+
+ assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
+ }
+}
Property changes on: jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -51,7 +51,7 @@
protected TaskService taskService;
protected List<ProcessDefinition> processDefinitions;
- protected List<Task> tasks;
+ protected List<String> taskIds;
protected void setUp() throws Exception {
super.setUp();
@@ -86,9 +86,9 @@
}
}
- if (tasks != null) {
- for (Task task : tasks) {
- taskService.deleteTask(task.getId());
+ if (taskIds != null) {
+ for (String taskId : taskIds) {
+ taskService.deleteTask(taskId);
}
}
@@ -142,12 +142,12 @@
}
public void saveTask(Task task) {
- if (tasks == null) {
- tasks = new ArrayList<Task>();
+ taskService.saveTask(task);
+
+ if (taskIds == null) {
+ taskIds = new ArrayList<String>();
}
- tasks.add(task);
-
- taskService.saveTask(task);
+ taskIds.add(task.getId());
}
public HashSet<String> getNodeNames(String processInstanceId) {
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -69,7 +69,7 @@
super.runTest();
} catch (AssertionFailedError e) {
log.error("");
- log.error("ASSERTION FAILURE: "+e.getMessage());
+ log.error("ASSERTION FAILURE: "+e.getMessage(), e);
log.error("");
throw e;
} catch (Throwable t) {
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/test-db/pom.xml 2008-12-23 09:46:39 UTC (rev 3519)
@@ -45,7 +45,13 @@
<version>${version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-task</artifactId>
+ <version>${version}</version>
+ </dependency>
+
<!-- TODO remove PVM dependency for compilation (keep it for test)-->
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java (from rev 3439, jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java 2008-12-23 09:46:39 UTC (rev 3519)
@@ -0,0 +1,90 @@
+/*
+ * 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.svc;
+
+import java.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceTest extends DbTestCase {
+
+ public void testNewTask() {
+ String taskId = getName();
+ Task task = taskService.newTask(taskId);
+ assertEquals(taskId, task.getId());
+ // new task is transient
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+
+ public void testGenerateTaskId() {
+ Task task = taskService.newTask();
+ String taskId = task.getId();
+ assertNull("expected null, but was " + taskId, taskId);
+ // save task to generate identifier
+ saveTask(task);
+ assertNotNull("expected non-null task id", task.getId());
+ }
+
+ public void testSaveTask() {
+ String taskId = getName();
+ Task task = taskService.newTask(taskId);
+ saveTask(task);
+ // task was made persistent
+ task = taskService.getTask(taskId);
+ assertNotNull("expected non-null task", task);
+ // make some change
+ Date dueDate = new Date();
+ task.setDueDate(dueDate);
+ taskService.saveTask(task);
+ // verify change is applied
+ task = taskService.getTask(taskId);
+ assertEquals(dueDate, task.getDueDate());
+ }
+
+ public void testGetTask() {
+ String taskId = getName();
+ // ensure task does not exist
+ Task task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ // create task and verify it exists
+ task = taskService.newTask(taskId);
+ saveTask(task);
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ }
+
+ public void testDeleteTask() {
+ String taskId = getName();
+ Task task = taskService.newTask(taskId);
+ taskService.saveTask(task);
+ // task was made persistent
+ assertNotNull("expected non-null task", taskService.getTask(taskId));
+ // delete task and verify it does not exist
+ taskService.deleteTask(taskId);
+ task = taskService.getTask(taskId);
+ assertNull("expected null, but was " + task, task);
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/TaskServiceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-23 09:27:51 UTC (rev 3518)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.cfg.xml 2008-12-23 09:46:39 UTC (rev 3519)
@@ -17,6 +17,7 @@
<process-service />
<execution-service />
<management-service />
+ <task-service />
<command-service>
<retry-interceptor />
@@ -33,6 +34,7 @@
<mapping resource="jbpm.pvm.variable.hbm.xml" />
<mapping resource="jbpm.pvm.job.hbm.xml" />
<mapping resource="jbpm.jpdl.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
<cache-configuration resource="jbpm.pvm.cache.xml"
usage="nonstrict-read-write" />
</hibernate-configuration>
@@ -68,6 +70,7 @@
<transaction />
<pvm-db-session />
<job-db-session />
+ <task-db-session />
<message-session />
<timer-session />
</environment>
More information about the jbpm-commits
mailing list