4 Replies Latest reply on May 5, 2015 6:43 AM by jimmy001

    How to get the type of a task value in jBPM 6?

    Patrick Schäfer Newbie

      Hello,

       

      how can I retrieve information about the type of a task value? I use the org.jbpm.services.api to get the task input  and output mappings.

      The result is a  Map<String, String> with key = id of the datainput in the bpmn2 file e.g. <bpmn2:dataInput id="_9B433374-E950-4FFA-9577-E7C235384BA5_TaskNameInputX" /> and value = name of the task value.

      In addition I need the type of the value to display custom forms in my application. The only type description is offered by the porcess variables. There I can retrieve a map with value name and type.

      My question, can I get the mapping between task input and output values and process values to retrieve type information?

      In my opinion the methods getTaskInputMappings and getTaskOutputMappings of the DefinitionService (BPMN2DataServiceImpl) should offer these information. Any help? Thank you!

        • 1. Re: How to get the type of a task value in jBPM 6?
          Patrick Schäfer Newbie

          I found the code, where the task inputs and outputs are set. It can be found in the class HumanTaskGetInformationHandler. In my opinion the mapping of the inputParams and outputParams maps at the end are unnecessary or is there the mapping between porcess values and task values missing? What do you think?

           

          @Override

              protected void readIoSpecification(org.w3c.dom.Node xmlNode,

          Map<String, String> dataInputs, Map<String, String> dataOutputs) {

                  dataInputs.clear();

                  dataOutputs.clear();

           

                  org.w3c.dom.Node subNode = xmlNode.getFirstChild();

                  while (subNode instanceof Element) {

          String subNodeName = subNode.getNodeName();

                      if ("dataInput".equals(subNodeName)) {

          String id = ((Element) subNode).getAttribute("id");

          String inputName = ((Element) subNode).getAttribute("name");

          dataInputs.put(id, inputName);

                      }

                      if ("dataOutput".equals(subNodeName)) {

          String id = ((Element) subNode).getAttribute("id");

          String outputName = ((Element) subNode).getAttribute("name");

          dataOutputs.put(id, outputName);

                      }

                      subNode = subNode.getNextSibling();

                  }

                  NamedNodeMap map = xmlNode.getParentNode().getAttributes();

                  Node nodeName = map.getNamedItem("name");

                  String name = nodeName.getNodeValue();

           

                  String mainProcessId = module.getRepoHelper().getProcess().getId();

                  UserTaskDefinitionImpl task = (UserTaskDefinitionImpl)repository.getProcessDesc(mainProcessId).getTasks().get(name);

                  if (task == null) {

                      task = new UserTaskDefinitionImpl();

                      task.setName(name);

                      repository.getProcessDesc(mainProcessId).getTasks().put(task.getName(), task);

                  }

           

                  Map<String, String> inputParams = new HashMap<String, String>();

              

              

                  for (Map.Entry<String, String> in : dataInputs.entrySet()) {

                      inputParams.put(in.getKey(), in.getValue());

                  }

                  Map<String, String> outputParams = new HashMap<String, String>();

                  for (Map.Entry<String, String> out : dataOutputs.entrySet()) {

                      outputParams.put(out.getKey(), out.getValue());

                  }

           

                  task.setTaskInputMappings(inputParams);

                  task.setTaskOutputMappings(outputParams);

                  task.setComment(inputParams.get("Comment"));

                  task.setCreatedBy(inputParams.get("CreatedBy"));

                  task.setPriority(getInteger(inputParams.get("Priority")));

                  task.setSkippable("true".equalsIgnoreCase(inputParams.get("Skippable")));

                  repository.getProcessDesc(mainProcessId).getTaskInputMappings().put(task.getName(), inputParams);

                  repository.getProcessDesc(mainProcessId).getTaskOutputMappings().put(task.getName(), outputParams);

              }

          • 2. Re: How to get the type of a task value in jBPM 6?
            Maciej Swiderski Master

            this has been added as part of jira JBPM-4608 and will go out with 6.3. Commit for this can be found here. If you would like to take advantage of it earlier then you would need to use latest snapshot version.

             

            HTH

            • 3. Re: How to get the type of a task value in jBPM 6?
              Patrick Schäfer Newbie

              Thank you Maciej! That's exactly what I have been looking for!

              • 4. Re: How to get the type of a task value in jBPM 6?
                jimmy001 Apprentice

                Hi!

                 

                That is all good and great you have solved your problem, but is there a way to get the task variable => process variable mapping? Currently the result returns a mapping from variable name to variable type.

                What I would expect is a result which includes the information from "bpmn2:dataInputAssociation" which decribes the mapping from task variable => process variable.

                Is there anything like this?

                 

                Thx