AnsweredAssumed Answered

Getting all deployed Workflow Definitions

Question asked by amiramira on Feb 24, 2015
Latest reply on Mar 1, 2015 by amiramira
Hi, I am sorry for my English
I want to get all deployed Workflow Definition this is what i did


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.alfresco.repo.workflow.BPMEngineRegistry;
import org.alfresco.repo.workflow.WorkflowComponent;
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition;

public class WorkflowManag {

   private WorkflowAdminService workflowAdminService;
   BPMEngineRegistry registry = new BPMEngineRegistry();

   public void setBPMEngineRegistry(BPMEngineRegistry registry) {
      this.registry = registry;
   }
   
   public void setWorkflowAdminService(
         WorkflowAdminService workflowAdminService) {
      this.workflowAdminService = workflowAdminService;
   }

   public WorkflowManag(){
   }
 
   
   public List<WorkflowDefinition> getAllDefinitions() {
      List<WorkflowDefinition> definitions = new ArrayList<WorkflowDefinition>();
      String[] ids = registry.getWorkflowComponents();
      
      System.out.println(ids);

      for (String id : ids) {
         if (workflowAdminService.isEngineVisible(id)) {
            WorkflowComponent component = registry.getWorkflowComponent(id);
            definitions.addAll(component.getAllDefinitions());
         }
      
      }
      System.out.println("11111");
      return Collections.unmodifiableList(definitions);

and this is the class test

WorkflowManag wf=new WorkflowManag();
         List<WorkflowDefinition> l=wf.getAllDefinitions();
          System.out.println("aaaaaaaaa"+l.size());
          
          BPMEngineRegistry registry = new BPMEngineRegistry();
         if (registry.getWorkflowComponents().length==0) {
            System.out.println("your reg is empty ");
         }else {
            System.out.println(registry.getWorkflowComponents());
         }


when i execute i get this

[Ljava.lang.String;@1192410
11111
aaaaaaaaa0
your reg is empty

why the registry is empty!!

Thanks



Outcomes