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;
}
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();
}
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);
}
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();
}
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);
}
Aggregations