Filter Archived Human Task by Process Name


Hi every body,

I need write custom rest API for filtering archiving human task with Process Name.
Once I do, but result not exactly true same as Bonita API "/bonita/API/bpm/archivedHumanTask?p=0&c=10&o=reached_state_date DESC&f=assigned_id=4&f=state=completed&d=rootContainerId".

This is my code :

 RestApiResponse doHandle(HttpServletRequest request, RestApiResponseBuilder responseBuilder, RestAPIContext context) {
    // To retrieve query parameters use the request.getParameter(..) method.
    // Be careful, parameter values are always returned as String values

    def ProcessName = request.getParameter "ProcessName"
    if (ProcessName == null) {
        return buildResponse(responseBuilder, HttpServletResponse.SC_BAD_REQUEST,"""{"error" : "the parameter ProcessName is missing"}""")

    def UserId = request.getParameter "UserId"
    if (UserId == null) {
        return buildResponse(responseBuilder, HttpServletResponse.SC_BAD_REQUEST,"""{"error" : "the parameter UserId is missing"}""")

    def Count = request.getParameter "Count"
    if (Count == null) {
        Count = -1;

    long maxResults = context.apiClient.getProcessAPI().getNumberOfProcessDeploymentInfos();
    final SearchOptionsBuilder processDepBuilder = new SearchOptionsBuilder(0, (int)maxResults);
    processDepBuilder.filter(ProcessDeploymentInfoSearchDescriptor.NAME, ProcessName);
    final SearchResult<ProcessDeploymentInfo> processDepSearchResult = context.apiClient.getProcessAPI().searchProcessDeploymentInfos(processDepBuilder.done());
    List<ProcessDeploymentInfo> processDepFinalResult = new ArrayList<ProcessDeploymentInfo>();
    for(object in processDepSearchResult.result)

    maxResults = Count;

    final SearchOptionsBuilder archiveHumanTaskBuilder = new SearchOptionsBuilder(0, (int)maxResults);
    int lengthOfList = processDepFinalResult.size();
    int counter = 0;
    for(object in processDepFinalResult)
        counter = counter + 1;
        archiveHumanTaskBuilder.filter(ArchivedHumanTaskInstanceSearchDescriptor.PROCESS_DEFINITION_ID, object.getProcessId());
        if(counter != lengthOfList)
    archiveHumanTaskBuilder.filter(ArchivedHumanTaskInstanceSearchDescriptor.ASSIGNEE_ID, UserId);

    final SearchResult<ArchivedHumanTaskInstance> archivedHumanTaskSearchResult = context.apiClient.getProcessAPI().searchArchivedHumanTasks(archiveHumanTaskBuilder.done());

    List<ArchivedHumanTaskInstance> archivedHumanTaskFinalResult = new ArrayList<ArchivedHumanTaskInstance>();

    for(object in archivedHumanTaskSearchResult.result)

    for (int i=0; i<archivedHumanTaskFinalResult.size()-1;++i)
        for (int j=i+1;j<archivedHumanTaskFinalResult.size();++j)
            if (archivedHumanTaskFinalResult.get(i).flownodeDefinitionId.equals(archivedHumanTaskFinalResult.get(j).flownodeDefinitionId))

    def result = archivedHumanTaskFinalResult;

    // Send the result as a JSON representation
    // You may use buildPagedResponse if your result is multiple
    return buildResponse(responseBuilder, HttpServletResponse.SC_OK, new JsonBuilder(result).toPrettyString())

Please Guide Me,


Submitted by Sean McP on Fri, 05/26/2017 - 21:25

...but result not exactly true same...

So what are the differences in the results? What's the problem?

We're not mind readers... ;)

Bonita API "/bonita/API/bpm/archivedHumanTask?p=0&c=10&o=reached_state_date DESC&f=assigned_id=4&f=state=completed&d=rootContainerId"

Why not just use the Bonitasoft call as shown?

Note: I think there is a small problem in that the piece coded reached_state_date DESC should infact be reached_state_date%20DESC, URI's need to be encoded.


Submitted by the.shirini on Sat, 05/27/2017 - 09:51

Hi Sean,

My result with custom API return some archived task for other userid(ex. Vahid) and beside task for selected userid(ex. Ali user need query result), and also return some archived task not related to Ali but just Ali delegate start process for another user, for example Ali start process for Vahid and in continue vahid done his related tasks but in API result because Ali start process for Vahid in archived Ali task show all done vahid task too.

Why not just use the Bonita soft call as shown?
because we need filter archivedHumanTask by processName for special user.

Best Regards

No answers yet.