org.activiti.engine.impl.bpmn.parser.BpmnParse Java Examples

The following examples show how to use org.activiti.engine.impl.bpmn.parser.BpmnParse. 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: StartEventParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void selectInitial(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
    if (processDefinition.getInitial() == null) {
        processDefinition.setInitial(startEventActivity);
    } else {
        // validate that there is a single none start event / timer start event:
        if (!startEventActivity.getProperty("type").equals("messageStartEvent")
                && !startEventActivity.getProperty("type").equals("signalStartEvent")
                && !startEventActivity.getProperty("type").equals("startTimerEvent")) {
            String currentInitialType = (String) processDefinition.getInitial().getProperty("type");
            if (currentInitialType.equals("messageStartEvent")) {
                processDefinition.setInitial(startEventActivity);
            } else {
                throw new ActivitiException("multiple none start events or timer start events not supported on process definition");
            }
        }
    }
}
 
Example #2
Source File: MessageEventDefinitionWithExtensionElementsTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testParseMessagedDefinitionWithExtension() {
  BpmnParse bpmnParseMock = Mockito.mock(BpmnParse.class);
  MessageEventDefinition messageEventDefinitionMock = Mockito.mock(MessageEventDefinition.class);
  BpmnModel bpmnModelMock = Mockito.mock(BpmnModel.class);
  Message messageMock = Mockito.mock(Message.class);
  @SuppressWarnings("unchecked")
  Map<String, List<ExtensionElement>> extensionElementMap = Mockito.mock(Map.class);

  Mockito.when(bpmnParseMock.getBpmnModel()).thenReturn(bpmnModelMock);
  Mockito.when(messageEventDefinitionMock.getMessageRef()).thenReturn("messageId");
  Mockito.when(bpmnModelMock.containsMessageId("messageId")).thenReturn(true);
  Mockito.when(bpmnModelMock.getMessage("messageId")).thenReturn(messageMock);
  Mockito.when(messageMock.getName()).thenReturn("MessageWithExtensionElements");
  Mockito.when(messageMock.getExtensionElements()).thenReturn(extensionElementMap);

  MessageEventDefinitionParseHandler handler = new MessageEventDefinitionParseHandler();
  handler.parse(bpmnParseMock, messageEventDefinitionMock);

  Mockito.verify(messageEventDefinitionMock).setMessageRef("MessageWithExtensionElements");
  Mockito.verify(messageEventDefinitionMock).setExtensionElements(extensionElementMap);
}
 
Example #3
Source File: AbstractExternalInvocationBpmnParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public AbstractDataAssociation createDataInputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
    if (dataAssociationElement.getAssignments().isEmpty()) {
        return new MessageImplicitDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());
    } else {
        SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(
                dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef());

        for (org.flowable.bpmn.model.Assignment assignmentElement : dataAssociationElement.getAssignments()) {
            if (StringUtils.isNotEmpty(assignmentElement.getFrom()) && StringUtils.isNotEmpty(assignmentElement.getTo())) {
                Expression from = bpmnParse.getExpressionManager().createExpression(assignmentElement.getFrom());
                Expression to = bpmnParse.getExpressionManager().createExpression(assignmentElement.getTo());
                Assignment assignment = new Assignment(from, to);
                dataAssociation.addAssignment(assignment);
            }
        }
        return dataAssociation;
    }
}
 
Example #4
Source File: ProxyUserTaskBpmnParseHandler.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void parse(BpmnParse bpmnParse, BaseElement baseElement) {
    if (!(baseElement instanceof UserTask)) {
        return;
    }

    if (useDefaultUserTaskParser) {
        new UserTaskParseHandler().parse(bpmnParse, baseElement);
    }

    UserTask userTask = (UserTask) baseElement;
    logger.debug("bpmnParse : {}, userTask : {}", bpmnParse, userTask);

    TaskDefinition taskDefinition = (TaskDefinition) bpmnParse
            .getCurrentActivity().getProperty(
                    UserTaskParseHandler.PROPERTY_TASK_DEFINITION);

    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_CREATE);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_ASSIGNMENT);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_COMPLETE);
    this.configEvent(taskDefinition, bpmnParse,
            TaskListener.EVENTNAME_DELETE);
}
 
Example #5
Source File: IntermediateThrowEventParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent) {

    ActivityImpl nestedActivityImpl = createActivityOnCurrentScope(bpmnParse, intermediateEvent, BpmnXMLConstants.ELEMENT_EVENT_THROW);

    EventDefinition eventDefinition = null;
    if (!intermediateEvent.getEventDefinitions().isEmpty()) {
        eventDefinition = intermediateEvent.getEventDefinitions().get(0);
    }

    nestedActivityImpl.setAsync(intermediateEvent.isAsynchronous());
    nestedActivityImpl.setExclusive(!intermediateEvent.isNotExclusive());

    if (eventDefinition instanceof SignalEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else if (eventDefinition instanceof org.flowable.bpmn.model.CompensateEventDefinition) {
        bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
    } else if (eventDefinition == null) {
        nestedActivityImpl.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowNoneEventActivityBehavior(intermediateEvent));
    } else {
        LOGGER.warn("Unsupported intermediate throw event type for throw event {}", intermediateEvent.getId());
    }
}
 
Example #6
Source File: SubProcessParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {

    subProcess.setBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocessActivityBehavior(subProcess));

    bpmnParse.processFlowElements(subProcess.getFlowElements());
    processArtifacts(bpmnParse, subProcess.getArtifacts());

    // no data objects for event subprocesses
    /*
     * if (!(subProcess instanceof EventSubProcess)) { // parse out any data objects from the template in order to set up the necessary process variables Map<String, Object> variables =
     * processDataObjects(bpmnParse, subProcess.getDataObjects(), activity); activity.setVariables(variables); }
     * 
     * bpmnParse.removeCurrentScope(); bpmnParse.removeCurrentSubProcess();
     * 
     * if (subProcess.getIoSpecification() != null) { IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification()); activity.setIoSpecification(ioSpecification);
     * }
     */

  }
 
Example #7
Source File: SendTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {

    if (StringUtils.isNotEmpty(sendTask.getType())) {
      
      if (sendTask.getType().equalsIgnoreCase("mail")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("mule")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("camel")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("dmn")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createDmnActivityBehavior(sendTask));
      }

    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) {

      WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask);
      sendTask.setBehavior(webServiceActivityBehavior);
       
    } else {
      logger.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask " + sendTask.getId());
    }
  }
 
Example #8
Source File: CustomSequenceFlowBpmnParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SequenceFlow flow) {

        // Do the regular stuff
        super.executeParse(bpmnParse, flow);

        // Add extension element conditions
        Map<String, List<ExtensionElement>> extensionElements = flow.getExtensionElements();
        if (extensionElements.containsKey("activiti_custom_condition")) {
            List<ExtensionElement> conditionsElements = extensionElements.get("activiti_custom_condition");
            CustomSetConditionsExecutionListener customFlowListener = new CustomSetConditionsExecutionListener();
            customFlowListener.setFlowId(flow.getId());
            for (ExtensionElement conditionElement : conditionsElements) {
                customFlowListener.addCondition(conditionElement.getElementText());
            }
            ActivityImpl activity = findActivity(bpmnParse, flow.getSourceRef());
            activity.addExecutionListener("start", customFlowListener);
        }
    }
 
Example #9
Source File: MessageEventDefinitionParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
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());
  }

  if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
    IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
    intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchMessageEventActivityBehavior(intermediateCatchEvent, messageDefinition));

  } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
    BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
    boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryMessageEventActivityBehavior(boundaryEvent, messageDefinition, boundaryEvent.isCancelActivity()));
  }

  else {
    // What to do here?
  }

}
 
Example #10
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private static String findLocalErrorEventHandler(ActivityExecution execution, String errorCode) {
    PvmScope scope = execution.getActivity();
    while (scope != null) {

        @SuppressWarnings("unchecked")
        List<ErrorEventDefinition> definitions = (List<ErrorEventDefinition>) scope.getProperty(BpmnParse.PROPERTYNAME_ERROR_EVENT_DEFINITIONS);
        if (definitions != null) {
            // definitions are sorted by precedence, ie. event subprocesses first.
            for (ErrorEventDefinition errorEventDefinition : definitions) {
                if (errorEventDefinition.catches(errorCode)) {
                    return scope.findActivity(errorEventDefinition.getHandlerActivityId()).getId();
                }
            }
        }

        // search for error handlers in parent scopes
        if (scope instanceof PvmActivity) {
            scope = ((PvmActivity) scope).getParent();
        } else {
            scope = null;
        }
    }
    return null;
}
 
Example #11
Source File: SignalEventDefinitionParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDefinition) {

    Signal signal = null;
    if (bpmnParse.getBpmnModel().containsSignalId(signalDefinition.getSignalRef())) {
      signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef());
    }

    if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
      IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
      intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchSignalEventActivityBehavior(intermediateCatchEvent, signalDefinition, signal));

    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
      BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
      boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundarySignalEventActivityBehavior(boundaryEvent, signalDefinition, signal, boundaryEvent.isCancelActivity()));
    }
  }
 
Example #12
Source File: IntermediateCatchEventParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, IntermediateCatchEvent event) {
  EventDefinition eventDefinition = null;
  if (!event.getEventDefinitions().isEmpty()) {
    eventDefinition = event.getEventDefinitions().get(0);
  }

  if (eventDefinition == null) {
    event.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchEventActivityBehavior(event));

  } else {
    if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof SignalEventDefinition || eventDefinition instanceof MessageEventDefinition) {

      bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);

    } else {
      logger.warn("Unsupported intermediate catch event type for event " + event.getId());
    }
  }
}
 
Example #13
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void addEventSubscriptionDeclaration(BpmnParse bpmnParse, EventSubscriptionDeclaration subscription, EventDefinition parsedEventDefinition, ScopeImpl scope) {
    List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) scope.getProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventDefinitions == null) {
        eventDefinitions = new ArrayList<>();
        scope.setProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION, eventDefinitions);
    } else {
        // if this is a message event, validate that it is the only one with the provided name for this scope
        if (subscription.getEventType().equals("message")) {
            for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
                if (eventDefinition.getEventType().equals("message")
                        && eventDefinition.getEventName().equals(subscription.getEventName())
                        && eventDefinition.isStartEvent() == subscription.isStartEvent()) {

                    LOGGER.warn("Cannot have more than one message event subscription with name '{}' for scope '{}'", subscription.getEventName(), scope.getId());
                }
            }
        }
    }
    eventDefinitions.add(subscription);
}
 
Example #14
Source File: BpmnDeployer.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void addTimerDeclarations(ProcessDefinitionEntity processDefinition, List<TimerJobEntity> timers) {
    List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_START_TIMER);
    if (timerDeclarations != null) {
        for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
            TimerJobEntity timer = timerDeclaration.prepareTimerEntity(null);
            if (timer != null) {
                timer.setProcessDefinitionId(processDefinition.getId());

                // Inherit timer (if applicable)
                if (processDefinition.getTenantId() != null) {
                    timer.setTenantId(processDefinition.getTenantId());
                }
                timers.add(timer);
            }
        }
    }
}
 
Example #15
Source File: SequenceFlowParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {

    ScopeImpl scope = bpmnParse.getCurrentScope();

    ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef());
    ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef());

    Expression skipExpression;
    if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
        ExpressionManager expressionManager = bpmnParse.getExpressionManager();
        skipExpression = expressionManager.createExpression(sequenceFlow.getSkipExpression());
    } else {
        skipExpression = null;
    }

    TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId(), skipExpression);
    bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition);
    transition.setProperty("name", sequenceFlow.getName());
    transition.setProperty("documentation", sequenceFlow.getDocumentation());
    transition.setDestination(destinationActivity);

    if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
        Condition expressionCondition = new UelExpressionCondition(sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition);
    }

    createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);

}
 
Example #16
Source File: AbstractActivityBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void parse(BpmnParse bpmnParse, BaseElement element) {
    super.parse(bpmnParse, element);

    if (element instanceof Activity
            && ((Activity) element).getLoopCharacteristics() != null) {
        createMultiInstanceLoopCharacteristics(bpmnParse, (Activity) element);
    }
}
 
Example #17
Source File: SecureJavascriptTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {
  String language = scriptTask.getScriptFormat();
  if (LANGUAGE_JAVASCRIPT.equalsIgnoreCase(language)) {
    createSecureJavascriptTaskBehavior(bpmnParse, scriptTask, language);
  } else {
    super.executeParse(bpmnParse, scriptTask);
  }
}
 
Example #18
Source File: AlfrescoProcessBpmnParseHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, Process process)
{
    ProcessDefinitionEntity processDefinition = bpmnParse.getCurrentProcessDefinition();
    processDefinition.addExecutionListener(ExecutionListener.EVENTNAME_START, processCreateListener);
    if (multiTenancyEnabled && tenantService.isEnabled())
    {
        String key = tenantService.getName(processDefinition.getKey());
        processDefinition.setKey(key);
    }
}
 
Example #19
Source File: ReceiveTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ReceiveTask receiveTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, receiveTask, BpmnXMLConstants.ELEMENT_TASK_RECEIVE);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createReceiveTaskActivityBehavior(receiveTask));

    activity.setAsync(receiveTask.isAsynchronous());
    activity.setExclusive(!receiveTask.isNotExclusive());
}
 
Example #20
Source File: AbstractExternalInvocationBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public AbstractDataAssociation createDataOutputAssociation(BpmnParse bpmnParse, DataAssociation dataAssociationElement) {
    if (StringUtils.isNotEmpty(dataAssociationElement.getSourceRef())) {
        return new MessageImplicitDataOutputAssociation(dataAssociationElement.getTargetRef(), dataAssociationElement.getSourceRef());
    } else {
        Expression transformation = bpmnParse.getExpressionManager().createExpression(dataAssociationElement.getTransformation());
        AbstractDataAssociation dataOutputAssociation = new TransformationDataOutputAssociation(null, dataAssociationElement.getTargetRef(), transformation);
        return dataOutputAssociation;
    }
}
 
Example #21
Source File: BusinessRuleParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, BusinessRuleTask businessRuleTask) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, businessRuleTask, BpmnXMLConstants.ELEMENT_TASK_BUSINESSRULE);
    activity.setAsync(businessRuleTask.isAsynchronous());
    activity.setExclusive(!businessRuleTask.isNotExclusive());
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBusinessRuleTaskActivityBehavior(businessRuleTask));
}
 
Example #22
Source File: AbstractBpmnParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
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());

    // an association may reference elements that are not parsed as activities (like for instance
    // text annotations so do not throw an exception if sourceActivity or targetActivity are null)
    // 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());
            }
        }
    }
}
 
Example #23
Source File: ProxyUserTaskBpmnParseHandler.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void configEvent(TaskDefinition taskDefinition, BpmnParse bpmnParse,
        String eventName) {
    ActivitiListener activitiListener = new ActivitiListener();
    activitiListener.setEvent(eventName);
    activitiListener
            .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    activitiListener.setImplementation("#{" + taskListenerId + "}");
    taskDefinition
            .addTaskListener(eventName, bpmnParse.getListenerFactory()
                    .createDelegateExpressionTaskListener(activitiListener));
}
 
Example #24
Source File: CancelEventDefinitionParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) {
    if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        ActivityImpl activity = bpmnParse.getCurrentActivity();
        activity.setProperty("type", "cancelBoundaryCatch");
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelBoundaryEventActivityBehavior(cancelEventDefinition));
    }

}
 
Example #25
Source File: StartEventParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, StartEvent startEvent) {
    ActivityImpl startEventActivity = createActivityOnCurrentScope(bpmnParse, startEvent, BpmnXMLConstants.ELEMENT_EVENT_START);

    ScopeImpl scope = bpmnParse.getCurrentScope();
    if (scope instanceof ProcessDefinitionEntity) {
        createProcessDefinitionStartEvent(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope);
        selectInitial(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope);
        createStartFormHandlers(bpmnParse, startEvent, (ProcessDefinitionEntity) scope);
    } else {
        createScopeStartEvent(bpmnParse, startEventActivity, startEvent);
    }
}
 
Example #26
Source File: ExclusiveGatewayParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ExclusiveGateway gateway) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_EXCLUSIVE);

    activity.setAsync(gateway.isAsynchronous());
    activity.setExclusive(!gateway.isNotExclusive());

    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createExclusiveGatewayActivityBehavior(gateway));
}
 
Example #27
Source File: SendTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {

    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, sendTask, BpmnXMLConstants.ELEMENT_TASK_SEND);

    activity.setAsync(sendTask.isAsynchronous());
    activity.setExclusive(!sendTask.isNotExclusive());

    if (StringUtils.isNotEmpty(sendTask.getType())) {
        if (sendTask.getType().equalsIgnoreCase("mail")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
        } else if (sendTask.getType().equalsIgnoreCase("mule")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        } else if (sendTask.getType().equalsIgnoreCase("camel")) {
            activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
        }

        // for web service
    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) &&
            StringUtils.isNotEmpty(sendTask.getOperationRef())) {

        WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask, bpmnParse.getBpmnModel());
        activity.setActivityBehavior(webServiceActivityBehavior);

    } else {
        LOGGER.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask {}", sendTask.getId());
    }
}
 
Example #28
Source File: ProcessDefinitionDiagramHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Generates a diagram resource for a ProcessDefinitionEntity and associated BpmnParse.  The
 * returned resource has not yet been persisted, nor attached to the ProcessDefinitionEntity.
 * This requires that the ProcessDefinitionEntity have its key and resource name already set.
 * 
 * The caller must determine whether creating a diagram for this process definition is appropriate or not,
 * for example see {@link #shouldCreateDiagram(ProcessDefinitionEntity, DeploymentEntity)}.
 */
public ResourceEntity createDiagramForProcessDefinition(ProcessDefinitionEntity processDefinition, BpmnParse bpmnParse) {
  
  if (StringUtils.isEmpty(processDefinition.getKey()) || StringUtils.isEmpty(processDefinition.getResourceName())) {
    throw new IllegalStateException("Provided process definition must have both key and resource name set.");
  }
  
  ResourceEntity resource = createResourceEntity();
  ProcessEngineConfiguration processEngineConfiguration = Context.getCommandContext().getProcessEngineConfiguration();
  try {
    byte[] diagramBytes = IoUtil.readInputStream(
        processEngineConfiguration.getProcessDiagramGenerator().generateDiagram(bpmnParse.getBpmnModel(), "png",
            processEngineConfiguration.getActivityFontName(),
            processEngineConfiguration.getLabelFontName(),
            processEngineConfiguration.getAnnotationFontName(),
            processEngineConfiguration.getClassLoader()), null);
      String diagramResourceName = ResourceNameUtil.getProcessDiagramResourceName(
          processDefinition.getResourceName(), processDefinition.getKey(), "png");
      
      resource.setName(diagramResourceName);
      resource.setBytes(diagramBytes);
      resource.setDeploymentId(processDefinition.getDeploymentId());

      // Mark the resource as 'generated'
      resource.setGenerated(true);
      
  } catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
    log.warn("Error while generating process diagram, image will not be stored in repository", t);
    resource = null;
  }
  
  return resource;
}
 
Example #29
Source File: ManualTaskParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeParse(BpmnParse bpmnParse, ManualTask manualTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, manualTask, BpmnXMLConstants.ELEMENT_TASK_MANUAL);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createManualTaskActivityBehavior(manualTask));

    activity.setAsync(manualTask.isAsynchronous());
    activity.setExclusive(!manualTask.isNotExclusive());
}
 
Example #30
Source File: StartEventParseHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void createStartFormHandlers(BpmnParse bpmnParse, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
    if (processDefinition.getInitial() != null) {
        if (startEvent.getId().equals(processDefinition.getInitial().getId())) {
            StartFormHandler startFormHandler = new DefaultStartFormHandler();
            startFormHandler.parseConfiguration(startEvent.getFormProperties(), startEvent.getFormKey(), bpmnParse.getDeployment(), processDefinition);
            processDefinition.setStartFormHandler(startFormHandler);
        }
    }
}