4 Replies Latest reply on Feb 2, 2012 10:52 AM by sebb

    Result Mapping for ServiceTask in CustomWorkItemEditor

    sebb

      Since I try to make the creation of processes as easy as possible I'd like to make a default result mapping in my CustomWorkItemEditor. I know how to do the parameter mapping, but not how to map the results. I think of a default result and error object (resp. variable in my proces). So that I can map every response from my ServiceTask either to the result variable or to the error variable if the response is an exception.

       

      Is this possible? Currenty I dont know how to access the result mapping of the process inside of the CustomWorkItemEditor, becaues WorkImpl does only allow access to the parameters.

        • 1. Re: Result Mapping for ServiceTask in CustomWorkItemEditor
          melc

          Hi,

          If i understood correctly, you can return results from your custom work item by passing your parameters to the

          completeWorkItem(WorkItem workItem, WorkItemManager manager, Map<String, Object> results) method of WorkItemManager object

          i.e.

           

          Map<String, Object> results;

          results.put("result", resultObject); results.put("error",errorObject);

          manager.completeWorkItem(workItem.getId(), results);

          or even better from the StatefulKnowledgeSession object via

          ksession.getWorkItemManager().completeWorkItem(....) .

           

          Then you can assign the result mapping i.e from editors.

          • 2. Re: Result Mapping for ServiceTask in CustomWorkItemEditor
            sebb

            Thanks for your reply.

             

            Yes, that is the way how you do it at "runtime". But I was searching for a solution at design time:

             

            Usually you have to edit the property "Result Mapping" in the eclipse plugin in order to use the result (that you have passed with the completeWorkItem method) in the process as a variable. I was thinking of a shortcut that can be done inside the custom dialog of the serviceTask.

            • 3. Re: Result Mapping for ServiceTask in CustomWorkItemEditor
              melc

              One way of doing it could be by seting variables of the StatefulKnowledgeSession. The StatefulKnowledgeSession could be passed to the constructor of your work item handler.

              • 4. Re: Result Mapping for ServiceTask in CustomWorkItemEditor
                sebb

                You are on the wrong way, but thanks for your contribution Just to clear it up:

                 

                I am talking about a custom work item Editor not about a Handler.

                 

                Its something like this:

                 

                public class MyWorkItemEditor extends EditBeanDialog<Work> implements WorkEditor{

                public MyWorkItemEditor(Shell parentShell){
                     super(parentShell, "Title of my editor");
                }

                protected Control createDialogArea(Composite parent) {
                     //create my gui stuff
                }

                etc.

                So I am talking about the GUI Dialog that pops up when clicking on a Service Task in the eclipse jbpm plugin =)