Java Code Examples for org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getInitial()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#getInitial() . 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: AutoCompleteFirstTaskListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example 3
Source File: AutoCompleteFirstTaskEventListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example 4
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);
        }
    }
}
 
Example 5
Source File: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 获得提交节点
 */
public String findFirstUserTaskActivityId(String processDefinitionId,
        String initiator) {
    GetDeploymentProcessDefinitionCmd getDeploymentProcessDefinitionCmd = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId);
    ProcessDefinitionEntity processDefinitionEntity = processEngine
            .getManagementService().executeCommand(
                    getDeploymentProcessDefinitionCmd);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.info("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity.getId();
}
 
Example 6
Source File: ReOpenProcessCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public ExecutionEntity createProcessInstance(
        ProcessDefinitionEntity processDefinition, String id) {
    ActivityImpl initial = processDefinition.getInitial();

    if (initial == null) {
        throw new ActivitiException(
                "Cannot start process instance, initial activity where the process instance should start is null.");
    }

    ExecutionEntity processInstance = new ExecutionEntity(initial);
    processInstance.setId(id);
    processInstance.insert();
    processInstance.setProcessDefinition(processDefinition);
    processInstance.setTenantId(processDefinition.getTenantId());
    processInstance.setProcessInstance(processInstance);
    processInstance.initialize();

    InterpretableExecution scopeInstance = processInstance;

    List<ActivityImpl> initialActivityStack = processDefinition
            .getInitialActivityStack(initial);

    for (ActivityImpl initialActivity : initialActivityStack) {
        if (initialActivity.isScope()) {
            scopeInstance = (InterpretableExecution) scopeInstance
                    .createExecution();
            scopeInstance.setActivity(initialActivity);

            if (initialActivity.isScope()) {
                scopeInstance.initialize();
            }
        }
    }

    scopeInstance.setActivity(initial);

    return processInstance;
}
 
Example 7
Source File: FindFirstTaskFormCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
public FirstTaskForm execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);

    if (processDefinitionEntity == null) {
        throw new IllegalArgumentException(
                "cannot find processDefinition : " + processDefinitionId);
    }

    if (processDefinitionEntity.hasStartFormKey()) {
        return this.findStartEventForm(processDefinitionEntity);
    }

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.info("first activity is not userTask, just skip");

        return new FirstTaskForm();
    }

    FirstTaskForm firstTaskForm = new FirstTaskForm();
    firstTaskForm.setProcessDefinitionId(processDefinitionId);
    firstTaskForm.setExists(true);
    firstTaskForm.setTaskForm(true);

    String taskDefinitionKey = targetActivity.getId();
    logger.debug("activityId : {}", targetActivity.getId());
    firstTaskForm.setActivityId(taskDefinitionKey);

    TaskDefinition taskDefinition = processDefinitionEntity
            .getTaskDefinitions().get(taskDefinitionKey);

    Expression expression = taskDefinition.getAssigneeExpression();

    if (expression != null) {
        String expressionText = expression.getExpressionText();
        logger.debug("{}", expressionText);
        logger.debug("{}", startActivity.getProperties());
        logger.debug("{}", processDefinitionEntity.getProperties());
        firstTaskForm.setAssignee(expressionText);
    } else {
        logger.info("cannot find expression : {}, {}", processDefinitionId,
                taskDefinitionKey);
    }

    String initiatorVariableName = (String) processDefinitionEntity
            .getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
    firstTaskForm.setInitiatorName(initiatorVariableName);

    DefaultFormHandler formHandler = (DefaultFormHandler) taskDefinition
            .getTaskFormHandler();

    if (formHandler.getFormKey() != null) {
        String formKey = formHandler.getFormKey().getExpressionText();
        firstTaskForm.setFormKey(formKey);
    } else {
        logger.info("cannot find formKey from xml : {}, {}",
                processDefinitionId, taskDefinitionKey);
    }

    return firstTaskForm;
}