Java Code Examples for org.flowable.engine.repository.ProcessDefinition#getName()

The following examples show how to use org.flowable.engine.repository.ProcessDefinition#getName() . 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: TaskRepresentation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public TaskRepresentation(TaskInfo taskInfo, ProcessDefinition processDefinition) {
    initializeTaskDetails(taskInfo);

    if (processDefinition != null) {
        this.processDefinitionName = processDefinition.getName();
        this.processDefinitionDescription = processDefinition.getDescription();
        this.processDefinitionKey = processDefinition.getKey();
        this.processDefinitionCategory = processDefinition.getCategory();
        this.processDefinitionVersion = processDefinition.getVersion();
        this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
    }
}
 
Example 2
Source File: ProcessDefinitionRepresentation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessDefinitionRepresentation(ProcessDefinition processDefinition) {
    this.id = processDefinition.getId();
    this.name = processDefinition.getName();
    this.description = processDefinition.getDescription();
    this.key = processDefinition.getKey();
    this.category = processDefinition.getCategory();
    this.version = processDefinition.getVersion();
    this.deploymentId = processDefinition.getDeploymentId();
    this.tenantId = processDefinition.getTenantId();
    this.hasStartForm = processDefinition.hasStartFormKey();
}
 
Example 3
Source File: ProcessInstanceRepresentation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void mapProcessDefinition(ProcessDefinition processDefinition) {
    if (processDefinition != null) {
        this.processDefinitionName = processDefinition.getName();
        this.processDefinitionDescription = processDefinition.getDescription();
        this.processDefinitionKey = processDefinition.getKey();
        this.processDefinitionCategory = processDefinition.getCategory();
        this.processDefinitionVersion = processDefinition.getVersion();
        this.processDefinitionDeploymentId = processDefinition.getDeploymentId();
    }
}
 
Example 4
Source File: ProcessInstanceHelper.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance createProcessInstance(ProcessDefinition processDefinition, String businessKey, String processInstanceName,
                String overrideDefinitionTenantId, String predefinedProcessInstanceId, Map<String, Object> variables, Map<String, Object> transientVariables, 
                String callbackId, String callbackType, String referenceId, String referenceType, String stageInstanceId, boolean startProcessInstance) {

    CommandContext commandContext = Context.getCommandContext();
    if (Flowable5Util.isFlowable5ProcessDefinition(processDefinition, commandContext)) {
        Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
        return compatibilityHandler.startProcessInstance(processDefinition.getKey(), processDefinition.getId(),
                variables, transientVariables, businessKey, processDefinition.getTenantId(), processInstanceName);
    }

    // Do not start process a process instance if the process definition is suspended
    if (ProcessDefinitionUtil.isProcessDefinitionSuspended(processDefinition.getId())) {
        throw new FlowableException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }

    // Get model from cache
    Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());
    if (process == null) {
        throw new FlowableException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found");
    }

    FlowElement initialFlowElement = process.getInitialFlowElement();
    if (initialFlowElement == null) {
        throw new FlowableException("No start element found for process definition " + processDefinition.getId());
    }

    return createAndStartProcessInstanceWithInitialFlowElement(processDefinition, businessKey, processInstanceName, overrideDefinitionTenantId, 
                    predefinedProcessInstanceId, initialFlowElement, process, variables, transientVariables, 
                    callbackId, callbackType, referenceId, referenceType, stageInstanceId, startProcessInstance);
}
 
Example 5
Source File: NeedsActiveProcessDefinitionCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public T execute(CommandContext commandContext) {
    DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinition processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);

    if (deploymentManager.isProcessDefinitionSuspended(processDefinitionId)) {
        throw new ActivitiException("Cannot execute operation because process definition '"
                + processDefinition.getName() + "' (id=" + processDefinition.getId() + ") is suspended");
    }

    return execute(commandContext, processDefinition);
}
 
Example 6
Source File: ProcessInstanceHelper.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessInstance createAndStartProcessInstanceByMessage(ProcessDefinition processDefinition, String messageName, String businessKey, 
        Map<String, Object> variables, Map<String, Object> transientVariables,
        String callbackId, String callbackType, String referenceId, String referenceType) {

    CommandContext commandContext = Context.getCommandContext();
    if (Flowable5Util.isFlowable5ProcessDefinition(processDefinition, commandContext)) {
        return CommandContextUtil.getProcessEngineConfiguration(commandContext).getFlowable5CompatibilityHandler().startProcessInstanceByMessage(
                messageName, variables, transientVariables, businessKey, processDefinition.getTenantId());
    }

    // Do not start process a process instance if the process definition is suspended
    if (ProcessDefinitionUtil.isProcessDefinitionSuspended(processDefinition.getId())) {
        throw new FlowableException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }

    // Get model from cache
    Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());
    if (process == null) {
        throw new FlowableException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found");
    }

    FlowElement initialFlowElement = null;
    for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof StartEvent) {
            StartEvent startEvent = (StartEvent) flowElement;
            if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions()) && startEvent.getEventDefinitions().get(0) instanceof MessageEventDefinition) {

                MessageEventDefinition messageEventDefinition = (MessageEventDefinition) startEvent.getEventDefinitions().get(0);
                String actualMessageName = EventDefinitionExpressionUtil.determineMessageName(commandContext, messageEventDefinition, null);
                if (Objects.equals(actualMessageName, messageName)) {
                    initialFlowElement = flowElement;
                    break;
                }
            }
        }
    }
    if (initialFlowElement == null) {
        throw new FlowableException("No message start event found for process definition " + processDefinition.getId() + " and message name " + messageName);
    }

    return createAndStartProcessInstanceWithInitialFlowElement(processDefinition, businessKey, null, null, null, initialFlowElement, 
                    process, variables, transientVariables, callbackId, callbackType, referenceId, referenceType, null, true);
}
 
Example 7
Source File: StartProcessInstanceCmd.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessInstance execute(CommandContext commandContext) {
    DeploymentManager deploymentManager = commandContext
            .getProcessEngineConfiguration()
            .getDeploymentManager();

    // Find the process definition
    ProcessDefinition processDefinition = null;
    if (processDefinitionId != null) {
        processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", ProcessDefinition.class);
        }
    } else if (processDefinitionKey != null && (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId))) {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey + "'", ProcessDefinition.class);
        }
    } else if (processDefinitionKey != null && tenantId != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitionKey, tenantId);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("No process definition found for key '" + processDefinitionKey + "' for tenant identifier " + tenantId, ProcessDefinition.class);
        }
    } else {
        throw new ActivitiIllegalArgumentException("processDefinitionKey and processDefinitionId are null");
    }

    // Do not start process a process instance if the process definition is suspended
    if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        throw new ActivitiException("Cannot start process instance. Process definition "
                + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }

    // Start the process instance
    ExecutionEntity processInstance = ((ProcessDefinitionEntity) processDefinition).createProcessInstance(businessKey);

    // now set the variables passed into the start command
    initializeVariables(processInstance);

    // now set processInstance name
    if (processInstanceName != null) {
        processInstance.setName(processInstanceName);
        commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstance.getId(), processInstanceName);
    }

    processInstance.start();

    return processInstance;
}