org.activiti.bpmn.model.Process.getFlowElement()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(523)

本文整理了Java中org.activiti.bpmn.model.Process.getFlowElement()方法的一些代码示例,展示了Process.getFlowElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Process.getFlowElement()方法的具体详情如下:
包路径:org.activiti.bpmn.model.Process
类名称:Process
方法名:getFlowElement

Process.getFlowElement介绍

暂无

代码示例

代码示例来源:origin: Activiti/Activiti

protected FlowNode getFlowNodeFromScope(String elementId, BaseElement scope) {
 FlowNode flowNode = null;
 if (StringUtils.isNotEmpty(elementId)) {
  if (scope instanceof Process) {
   flowNode = (FlowNode) ((Process) scope).getFlowElement(elementId);
  } else if (scope instanceof SubProcess) {
   flowNode = (FlowNode) ((SubProcess) scope).getFlowElement(elementId);
  }
 }
 return flowNode;
}

代码示例来源:origin: Activiti/Activiti

FlowElement source = process.getFlowElement(sourceRef, true);
FlowElement target = process.getFlowElement(targetRef, true);

代码示例来源:origin: Activiti/Activiti

protected void handleCompensationEventDefinition(BpmnModel bpmnModel, Process process, Event event, EventDefinition eventDefinition, List<ValidationError> errors) {
 CompensateEventDefinition compensateEventDefinition = (CompensateEventDefinition) eventDefinition;
 // Check activityRef
 if ((StringUtils.isNotEmpty(compensateEventDefinition.getActivityRef()) && process.getFlowElement(compensateEventDefinition.getActivityRef(), true) == null)) {
  addError(errors, Problems.COMPENSATE_EVENT_INVALID_ACTIVITY_REF, process, event, "Invalid attribute value for 'activityRef': no activity with the given id");
 }
}

代码示例来源:origin: Activiti/Activiti

protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {
 org.activiti.bpmn.model.Process process = bpmnParse.getCurrentProcess();
 sequenceFlow.setSourceFlowElement(process.getFlowElement(sequenceFlow.getSourceRef(), true));
 sequenceFlow.setTargetFlowElement(process.getFlowElement(sequenceFlow.getTargetRef(), true));
}

代码示例来源:origin: Activiti/Activiti

public FlowElement getCurrentFlowElement() {
 if (currentFlowElement == null) {
  String processDefinitionId = getProcessDefinitionId();
  if (processDefinitionId != null) {
   org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
   currentFlowElement = process.getFlowElement(getCurrentActivityId(), true);
  }
 }
 return currentFlowElement;
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 List<EventGateway> eventGateways = process.findFlowElementsOfType(EventGateway.class);
 for (EventGateway eventGateway : eventGateways) {
  for (SequenceFlow sequenceFlow : eventGateway.getOutgoingFlows()) {
   FlowElement flowElement = process.getFlowElement(sequenceFlow.getTargetRef(), true);
   if (flowElement != null && !(flowElement instanceof IntermediateCatchEvent)) {
    addError(errors, Problems.EVENT_GATEWAY_ONLY_CONNECTED_TO_INTERMEDIATE_EVENTS, process, eventGateway, "Event based gateway can only be connected to elements of type intermediateCatchEvent");
   }
  }
 }
}

代码示例来源:origin: Activiti/Activiti

/**
 * Verifies if the element with the given source identifier can reach the element with the target identifier through following sequence flow.
 */
public static boolean isReachable(String processDefinitionId, String sourceElementId, String targetElementId) {
 // Fetch source and target elements
 Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
 FlowElement sourceFlowElement = process.getFlowElement(sourceElementId, true);
 FlowNode sourceElement = null;
 if (sourceFlowElement instanceof FlowNode) {
  sourceElement = (FlowNode) sourceFlowElement;
 } else if (sourceFlowElement instanceof SequenceFlow) {
  sourceElement = (FlowNode) ((SequenceFlow) sourceFlowElement).getTargetFlowElement();
 }
 FlowElement targetFlowElement = process.getFlowElement(targetElementId, true);
 FlowNode targetElement = null;
 if (targetFlowElement instanceof FlowNode) {
  targetElement = (FlowNode) targetFlowElement;
 } else if (targetFlowElement instanceof SequenceFlow) {
  targetElement = (FlowNode) ((SequenceFlow) targetFlowElement).getTargetFlowElement();
 }
 if (sourceElement == null) {
  throw new ActivitiException("Invalid sourceElementId '" + sourceElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
 }
 if (targetElement == null) {
  throw new ActivitiException("Invalid targetElementId '" + targetElementId + "': no element found for this id n process definition '" + processDefinitionId + "'");
 }
 Set<String> visitedElements = new HashSet<String>();
 return isReachable(process, sourceElement, targetElement, visitedElements);
}

代码示例来源:origin: Activiti/Activiti

public void executeTaskListeners(TaskEntity taskEntity, String eventType) {
 if (taskEntity.getProcessDefinitionId() != null) {
  org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId());
  FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true);
  if (flowElement instanceof UserTask) {
   UserTask userTask = (UserTask) flowElement;
   executeTaskListeners(userTask, taskEntity, eventType);
  }
 }
}

代码示例来源:origin: Activiti/Activiti

protected int getMaxIterations(org.activiti.bpmn.model.Process process, String activityId) {
 FlowElement flowElement = process.getFlowElement(activityId, true);
 if (flowElement != null) {
  if (flowElement instanceof Event) {
       Event event = (Event) flowElement;
   List<EventDefinition> eventDefinitions = event.getEventDefinitions();
       if (eventDefinitions != null) {
         for (EventDefinition eventDefinition : eventDefinitions) {
     if (eventDefinition instanceof TimerEventDefinition) {
      TimerEventDefinition timerEventDefinition = (TimerEventDefinition) eventDefinition;
      if (timerEventDefinition.getTimeCycle() != null) {
       return calculateMaxIterationsValue(timerEventDefinition.getTimeCycle());
      }
     }
    }
        }
      }
 }
 return -1;
}

代码示例来源:origin: Activiti/Activiti

for (SequenceFlow sequenceFlow : sequenceFlows) {
 String targetRef = sequenceFlow.getTargetRef();
 FlowNode sequenceFlowTarget = (FlowNode) process.getFlowElement(targetRef, true);
 if (sequenceFlowTarget != null && !visitedElements.contains(sequenceFlowTarget.getId())) {
  boolean reachable = isReachable(process, sequenceFlowTarget, targetElement, visitedElements);

代码示例来源:origin: Activiti/Activiti

/**
 * Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution.
 */
protected FlowElement getCurrentFlowElement(final ExecutionEntity execution) {
 if (execution.getCurrentFlowElement() != null) {
  return execution.getCurrentFlowElement();
 } else if (execution.getCurrentActivityId() != null) {
  String processDefinitionId = execution.getProcessDefinitionId();
  org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
  String activityId = execution.getCurrentActivityId();
  FlowElement currentFlowElement = process.getFlowElement(activityId, true);
  return currentFlowElement;
 }
 return null;
}

代码示例来源:origin: Activiti/Activiti

/**
 * To be used in an {@link ActivityBehavior} or {@link JavaDelegate}: leaves
 * the current activity via one specific sequenceflow.
 */
public static void leaveDelegate(DelegateExecution delegateExecution,
                 String sequenceFlowId) {
  String processDefinitionId = delegateExecution.getProcessDefinitionId();
  Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
  FlowElement flowElement = process.getFlowElement(sequenceFlowId);
  if (flowElement instanceof SequenceFlow) {
    delegateExecution.setCurrentFlowElement(flowElement);
    Context.getAgenda().planTakeOutgoingSequenceFlowsOperation((ExecutionEntity) delegateExecution,
                                  false);
  } else {
    throw new ActivitiException(sequenceFlowId + " does not match a sequence flow");
  }
}

代码示例来源:origin: Activiti/Activiti

&& !inactiveExecution.isDeleted()) {
FlowNode flowNode = (FlowNode) process.getFlowElement(inactiveExecution.getActivityId(), true);
InactiveActivityBehavior inactiveActivityBehavior = ((InactiveActivityBehavior) flowNode.getBehavior());
logger.debug("Found InactiveActivityBehavior instance of class {} that can be executed on activity '{}'", inactiveActivityBehavior.getClass(), flowNode.getId());

代码示例来源:origin: Activiti/Activiti

String activityId = TimerEventHandler.getActivityIdFromConfiguration(configuration);
if (activityId != null) {
 FlowElement flowElement = process.getFlowElement(activityId, true);
 if (flowElement == null) {
  throw new ActivitiException("Could not find matching FlowElement for activityId " + activityId);

代码示例来源:origin: Activiti/Activiti

FlowElement flowElement = process.getFlowElement(eventSubscription.getActivityId(), true);
if (flowElement == null) {
 throw new ActivitiException("Could not find matching FlowElement for activityId " + eventSubscription.getActivityId());

代码示例来源:origin: Activiti/Activiti

protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) {
 // check that the new process definition version contains the current activity
 org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId());
 if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { 
  throw new ActivitiException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '"
    + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "').");
 }
 // switch the process instance to the new process definition version
 execution.setProcessDefinitionId(newProcessDefinition.getId());
 execution.setProcessDefinitionName(newProcessDefinition.getName());
 execution.setProcessDefinitionKey(newProcessDefinition.getKey());
 // and change possible existing tasks (as the process definition id is stored there too)
 List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId());
 for (TaskEntity taskEntity : tasks) {
  taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
  commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId());
 }
}

代码示例来源:origin: Activiti/Activiti

List<Association> associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId());
for (Association association : associations) {
 FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true);
 if (targetElement instanceof Activity) {
  Activity activity = (Activity) targetElement;

代码示例来源:origin: Activiti/Activiti

FlowElement flowElement = process.getFlowElement(eventSubscription.getActivityId(), true);

代码示例来源:origin: org.activiti/activiti-engine

public FlowElement getCurrentFlowElement() {
 if (currentFlowElement == null) {
  String processDefinitionId = getProcessDefinitionId();
  if (processDefinitionId != null) {
   org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
   currentFlowElement = process.getFlowElement(getCurrentActivityId(), true);
  }
 }
 return currentFlowElement;
}

代码示例来源:origin: org.activiti/activiti-engine

public void executeTaskListeners(TaskEntity taskEntity, String eventType) {
 if (taskEntity.getProcessDefinitionId() != null) {
  org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(taskEntity.getProcessDefinitionId());
  FlowElement flowElement = process.getFlowElement(taskEntity.getTaskDefinitionKey(), true);
  if (flowElement instanceof UserTask) {
   UserTask userTask = (UserTask) flowElement;
   executeTaskListeners(userTask, taskEntity, eventType);
  }
 }
}

相关文章