3 Replies Latest reply on Jun 29, 2010 9:50 AM by Joe Gottman

    How to get a list of available transitions for an ActivityExecution

    Joe Gottman Newbie

         I am trying to collect metadata for a Process.  Is there any way to determine the list of available outgoing Transition names for an ActivityExecution?  I'd like to be able to list the legal values for signalName in ExecutionService.signalExecutionByID, or the legal values for outcome in TaskService.completeTask.

        • 1. Re: How to get a list of available transitions for an ActivityExecution
          Jorge Ferreira Newbie

          I do not know if that can be achieved with the public API. If there is a way with the public API you SHOULD prefer that solution to the one that I present below.

          ActivityExecution execution = ...;

          ExecutionImpl executionImpl = (ExecutionImpl) execution;

          ActivityImpl activityImpl = executionImpl.getActivity();

          Map<String, Transition> transitions = activityImpl.getOutgoingTransitionsMap(); // the leaving transitions, keyed by transition name

          1 of 1 people found this helpful
          • 2. Re: How to get a list of available transitions for an ActivityExecution
            Joe Gottman Newbie

            Unfortunately, this did not work for me.  When I tried, this, a JbpmException was thrown by ExceptionImpl.getActivity().  It's message was "no environment to get org.jbpm.pvm.internal.session.RepositorySession".

            • 3. Re: How to get a list of available transitions for an ActivityExecution
              Joe Gottman Newbie

              I finally figured it out.  Jorge's answer was almost correct, but I had to manually create an Environment variable for ExecutionImpl.getActivity() to succeed.  So the final code was

               

              EnvironmentFactory environmentFactory = (EnvironmentFactory)processEngine;
                  Execution execution = executionService.findExecutionById(executionID);
                  if (execution instanceof ExecutionImpl) {
                   ExecutionImpl executionImpl = (ExecutionImpl)execution;
                   EnvironmentImpl environment = environmentFactory.openEnvironment();
                   ActivityImpl activityImpl = null;
                   try {
                    activityImpl = executionImpl.getActivity();
                    } finally {
                    environment.close();
                   } 

                   if (activityImpl != null) {   
                       return activityImpl.getOutgoingTransitionsMap().keySet();

                   }
                  }    

                  return Collections.<String>emptySet();