提交 e622e3b5 编写于 作者: T tombaeyens

ACT-80 fixing various persistence related problems

上级 def4247c
...@@ -32,12 +32,12 @@ public class CallActivityTest extends ProcessEngineTestCase { ...@@ -32,12 +32,12 @@ public class CallActivityTest extends ProcessEngineTestCase {
// After the process has started, the 'verify credit history' task should be active // After the process has started, the 'verify credit history' task should be active
runtimeService.startProcessInstanceByKey("orderProcess"); runtimeService.startProcessInstanceByKey("orderProcess");
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
Task verifyCreditTask = taskQuery.singleResult(); Task verifyCreditTask = taskQuery.listPage();
assertEquals("Verify credit history", verifyCreditTask.getName()); assertEquals("Verify credit history", verifyCreditTask.getName());
// Completing the task with approval, will end the subprocess and continue the original process // Completing the task with approval, will end the subprocess and continue the original process
taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true)); taskService.complete(verifyCreditTask.getId(), CollectionUtil.singletonMap("creditApproved", true));
Task prepareAndShipTask = taskQuery.singleResult(); Task prepareAndShipTask = taskQuery.listPage();
assertEquals("Prepare and Ship", prepareAndShipTask.getName()); assertEquals("Prepare and Ship", prepareAndShipTask.getName());
} }
} }
...@@ -34,7 +34,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase { ...@@ -34,7 +34,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("interruptingBoundaryTimer"); ProcessInstance pi = runtimeService.startProcessInstanceByKey("interruptingBoundaryTimer");
// There should be one task, with a timer : first line support // There should be one task, with a timer : first line support
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("First line support", task.getName()); assertEquals("First line support", task.getName());
// Set clock to the future such that the timer can fire // Set clock to the future such that the timer can fire
...@@ -42,7 +42,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase { ...@@ -42,7 +42,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase {
waitForJobExecutorToProcessAllJobs(10000L, 250L); waitForJobExecutorToProcessAllJobs(10000L, 250L);
// The timer has fired, and the second task (secondlinesupport) now exists // The timer has fired, and the second task (secondlinesupport) now exists
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); task = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("Second line support", task.getName()); assertEquals("Second line support", task.getName());
} }
......
...@@ -31,14 +31,14 @@ public class UelExpressionTest extends ProcessEngineTestCase { ...@@ -31,14 +31,14 @@ public class UelExpressionTest extends ProcessEngineTestCase {
UelExpressionTestOrder order = new UelExpressionTestOrder(150); UelExpressionTestOrder order = new UelExpressionTestOrder(150);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("uelExpressions", ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
CollectionUtil.singletonMap("order", order)); CollectionUtil.singletonMap("order", order));
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).listPage();
assertEquals("Standard service", task.getName()); assertEquals("Standard service", task.getName());
// While an order of 300, gives us a premium service (goes through an UEL method expression) // While an order of 300, gives us a premium service (goes through an UEL method expression)
order = new UelExpressionTestOrder(300); order = new UelExpressionTestOrder(300);
processInstance = runtimeService.startProcessInstanceByKey("uelExpressions", processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
CollectionUtil.singletonMap("order", order)); CollectionUtil.singletonMap("order", order));
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).listPage();
assertEquals("Premium service", task.getName()); assertEquals("Premium service", task.getName());
} }
......
...@@ -41,19 +41,19 @@ public class ExclusiveGatewayTest extends ProcessEngineTestCase { ...@@ -41,19 +41,19 @@ public class ExclusiveGatewayTest extends ProcessEngineTestCase {
// Test with input == 1 // Test with input == 1
variables.put("input", 1); variables.put("input", 1);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables); ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("Send e-mail for more information", task.getName()); assertEquals("Send e-mail for more information", task.getName());
// Test with input == 2 // Test with input == 2
variables.put("input", 2); variables.put("input", 2);
pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables); pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); task = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("Check account balance", task.getName()); assertEquals("Check account balance", task.getName());
// Test with input == 3 // Test with input == 3
variables.put("input", 3); variables.put("input", 3);
pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables); pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); task = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("Call customer", task.getName()); assertEquals("Call customer", task.getName());
// Test with input == 4 // Test with input == 4
......
...@@ -30,7 +30,7 @@ public class ReceiveTaskTest extends ProcessEngineTestCase { ...@@ -30,7 +30,7 @@ public class ReceiveTaskTest extends ProcessEngineTestCase {
Execution execution = runtimeService.createExecutionQuery() Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId()) .processInstanceId(pi.getId())
.activityId("waitState") .activityId("waitState")
.singleResult(); .listPage();
assertNotNull(execution); assertNotNull(execution);
runtimeService.signal(execution.getId()); runtimeService.signal(execution.getId());
......
...@@ -29,7 +29,7 @@ public class JavaServiceTaskTest extends ProcessEngineTestCase { ...@@ -29,7 +29,7 @@ public class JavaServiceTaskTest extends ProcessEngineTestCase {
Execution execution = runtimeService.createExecutionQuery() Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(pi.getId()) .processInstanceId(pi.getId())
.activityId("waitState") .activityId("waitState")
.singleResult(); .listPage();
assertEquals("ACTIVITI BPM ENGINE", runtimeService.getVariable(execution.getId(), "input")); assertEquals("ACTIVITI BPM ENGINE", runtimeService.getVariable(execution.getId(), "input"));
} }
......
...@@ -50,7 +50,7 @@ public class SubProcessTest extends ProcessEngineTestCase { ...@@ -50,7 +50,7 @@ public class SubProcessTest extends ProcessEngineTestCase {
// Completing boith the tasks finishes the subprocess and enables the task after the subprocess // Completing boith the tasks finishes the subprocess and enables the task after the subprocess
taskService.complete(investigateHardwareTask.getId()); taskService.complete(investigateHardwareTask.getId());
taskService.complete(investigateSoftwareTask.getId()); taskService.complete(investigateSoftwareTask.getId());
Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult(); Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.getId()).listPage();
assertEquals("Write report", writeReportTask.getName()); assertEquals("Write report", writeReportTask.getName());
// Clean up // Clean up
......
...@@ -31,22 +31,18 @@ public class TablePageQueryTest extends ProcessEngineTestCase { ...@@ -31,22 +31,18 @@ public class TablePageQueryTest extends ProcessEngineTestCase {
TablePage tablePage = managementService.createTablePageQuery() TablePage tablePage = managementService.createTablePageQuery()
.tableName("ACT_TASK") .tableName("ACT_TASK")
.start(0) .listPage(0, 5);
.size(5)
.singleResult();
assertEquals(0, tablePage.getStart()); assertEquals(0, tablePage.getFirstResult());
assertEquals(5, tablePage.getSize()); assertEquals(5, tablePage.getSize());
assertEquals(5, tablePage.getRows().size()); assertEquals(5, tablePage.getRows().size());
assertEquals(20, tablePage.getTotal()); assertEquals(20, tablePage.getTotal());
tablePage = managementService.createTablePageQuery() tablePage = managementService.createTablePageQuery()
.tableName("ACT_TASK") .tableName("ACT_TASK")
.start(14) .listPage(14, 10);
.size(10)
.singleResult();
assertEquals(14, tablePage.getStart()); assertEquals(14, tablePage.getFirstResult());
assertEquals(6, tablePage.getSize()); assertEquals(6, tablePage.getSize());
assertEquals(6, tablePage.getRows().size()); assertEquals(6, tablePage.getRows().size());
assertEquals(20, tablePage.getTotal()); assertEquals(20, tablePage.getTotal());
...@@ -60,20 +56,16 @@ public class TablePageQueryTest extends ProcessEngineTestCase { ...@@ -60,20 +56,16 @@ public class TablePageQueryTest extends ProcessEngineTestCase {
// With an ascending sort // With an ascending sort
TablePage tablePage = managementService.createTablePageQuery() TablePage tablePage = managementService.createTablePageQuery()
.tableName("ACT_TASK") .tableName("ACT_TASK")
.start(1)
.size(7)
.orderAsc("NAME_") .orderAsc("NAME_")
.singleResult(); .listPage(1, 7);
String[] expectedTaskNames = new String[] {"B", "C", "D", "E", "F", "G", "H"}; String[] expectedTaskNames = new String[] {"B", "C", "D", "E", "F", "G", "H"};
verifyTaskNames(expectedTaskNames, tablePage.getRows()); verifyTaskNames(expectedTaskNames, tablePage.getRows());
// With a descending sort // With a descending sort
tablePage = managementService.createTablePageQuery() tablePage = managementService.createTablePageQuery()
.tableName("ACT_TASK") .tableName("ACT_TASK")
.start(6)
.size(8)
.orderDesc("NAME_") .orderDesc("NAME_")
.singleResult(); .listPage(6, 8);
expectedTaskNames = new String[] {"I", "H", "G", "F", "E", "D", "C", "B"} ; expectedTaskNames = new String[] {"I", "H", "G", "F", "E", "D", "C", "B"} ;
verifyTaskNames(expectedTaskNames, tablePage.getRows()); verifyTaskNames(expectedTaskNames, tablePage.getRows());
......
...@@ -93,14 +93,20 @@ public class ProcessDefinitionsTest extends ProcessEngineTestCase { ...@@ -93,14 +93,20 @@ public class ProcessDefinitionsTest extends ProcessEngineTestCase {
.list(); .list();
assertNotNull(processDefinitions); assertNotNull(processDefinitions);
assertEquals(1, processDefinitions.size()); assertEquals(2, processDefinitions.size());
ProcessDefinition processDefinition = processDefinitions.get(0); ProcessDefinition processDefinition = processDefinitions.get(0);
assertEquals("IDR", processDefinition.getKey()); assertEquals("IDR", processDefinition.getKey());
assertEquals("Insurance Damage Report", processDefinition.getName()); assertEquals("Insurance Damage Report", processDefinition.getName());
assertEquals("IDR:2", processDefinition.getId());
assertEquals(2, processDefinition.getVersion());
processDefinition = processDefinitions.get(1);
assertEquals("IDR", processDefinition.getKey());
assertEquals("Insurance Damage Report", processDefinition.getName());
assertEquals("IDR:1", processDefinition.getId()); assertEquals("IDR:1", processDefinition.getId());
assertEquals(1, processDefinition.getVersion()); assertEquals(1, processDefinition.getVersion());
deleteDeployments(deploymentIds); deleteDeployments(deploymentIds);
} }
...@@ -114,6 +120,4 @@ public class ProcessDefinitionsTest extends ProcessEngineTestCase { ...@@ -114,6 +120,4 @@ public class ProcessDefinitionsTest extends ProcessEngineTestCase {
repositoryService.deleteDeployment(deploymentId); repositoryService.deleteDeployment(deploymentId);
} }
} }
} }
...@@ -51,7 +51,7 @@ public class TaskFormsTest extends ProcessEngineTestCase { ...@@ -51,7 +51,7 @@ public class TaskFormsTest extends ProcessEngineTestCase {
runtimeService.startProcessInstanceByKey("vacationRequest", parameters); runtimeService.startProcessInstanceByKey("vacationRequest", parameters);
// Management should now have a task assigned to them // Management should now have a task assigned to them
Task task = taskService.createTaskQuery().candidateGroup("management").singleResult(); Task task = taskService.createTaskQuery().candidateGroup("management").listPage();
assertEquals("Vacation request by kermit", task.getDescription()); assertEquals("Vacation request by kermit", task.getDescription());
Object taskForm = taskService.getTaskForm(task.getId()); Object taskForm = taskService.getTaskForm(task.getId());
assertNotNull(taskForm); assertNotNull(taskForm);
...@@ -63,7 +63,7 @@ public class TaskFormsTest extends ProcessEngineTestCase { ...@@ -63,7 +63,7 @@ public class TaskFormsTest extends ProcessEngineTestCase {
assertNull(repositoryService.getStartFormByKey("noStartOrTaskForm")); assertNull(repositoryService.getStartFormByKey("noStartOrTaskForm"));
runtimeService.startProcessInstanceByKey("noStartOrTaskForm"); runtimeService.startProcessInstanceByKey("noStartOrTaskForm");
Task task = taskService.createTaskQuery().singleResult(); Task task = taskService.createTaskQuery().listPage();
assertNull(taskService.getTaskForm(task.getId())); assertNull(taskService.getTaskForm(task.getId()));
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.activiti.examples.mgmt; package org.activiti.test.processengines;
import java.util.List; import java.util.List;
...@@ -19,6 +19,7 @@ import junit.framework.TestCase; ...@@ -19,6 +19,7 @@ import junit.framework.TestCase;
import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineInfo; import org.activiti.engine.ProcessEngineInfo;
import org.activiti.engine.ProcessEngines; import org.activiti.engine.ProcessEngines;
import org.activiti.engine.test.ProcessEngineTestCase;
/** /**
* @author Tom Baeyens * @author Tom Baeyens
...@@ -28,6 +29,7 @@ public class ProcessEnginesTest extends TestCase { ...@@ -28,6 +29,7 @@ public class ProcessEnginesTest extends TestCase {
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
ProcessEngineTestCase.closeProcessEngines();
ProcessEngines.init(); ProcessEngines.init();
} }
......
...@@ -28,7 +28,7 @@ public interface ExecutionQuery { ...@@ -28,7 +28,7 @@ public interface ExecutionQuery {
ExecutionQuery processDefinitionId(String processDefinitionId); ExecutionQuery processDefinitionId(String processDefinitionId);
List<Execution> list(); List<Execution> list();
List<Execution> paginatedList(int start, int maxResults); List<Execution> listPage(int start, int maxResults);
Execution singleResult(); Execution listPage();
long count(); long count();
} }
...@@ -31,10 +31,10 @@ public interface JobQuery { ...@@ -31,10 +31,10 @@ public interface JobQuery {
long count(); long count();
Job singleResult(); Job listPage();
List<Job> list(); List<Job> list();
List<Job> paginatedList(int start, int size); List<Job> listPage(int start, int size);
} }
...@@ -17,24 +17,23 @@ package org.activiti.engine; ...@@ -17,24 +17,23 @@ package org.activiti.engine;
* holds the parameters of a page (partial result) for a query. * holds the parameters of a page (partial result) for a query.
* *
* @author Joram Barrez * @author Joram Barrez
* @author Tom Baeyens
*/ */
public class Page { public class Page {
protected int offset; protected int firstResult;
protected int maxResults; protected int maxResults;
public Page(int offset, int maxResults) { public Page(int firstResult, int maxResults) {
this.offset = offset; this.firstResult = firstResult;
this.maxResults = maxResults; this.maxResults = maxResults;
} }
public int getOffset() { public int getFirstResult() {
return offset; return firstResult;
} }
public int getMaxResults() { public int getMaxResults() {
return maxResults; return maxResults;
} }
} }
...@@ -33,9 +33,9 @@ public interface ProcessDefinitionQuery { ...@@ -33,9 +33,9 @@ public interface ProcessDefinitionQuery {
long count(); long count();
ProcessDefinition singleResult(); ProcessDefinition listPage();
List<ProcessDefinition> list(); List<ProcessDefinition> list();
List<ProcessDefinition> paginatedList(int start, int size); List<ProcessDefinition> listPage(int start, int size);
} }
...@@ -26,7 +26,7 @@ public interface ProcessInstanceQuery { ...@@ -26,7 +26,7 @@ public interface ProcessInstanceQuery {
ProcessInstanceQuery processDefinitionKey(String processDefinitionKey); ProcessInstanceQuery processDefinitionKey(String processDefinitionKey);
List<ProcessInstance> list(); List<ProcessInstance> list();
List<ProcessInstance> paginatedList(int start, int maxResults); List<ProcessInstance> listPage(int start, int maxResults);
ProcessInstance singleResult(); ProcessInstance listPage();
long count(); long count();
} }
...@@ -37,7 +37,7 @@ public class TablePage { ...@@ -37,7 +37,7 @@ public class TablePage {
* For example in a paginated database table, this value identifies the record number of * For example in a paginated database table, this value identifies the record number of
* the result on the first row. * the result on the first row.
*/ */
protected long start; protected long firstResult;
/** /**
* Indicates the key or column on which the signalData is sorted. * Indicates the key or column on which the signalData is sorted.
...@@ -62,13 +62,6 @@ public class TablePage { ...@@ -62,13 +62,6 @@ public class TablePage {
} }
public TablePage(String tableName, long start, long total, List<Map<String, Object>> rowData) {
this.tableName = tableName;
this.start = start;
this.total = total;
this.rowData = rowData;
}
public String getTableName() { public String getTableName() {
return tableName; return tableName;
} }
...@@ -81,12 +74,12 @@ public class TablePage { ...@@ -81,12 +74,12 @@ public class TablePage {
* @return the start index of this page * @return the start index of this page
* (ie the index of the first element in the page) * (ie the index of the first element in the page)
*/ */
public long getStart() { public long getFirstResult() {
return start; return firstResult;
} }
public void setStart(long start) { public void setFirstResult(long firstResult) {
this.start = start; this.firstResult = firstResult;
} }
public void setRows(List<Map<String, Object>> rowData) { public void setRows(List<Map<String, Object>> rowData) {
......
...@@ -24,17 +24,6 @@ public interface TablePageQuery { ...@@ -24,17 +24,6 @@ public interface TablePageQuery {
*/ */
TablePageQuery tableName(String tableName); TablePageQuery tableName(String tableName);
/**
* the record number of the first element of the page.
* Note that this is zero-based (ie. the first element has index '0')
*/
TablePageQuery start(int start);
/**
* the number of elements that the page maximum can contain
*/
TablePageQuery size(int size);
/** /**
* orders the resulting table page rows by the given column in ascending order. * orders the resulting table page rows by the given column in ascending order.
*/ */
...@@ -48,6 +37,5 @@ public interface TablePageQuery { ...@@ -48,6 +37,5 @@ public interface TablePageQuery {
/** /**
* executes the query and returns the {@link TablePage}. * executes the query and returns the {@link TablePage}.
*/ */
TablePage singleResult(); TablePage listPage(int firstResult, int maxResults);
} }
...@@ -42,10 +42,10 @@ public interface TaskQuery { ...@@ -42,10 +42,10 @@ public interface TaskQuery {
long count(); long count();
Task singleResult(); Task listPage();
List<Task> list(); List<Task> list();
List<Task> paginatedList(int start, int size); List<Task> listPage(int start, int size);
} }
...@@ -16,7 +16,6 @@ import java.util.List; ...@@ -16,7 +16,6 @@ import java.util.List;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.Page; import org.activiti.engine.Page;
import org.activiti.engine.SortOrder;
import org.activiti.engine.impl.interceptor.Command; import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext; import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor; import org.activiti.engine.impl.interceptor.CommandExecutor;
...@@ -33,14 +32,14 @@ public abstract class AbstractQuery<T> implements Command<Object>{ ...@@ -33,14 +32,14 @@ public abstract class AbstractQuery<T> implements Command<Object>{
protected static final String SORTORDER_DESC = "desc"; protected static final String SORTORDER_DESC = "desc";
private static enum ResultType { private static enum ResultType {
LIST, PAGINATED_LIST, SINGLE_RESULT, COUNT LIST, LIST_PAGE, SINGLE_RESULT, COUNT
} }
protected CommandExecutor commandExecutor; protected CommandExecutor commandExecutor;
protected String orderBy; protected String orderBy;
protected int start; protected int firstResult;
protected int size; protected int maxResults;
protected ResultType resultType; protected ResultType resultType;
protected AbstractQuery() { protected AbstractQuery() {
...@@ -51,7 +50,7 @@ public abstract class AbstractQuery<T> implements Command<Object>{ ...@@ -51,7 +50,7 @@ public abstract class AbstractQuery<T> implements Command<Object>{
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public T singleResult() { public T listPage() {
this.resultType = ResultType.SINGLE_RESULT; this.resultType = ResultType.SINGLE_RESULT;
return (T) commandExecutor.execute(this); return (T) commandExecutor.execute(this);
} }
...@@ -63,10 +62,10 @@ public abstract class AbstractQuery<T> implements Command<Object>{ ...@@ -63,10 +62,10 @@ public abstract class AbstractQuery<T> implements Command<Object>{
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<T> paginatedList(int start, int size) { public List<T> listPage(int firstResult, int maxResults) {
this.start = start; this.firstResult = firstResult;
this.size = size; this.maxResults = maxResults;
this.resultType = ResultType.PAGINATED_LIST; this.resultType = ResultType.LIST_PAGE;
return (List) commandExecutor.execute(this); return (List) commandExecutor.execute(this);
} }
...@@ -80,8 +79,8 @@ public abstract class AbstractQuery<T> implements Command<Object>{ ...@@ -80,8 +79,8 @@ public abstract class AbstractQuery<T> implements Command<Object>{
return executeList(commandContext, null); return executeList(commandContext, null);
} else if (resultType==ResultType.SINGLE_RESULT) { } else if (resultType==ResultType.SINGLE_RESULT) {
return executeSingleResult(commandContext); return executeSingleResult(commandContext);
} else if (resultType==ResultType.PAGINATED_LIST) { } else if (resultType==ResultType.LIST_PAGE) {
return executeList(commandContext, new Page(start, size)); return executeList(commandContext, new Page(firstResult, maxResults));
} else { } else {
return executeCount(commandContext); return executeCount(commandContext);
} }
...@@ -111,7 +110,7 @@ public abstract class AbstractQuery<T> implements Command<Object>{ ...@@ -111,7 +110,7 @@ public abstract class AbstractQuery<T> implements Command<Object>{
} else { } else {
orderBy = orderBy+", "; orderBy = orderBy+", ";
} }
orderBy += orderBy+column+" "+sortOrder; orderBy = orderBy+column+" "+sortOrder;
} }
public String getOrderBy() { public String getOrderBy() {
......
...@@ -84,7 +84,7 @@ public class ExecutionQueryImpl extends AbstractQuery<Execution> implements Exec ...@@ -84,7 +84,7 @@ public class ExecutionQueryImpl extends AbstractQuery<Execution> implements Exec
public List<Execution> executeList(CommandContext commandContext, Page page) { public List<Execution> executeList(CommandContext commandContext, Page page) {
return (List) commandContext return (List) commandContext
.getRuntimeSession() .getRuntimeSession()
.findExecutionsByQueryCriteria(this); .findExecutionsByQueryCriteria(this, page);
} }
public String getProcessDefinitionKey() { public String getProcessDefinitionKey() {
......
...@@ -85,7 +85,7 @@ public class ProcessInstanceQueryImpl extends AbstractQuery<ProcessInstance> imp ...@@ -85,7 +85,7 @@ public class ProcessInstanceQueryImpl extends AbstractQuery<ProcessInstance> imp
public List<ProcessInstance> executeList(CommandContext commandContext, Page page) { public List<ProcessInstance> executeList(CommandContext commandContext, Page page) {
return (List) commandContext return (List) commandContext
.getRuntimeSession() .getRuntimeSession()
.findExecutionsByQueryCriteria(this); .findExecutionsByQueryCriteria(this, page);
} }
public String getProcessDefinitionKey() { public String getProcessDefinitionKey() {
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
*/ */
package org.activiti.engine.impl; package org.activiti.engine.impl;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.SortOrder;
import org.activiti.engine.TablePage; import org.activiti.engine.TablePage;
import org.activiti.engine.TablePageQuery; import org.activiti.engine.TablePageQuery;
import org.activiti.engine.impl.interceptor.Command; import org.activiti.engine.impl.interceptor.Command;
...@@ -25,63 +23,59 @@ import org.activiti.engine.impl.interceptor.CommandExecutor; ...@@ -25,63 +23,59 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
* *
* @author Joram Barrez * @author Joram Barrez
*/ */
public class TablePageQueryImpl implements TablePageQuery { public class TablePageQueryImpl implements TablePageQuery, Command<TablePage> {
CommandExecutor commandExecutor;
protected CommandExecutor commandExecutor;
protected String tableName; protected String tableName;
protected int start = -1; protected String orderBy;
protected int maxRows = -1; protected int firstResult;
protected String sortColumn; protected int maxResults;
protected SortOrder sortOrder;
public TablePageQueryImpl() {
}
public TablePageQueryImpl(CommandExecutor commandExecutor) { public TablePageQueryImpl(CommandExecutor commandExecutor) {
this.commandExecutor = commandExecutor; this.commandExecutor = commandExecutor;
} }
public TablePageQuery tableName(String tableName) { public TablePageQueryImpl tableName(String tableName) {
this.tableName = tableName; this.tableName = tableName;
return this; return this;
} }
public TablePageQuery start(int start) { public TablePageQueryImpl orderAsc(String column) {
this.start = start; addOrder(column, AbstractQuery.SORTORDER_ASC);
return this; return this;
} }
public TablePageQuery size(int size) { public TablePageQueryImpl orderDesc(String column) {
this.maxRows = size; addOrder(column, AbstractQuery.SORTORDER_DESC);
return this; return this;
} }
public TablePageQuery orderAsc(String column) { public String getTableName() {
if (sortColumn != null) { return tableName;
throw new ActivitiException("Invalid usage: cannot use both orderAsc and orderDesc in same query");
}
this.sortOrder = SortOrder.ASC;
this.sortColumn = column;
return this;
} }
public TablePageQuery orderDesc(String column) { protected void addOrder(String column, String sortOrder) {
if (sortColumn != null) { if (orderBy==null) {
throw new ActivitiException("Invalid usage: cannot use both orderAsc and orderDesc in same query"); orderBy = "";
} else {
orderBy = orderBy+", ";
} }
this.sortOrder = SortOrder.DESC; orderBy = orderBy+column+" "+sortOrder;
this.sortColumn = column;
return this;
} }
public TablePage singleResult() { public TablePage listPage(int firstResult, int maxResults) {
return commandExecutor.execute(new Command<TablePage>() { this.firstResult = firstResult;
public TablePage execute(CommandContext commandContext) { this.maxResults = maxResults;
if (tableName == null || start == -1 || maxRows == -1) { return commandExecutor.execute(this);
throw new ActivitiException("Table name, offset and maxResults are " + }
"minimally needed to execute a TablePageQuery");
} public TablePage execute(CommandContext commandContext) {
return commandContext.getManagementSession() return commandContext
.getTablePage(tableName, start, maxRows, sortColumn, sortOrder); .getManagementSession()
}; .getTablePage(this, firstResult, maxResults);
});
} }
} }
...@@ -70,7 +70,7 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService { ...@@ -70,7 +70,7 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
public List<Task> findAssignedTasks(String assignee, Page page) { public List<Task> findAssignedTasks(String assignee, Page page) {
TaskQuery query = createTaskQuery().assignee(assignee); TaskQuery query = createTaskQuery().assignee(assignee);
if (page != null) { if (page != null) {
return query.paginatedList(page.getOffset(), page.getMaxResults()); return query.listPage(page.getFirstResult(), page.getMaxResults());
} else { } else {
return query.list(); return query.list();
} }
...@@ -83,7 +83,7 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService { ...@@ -83,7 +83,7 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
public List<Task> findUnassignedTasks(String userId, Page page) { public List<Task> findUnassignedTasks(String userId, Page page) {
TaskQuery query = createTaskQuery().candidateUser(userId); TaskQuery query = createTaskQuery().candidateUser(userId);
if (page != null) { if (page != null) {
return query.paginatedList(page.getOffset(), page.getMaxResults()); return query.listPage(page.getFirstResult(), page.getMaxResults());
} else { } else {
return query.list(); return query.list();
} }
......
...@@ -38,9 +38,11 @@ public class BpmnDeployer implements Deployer, ProcessEngineConfigurationAware { ...@@ -38,9 +38,11 @@ public class BpmnDeployer implements Deployer, ProcessEngineConfigurationAware {
public static final String BPMN_RESOURCE_SUFFIX = "bpmn20.xml"; public static final String BPMN_RESOURCE_SUFFIX = "bpmn20.xml";
protected ExpressionManager expressionManager; protected ExpressionManager expressionManager;
protected BpmnParser bpmnParser;
public void configurationCompleted(ProcessEngineConfiguration processEngineConfiguration) { public void configurationCompleted(ProcessEngineConfiguration processEngineConfiguration) {
this.expressionManager = processEngineConfiguration.getExpressionManager(); this.expressionManager = processEngineConfiguration.getExpressionManager();
this.bpmnParser = new BpmnParser(expressionManager);
} }
public List<ProcessDefinitionEntity> deploy(DeploymentEntity deployment) { public List<ProcessDefinitionEntity> deploy(DeploymentEntity deployment) {
...@@ -54,7 +56,7 @@ public class BpmnDeployer implements Deployer, ProcessEngineConfigurationAware { ...@@ -54,7 +56,7 @@ public class BpmnDeployer implements Deployer, ProcessEngineConfigurationAware {
ResourceEntity resource = resources.get(resourceName); ResourceEntity resource = resources.get(resourceName);
byte[] bytes = resource.getBytes(); byte[] bytes = resource.getBytes();
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes); ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BpmnParse bpmnParse = new BpmnParser(expressionManager) BpmnParse bpmnParse = bpmnParser
.createParse() .createParse()
.sourceInputStream(inputStream) .sourceInputStream(inputStream)
.name(resourceName) .name(resourceName)
......
...@@ -15,9 +15,9 @@ package org.activiti.engine.impl.cfg; ...@@ -15,9 +15,9 @@ package org.activiti.engine.impl.cfg;
import java.util.Map; import java.util.Map;
import org.activiti.engine.SortOrder;
import org.activiti.engine.TableMetaData; import org.activiti.engine.TableMetaData;
import org.activiti.engine.TablePage; import org.activiti.engine.TablePage;
import org.activiti.engine.impl.TablePageQueryImpl;
import org.activiti.engine.impl.persistence.db.IdBlock; import org.activiti.engine.impl.persistence.db.IdBlock;
...@@ -28,7 +28,7 @@ public interface ManagementSession { ...@@ -28,7 +28,7 @@ public interface ManagementSession {
/* Management */ /* Management */
Map<String, Long> getTableCount(); Map<String, Long> getTableCount();
TablePage getTablePage(String tableName, int offset, int maxResults, String sortColumn, SortOrder sortOrder); TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults);
TableMetaData getTableMetaData(String tableName); TableMetaData getTableMetaData(String tableName);
IdBlock getNextIdBlock(); IdBlock getNextIdBlock();
......
...@@ -34,7 +34,7 @@ public interface RuntimeSession { ...@@ -34,7 +34,7 @@ public interface RuntimeSession {
void deleteProcessInstance(String processInstanceId, String deleteReason); void deleteProcessInstance(String processInstanceId, String deleteReason);
ExecutionEntity findSubProcessInstanceBySuperExecutionId(String superExecutionId); ExecutionEntity findSubProcessInstanceBySuperExecutionId(String superExecutionId);
long findExecutionCountByQueryCriteria(Object executionQuery); long findExecutionCountByQueryCriteria(Object executionQuery);
List<ExecutionEntity> findExecutionsByQueryCriteria(Object executionQuery); List<ExecutionEntity> findExecutionsByQueryCriteria(Object executionQuery, Page page);
List<ExecutionEntity> findChildExecutionsByParentExecutionId(String executionId); List<ExecutionEntity> findChildExecutionsByParentExecutionId(String executionId);
ExecutionEntity findExecutionById(String activityInstanceId); ExecutionEntity findExecutionById(String activityInstanceId);
...@@ -46,9 +46,9 @@ public interface RuntimeSession { ...@@ -46,9 +46,9 @@ public interface RuntimeSession {
JobEntity findJobById(String jobId); JobEntity findJobById(String jobId);
List<JobEntity> findJobs(); List<JobEntity> findJobs();
List<JobEntity> findNextJobsToExecute(int maxNrOfJobs); List<JobEntity> findNextJobsToExecute(Page page);
List<JobEntity> findLockedJobs(); List<JobEntity> findLockedJobs();
List<TimerEntity> findUnlockedTimersByDuedate(Date duedate, int nrOfTimers); List<TimerEntity> findUnlockedTimersByDuedate(Date duedate, Page page);
List<TimerEntity> findTimersByExecutionId(String executionId); List<TimerEntity> findTimersByExecutionId(String executionId);
List<Job> findJobsByQueryCriteria(JobQueryImpl jobQuery, Page page); List<Job> findJobsByQueryCriteria(JobQueryImpl jobQuery, Page page);
long findJobCountByQueryCriteria(JobQueryImpl jobQuery); long findJobCountByQueryCriteria(JobQueryImpl jobQuery);
......
...@@ -17,6 +17,7 @@ import java.util.Calendar; ...@@ -17,6 +17,7 @@ import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import org.activiti.engine.Page;
import org.activiti.engine.impl.cfg.RuntimeSession; import org.activiti.engine.impl.cfg.RuntimeSession;
import org.activiti.engine.impl.interceptor.Command; import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext; import org.activiti.engine.impl.interceptor.CommandContext;
...@@ -44,7 +45,7 @@ public class AcquireJobsCmd implements Command<AcquiredJobs> { ...@@ -44,7 +45,7 @@ public class AcquireJobsCmd implements Command<AcquiredJobs> {
AcquiredJobs acquiredJobs = new AcquiredJobs(); AcquiredJobs acquiredJobs = new AcquiredJobs();
List<JobEntity> jobs = runtimeSession.findNextJobsToExecute(maxJobsPerAcquisition); List<JobEntity> jobs = runtimeSession.findNextJobsToExecute(new Page(0, maxJobsPerAcquisition));
for (JobEntity job: jobs) { for (JobEntity job: jobs) {
List<String> jobIds = new ArrayList<String>(); List<String> jobIds = new ArrayList<String>();
......
...@@ -15,6 +15,7 @@ package org.activiti.engine.impl.jobexecutor; ...@@ -15,6 +15,7 @@ package org.activiti.engine.impl.jobexecutor;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.activiti.engine.Page;
import org.activiti.engine.impl.interceptor.Command; import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext; import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.runtime.TimerEntity; import org.activiti.engine.impl.persistence.runtime.TimerEntity;
...@@ -27,15 +28,14 @@ import org.activiti.engine.impl.persistence.runtime.TimerEntity; ...@@ -27,15 +28,14 @@ import org.activiti.engine.impl.persistence.runtime.TimerEntity;
public class GetUnlockedTimersByDuedateCmd implements Command<List<TimerEntity>> { public class GetUnlockedTimersByDuedateCmd implements Command<List<TimerEntity>> {
protected Date duedate; protected Date duedate;
protected Page page;
protected int nrOfTimers = -1; public GetUnlockedTimersByDuedateCmd(Date duedate, Page page) {
public GetUnlockedTimersByDuedateCmd(Date duedate, int nrOfTimers) {
this.duedate = duedate; this.duedate = duedate;
this.nrOfTimers = nrOfTimers; this.page = page;
} }
public List<TimerEntity> execute(CommandContext commandContext) { public List<TimerEntity> execute(CommandContext commandContext) {
return commandContext.getRuntimeSession().findUnlockedTimersByDuedate(duedate, nrOfTimers); return commandContext.getRuntimeSession().findUnlockedTimersByDuedate(duedate, page);
} }
} }
...@@ -17,6 +17,7 @@ import java.util.List; ...@@ -17,6 +17,7 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.activiti.engine.Page;
import org.activiti.engine.impl.interceptor.CommandExecutor; import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.persistence.runtime.TimerEntity; import org.activiti.engine.impl.persistence.runtime.TimerEntity;
import org.activiti.engine.impl.util.ClockUtil; import org.activiti.engine.impl.util.ClockUtil;
...@@ -73,7 +74,7 @@ public class JobAcquisitionThread extends Thread { ...@@ -73,7 +74,7 @@ public class JobAcquisitionThread extends Thread {
// check if the next timer should fire before the normal sleep time is over // check if the next timer should fire before the normal sleep time is over
Date duedate = new Date(ClockUtil.getCurrentTime().getTime() + millisToWait); Date duedate = new Date(ClockUtil.getCurrentTime().getTime() + millisToWait);
List<TimerEntity> nextTimers = commandExecutor.execute(new GetUnlockedTimersByDuedateCmd(duedate, 1)); List<TimerEntity> nextTimers = commandExecutor.execute(new GetUnlockedTimersByDuedateCmd(duedate, new Page(0, 1)));
if (!nextTimers.isEmpty()) { if (!nextTimers.isEmpty()) {
long millisTillNextTimer = nextTimers.get(0).getDuedate().getTime() - ClockUtil.getCurrentTime().getTime(); long millisTillNextTimer = nextTimers.get(0).getDuedate().getTime() - ClockUtil.getCurrentTime().getTime();
......
...@@ -43,6 +43,8 @@ public class TimerExecuteNestedActivityJobHandler implements JobHandler { ...@@ -43,6 +43,8 @@ public class TimerExecuteNestedActivityJobHandler implements JobHandler {
} }
try { try {
execution.setActivity(borderEventActivity);
borderEventActivity borderEventActivity
.getActivityBehavior() .getActivityBehavior()
.execute(execution); .execute(execution);
......
...@@ -24,13 +24,14 @@ import java.util.logging.Logger; ...@@ -24,13 +24,14 @@ import java.util.logging.Logger;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiOptimisticLockingException; import org.activiti.engine.ActivitiOptimisticLockingException;
import org.activiti.engine.SortOrder;
import org.activiti.engine.TableMetaData; import org.activiti.engine.TableMetaData;
import org.activiti.engine.TablePage; import org.activiti.engine.TablePage;
import org.activiti.engine.impl.TablePageQueryImpl;
import org.activiti.engine.impl.cfg.ManagementSession; import org.activiti.engine.impl.cfg.ManagementSession;
import org.activiti.engine.impl.interceptor.CommandContext; import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.Session; import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.persistence.repository.PropertyEntity; import org.activiti.engine.impl.persistence.repository.PropertyEntity;
import org.apache.ibatis.session.RowBounds;
/** /**
...@@ -84,32 +85,19 @@ public class DbManagementSession implements ManagementSession, Session { ...@@ -84,32 +85,19 @@ public class DbManagementSession implements ManagementSession, Session {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TablePage getTablePage(String tableName, int offset, int maxResults, public TablePage getTablePage(TablePageQueryImpl tablePageQuery, int firstResult, int maxResults) {
String sortColumn, SortOrder sortOrder) {
TablePage tablePage = new TablePage(); TablePage tablePage = new TablePage();
Map<String, String> params = new HashMap<String, String>(); List<Map<String, Object>> tableData = (List<Map<String, Object>>) dbSqlSession
params.put("tableName", tableName); .getSqlSession()
if (sortColumn != null) { .selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults));
params.put("sortColumn", sortColumn);
if (sortOrder.equals(SortOrder.ASC)) {
params.put("sortOrder", "asc");
} else {
params.put("sortOrder", "desc");
}
tablePage.setSort(sortColumn);
tablePage.setOrder(sortOrder);
}
List<Map<String, Object>> tableData = tablePage.setTableName(tablePageQuery.getTableName());
(List<Map<String, Object>>) dbSqlSession.selectList("selectTableData", params, offset, maxResults); tablePage.setTotal(getTableCount(tablePageQuery.getTableName()));
tablePage.setTableName(tableName);
tablePage.setStart(offset);
tablePage.setTotal(getTableCount(tableName));
tablePage.setRows(tableData); tablePage.setRows(tableData);
tablePage.setFirstResult(firstResult);
return tablePage; return tablePage;
} }
...@@ -162,5 +150,4 @@ public class DbManagementSession implements ManagementSession, Session { ...@@ -162,5 +150,4 @@ public class DbManagementSession implements ManagementSession, Session {
public void flush() { public void flush() {
} }
} }
...@@ -55,7 +55,19 @@ public class DbRepositorySession implements Session, RepositorySession { ...@@ -55,7 +55,19 @@ public class DbRepositorySession implements Session, RepositorySession {
for (Deployer deployer: dbRepositorySessionFactory.getDeployers()) { for (Deployer deployer: dbRepositorySessionFactory.getDeployers()) {
List<ProcessDefinitionEntity> processDefinitions = deployer.deploy(deployment); List<ProcessDefinitionEntity> processDefinitions = deployer.deploy(deployment);
for (ProcessDefinitionEntity processDefinition : processDefinitions) { for (ProcessDefinitionEntity processDefinition : processDefinitions) {
int processDefinitionVersion;
ProcessDefinitionEntity latestProcessDefinition = findLatestProcessDefinitionByKey(processDefinition.getKey());
if (latestProcessDefinition!=null) {
processDefinitionVersion = latestProcessDefinition.getVersion()+1;
} else {
processDefinitionVersion = 1;
}
processDefinition.setVersion(processDefinitionVersion);
processDefinition.setDeploymentId(deployment.getId()); processDefinition.setDeploymentId(deployment.getId());
processDefinition.setId(processDefinition.getKey()+":"+processDefinition.getVersion());
dbSqlSession.insert(processDefinition); dbSqlSession.insert(processDefinition);
addToProcessDefinitionCache(processDefinition); addToProcessDefinitionCache(processDefinition);
} }
...@@ -157,6 +169,10 @@ public class DbRepositorySession implements Session, RepositorySession { ...@@ -157,6 +169,10 @@ public class DbRepositorySession implements Session, RepositorySession {
return (ProcessDefinitionEntity) dbSqlSession.selectOne("selectProcessDefinitionById", processDefinitionId); return (ProcessDefinitionEntity) dbSqlSession.selectOne("selectProcessDefinitionById", processDefinitionId);
} }
protected ProcessDefinitionEntity findLatestProcessDefinitionByKey(String processDefinitionKey) {
return (ProcessDefinitionEntity) dbSqlSession.selectOne("selectLatestProcessDefinitionByKey", processDefinitionKey);
}
public ProcessDefinitionEntity findDeployedLatestProcessDefinitionByKey(String processDefinitionKey) { public ProcessDefinitionEntity findDeployedLatestProcessDefinitionByKey(String processDefinitionKey) {
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) dbSqlSession.selectOne("selectLatestProcessDefinitionByKey", processDefinitionKey); ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) dbSqlSession.selectOne("selectLatestProcessDefinitionByKey", processDefinitionKey);
processDefinition = resolveProcessDefinition(processDefinition); processDefinition = resolveProcessDefinition(processDefinition);
...@@ -190,11 +206,7 @@ public class DbRepositorySession implements Session, RepositorySession { ...@@ -190,11 +206,7 @@ public class DbRepositorySession implements Session, RepositorySession {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<ProcessDefinition> findProcessDefinitionsByQueryCriteria(ProcessDefinitionQueryImpl processDefinitionQuery, Page page) { public List<ProcessDefinition> findProcessDefinitionsByQueryCriteria(ProcessDefinitionQueryImpl processDefinitionQuery, Page page) {
final String query = "selectProcessDefinitionsByQueryCriteria"; final String query = "selectProcessDefinitionsByQueryCriteria";
if (page == null) { return dbSqlSession.selectList(query, processDefinitionQuery, page);
return dbSqlSession.selectList(query, processDefinitionQuery);
} else {
return dbSqlSession.selectList(query, processDefinitionQuery, page.getOffset(), page.getMaxResults());
}
} }
public long findProcessDefinitionCountByQueryCriteria(ProcessDefinitionQueryImpl processDefinitionQuery) { public long findProcessDefinitionCountByQueryCriteria(ProcessDefinitionQueryImpl processDefinitionQuery) {
......
...@@ -55,8 +55,8 @@ public class DbRuntimeSession implements Session, RuntimeSession { ...@@ -55,8 +55,8 @@ public class DbRuntimeSession implements Session, RuntimeSession {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<ExecutionEntity> findExecutionsByQueryCriteria(Object executionQuery) { public List<ExecutionEntity> findExecutionsByQueryCriteria(Object executionQuery, Page page) {
return dbSqlSession.selectList("selectExecutionsByQueryCriteria", executionQuery); return dbSqlSession.selectList("selectExecutionsByQueryCriteria", executionQuery, page);
} }
public ExecutionEntity findExecutionById(String executionId) { public ExecutionEntity findExecutionById(String executionId) {
...@@ -106,9 +106,9 @@ public class DbRuntimeSession implements Session, RuntimeSession { ...@@ -106,9 +106,9 @@ public class DbRuntimeSession implements Session, RuntimeSession {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<JobEntity> findNextJobsToExecute(int maxNrOfJobs) { public List<JobEntity> findNextJobsToExecute(Page page) {
Date now = ClockUtil.getCurrentTime(); Date now = ClockUtil.getCurrentTime();
return dbSqlSession.selectList("selectNextJobsToExecute", now, 0, maxNrOfJobs); return dbSqlSession.selectList("selectNextJobsToExecute", now, page);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -117,13 +117,9 @@ public class DbRuntimeSession implements Session, RuntimeSession { ...@@ -117,13 +117,9 @@ public class DbRuntimeSession implements Session, RuntimeSession {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<TimerEntity> findUnlockedTimersByDuedate(Date duedate, int nrOfTimers) { public List<TimerEntity> findUnlockedTimersByDuedate(Date duedate, Page page) {
final String query = "selectUnlockedTimersByDuedate"; final String query = "selectUnlockedTimersByDuedate";
if (nrOfTimers > 0) { return dbSqlSession.selectList(query, duedate, page);
return dbSqlSession.selectList(query, duedate, 0, nrOfTimers);
} else {
return dbSqlSession.selectList(query, duedate);
}
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -134,11 +130,7 @@ public class DbRuntimeSession implements Session, RuntimeSession { ...@@ -134,11 +130,7 @@ public class DbRuntimeSession implements Session, RuntimeSession {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Job> findJobsByQueryCriteria(JobQueryImpl jobQuery, Page page) { public List<Job> findJobsByQueryCriteria(JobQueryImpl jobQuery, Page page) {
final String query = "org.activiti.persistence.selectJobByQueryCriteria"; final String query = "org.activiti.persistence.selectJobByQueryCriteria";
if (page == null) { return dbSqlSession.selectList(query, jobQuery, page);
return dbSqlSession.selectList(query, jobQuery);
} else {
return dbSqlSession.selectList(query, jobQuery, page.getOffset(), page.getMaxResults());
}
} }
public long findJobCountByQueryCriteria(JobQueryImpl jobQuery) { public long findJobCountByQueryCriteria(JobQueryImpl jobQuery) {
......
...@@ -21,6 +21,7 @@ import java.util.logging.Level; ...@@ -21,6 +21,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.activiti.engine.ActivitiException; import org.activiti.engine.ActivitiException;
import org.activiti.engine.Page;
import org.activiti.engine.impl.interceptor.Session; import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.persistence.PersistentObject; import org.activiti.engine.impl.persistence.PersistentObject;
import org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity; import org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity;
...@@ -143,9 +144,14 @@ public class DbSqlSession implements Session { ...@@ -143,9 +144,14 @@ public class DbSqlSession implements Session {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List selectList(String statement, Object parameter, int offset, int maxResults) { public List selectList(String statement, Object parameter, Page page) {
statement = dbSqlSessionFactory.mapStatement(statement); statement = dbSqlSessionFactory.mapStatement(statement);
List loadedObjects = sqlSession.selectList(statement, parameter, new RowBounds(offset, maxResults)); List loadedObjects;
if (page!=null) {
loadedObjects = sqlSession.selectList(statement, parameter, new RowBounds(page.getFirstResult(), page.getMaxResults()));
} else {
loadedObjects = sqlSession.selectList(statement, parameter);
}
return filterLoadedObjects(loadedObjects); return filterLoadedObjects(loadedObjects);
} }
......
...@@ -55,11 +55,7 @@ public class DbTaskSession implements TaskSession, Session { ...@@ -55,11 +55,7 @@ public class DbTaskSession implements TaskSession, Session {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Task> findTasksByQueryCriteria(TaskQueryImpl taskQuery, Page page) { public List<Task> findTasksByQueryCriteria(TaskQueryImpl taskQuery, Page page) {
final String query = "selectTaskByQueryCriteria"; final String query = "selectTaskByQueryCriteria";
if (page == null) { return dbSqlSession.selectList(query, taskQuery, page);
return dbSqlSession.selectList(query, taskQuery);
} else {
return dbSqlSession.selectList(query, taskQuery, page.getOffset(), page.getMaxResults());
}
} }
public long findTaskCountByQueryCriteria(TaskQueryImpl taskQuery) { public long findTaskCountByQueryCriteria(TaskQueryImpl taskQuery) {
......
...@@ -27,13 +27,10 @@ public class ByteArrayEntity implements Serializable, PersistentObject { ...@@ -27,13 +27,10 @@ public class ByteArrayEntity implements Serializable, PersistentObject {
private static final Object PERSISTENTSTATE_NULL = new Object(); private static final Object PERSISTENTSTATE_NULL = new Object();
protected String id; protected String id;
protected int revision;
protected String name; protected String name;
protected byte[] bytes; protected byte[] bytes;
protected String deploymentId; protected String deploymentId;
protected ByteArrayType variable; protected ByteArrayType variable;
public ByteArrayEntity() { public ByteArrayEntity() {
...@@ -50,19 +47,16 @@ public class ByteArrayEntity implements Serializable, PersistentObject { ...@@ -50,19 +47,16 @@ public class ByteArrayEntity implements Serializable, PersistentObject {
} }
public byte[] getBytes() { public byte[] getBytes() {
// // the bytes are lazy initialized
// if (bytes == null) {
// bytes = CommandContext
// .getCurrent()
// .getPersistenceSession()
// .getByteArrayBytes(id);
// }
return bytes; return bytes;
} }
public Object getPersistentState() { public Object getPersistentState() {
return (bytes != null ? bytes : PERSISTENTSTATE_NULL); return (bytes != null ? bytes : PERSISTENTSTATE_NULL);
} }
public int getRevisionNext() {
return revision+1;
}
// getters and setters ////////////////////////////////////////////////////// // getters and setters //////////////////////////////////////////////////////
...@@ -84,5 +78,10 @@ public class ByteArrayEntity implements Serializable, PersistentObject { ...@@ -84,5 +78,10 @@ public class ByteArrayEntity implements Serializable, PersistentObject {
public void setBytes(byte[] bytes) { public void setBytes(byte[] bytes) {
this.bytes = bytes; this.bytes = bytes;
} }
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
} }
...@@ -39,6 +39,7 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject { ...@@ -39,6 +39,7 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
protected String id; protected String id;
protected int revision;
protected Date duedate; protected Date duedate;
...@@ -73,6 +74,10 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject { ...@@ -73,6 +74,10 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject {
persistentState.put("exception", exception); persistentState.put("exception", exception);
return persistentState; return persistentState;
} }
public int getRevisionNext() {
return revision+1;
}
public void setExecution(ExecutionEntity execution) { public void setExecution(ExecutionEntity execution) {
executionId = execution.getId(); executionId = execution.getId();
...@@ -147,4 +152,10 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject { ...@@ -147,4 +152,10 @@ public abstract class JobEntity implements Serializable, Job, PersistentObject {
public void setJobHandlerConfiguration(String jobHandlerConfiguration) { public void setJobHandlerConfiguration(String jobHandlerConfiguration) {
this.jobHandlerConfiguration = jobHandlerConfiguration; this.jobHandlerConfiguration = jobHandlerConfiguration;
} }
public int getRevision() {
return revision;
}
public void setRevision(int revision) {
this.revision = revision;
}
} }
...@@ -119,6 +119,10 @@ public class VariableInstanceEntity implements Serializable, PersistentObject { ...@@ -119,6 +119,10 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
} }
return persistentState; return persistentState;
} }
public int getRevisionNext() {
return revision+1;
}
// lazy initialized relations /////////////////////////////////////////////// // lazy initialized relations ///////////////////////////////////////////////
......
...@@ -93,6 +93,9 @@ public class ActivityContextBindings implements Bindings { ...@@ -93,6 +93,9 @@ public class ActivityContextBindings implements Bindings {
} }
public Object remove(Object key) { public Object remove(Object key) {
if (UNSTORED_KEYS.contains(key)) {
return null;
}
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
......
...@@ -98,7 +98,7 @@ public class ProcessEngineTestCase extends PvmTestCase { ...@@ -98,7 +98,7 @@ public class ProcessEngineTestCase extends PvmTestCase {
.getRuntimeService() .getRuntimeService()
.createProcessInstanceQuery() .createProcessInstanceQuery()
.processInstanceId(processInstanceId) .processInstanceId(processInstanceId)
.singleResult(); .listPage();
if (processInstance!=null) { if (processInstance!=null) {
throw new AssertionFailedError("expected finished process instance '"+processInstanceId+"' but it was still in the db"); throw new AssertionFailedError("expected finished process instance '"+processInstanceId+"' but it was still in the db");
......
...@@ -33,14 +33,14 @@ ...@@ -33,14 +33,14 @@
<!-- TABLE DATA --> <!-- TABLE DATA -->
<!-- The property passing doesn't seem to work with parameterType='string', so we are forced to use a map here --> <!-- The property passing doesn't seem to work with parameterType='string', so we are forced to use a map here -->
<select id="selectTableCount" parameterType="map" resultType="long" > <select id="selectTableCount" parameterType="org.activiti.engine.impl.TablePageQueryImpl" resultType="long" >
select count(*) from ${tableName} select count(*) from ${tableName}
</select> </select>
<select id="selectTableData" parameterType="map" resultType="map"> <select id="selectTableData" parameterType="org.activiti.engine.impl.TablePageQueryImpl" resultType="map">
select * from ${tableName} select * from ${tableName}
<if test="sortColumn != null"> <if test="orderBy != null">
order by ${sortColumn} ${sortOrder} order by ${orderBy}
</if> </if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
<insert id="insertTimer" parameterType="org.activiti.engine.impl.persistence.runtime.TimerEntity"> <insert id="insertTimer" parameterType="org.activiti.engine.impl.persistence.runtime.TimerEntity">
insert into ACT_JOB ( insert into ACT_JOB (
ID_, ID_,
REV_,
TYPE_, TYPE_,
LOCK_OWNER_, LOCK_OWNER_,
LOCK_EXP_TIME_, LOCK_EXP_TIME_,
...@@ -113,6 +114,7 @@ ...@@ -113,6 +114,7 @@
HANDLER_TYPE_, HANDLER_TYPE_,
HANDLER_CFG_ ) HANDLER_CFG_ )
values (#{id, jdbcType=VARCHAR}, values (#{id, jdbcType=VARCHAR},
1,
'timer', 'timer',
#{lockOwner, jdbcType=VARCHAR}, #{lockOwner, jdbcType=VARCHAR},
#{lockExpirationTime, jdbcType=TIMESTAMP}, #{lockExpirationTime, jdbcType=TIMESTAMP},
...@@ -133,6 +135,7 @@ ...@@ -133,6 +135,7 @@
<update id="updateTimer" parameterType="org.activiti.engine.impl.persistence.runtime.TimerEntity"> <update id="updateTimer" parameterType="org.activiti.engine.impl.persistence.runtime.TimerEntity">
update ACT_JOB update ACT_JOB
<set> <set>
REV= #{revisionNext, jdbcType=INTEGER},
LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP}, LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP},
LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR}, LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR},
RETRIES_ = #{retries, jdbcType=INTEGER}, RETRIES_ = #{retries, jdbcType=INTEGER},
...@@ -140,6 +143,7 @@ ...@@ -140,6 +143,7 @@
DUEDATE_ = #{duedate, jdbcType=TIMESTAMP} DUEDATE_ = #{duedate, jdbcType=TIMESTAMP}
</set> </set>
where ID_= #{id, jdbcType=VARCHAR} where ID_= #{id, jdbcType=VARCHAR}
and REV = #{revision, jdbcType=INTEGER}
</update> </update>
<!-- TIMER SELECT --> <!-- TIMER SELECT -->
...@@ -169,6 +173,7 @@ ...@@ -169,6 +173,7 @@
<insert id="insertMessage" parameterType="org.activiti.engine.impl.persistence.runtime.MessageEntity"> <insert id="insertMessage" parameterType="org.activiti.engine.impl.persistence.runtime.MessageEntity">
insert into ACT_JOB ( insert into ACT_JOB (
ID_, ID_,
REV_,
TYPE_, TYPE_,
LOCK_OWNER_, LOCK_OWNER_,
LOCK_EXP_TIME_, LOCK_EXP_TIME_,
...@@ -180,6 +185,7 @@ ...@@ -180,6 +185,7 @@
HANDLER_TYPE_, HANDLER_TYPE_,
HANDLER_CFG_) HANDLER_CFG_)
values (#{id, jdbcType=VARCHAR}, values (#{id, jdbcType=VARCHAR},
1,
'message', 'message',
#{lockOwner, jdbcType=VARCHAR}, #{lockOwner, jdbcType=VARCHAR},
#{lockExpirationTime, jdbcType=TIMESTAMP}, #{lockExpirationTime, jdbcType=TIMESTAMP},
...@@ -198,12 +204,14 @@ ...@@ -198,12 +204,14 @@
<update id="updateMessage" parameterType="org.activiti.engine.impl.persistence.runtime.MessageEntity"> <update id="updateMessage" parameterType="org.activiti.engine.impl.persistence.runtime.MessageEntity">
update ACT_JOB update ACT_JOB
<set> <set>
REV_ = #{revisionNext, jdbcType=INTEGER},
LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP}, LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP},
LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR}, LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR},
RETRIES_ = #{retries, jdbcType=INTEGER}, RETRIES_ = #{retries, jdbcType=INTEGER},
EXCEPTION_ = #{exception, jdbcType=VARCHAR} EXCEPTION_ = #{exception, jdbcType=VARCHAR}
</set> </set>
where ID_= #{id, jdbcType=VARCHAR} where ID_= #{id, jdbcType=VARCHAR}
and REV = #{revision, jdbcType=INTEGER}
</update> </update>
</mapper> </mapper>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<update id="updateVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity"> <update id="updateVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
update ACT_VARIABLE update ACT_VARIABLE
set set
REV_ = #{revisionNext, jdbcType=INTEGER} REV_ = #{revisionNext, jdbcType=INTEGER},
BYTEARRAY_ID_ = #{byteArrayValueId, jdbcType=VARCHAR}, BYTEARRAY_ID_ = #{byteArrayValueId, jdbcType=VARCHAR},
DOUBLE_ = #{doubleValue, jdbcType=DOUBLE}, DOUBLE_ = #{doubleValue, jdbcType=DOUBLE},
LONG_ = #{longValue, jdbcType=BIGINT}, LONG_ = #{longValue, jdbcType=BIGINT},
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<update id="updateByteArray" parameterType="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity"> <update id="updateByteArray" parameterType="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity">
update ACT_BYTEARRAY update ACT_BYTEARRAY
set set
REV_ = #{revisionNext, jdbcType=INTEGER} REV_ = #{revisionNext, jdbcType=INTEGER},
BYTES_ = #{bytes, jdbcType=BLOB} BYTES_ = #{bytes, jdbcType=BLOB}
where ID_ = #{id} where ID_ = #{id}
and REV_ = #{revision, jdbcType=INTEGER} and REV_ = #{revision, jdbcType=INTEGER}
......
...@@ -37,17 +37,17 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase { ...@@ -37,17 +37,17 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase {
// one task in the subprocess should be active after starting the process instance // one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
Task taskBeforeSubProcess = taskQuery.singleResult(); Task taskBeforeSubProcess = taskQuery.listPage();
assertEquals("Task before subprocess", taskBeforeSubProcess.getName()); assertEquals("Task before subprocess", taskBeforeSubProcess.getName());
// Completing the task continues the process which leads to calling the subprocess // Completing the task continues the process which leads to calling the subprocess
taskService.complete(taskBeforeSubProcess.getId()); taskService.complete(taskBeforeSubProcess.getId());
Task taskInSubProcess = taskQuery.singleResult(); Task taskInSubProcess = taskQuery.listPage();
assertEquals("Task in subprocess", taskInSubProcess.getName()); assertEquals("Task in subprocess", taskInSubProcess.getName());
// Completing the task in the subprocess, finishes the subprocess // Completing the task in the subprocess, finishes the subprocess
taskService.complete(taskInSubProcess.getId()); taskService.complete(taskInSubProcess.getId());
Task taskAfterSubProcess = taskQuery.singleResult(); Task taskAfterSubProcess = taskQuery.listPage();
assertEquals("Task after subprocess", taskAfterSubProcess.getName()); assertEquals("Task after subprocess", taskAfterSubProcess.getName());
// Completing this task end the process instance // Completing this task end the process instance
...@@ -67,7 +67,7 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase { ...@@ -67,7 +67,7 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase {
// one task in the subprocess should be active after starting the process instance // one task in the subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
Task taskBeforeSubProcess = taskQuery.singleResult(); Task taskBeforeSubProcess = taskQuery.listPage();
assertEquals("Task in subprocess", taskBeforeSubProcess.getName()); assertEquals("Task in subprocess", taskBeforeSubProcess.getName());
// Completing this task ends the subprocess which leads to the end of the whole process instance // Completing this task ends the subprocess which leads to the end of the whole process instance
...@@ -113,14 +113,14 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase { ...@@ -113,14 +113,14 @@ public class CallActivityAdvancedTest extends ProcessEngineImplTestCase {
// After process start, the task in the subprocess should be active // After process start, the task in the subprocess should be active
runtimeService.startProcessInstanceByKey("timerOnCallActivity"); runtimeService.startProcessInstanceByKey("timerOnCallActivity");
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInSubProcess = taskQuery.singleResult(); Task taskInSubProcess = taskQuery.listPage();
assertEquals("Task in subprocess", taskInSubProcess.getName()); assertEquals("Task in subprocess", taskInSubProcess.getName());
// When the timer on the subprocess is fired, the complete subprocess is destroyed // When the timer on the subprocess is fired, the complete subprocess is destroyed
ClockUtil.setCurrentTime(new Date(startTime.getTime() + (6 * 60 * 1000))); // + 6 minutes, timer fires on 5 minutes ClockUtil.setCurrentTime(new Date(startTime.getTime() + (6 * 60 * 1000))); // + 6 minutes, timer fires on 5 minutes
waitForJobExecutorToProcessAllJobs(10000000, 1000000); waitForJobExecutorToProcessAllJobs(10000, 100);
Task escalatedTask = taskQuery.singleResult(); Task escalatedTask = taskQuery.listPage();
assertEquals("Escalated Task", escalatedTask.getName()); assertEquals("Escalated Task", escalatedTask.getName());
// Completing the task ends the complete process // Completing the task ends the complete process
......
...@@ -93,7 +93,7 @@ public class EngineRebootProcessDefinitionCacheTest extends TestCase { ...@@ -93,7 +93,7 @@ public class EngineRebootProcessDefinitionCacheTest extends TestCase {
.getRuntimeService() .getRuntimeService()
.createProcessInstanceQuery() .createProcessInstanceQuery()
.processInstanceId(processInstanceId) .processInstanceId(processInstanceId)
.singleResult(); .listPage();
assertNotNull(processInstance); assertNotNull(processInstance);
...@@ -111,7 +111,7 @@ public class EngineRebootProcessDefinitionCacheTest extends TestCase { ...@@ -111,7 +111,7 @@ public class EngineRebootProcessDefinitionCacheTest extends TestCase {
.getRuntimeService() .getRuntimeService()
.createProcessInstanceQuery() .createProcessInstanceQuery()
.processInstanceId(processInstanceId) .processInstanceId(processInstanceId)
.singleResult(); .listPage();
assertNull(processInstance); assertNull(processInstance);
......
...@@ -23,7 +23,7 @@ import org.activiti.engine.test.ProcessEngineImplTestCase; ...@@ -23,7 +23,7 @@ import org.activiti.engine.test.ProcessEngineImplTestCase;
*/ */
public class CommandContextTest extends ProcessEngineImplTestCase { public class CommandContextTest extends ProcessEngineImplTestCase {
public void testOne() { public void testCommandContextGetCurrentAfterException() {
try { try {
processEngineConfiguration.getCommandExecutor().execute(new Command<Object>() { processEngineConfiguration.getCommandExecutor().execute(new Command<Object>() {
public Object execute(CommandContext commandContext) { public Object execute(CommandContext commandContext) {
......
...@@ -560,7 +560,9 @@ public class ExecutionImpl implements ...@@ -560,7 +560,9 @@ public class ExecutionImpl implements
parent.collectVariables(collectedVariables); parent.collectVariables(collectedVariables);
} }
ensureVariablesInitialized(); ensureVariablesInitialized();
collectedVariables.putAll(variables); for (String variableName: variables.keySet()) {
collectedVariables.put(variableName, variables.get(variableName));
}
} }
public void setVariables(Map<String, Object> variables) { public void setVariables(Map<String, Object> variables) {
......
...@@ -41,10 +41,13 @@ public class TableDataGet extends ActivitiWebScript ...@@ -41,10 +41,13 @@ public class TableDataGet extends ActivitiWebScript
{ {
String tableName = getMandatoryPathParameter(req, "tableName"); String tableName = getMandatoryPathParameter(req, "tableName");
int size = getInt(req, "size", 10); int size = getInt(req, "size", 10);
TablePageQuery query = getManagementService().createTablePageQuery() int firstResult = getInt(req, "start", 10);
.tableName(tableName) int maxResults = size;
.start(getInt(req, "start", 10))
.size(size); TablePageQuery query = getManagementService()
.createTablePageQuery()
.tableName(tableName);
String sort = getString(req, "sort"); String sort = getString(req, "sort");
if (sort != null && !sort.trim().equals("")) { if (sort != null && !sort.trim().equals("")) {
String order = getString(req, "order", "asc"); String order = getString(req, "order", "asc");
...@@ -55,8 +58,9 @@ public class TableDataGet extends ActivitiWebScript ...@@ -55,8 +58,9 @@ public class TableDataGet extends ActivitiWebScript
query.orderDesc(sort); query.orderDesc(sort);
} }
} }
model.put("size", size);
model.put("tablePage", query.singleResult()); model.put("size", maxResults);
model.put("tablePage", query.listPage(firstResult, maxResults));
} }
} }
\ No newline at end of file
...@@ -55,7 +55,7 @@ public class TasksGet extends ActivitiWebScript ...@@ -55,7 +55,7 @@ public class TasksGet extends ActivitiWebScript
else { else {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Tasks must be filtered with 'assignee', 'candidate' or 'candidate-group'"); throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Tasks must be filtered with 'assignee', 'candidate' or 'candidate-group'");
} }
model.put("tasks", tq.paginatedList(start, size)); model.put("tasks", tq.listPage(start, size));
model.put("start", start); model.put("start", start);
model.put("total", tq.count()); model.put("total", tq.count());
model.put("size", size); model.put("size", size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册