org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl Java Examples

The following examples show how to use org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl. 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: ExecutionEntity.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public PvmProcessInstance createSubProcessInstance(PvmProcessDefinition processDefinition) {
    ExecutionEntity subProcessInstance = newExecution();

    // manage bidirectional super-subprocess relation
    subProcessInstance.setSuperExecution(this);
    this.setSubProcessInstance(subProcessInstance);

    // Initialize the new execution
    subProcessInstance.setProcessDefinition((ProcessDefinitionImpl) processDefinition);
    subProcessInstance.setProcessInstance(subProcessInstance);

    Context.getCommandContext().getHistoryManager()
            .recordSubProcessInstanceStart(this, subProcessInstance);

    if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, subProcessInstance));
    }
    return subProcessInstance;
}
 
Example #2
Source File: ListActivityCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Map<String, String> execute(CommandContext commandContext) {
    ExecutionEntity executionEntity = Context.getCommandContext()
            .getExecutionEntityManager().findExecutionById(executionId);
    ProcessDefinitionImpl processDefinition = executionEntity
            .getProcessDefinition();
    Map<String, String> map = new HashMap<String, String>();

    for (ActivityImpl activity : processDefinition.getActivities()) {
        logger.info("{}", activity.getProperties());

        if ("userTask".equals(activity.getProperty("type"))) {
            map.put(activity.getId(), (String) activity.getProperty("name"));
        }
    }

    return map;
}
 
Example #3
Source File: JumpToActivityCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
    for (TaskEntity taskEntity : commandContext.getTaskEntityManager()
            .findTasksByExecutionId(executionId)) {
        taskEntity.setVariableLocal("跳转原因", jumpOrigin);
        commandContext.getTaskEntityManager().deleteTask(taskEntity,
                jumpOrigin, false);
    }

    ExecutionEntity executionEntity = commandContext
            .getExecutionEntityManager().findExecutionById(executionId);
    ProcessDefinitionImpl processDefinition = executionEntity
            .getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(activityId);

    executionEntity.executeActivity(activity);

    return null;
}
 
Example #4
Source File: JumpCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public Object execute(CommandContext commandContext) {
    // for (TaskEntity taskEntity : commandContext.getTaskEntityManager()
    // .findTasksByExecutionId(executionId)) {
    // taskEntity.setVariableLocal("跳转原因", jumpOrigin);
    // commandContext.getTaskEntityManager().deleteTask(taskEntity,
    // jumpOrigin, false);
    // }
    ExecutionEntity executionEntity = commandContext
            .getExecutionEntityManager().findExecutionById(executionId);
    executionEntity.destroyScope(jumpOrigin);

    ProcessDefinitionImpl processDefinition = executionEntity
            .getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(activityId);

    executionEntity.executeActivity(activity);

    return null;
}
 
Example #5
Source File: JumpActivityCmd.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
public ExecutionEntity execute(CommandContext commandContext) {

        // 查询活动的分支
        ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);

        // 销毁当前分支
        executionEntity.destroyScope(jumpOrigin);

        // 从流程定义中查询目标Activity
        ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
        ActivityImpl activity = processDefinition.findActivity(activityId);

        // 节点跳转到目标活动
        executionEntity.executeActivity(activity);

        return executionEntity;
    }
 
Example #6
Source File: TestBPMN001.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
@Test
public void queryProcessDefinition() throws Exception {
	
	RepositoryService repositoryService = (RepositoryService) AppContext.getBean("repositoryService");
	ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
	List<ProcessDefinition> processDefs = processDefinitionQuery
		.processDefinitionKey("Employee360DegreeFeedbackProjectPublishProcess")
		.orderByProcessDefinitionVersion()
		.desc()
		.list();
	for (ProcessDefinition pd : processDefs) {
		System.out.println( pd.getId() + " , " + pd.getName() + " , " 
				+ pd.getKey() + " , " + pd.getVersion() );
		ProcessDefinitionImpl pdObj = (ProcessDefinitionImpl)repositoryService.getProcessDefinition(pd.getId());
		System.out.println(pdObj.getActivities());
	}
	
}
 
Example #7
Source File: AtomicOperationProcessStartInitial.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void eventNotificationsCompleted(InterpretableExecution execution) {
    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
    StartingExecution startingExecution = execution.getStartingExecution();
    if (activity == startingExecution.getInitial()) {
        execution.disposeStartingExecution();
        execution.performOperation(ACTIVITY_EXECUTE);

    } else {
        List<ActivityImpl> initialActivityStack = processDefinition.getInitialActivityStack(startingExecution.getInitial());
        int index = initialActivityStack.indexOf(activity);
        activity = initialActivityStack.get(index + 1);

        InterpretableExecution executionToUse = null;
        if (activity.isScope()) {
            executionToUse = (InterpretableExecution) execution.getExecutions().get(0);
        } else {
            executionToUse = execution;
        }
        executionToUse.setActivity(activity);
        executionToUse.performOperation(PROCESS_START_INITIAL);
    }
}
 
Example #8
Source File: AtomicOperationProcessStart.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected void eventNotificationsCompleted(InterpretableExecution execution) {
    if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        Map<String, Object> variablesMap = null;
        try {
            variablesMap = execution.getVariables();
        } catch (Throwable t) {
            // In some rare cases getting the execution variables can fail (JPA entity load failure for example)
            // We ignore the exception here, because it's only meant to include variables in the initialized event.
        }
        Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                ActivitiEventBuilder.createEntityWithVariablesEvent(FlowableEngineEventType.ENTITY_INITIALIZED,
                        execution, variablesMap, false));
        Context.getProcessEngineConfiguration().getEventDispatcher()
                .dispatchEvent(ActivitiEventBuilder.createProcessStartedEvent(execution, variablesMap, false));
    }

    ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
    StartingExecution startingExecution = execution.getStartingExecution();
    List<ActivityImpl> initialActivityStack = processDefinition.getInitialActivityStack(startingExecution.getInitial());
    execution.setActivity(initialActivityStack.get(0));
    execution.performOperation(PROCESS_START_INITIAL);
}
 
Example #9
Source File: EventSubscriptionEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ActivityImpl getActivity() {
    if (activity == null && activityId != null) {
        ExecutionEntity execution = getExecution();
        if (execution != null) {
            ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
            activity = processDefinition.findActivity(activityId);
        }
    }
    return activity;
}
 
Example #10
Source File: JumpTaskCmd.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
@Override
public Comment execute(CommandContext commandContext) {

    for (TaskEntity taskEntity : commandContext.getTaskEntityManager().findTasksByExecutionId(executionId)) {
        commandContext.getTaskEntityManager().deleteTask(taskEntity, "jump", false);
    }
    ExecutionEntity executionEntity = Context.getCommandContext().getExecutionEntityManager().findExecutionById(executionId);
    ProcessDefinitionImpl processDefinition = executionEntity.getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(activityId);
    executionEntity.executeActivity(activity);

    return null;
}
 
Example #11
Source File: ExecutionImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public PvmProcessInstance createSubProcessInstance(PvmProcessDefinition processDefinition) {
    ExecutionImpl subProcessInstance = newExecution();

    // manage bidirectional super-subprocess relation
    subProcessInstance.setSuperExecution(this);
    this.setSubProcessInstance(subProcessInstance);

    // Initialize the new execution
    subProcessInstance.setProcessDefinition((ProcessDefinitionImpl) processDefinition);
    subProcessInstance.setProcessInstance(subProcessInstance);

    return subProcessInstance;
}
 
Example #12
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * ensures initialization and returns the process definition.
 */
@Override
public ProcessDefinitionImpl getProcessDefinition() {
    ensureProcessDefinitionInitialized();
    return processDefinition;
}
 
Example #13
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void setProcessDefinition(ProcessDefinitionImpl processDefinition) {
    this.processDefinition = processDefinition;
    this.processDefinitionId = processDefinition.getId();
    this.processDefinitionKey = processDefinition.getKey();
}
 
Example #14
Source File: ExecutionImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void setProcessDefinition(ProcessDefinitionImpl processDefinition) {
    this.processDefinition = processDefinition;
}
 
Example #15
Source File: ExecutionImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/**
 * ensures initialization and returns the process definition.
 */
@Override
public ProcessDefinitionImpl getProcessDefinition() {
    ensureProcessDefinitionInitialized();
    return processDefinition;
}
 
Example #16
Source File: CounterSignCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 返回流程定义对象
 */
protected ProcessDefinitionImpl getProcessDefinition() {
    return this.getProcessInstanceEntity().getProcessDefinition();
}
 
Example #17
Source File: ProcessDefinitionBuilder.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public ProcessDefinitionBuilder(String processDefinitionId) {
    processDefinition = new ProcessDefinitionImpl(processDefinitionId);
    scopeStack.push(processDefinition);
}
 
Example #18
Source File: InterpretableExecution.java    From flowable-engine with Apache License 2.0 votes vote down vote up
ProcessDefinitionImpl getProcessDefinition(); 
Example #19
Source File: InterpretableExecution.java    From flowable-engine with Apache License 2.0 votes vote down vote up
void setProcessDefinition(ProcessDefinitionImpl processDefinitionImpl); 
Example #20
Source File: UnresolvedReference.java    From flowable-engine with Apache License 2.0 votes vote down vote up
void resolve(ProcessDefinitionImpl processDefinition);