cancel
Showing results for 
Search instead for 
Did you mean: 

how to evaluate with UelExpressionCondition

zhengke
Champ in-the-making
Champ in-the-making
i want to get the next node from Transition, but the Transition is exclusiveGateway,so i want to get the UelExpressionCondition from the Transition and get the evaluate result using UelExpressionCondition.evaluate

code:
List<ActivityImpl> activitiList = new ArrayList<ActivityImpl>();
TaskEntity taskEntity = (TaskEntity) taskService.createTaskQuery().taskId("202").singleResult();
      
String processDefinitionId = taskEntity.getProcessDefinitionId();
activitiList = (List<ActivityImpl>) ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition(processDefinitionId).getActivities();
ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(taskEntity.getExecutionId()).singleResult();//执行实例
      
String activitiId = executionEntity.getActivityId();
for(ActivityImpl activityImpl : activitiList) {
  if(activitiId.equals(activityImpl.getId())) {
    List<PvmTransition> transitionImpls = activityImpl.getOutgoingTransitions();
    for(int i = 0; i < transitionImpls.size(); i++) {
   TransitionImpl transitionImpl = (TransitionImpl) transitionImpls.get(i);
   if(transitionImpl.getDestination().getProperty("type") != null && "exclusiveGateway".equals(transitionImpl.getDestination().getProperty("type"))) {
            //how can i get the DelegateExecution object
       System.out.println(((UelExpressionCondition)transitionImpl.getDestination().getOutgoingTransitions().get(0).getProperty("condition")).evaluate(execution));
   }
               
    }
  }
}
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
You can only evaluate ActivitiExpressions using a VariableScope (e.g.. execution), to ensure the expression has access to the variables in the process… Trying to figure out what the next transition will be seems a bit odd, what's your use-case? Why implement a condition in a process and evaluate it yourself and not let the process handle it?

kafeitu
Champ on-the-rise
Champ on-the-rise
You can only evaluate ActivitiExpressions using a VariableScope (e.g.. execution), to ensure the expression has access to the variables in the process… Trying to figure out what the next transition will be seems a bit odd, what's your use-case? Why implement a condition in a process and evaluate it yourself and not let the process handle it?

In china many people would like to do like zhengke…

This is chinese elements, maybe and only.