Skip to content

Commit

Permalink
BPMSPL-193 - Expose the jBPM Executor as a Public API BZ-1210802 - Jo…
Browse files Browse the repository at this point in the history
…bExecutor: Sorting and paging start behave strange after jobs are created and cancelled
  • Loading branch information
mswiderski committed Jul 17, 2015
1 parent 8697d52 commit 82f800c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.jbpm.services.api.ProcessService;
import org.jbpm.services.api.RuntimeDataService;
import org.jbpm.services.api.UserTaskService;
import org.kie.internal.executor.api.ExecutorService;
import org.kie.api.executor.ExecutorService;
import org.kie.server.services.api.KieServerApplicationComponentsService;
import org.kie.server.services.api.KieServerRegistry;
import org.kie.server.services.api.SupportedTransports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@

import org.apache.commons.io.input.ClassLoaderObjectInputStream;
import org.jbpm.executor.RequeueAware;
import org.kie.internal.executor.api.CommandContext;
import org.kie.internal.executor.api.ErrorInfo;
import org.kie.internal.executor.api.ExecutionResults;
import org.kie.internal.executor.api.ExecutorService;
import org.kie.internal.executor.api.RequestInfo;
import org.kie.internal.executor.api.STATUS;
import org.kie.api.executor.CommandContext;
import org.kie.api.executor.ErrorInfo;
import org.kie.api.executor.ExecutionResults;
import org.kie.api.executor.ExecutorService;
import org.kie.api.executor.RequestInfo;
import org.kie.api.executor.STATUS;
import org.kie.api.runtime.query.QueryContext;
import org.kie.server.api.model.instance.ErrorInfoInstance;
import org.kie.server.api.model.instance.ErrorInfoInstanceList;
import org.kie.server.api.model.instance.JobRequestInstance;
Expand Down Expand Up @@ -99,7 +100,6 @@ public void requeueRequest(long requestId) {

public RequestInfoInstanceList getRequestsByStatus(List<String> statuses, Integer page, Integer pageSize) {

// TODO use paging when executor service supports it
List<STATUS> statusList = new ArrayList<STATUS>();
if (statuses != null && !statuses.isEmpty()) {
for (String status : statuses) {
Expand All @@ -108,31 +108,29 @@ public RequestInfoInstanceList getRequestsByStatus(List<String> statuses, Intege
} else {
statusList.add(STATUS.QUEUED);
}
List<RequestInfo> requests = executorService.getRequestsByStatus(statusList);
List<RequestInfo> requests = executorService.getRequestsByStatus(statusList, buildQueryContext(page, pageSize));

RequestInfoInstanceList result = convertToRequestInfoList(requests, false, false);

return result;
}

public RequestInfoInstanceList getRequestsByBusinessKey(String businessKey, Integer page, Integer pageSize) {
// TODO use paging when executor service supports it
List<RequestInfo> requests = executorService.getRequestsByBusinessKey(businessKey);

List<RequestInfo> requests = executorService.getRequestsByBusinessKey(businessKey, buildQueryContext(page, pageSize));

RequestInfoInstanceList result = convertToRequestInfoList(requests, false, false);

return result;
}

public RequestInfoInstanceList getRequestsByCommand(String command, Integer page, Integer pageSize) {
// TODO use paging when executor service supports it and enable this method when executor service support it
// List<RequestInfo> requests = executorService.getRequestsByCommand(businessKey);
//
// RequestInfoInstanceList result = convertToRequestInfoList(requests, false, false);
//
// return result;

return new RequestInfoInstanceList();

List<RequestInfo> requests = executorService.getRequestsByCommand(command, buildQueryContext(page, pageSize));

RequestInfoInstanceList result = convertToRequestInfoList(requests, false, false);

return result;
}

// instance details
Expand Down Expand Up @@ -242,4 +240,8 @@ protected Map<String, Object> readContent(byte[] data, ClassLoader classLoader)

return new HashMap<String, Object>();
}

protected QueryContext buildQueryContext(Integer page, Integer pageSize) {
return new QueryContext(page * pageSize, pageSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.kie.internal.identity.IdentityProvider;
import org.kie.internal.process.CorrelationKey;
import org.kie.internal.process.CorrelationKeyFactory;
import org.kie.internal.query.QueryContext;
import org.kie.api.runtime.query.QueryContext;
import org.kie.internal.query.QueryFilter;
import org.kie.internal.task.api.AuditTask;
import org.kie.internal.task.api.model.TaskEvent;
Expand Down

0 comments on commit 82f800c

Please sign in to comment.