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());
}
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());
}
}
}
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);
}
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());
}
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());
}
Aggregations