use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class DefaultWorkflowDefinitionConversionListener method initializeProcess.
protected void initializeProcess(WorkflowDefinitionConversion conversion) {
WorkflowDefinition workflowDefinition = conversion.getWorkflowDefinition();
// Create new process
Process process = conversion.getProcess();
process.setId(generateProcessId(workflowDefinition));
process.setName(workflowDefinition.getName());
process.setDocumentation(workflowDefinition.getDescription());
if (workflowDefinition.getCategory() != null) {
conversion.getBpmnModel().setTargetNamespace(workflowDefinition.getCategory());
}
conversion.setProcess(process);
// Add start-event
StartEvent startEvent = new StartEvent();
startEvent.setId(START_EVENT_ID);
if (workflowDefinition.getStartFormDefinition() != null && workflowDefinition.getStartFormDefinition().getFormKey() != null) {
startEvent.setFormKey(workflowDefinition.getStartFormDefinition().getFormKey());
}
process.addFlowElement(startEvent);
conversion.setLastActivityId(startEvent.getId());
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class StartEventXMLConverter method writeExtensionChildElements.
@Override
protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
StartEvent startEvent = (StartEvent) element;
didWriteExtensionStartElement = writeFormProperties(startEvent, didWriteExtensionStartElement, xtw);
return didWriteExtensionStartElement;
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class AbstractActivitiTestCase method createOneTaskTestProcess.
/**
* Since the 'one task process' is used everywhere the actual process content
* doesn't matter, instead of copying around the BPMN 2.0 xml one could use
* this method which gives a {@link BpmnModel} version of the same process back.
*/
public BpmnModel createOneTaskTestProcess() {
BpmnModel model = new BpmnModel();
org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
model.addProcess(process);
process.setId("oneTaskProcess");
process.setName("The one task process");
StartEvent startEvent = new StartEvent();
startEvent.setId("start");
process.addFlowElement(startEvent);
UserTask userTask = new UserTask();
userTask.setName("The Task");
userTask.setId("theTask");
userTask.setAssignee("kermit");
process.addFlowElement(userTask);
EndEvent endEvent = new EndEvent();
endEvent.setId("theEnd");
process.addFlowElement(endEvent);
process.addFlowElement(new SequenceFlow("start", "theTask"));
process.addFlowElement(new SequenceFlow("theTask", "theEnd"));
return model;
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class MessageEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
String messageRef = messageDefinition.getMessageRef();
if (bpmnModel.containsMessageId(messageRef)) {
Message message = bpmnModel.getMessage(messageRef);
messageDefinition.setMessageRef(message.getName());
messageDefinition.setExtensionElements(message.getExtensionElements());
}
EventSubscriptionDeclaration eventSubscription = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
ScopeImpl scope = bpmnParse.getCurrentScope();
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent && bpmnParse.getCurrentSubProcess() != null) {
// the scope of the event subscription is the parent of the event
// subprocess (subscription must be created when parent is initialized)
ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
eventSubscriptionDeclaration.setActivityId(activity.getId());
eventSubscriptionDeclaration.setStartEvent(false);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, catchingScope);
} else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
activity.setProperty("type", "messageStartEvent");
eventSubscription.setStartEvent(true);
eventSubscription.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, bpmnParse.getCurrentProcessDefinition());
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
activity.setProperty("type", "intermediateMessageCatch");
if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
eventSubscription.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity.getParent());
} else {
activity.setScope(true);
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
activity.setProperty("type", "boundaryMessage");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
eventSubscriptionDeclaration.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, activity.getParent());
if (activity.getParent() instanceof ActivityImpl) {
((ActivityImpl) activity.getParent()).setScope(true);
}
} else {
// What to do here?
}
}
use of org.activiti.bpmn.model.StartEvent in project Activiti by Activiti.
the class ErrorEventDefinitionParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
ErrorEventDefinition modelErrorEvent = (ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(modelErrorEvent.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(modelErrorEvent.getErrorCode());
modelErrorEvent.setErrorCode(errorCode);
}
ScopeImpl scope = bpmnParse.getCurrentScope();
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
scope.setProperty(PROPERTYNAME_INITIAL, activity);
// the scope of the event subscription is the parent of the event
// subprocess (subscription must be created when parent is initialized)
ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
createErrorStartEventDefinition(modelErrorEvent, activity, catchingScope);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
// non-interrupting not yet supported
boolean interrupting = true;
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId());
createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity);
}
}
Aggregations