org.camunda.bpm.model.bpmn.instance.BoundaryEvent Java Examples

The following examples show how to use org.camunda.bpm.model.bpmn.instance.BoundaryEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BoundaryEventImpl.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #2
Source File: BoundaryEventImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: CompensationModels.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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);

  }
 
Example #4
Source File: CompensateEventOrderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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);

  }
 
Example #5
Source File: ExternalTaskHandlerIT.java    From camunda-external-task-client-java with Apache License 2.0 5 votes vote down vote up
private void adjustProcessToAddErrorMessageVariable() {
  BoundaryEvent boundaryError = BPMN_ERROR_EXTERNAL_TASK_PROCESS.getModelElementById("catchBPMNError");

  Collection<ErrorEventDefinition> errorDefinitions = boundaryError.getChildElementsByType(ErrorEventDefinition.class);

  ErrorEventDefinition errorDefinition = errorDefinitions.iterator().next();
  errorDefinition.setCamundaErrorMessageVariable("errorMessage");
}
 
Example #6
Source File: AbstractActivityBuilder.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #7
Source File: BoundaryEventBuilder.java    From camunda-bpmn-model with Apache License 2.0 4 votes vote down vote up
public BoundaryEventBuilder(BpmnModelInstance modelInstance, BoundaryEvent element) {
  super(modelInstance, element, BoundaryEventBuilder.class);
}
 
Example #8
Source File: AbstractActivityBuilder.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #9
Source File: BoundaryEventBuilder.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public BoundaryEventBuilder(BpmnModelInstance modelInstance, BoundaryEvent element) {
  super(modelInstance, element, BoundaryEventBuilder.class);
}