Java Code Examples for org.activiti.bpmn.model.SequenceFlow#setTargetRef()

The following examples show how to use org.activiti.bpmn.model.SequenceFlow#setTargetRef() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventJavaTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testStartEventWithExecutionListener() throws Exception {
  BpmnModel bpmnModel = new BpmnModel();
  Process process = new Process();
  process.setId("simpleProcess");
  process.setName("Very simple process");
  bpmnModel.getProcesses().add(process);
  StartEvent startEvent = new StartEvent();
  startEvent.setId("startEvent1");
  TimerEventDefinition timerDef = new TimerEventDefinition();
  timerDef.setTimeDuration("PT5M");
  startEvent.getEventDefinitions().add(timerDef);
  ActivitiListener listener = new ActivitiListener();
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  listener.setImplementation("${test}");
  listener.setEvent("end");
  startEvent.getExecutionListeners().add(listener);
  process.addFlowElement(startEvent);
  UserTask task = new UserTask();
  task.setId("reviewTask");
  task.setAssignee("kermit");
  process.addFlowElement(task);
  SequenceFlow flow1 = new SequenceFlow();
  flow1.setId("flow1");
  flow1.setSourceRef("startEvent1");
  flow1.setTargetRef("reviewTask");
  process.addFlowElement(flow1);
  EndEvent endEvent = new EndEvent();
  endEvent.setId("endEvent1");
  process.addFlowElement(endEvent);

  byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);

  new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));

  Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
  repositoryService.deleteDeployment(deployment.getId());
}
 
Example 2
Source File: SequenceFlowXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  SequenceFlow sequenceFlow = new SequenceFlow();
  BpmnXMLUtil.addXMLLocation(sequenceFlow, xtr);
  sequenceFlow.setSourceRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SOURCE_REF));
  sequenceFlow.setTargetRef(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_TARGET_REF));
  sequenceFlow.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
  sequenceFlow.setSkipExpression(xtr.getAttributeValue(null, ATTRIBUTE_FLOW_SKIP_EXPRESSION));

  parseChildElements(getXMLElementName(), sequenceFlow, model, xtr);

  return sequenceFlow;
}
 
Example 3
Source File: EventJavaTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testStartEventWithExecutionListener() throws Exception {
  BpmnModel bpmnModel = new BpmnModel();
  Process process = new Process();
  process.setId("simpleProcess");
  process.setName("Very simple process");
  bpmnModel.getProcesses().add(process);
  StartEvent startEvent = new StartEvent();
  startEvent.setId("startEvent1");
  TimerEventDefinition timerDef = new TimerEventDefinition();
  timerDef.setTimeDuration("PT5M");
  startEvent.getEventDefinitions().add(timerDef);
  ActivitiListener listener = new ActivitiListener();
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  listener.setImplementation("${test}");
  listener.setEvent("end");
  startEvent.getExecutionListeners().add(listener);
  process.addFlowElement(startEvent);
  UserTask task = new UserTask();
  task.setId("reviewTask");
  task.setAssignee("kermit");
  process.addFlowElement(task);
  SequenceFlow flow1 = new SequenceFlow();
  flow1.setId("flow1");
  flow1.setSourceRef("startEvent1");
  flow1.setTargetRef("reviewTask");
  process.addFlowElement(flow1);
  EndEvent endEvent = new EndEvent();
  endEvent.setId("endEvent1");
  process.addFlowElement(endEvent);
  
  byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
  
  new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
  
  Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml))
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  repositoryService.deleteDeployment(deployment.getId());
}
 
Example 4
Source File: SequenceFlowJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
  SequenceFlow flow = new SequenceFlow();

  String sourceRef = BpmnJsonConverterUtil.lookForSourceRef(elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES));
  if (sourceRef != null) {
    flow.setSourceRef(sourceRef);
    JsonNode targetNode = elementNode.get("target");
    if (targetNode != null && targetNode.isNull() == false) {
      String targetId = targetNode.get(EDITOR_SHAPE_ID).asText();
      if (shapeMap.get(targetId) != null) {
        flow.setTargetRef(BpmnJsonConverterUtil.getElementId(shapeMap.get(targetId)));
      }
    }
  }

  JsonNode conditionNode = getProperty(PROPERTY_SEQUENCEFLOW_CONDITION, elementNode);
  if (conditionNode != null) {

    if (conditionNode.isTextual() && conditionNode.isNull() == false) {
      flow.setConditionExpression(conditionNode.asText());

    } else if (conditionNode.get("expression") != null) {
      JsonNode expressionNode = conditionNode.get("expression");
      if (expressionNode.get("type") != null) {
        String expressionType = expressionNode.get("type").asText();

        if ("variables".equalsIgnoreCase(expressionType) && expressionNode.get("fieldType") != null) {

          String fieldType = expressionNode.get("fieldType").asText();

          if ("field".equalsIgnoreCase(fieldType)) {
            setFieldConditionExpression(flow, expressionNode);

          } else if ("outcome".equalsIgnoreCase(fieldType)) {
            setOutcomeConditionExpression(flow, expressionNode);
          }

        } else if (expressionNode.get("staticValue") != null && expressionNode.get("staticValue").isNull() == false) {
          flow.setConditionExpression(expressionNode.get("staticValue").asText());
        }
      }
    }
  }

  return flow;
}
 
Example 5
Source File: DynamicProcess.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
protected SequenceFlow createSequenceFlow(String from, String to) {
    SequenceFlow flow = new SequenceFlow();
    flow.setSourceRef(from);
    flow.setTargetRef(to);
    return flow;
}