JBoss Community

Re: How to Complete a WorkItem using REST API

created by analamala in jBPM - View the full discussion

Thank you Chris. Your feedback is again very valuable. I took approach 1 and everything worked perfectly at the end. Here is what I did.

 

  • gwt-console-server\WEB-INF\lib\jbpm-gwt-core-5.1.0.Final.jar\org\jbpm\integration\console\CommandDelegate.java. Added the following method.

public void completeWorkItem(String workItemId,

            Map<String,Object> results) {

        ksession.getWorkItemManager().completeWorkItem(

                new Long(workItemId).longValue(), results);

    }

 

  • gwt-console-server\WEB-INF\lib\jbpm-gwt-core-5.1.0.Final.jar\org\jbpm\integration\console\ProcessManagement.java. Added the following two methods

public void completeWorkItem(String workItemId) {

        delegate.completeWorkItem(workItemId, null);       

    }   

 

    @Override

    public void completeWorkItem(String workItemId, Map<String,Object> results) {

        delegate.completeWorkItem(workItemId, results);       

    }  

 

  • gwt-console-server\WEB-INF\lib\gwt-console-server-integration-2.1.jar\org\jboss\bpm\console\server\integration\ProcessManagement.java. Added the following method.

void completeWorkItem(String workItemId, Map<String,Object> results);

 

  • Finally I integrated all the changes into gwt-console-server\WEB-INF\classes\org\jboss\bpm\console\server\ProcessMgmtFacade.java. Added the following REST method.

@POST

    @Path("definition/{id}/ctr_component_complete")

    @Produces("application/json")

    public Response ctrComponentComplete(@PathParam("id") String definitionId,

            @FormParam("workitemID") String workItemID) {

        try {

            getProcessManagement().completeWorkItem(workItemID, null);

            return createJsonResponse("SUCCESS");

        } catch (Throwable t) {

            throw new WebApplicationException(t, 500);

        }

    }

 

 

I deployed my changes and was SUCCESSFULLY able to verify that the jbpm-console web application state and the diagram highlighting are updating as expected.

 

Thanks for your help again.

 

-Ajay

Reply to this message by going to Community

Start a new discussion in jBPM at Community