当前位置: 首页>>代码示例>>Java>>正文


Java CommandContext类代码示例

本文整理汇总了Java中org.activiti.engine.impl.interceptor.CommandContext的典型用法代码示例。如果您正苦于以下问题:Java CommandContext类的具体用法?Java CommandContext怎么用?Java CommandContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandContext类属于org.activiti.engine.impl.interceptor包,在下文中一共展示了CommandContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
@Override
public Boolean execute(CommandContext commandContext) {
    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }

    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);

    if (task == null) {
        throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
    }
    boolean hasVariable = false;

    if (isLocal) {
        hasVariable = task.hasVariableLocal(variableName);
    } else {
        hasVariable = task.hasVariable(variableName);
    }

    return hasVariable;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:27,代码来源:HasTaskVariableCmd.java

示例2: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
@Override
public Void execute(CommandContext commandContext) {

    if (deploymentId == null) {
        throw new ActivitiIllegalArgumentException("Deployment id is null");
    }

    DeploymentEntity deployment = commandContext
            .getDeploymentEntityManager()
            .findDeploymentById(deploymentId);

    if (deployment == null) {
        throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class);
    }

    // Update category
    deployment.setCategory(category);

    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, deployment));
    }

    return null;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:26,代码来源:SetDeploymentCategoryCmd.java

示例3: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

    // taskEntity.fireEvent(TaskListener.EVENTNAME_COMPLETE);
    if ((Authentication.getAuthenticatedUserId() != null)
            && (taskEntity.getProcessInstanceId() != null)) {
        taskEntity.getProcessInstance().involveUser(
                Authentication.getAuthenticatedUserId(),
                IdentityLinkType.PARTICIPANT);
    }

    Context.getCommandContext().getTaskEntityManager()
            .deleteTask(taskEntity, comment, false);

    if (taskEntity.getExecutionId() != null) {
        ExecutionEntity execution = taskEntity.getExecution();
        execution.removeTask(taskEntity);

        // execution.signal(null, null);
    }

    return null;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:25,代码来源:DeleteTaskWithCommentCmd.java

示例4: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
public Object execute(CommandContext commandContext) {
    this.commandContext = commandContext;

    if (this.taskId != null) {
        TaskEntity taskEntity = commandContext.getTaskEntityManager()
                .findTaskById(taskId);
        activityId = taskEntity.getExecution().getActivityId();
        processInstanceId = taskEntity.getProcessInstanceId();
        this.collectionVariableName = "countersignUsers";
        this.collectionElementVariableName = "countersignUser";
    }

    if (operateType.equalsIgnoreCase("add")) {
        addInstance();
    } else if (operateType.equalsIgnoreCase("remove")) {
        removeInstance();
    }

    return null;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:CounterSignCmd.java

示例5: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
/**
 * 退回流程.
 * 
 * @return 0-退回成功 1-流程结束 2-下一结点已经通过,不能退回
 */
public Integer execute(CommandContext commandContext) {
    // 获得任务
    TaskEntity taskEntity = this.findTask(commandContext);

    // 找到想要回退到的节点
    ActivityImpl targetActivity = this.findTargetActivity(commandContext,
            taskEntity);
    logger.info("rollback to {}", this.activityId);
    logger.info("{}", targetActivity.getProperties());

    String type = (String) targetActivity.getProperty("type");

    if ("userTask".equals(type)) {
        logger.info("rollback to userTask");
        this.rollbackUserTask(commandContext);
    } else if ("startEvent".equals(type)) {
        logger.info("rollback to startEvent");
        this.rollbackStartEvent(commandContext);
    } else {
        throw new IllegalStateException("cannot rollback " + type);
    }

    return 0;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:30,代码来源:RollbackTaskCmd.java

示例6: findTargetActivity

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
/**
 * 查找回退的目的节点.
 */
public ActivityImpl findTargetActivity(CommandContext commandContext,
        TaskEntity taskEntity) {
    if (activityId == null) {
        String historyTaskId = this.findNearestUserTask(commandContext);
        HistoricTaskInstanceEntity historicTaskInstanceEntity = commandContext
                .getHistoricTaskInstanceEntityManager()
                .findHistoricTaskInstanceById(historyTaskId);
        this.activityId = historicTaskInstanceEntity.getTaskDefinitionKey();
    }

    String processDefinitionId = taskEntity.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    return processDefinitionEntity.findActivity(activityId);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:RollbackTaskCmd.java

示例7: findTargetHistoricActivity

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
/**
 * 找到想要回退对应的节点历史.
 */
public HistoricActivityInstanceEntity findTargetHistoricActivity(
        CommandContext commandContext, TaskEntity taskEntity,
        ActivityImpl activityImpl) {
    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl.activityId(activityImpl.getId());
    historicActivityInstanceQueryImpl.processInstanceId(taskEntity
            .getProcessInstanceId());
    historicActivityInstanceQueryImpl
            .orderByHistoricActivityInstanceEndTime().desc();

    HistoricActivityInstanceEntity historicActivityInstanceEntity = (HistoricActivityInstanceEntity) commandContext
            .getHistoricActivityInstanceEntityManager()
            .findHistoricActivityInstancesByQueryCriteria(
                    historicActivityInstanceQueryImpl, new Page(0, 1))
            .get(0);

    return historicActivityInstanceEntity;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:22,代码来源:RollbackTaskCmd.java

示例8: findTargetHistoricTask

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
/**
 * 找到想要回退对应的任务历史.
 */
public HistoricTaskInstanceEntity findTargetHistoricTask(
        CommandContext commandContext, TaskEntity taskEntity,
        ActivityImpl activityImpl) {
    HistoricTaskInstanceQueryImpl historicTaskInstanceQueryImpl = new HistoricTaskInstanceQueryImpl();
    historicTaskInstanceQueryImpl.taskDefinitionKey(activityImpl.getId());
    historicTaskInstanceQueryImpl.processInstanceId(taskEntity
            .getProcessInstanceId());
    historicTaskInstanceQueryImpl.setFirstResult(0);
    historicTaskInstanceQueryImpl.setMaxResults(1);
    historicTaskInstanceQueryImpl.orderByTaskCreateTime().desc();

    HistoricTaskInstanceEntity historicTaskInstanceEntity = (HistoricTaskInstanceEntity) commandContext
            .getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstancesByQueryCriteria(
                    historicTaskInstanceQueryImpl).get(0);

    return historicTaskInstanceEntity;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:22,代码来源:RollbackTaskCmd.java

示例9: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
protected Object execute(CommandContext commandContext,
        ExecutionEntity execution) {
    try {
        FlowNodeActivityBehavior activityBehavior = (FlowNodeActivityBehavior) execution
                .getActivity().getActivityBehavior();
        Method method = FlowNodeActivityBehavior.class.getDeclaredMethod(
                "leave", ActivityExecution.class);
        method.setAccessible(true);
        method.invoke(activityBehavior, execution);
        method.setAccessible(false);
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }

    return null;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:SignalStartEventCmd.java

示例10: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
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;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:JumpCmd.java

示例11: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
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;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:19,代码来源:JumpToActivityCmd.java

示例12: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
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;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:18,代码来源:ListActivityCmd.java

示例13: createJobWithoutExceptionStacktrace

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
private void createJobWithoutExceptionStacktrace() {
    CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor();
    commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
            JobEntityManager jobManager = commandContext.getJobEntityManager();

            jobEntity = new JobEntity();
            jobEntity.setJobType(Job.JOB_TYPE_MESSAGE);
            jobEntity.setRevision(1);
            jobEntity.setLockOwner(UUID.randomUUID().toString());
            jobEntity.setRetries(0);
            jobEntity.setExceptionMessage("I'm supposed to fail");

            jobManager.insert(jobEntity);

            assertNotNull(jobEntity.getId());

            return null;

        }
    });

}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:24,代码来源:JobQueryTest.java

示例14: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
@Override
public List<String> execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("executionId is null");
    }

    ExecutionEntity execution = commandContext
            .getExecutionEntityManager()
            .findExecutionById(executionId);

    if (execution == null) {
        throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
    }

    return execution.findActiveActivityIds();
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:17,代码来源:FindActiveActivityIdsCmd.java

示例15: execute

import org.activiti.engine.impl.interceptor.CommandContext; //导入依赖的package包/类
public List<String> execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("executionId is null");
    }

    ExecutionEntity execution = commandContext
            .getExecutionEntityManager()
            .findExecutionById(executionId);

    if (execution == null) {
        throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
    }

    List<String> executionVariables;
    if (isLocal) {
        executionVariables = new ArrayList<String>(execution.getVariableNamesLocal());
    } else {
        executionVariables = new ArrayList<String>(execution.getVariableNames());
    }

    return executionVariables;
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:23,代码来源:VariableScopeTest.java


注:本文中的org.activiti.engine.impl.interceptor.CommandContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。