AnsweredAssumed Answered

workflow called by java

Question asked by mythox on May 22, 2014
Latest reply on May 23, 2014 by kaynezhang
hi, i try to understand the concept of calling workflow by java, i made a simple class as below, but below nodeService.addChild i do not understand, and i cant find related document about it.  appreciate for any advice.

the workflow is a simple workflow with 1 parameter as a name, it will say hello to this name in the debug log 


public class TestCallWorkflowByJava extends ActionExecuterAbstractBase  {
   public static final String NAME = "test-workflow";
   public static final String PARAM_NAME = "hello-name";
   private NodeService nodeService;
   private WorkflowService workflowService;

   protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
      // Add definitions for action parameters
      paramList.add(new ParameterDefinitionImpl(          

   protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
      if (this.nodeService.exists(actionedUponNodeRef) == true) {
          String helloQName = (String) action.getParameterValue(PARAM_NAME);
          NodeRef workflowPackage = this.workflowService.createPackage(null);
          nodeService.addChild(workflowPackage, ?, ?, ?);      //  <–  i dunno know what should be add to these 3 question marks.
          Map<QName, Serializable> workflowProps = new HashMap<QName, Serializable>(16);
          workflowProps.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
          QName PROP_QNAME_HELLO_NAME = QName.createQName(PeWorkflowModel.NAMESPACE_PE_CONTENT_MODEL, PeWorkflowModel.PROP_HELLO_NAME);
          workflowProps.put(PROP_QNAME_HELLO_NAME, helloQName);
          WorkflowDefinition workflowDefinition = this.workflowService.getDefinitionByName("activiti$helloWorld");
          this.workflowService.startWorkflow(workflowDefinition.getId(), workflowProps);
   //   Setter
   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   public void setWorkflowService(WorkflowService workflowService) {
      this.workflowService = workflowService;