[jbpm-commits] JBoss JBPM SVN: r3701 - in jbpm4/trunk/modules: task/src/main/java/org/jbpm/task/internal/cmd and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jan 22 10:17:25 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-01-22 10:17:25 -0500 (Thu, 22 Jan 2009)
New Revision: 3701

Added:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java
Removed:
   jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java
   jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
   jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java
Log:
started thinking about task queries

Added: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java	                        (rev 0)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -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.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface TaskQuery {
+  
+  public static final String ASSIGNEE = "assignee";
+  public static final String CREATEDATE = "create-date";
+  public static final String DUEDATE = "due-date";
+  public static final String PRIORITY = "priority";
+
+  TaskQuery assignee(String assignee);
+  
+  TaskQuery page(int firstResult, int maxResults);
+  TaskQuery orderAsc(String property);
+  TaskQuery orderDesc(String property);
+  
+  List<Task> execute();
+}


Property changes on: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskQuery.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java	2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/TaskService.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -54,6 +54,8 @@
 
   List<String> getCandidates(String taskId);
   List<Role> getRoles(String taskId);
+  
+  TaskQuery createTaskQuery();
 
   /** retrieves the personal task of the given user, which might be different 
    * then the current authenticated user.  E.g. when a manager wants to 

Added: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -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.task.internal.cmd;
+
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.task.Task;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HqlQueryCmd implements Command<List<Task>> {
+  
+  public List<Task> execute(Environment environment) throws Exception {
+    return null;
+  }
+
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/cmd/HqlQueryCmd.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
===================================================================
--- jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java	                        (rev 0)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,66 @@
+/*
+ * 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.TaskQuery;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.task.Task;
+import org.jbpm.task.internal.cmd.HqlQueryCmd;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryImpl implements TaskQuery {
+  
+  protected CommandService commandService;
+  
+  protected String assignee = null;
+
+  public TaskQueryImpl(CommandService commandService) {
+    this.commandService = commandService;
+  }
+
+  public TaskQuery assignee(String assignee) {
+    this.assignee = assignee;
+    return this;
+  }
+
+  public TaskQuery orderAsc(String property) {
+    return null;
+  }
+
+  public TaskQuery orderDesc(String property) {
+    return null;
+  }
+
+  public TaskQuery page(int firstResult, int maxResults) {
+    return null;
+  }
+
+  public List<Task> execute() {
+    // TODO
+    return commandService.execute(null);
+  }
+}


Property changes on: jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskQueryImpl.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

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	2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/task/src/main/java/org/jbpm/task/internal/model/TaskServiceImpl.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -23,6 +23,7 @@
 
 import java.util.List;
 
+import org.jbpm.TaskQuery;
 import org.jbpm.TaskService;
 import org.jbpm.cmd.CommandService;
 import org.jbpm.task.Role;
@@ -95,4 +96,8 @@
   public List<Task> getGroupTaskList(String userId, int firstResult, int maxResults) {
     return null;
   }
+
+  public TaskQuery createTaskQuery() {
+    return new TaskQueryImpl(commandService);
+  }
 }

Deleted: 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	2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -1,54 +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.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 activity
-    // the task id is generated from the executionId and the task name
-    Task task = taskService.newTask();
-    task.setName("do laundry");
-    task.setAssignee("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.getAssignee());
-    assertEquals("do laundry", task.getName());
-    
-    taskService.submitTask(task.getId());
-    
-    assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
-  }
-}

Deleted: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java	2009-01-22 10:56:09 UTC (rev 3700)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -1,77 +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.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() {
-    Task task = taskService.newTask();
-    task = taskService.getTask(task.getId());
-    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() {
-    Task task = taskService.newTask();
-    saveTask(task);
-    String taskId = task.getId();
-    // 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 testDeleteTask() {
-    Task task = taskService.newTask();
-    taskService.saveTask(task);
-    String taskId = task.getId();
-    
-    // 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);
-  }
-}

Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java (from rev 3682, jbpm4/trunk/modules/task/src/test/java/org/jbpm/task/internal/model/TaskActivityScenarioTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,77 @@
+/*
+ * 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 java.util.List;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskListTest extends DbTestCase {
+
+  public void testDefaultScenario() {
+    Task task = taskService.newTask();
+    task.setName("do laundry");
+    task.setAssignee("johndoe");
+    saveTask(task);
+
+    task = taskService.newTask();
+    task.setName("change dyper");
+    task.setAssignee("johndoe");
+    saveTask(task);
+
+    task = taskService.newTask();
+    task.setName("start new business");
+    task.setAssignee("joesmoe");
+    saveTask(task);
+
+    task = taskService.newTask();
+    task.setName("find venture capital");
+    task.setAssignee("joesmoe");
+    saveTask(task);
+
+    /* 
+    List<Task> taskList = taskService.getPersonalTaskList("johndoe", 0, 10);
+    assertNotNull(taskList);
+    
+    task = taskList.get(0);
+    assertEquals("johndoe", task.getAssignee());
+    assertEquals("do laundry", task.getName());
+
+    task = taskList.get(1);
+    assertEquals("johndoe", task.getAssignee());
+    assertEquals("do laundry", task.getName());
+
+    assertEquals(2, taskList.size());
+    
+    
+    taskService.submitTask(task.getId());
+    
+    assertEquals(0, taskService.getPersonalTaskList("johndoe", 0, 10).size());
+    
+    */
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskListTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:mergeinfo
   + 
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java (from rev 3641, jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/svc/TaskServiceTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/main/java/org/jbpm/test/task/TaskServiceTest.java	2009-01-22 15:17:25 UTC (rev 3701)
@@ -0,0 +1,78 @@
+/*
+ * 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 java.util.Date;
+
+import org.jbpm.task.Task;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskServiceTest extends DbTestCase {
+
+  public void testNewTask() {
+    // creation of a new non-persisted task
+    Task task = taskService.newTask();
+    task = taskService.getTask(task.getId());
+    assertNull(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(task.getId());
+  }
+
+  public void testSaveTask() {
+    Task task = taskService.newTask();
+    saveTask(task);
+    String taskId = task.getId();
+    // 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 testDeleteTask() {
+    Task task = taskService.newTask();
+    taskService.saveTask(task);
+    String taskId = task.getId();
+    
+    // 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);
+  }
+}




More information about the jbpm-commits mailing list