use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class AbstractBpmnParseHandler method createAssociation.
protected void createAssociation(BpmnParse bpmnParse, Association association, ScopeImpl parentScope) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
if (bpmnModel.getArtifact(association.getSourceRef()) != null || bpmnModel.getArtifact(association.getTargetRef()) != null) {
// connected to a text annotation so skipping it
return;
}
ActivityImpl sourceActivity = parentScope.findActivity(association.getSourceRef());
ActivityImpl targetActivity = parentScope.findActivity(association.getTargetRef());
// However, we make sure they reference 'something':
if (sourceActivity == null) {
//bpmnModel.addProblem("Invalid reference sourceRef '" + association.getSourceRef() + "' of association element ", association.getId());
} else if (targetActivity == null) {
//bpmnModel.addProblem("Invalid reference targetRef '" + association.getTargetRef() + "' of association element ", association.getId());
} else {
if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch")) {
Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION);
if (isForCompensation == null || !(Boolean) isForCompensation) {
logger.warn("compensation boundary catch must be connected to element with isForCompensation=true");
} else {
ActivityImpl compensatedActivity = sourceActivity.getParentActivity();
compensatedActivity.setProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId());
}
}
}
}
use of org.activiti.bpmn.model.BpmnModel 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.BpmnModel in project Activiti by Activiti.
the class EventListenerConverterTest method connvertXMLToModel.
@Test
public void connvertXMLToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class FormPropertiesConverterTest method connvertJsonToModel.
@Test
public void connvertJsonToModel() throws Exception {
BpmnModel bpmnModel = readXMLFile();
validateModel(bpmnModel);
}
use of org.activiti.bpmn.model.BpmnModel in project Activiti by Activiti.
the class MapExceptionConverterTest method testMapExceptionWithNoErrorCode.
@Test
public void testMapExceptionWithNoErrorCode() throws Exception {
resourceName = "mapException/mapExceptionNoErrorCode.bpmn";
try {
BpmnModel bpmnModel = readXMLFile();
fail("No exception is thrown for mapExecution with no Error Code");
} catch (XMLException x) {
assertTrue(x.getMessage().indexOf("No errorCode defined") != -1);
} catch (Exception e) {
fail("wrong exception thrown. XmlException expected, " + e.getClass() + " thrown");
}
}
Aggregations