Search in sources :

Example 86 with BpmnModel

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());
            }
        }
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 87 with BpmnModel

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?
    }
}
Also used : Message(org.activiti.bpmn.model.Message) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 88 with BpmnModel

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);
}
Also used : BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 89 with 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);
}
Also used : BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Example 90 with 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");
    }
}
Also used : XMLException(org.activiti.bpmn.exceptions.XMLException) XMLException(org.activiti.bpmn.exceptions.XMLException) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.Test)

Aggregations

BpmnModel (org.activiti.bpmn.model.BpmnModel)149 Test (org.junit.Test)101 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)15 InputStream (java.io.InputStream)13 ByteArrayInputStream (java.io.ByteArrayInputStream)10 Deployment (org.activiti.engine.repository.Deployment)10 Process (org.activiti.bpmn.model.Process)8 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 StartEvent (org.activiti.bpmn.model.StartEvent)7 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 ArrayList (java.util.ArrayList)6 XMLInputFactory (javax.xml.stream.XMLInputFactory)6 XMLStreamReader (javax.xml.stream.XMLStreamReader)6 UserTask (org.activiti.bpmn.model.UserTask)6 FlowElement (org.activiti.bpmn.model.FlowElement)5 BpmnJsonConverter (org.activiti.editor.language.json.converter.BpmnJsonConverter)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 StreamResource (com.vaadin.terminal.StreamResource)4