Search in sources :

Example 6 with TimerEventDefinition

use of org.activiti.bpmn.model.TimerEventDefinition in project Activiti by Activiti.

the class EventJavaTest method testStartEventWithExecutionListener.

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());
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) UserTask(org.activiti.bpmn.model.UserTask) Deployment(org.activiti.engine.repository.Deployment) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) StartEvent(org.activiti.bpmn.model.StartEvent) EndEvent(org.activiti.bpmn.model.EndEvent) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 7 with TimerEventDefinition

use of org.activiti.bpmn.model.TimerEventDefinition in project Activiti by Activiti.

the class BaseBpmnJsonConverter method addEventProperties.

protected void addEventProperties(Event event, ObjectNode propertiesNode) {
    List<EventDefinition> eventDefinitions = event.getEventDefinitions();
    if (eventDefinitions.size() == 1) {
        EventDefinition eventDefinition = eventDefinitions.get(0);
        if (eventDefinition instanceof ErrorEventDefinition) {
            ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(errorDefinition.getErrorCode())) {
                propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorCode());
            }
        } else if (eventDefinition instanceof SignalEventDefinition) {
            SignalEventDefinition signalDefinition = (SignalEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(signalDefinition.getSignalRef())) {
                propertiesNode.put(PROPERTY_SIGNALREF, signalDefinition.getSignalRef());
            }
        } else if (eventDefinition instanceof MessageEventDefinition) {
            MessageEventDefinition messageDefinition = (MessageEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
                propertiesNode.put(PROPERTY_MESSAGEREF, messageDefinition.getMessageRef());
            }
        } else if (eventDefinition instanceof TimerEventDefinition) {
            TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
            if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
                propertiesNode.put(PROPERTY_TIMER_DURATON, timerDefinition.getTimeDuration());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
                propertiesNode.put(PROPERTY_TIMER_CYCLE, timerDefinition.getTimeCycle());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
                propertiesNode.put(PROPERTY_TIMER_DATE, timerDefinition.getTimeDate());
            }
            if (StringUtils.isNotEmpty(timerDefinition.getEndDate())) {
                propertiesNode.put(PROPERTY_TIMER_CYCLE_END_DATE, timerDefinition.getEndDate());
            }
        } else if (eventDefinition instanceof TerminateEventDefinition) {
            TerminateEventDefinition terminateEventDefinition = (TerminateEventDefinition) eventDefinition;
            propertiesNode.put(PROPERTY_TERMINATE_ALL, terminateEventDefinition.isTerminateAll());
        }
    }
}
Also used : ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TerminateEventDefinition(org.activiti.bpmn.model.TerminateEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 8 with TimerEventDefinition

use of org.activiti.bpmn.model.TimerEventDefinition in project Activiti by Activiti.

the class BaseBpmnJsonConverter method convertJsonToTimerDefinition.

protected void convertJsonToTimerDefinition(JsonNode objectNode, Event event) {
    String timeDate = getPropertyValueAsString(PROPERTY_TIMER_DATE, objectNode);
    String timeCycle = getPropertyValueAsString(PROPERTY_TIMER_CYCLE, objectNode);
    String timeDuration = getPropertyValueAsString(PROPERTY_TIMER_DURATON, objectNode);
    String endDate = getPropertyValueAsString(PROPERTY_TIMER_CYCLE_END_DATE, objectNode);
    TimerEventDefinition eventDefinition = new TimerEventDefinition();
    if (StringUtils.isNotEmpty(timeDate)) {
        eventDefinition.setTimeDate(timeDate);
    } else if (StringUtils.isNotEmpty(timeCycle)) {
        eventDefinition.setTimeCycle(timeCycle);
    } else if (StringUtils.isNotEmpty(timeDuration)) {
        eventDefinition.setTimeDuration(timeDuration);
    }
    if (StringUtils.isNotEmpty(endDate)) {
        eventDefinition.setEndDate(endDate);
    }
    event.getEventDefinitions().add(eventDefinition);
}
Also used : TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 9 with TimerEventDefinition

use of org.activiti.bpmn.model.TimerEventDefinition in project Activiti by Activiti.

the class BoundaryEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    BoundaryEvent errorElement = (BoundaryEvent) model.getMainProcess().getFlowElement("errorEvent");
    ErrorEventDefinition errorEvent = (ErrorEventDefinition) extractEventDefinition(errorElement);
    //always true
    assertTrue(errorElement.isCancelActivity());
    assertEquals("errorRef", errorEvent.getErrorCode());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent signalElement = (BoundaryEvent) model.getMainProcess().getFlowElement("signalEvent");
    SignalEventDefinition signalEvent = (SignalEventDefinition) extractEventDefinition(signalElement);
    assertFalse(signalElement.isCancelActivity());
    assertEquals("signalRef", signalEvent.getSignalRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent messageElement = (BoundaryEvent) model.getMainProcess().getFlowElement("messageEvent");
    MessageEventDefinition messageEvent = (MessageEventDefinition) extractEventDefinition(messageElement);
    assertFalse(messageElement.isCancelActivity());
    assertEquals("messageRef", messageEvent.getMessageRef());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
    BoundaryEvent timerElement = (BoundaryEvent) model.getMainProcess().getFlowElement("timerEvent");
    TimerEventDefinition timerEvent = (TimerEventDefinition) extractEventDefinition(timerElement);
    assertFalse(timerElement.isCancelActivity());
    assertEquals("PT5M", timerEvent.getTimeDuration());
    assertEquals("sid-F21E9F4D-EA19-44DF-B1D3-14663A809CAE", errorElement.getAttachedToRefId());
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 10 with TimerEventDefinition

use of org.activiti.bpmn.model.TimerEventDefinition in project Activiti by Activiti.

the class CatchEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement timerElement = model.getMainProcess().getFlowElement("timer_evt");
    EventDefinition timerEvent = extractEventDefinition(timerElement);
    assertTrue(timerEvent instanceof TimerEventDefinition);
    TimerEventDefinition ted = (TimerEventDefinition) timerEvent;
    assertEquals("PT5M", ted.getTimeDuration());
    FlowElement signalElement = model.getMainProcess().getFlowElement("signal_evt");
    EventDefinition signalEvent = extractEventDefinition(signalElement);
    assertTrue(signalEvent instanceof SignalEventDefinition);
    SignalEventDefinition sed = (SignalEventDefinition) signalEvent;
    assertEquals("signal_ref", sed.getSignalRef());
    FlowElement messageElement = model.getMainProcess().getFlowElement("message_evt");
    EventDefinition messageEvent = extractEventDefinition(messageElement);
    assertTrue(messageEvent instanceof MessageEventDefinition);
    MessageEventDefinition med = (MessageEventDefinition) messageEvent;
    assertEquals("message_ref", med.getMessageRef());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Aggregations

TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)19 EventDefinition (org.activiti.bpmn.model.EventDefinition)7 FlowElement (org.activiti.bpmn.model.FlowElement)7 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 StartEvent (org.activiti.bpmn.model.StartEvent)4 UserTask (org.activiti.bpmn.model.UserTask)4 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)3 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)2 Process (org.activiti.bpmn.model.Process)2 SubProcess (org.activiti.bpmn.model.SubProcess)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashMap (java.util.HashMap)1 List (java.util.List)1 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)1