Search in sources :

Example 1 with BoundaryEvent

use of org.camunda.bpm.model.bpmn.instance.BoundaryEvent in project camunda-bpmn-model by camunda.

the class AbstractActivityBuilder method calculateXCoordinate.

protected double calculateXCoordinate(Bounds boundaryEventBounds) {
    BpmnShape attachedToElement = findBpmnShape(element);
    double x = 0;
    if (attachedToElement != null) {
        Bounds attachedToBounds = attachedToElement.getBounds();
        Collection<BoundaryEvent> boundaryEvents = element.getParentElement().getChildElementsByType(BoundaryEvent.class);
        Collection<BoundaryEvent> attachedBoundaryEvents = new ArrayList<BoundaryEvent>();
        Iterator<BoundaryEvent> iterator = boundaryEvents.iterator();
        while (iterator.hasNext()) {
            BoundaryEvent tmp = iterator.next();
            if (tmp.getAttachedTo().equals(element)) {
                attachedBoundaryEvents.add(tmp);
            }
        }
        double attachedToX = attachedToBounds.getX();
        double attachedToWidth = attachedToBounds.getWidth();
        double boundaryWidth = boundaryEventBounds.getWidth();
        switch(attachedBoundaryEvents.size()) {
            case 2:
                {
                    x = attachedToX + attachedToWidth / 2 + boundaryWidth / 2;
                    break;
                }
            case 3:
                {
                    x = attachedToX + attachedToWidth / 2 - 1.5 * boundaryWidth;
                    break;
                }
            default:
                {
                    x = attachedToX + attachedToWidth / 2 - boundaryWidth / 2;
                    break;
                }
        }
    }
    return x;
}
Also used : BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape) BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) Bounds(org.camunda.bpm.model.bpmn.instance.dc.Bounds) ArrayList(java.util.ArrayList)

Example 2 with BoundaryEvent

use of org.camunda.bpm.model.bpmn.instance.BoundaryEvent in project camunda-bpmn-model by camunda.

the class AbstractActivityBuilder method boundaryEvent.

public BoundaryEventBuilder boundaryEvent(String id) {
    BoundaryEvent boundaryEvent = createSibling(BoundaryEvent.class, id);
    boundaryEvent.setAttachedTo(element);
    BpmnShape boundaryEventBpmnShape = createBpmnShape(boundaryEvent);
    setBoundaryEventCoordinates(boundaryEventBpmnShape);
    return boundaryEvent.builder();
}
Also used : BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) BpmnShape(org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)

Example 3 with BoundaryEvent

use of org.camunda.bpm.model.bpmn.instance.BoundaryEvent in project camunda-bpm-platform by camunda.

the class CompensateEventOrderTest method addServiceTaskCompensationHandler.

private void addServiceTaskCompensationHandler(BpmnModelInstance modelInstance, String boundaryEventId, String compensationHandlerId) {
    BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId);
    BaseElement scope = (BaseElement) boundaryEvent.getParentElement();
    ServiceTask compensationHandler = modelInstance.newInstance(ServiceTask.class);
    compensationHandler.setId(compensationHandlerId);
    compensationHandler.setForCompensation(true);
    compensationHandler.setCamundaClass(IncreaseCurrentTimeServiceTask.class.getName());
    scope.addChildElement(compensationHandler);
    Association association = modelInstance.newInstance(Association.class);
    association.setAssociationDirection(AssociationDirection.One);
    association.setSource(boundaryEvent);
    association.setTarget(compensationHandler);
    scope.addChildElement(association);
}
Also used : BaseElement(org.camunda.bpm.model.bpmn.instance.BaseElement) ServiceTask(org.camunda.bpm.model.bpmn.instance.ServiceTask) IncreaseCurrentTimeServiceTask(org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask) Association(org.camunda.bpm.model.bpmn.instance.Association) BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) IncreaseCurrentTimeServiceTask(org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask)

Example 4 with BoundaryEvent

use of org.camunda.bpm.model.bpmn.instance.BoundaryEvent in project camunda-bpmn-model by camunda.

the class BoundaryEventImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(BoundaryEvent.class, BPMN_ELEMENT_BOUNDARY_EVENT).namespaceUri(BPMN20_NS).extendsType(CatchEvent.class).instanceProvider(new ModelTypeInstanceProvider<BoundaryEvent>() {

        public BoundaryEvent newInstance(ModelTypeInstanceContext instanceContext) {
            return new BoundaryEventImpl(instanceContext);
        }
    });
    cancelActivityAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_CANCEL_ACTIVITY).defaultValue(true).build();
    attachedToRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_ATTACHED_TO_REF).required().qNameAttributeReference(Activity.class).build();
    typeBuilder.build();
}
Also used : BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) CatchEvent(org.camunda.bpm.model.bpmn.instance.CatchEvent) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 5 with BoundaryEvent

use of org.camunda.bpm.model.bpmn.instance.BoundaryEvent in project camunda-bpm-platform by camunda.

the class CompensationModels method addUserTaskCompensationHandler.

public static void addUserTaskCompensationHandler(BpmnModelInstance modelInstance, String boundaryEventId, String compensationHandlerId) {
    BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId);
    BaseElement scope = (BaseElement) boundaryEvent.getParentElement();
    UserTask compensationHandler = modelInstance.newInstance(UserTask.class);
    compensationHandler.setId(compensationHandlerId);
    compensationHandler.setForCompensation(true);
    scope.addChildElement(compensationHandler);
    Association association = modelInstance.newInstance(Association.class);
    association.setAssociationDirection(AssociationDirection.One);
    association.setSource(boundaryEvent);
    association.setTarget(compensationHandler);
    scope.addChildElement(association);
}
Also used : BaseElement(org.camunda.bpm.model.bpmn.instance.BaseElement) Association(org.camunda.bpm.model.bpmn.instance.Association) BoundaryEvent(org.camunda.bpm.model.bpmn.instance.BoundaryEvent) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask)

Aggregations

BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)5 Association (org.camunda.bpm.model.bpmn.instance.Association)2 BaseElement (org.camunda.bpm.model.bpmn.instance.BaseElement)2 BpmnShape (org.camunda.bpm.model.bpmn.instance.bpmndi.BpmnShape)2 ArrayList (java.util.ArrayList)1 IncreaseCurrentTimeServiceTask (org.camunda.bpm.engine.test.bpmn.event.compensate.helper.IncreaseCurrentTimeServiceTask)1 CatchEvent (org.camunda.bpm.model.bpmn.instance.CatchEvent)1 ServiceTask (org.camunda.bpm.model.bpmn.instance.ServiceTask)1 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)1 Bounds (org.camunda.bpm.model.bpmn.instance.dc.Bounds)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1