cancel
Showing results for 
Search instead for 
Did you mean: 

How to get process state

sliu
Champ in-the-making
Champ in-the-making
Hi,
We're planning to use Activiti API to interact with the engine, bypassing Activiti UI.
I'd like to know what API to use to get the process state. Let's take the monthly financial report example in user guide. I can start it by calling:
@Autowired
private ProcessEngine processEngine;
public someFunc() {
  ProcessInstance newReportProcess =
       processEngine.getRuntimeService().startProcessInstanceByKey("finance_report");
  String financeReportProcessId= newReportProcess .getBusinessKey();
  // keep the financeReportProcessId somewhere
}

Now we know the process is blocking at the first user activity ("write finance report"). What Activiti API should I use to get this state? Looks like ProcessInstance.isSuspended() can be used to check if it's blocked somewhere, but I'm looking a way to tell me it's blocked at "write report".

TIA
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
You should use RuntimeService, call this method with process-instance ID or execution-ID:


/** Finds the activity ids for all executions that are waiting in activities.
   * This is a list because a single activity can be active multiple times.
   * @param executionId id of the execution, cannot be null.
   * @throws ActivitiException when no execution exists with the given executionId.
   */
  List<String> getActiveActivityIds(String executionId);

The API isn't that huge, so it's always good to do a quick read through of the javadocs for the core-services: http://activiti.org/javadocs/index.html