• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: deleteHistoryActivities

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 删除历史节点.
 */
public void deleteHistoryActivities(List<String> historyNodeIds) {
    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    logger.info("historyNodeIds : {}", historyNodeIds);

    for (String id : historyNodeIds) {
        String taskId = jdbcTemplate.queryForObject(
                "select task_id_ from ACT_HI_ACTINST where id_=?",
                String.class, id);

        if (taskId != null) {
            Context.getCommandContext()
                    .getHistoricTaskInstanceEntityManager()
                    .deleteHistoricTaskInstanceById(taskId);
        }

        jdbcTemplate.update("delete from ACT_HI_ACTINST where id_=?", id);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:WithdrawTaskCmd.java


示例2: getHistoricActivityInstanceEntity

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 查询历史节点.
 */
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity(
        String historyTaskId) {
    logger.info("historyTaskId : {}", historyTaskId);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "SELECT ID_ FROM ACT_HI_ACTINST WHERE TASK_ID_=?",
            String.class, historyTaskId);
    logger.info("historicActivityInstanceId : {}",
            historicActivityInstanceId);

    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl
            .activityInstanceId(historicActivityInstanceId);

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

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


示例3: getHistoricActivityInstanceEntity

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public HistoricActivityInstanceEntity getHistoricActivityInstanceEntity(
        String historyTaskId) {
    logger.info("historyTaskId : {}", historyTaskId);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    String historicActivityInstanceId = jdbcTemplate.queryForObject(
            "select id_ from ACT_HI_ACTINST where task_id_=?",
            String.class, historyTaskId);
    logger.info("historicActivityInstanceId : {}",
            historicActivityInstanceId);

    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl
            .activityInstanceId(historicActivityInstanceId);

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

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


示例4: tracePhoto

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 读取带跟踪的图片
 * @param executionId	环节ID
 * @return	封装了各种节点信息
 */
public InputStream tracePhoto(String processDefinitionId, String executionId) {
	// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
	BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
	
	List<String> activeActivityIds = Lists.newArrayList();
	if (runtimeService.createExecutionQuery().executionId(executionId).count() > 0){
		activeActivityIds = runtimeService.getActiveActivityIds(executionId);
	}
	
	// 不使用spring请使用下面的两行代码
	// ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl)ProcessEngines.getDefaultProcessEngine();
	// Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());

	// 使用spring注入引擎请使用下面的这行代码
	Context.setProcessEngineConfiguration(processEngine.getProcessEngineConfiguration());

	return ProcessDiagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:24,代码来源:ActTaskService.java


示例5: getServiceRegistry

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
protected ServiceRegistry getServiceRegistry()
{
    ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
    if (config != null) 
    {
        // Fetch the registry that is injected in the activiti spring-configuration
        ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
        if (registry == null)
        {
            throw new RuntimeException(
                        "Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" + 
                        ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
        }
        return registry;
    }
    throw new IllegalStateException("No ProcessEngineCOnfiguration found in active context");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:ActivitiScriptBase.java


示例6: findFirstActivity

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 获得第一个节点.
 */
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;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:29,代码来源:AutoCompleteFirstTaskListener.java


示例7: invokeExpression

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void invokeExpression(String processDefinitionId, String activityId,
        int type) {
    String hql = "from BpmConfListener where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=? and type=?";
    List<BpmConfListener> bpmConfListeners = bpmConfListenerManager.find(
            hql, processDefinitionId, activityId, type);

    for (BpmConfListener bpmConfListener : bpmConfListeners) {
        String expressionText = bpmConfListener.getValue();

        try {
            ExpressionManager expressionManager = Context
                    .getProcessEngineConfiguration().getExpressionManager();

            Object result = expressionManager.createExpression(
                    expressionText).getValue(
                    Context.getExecutionContext().getExecution());
            logger.info("result : {}", result);
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        }
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:FunctionEventListener.java


示例8: processPosition

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void processPosition(DelegateTask delegateTask, String value) {
    String processInstanceId = delegateTask.getProcessInstanceId();
    HistoricProcessInstanceEntity historicProcessInstanceEntity = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String initiator = historicProcessInstanceEntity.getStartUserId();
    OrgConnector orgConnector = (OrgConnector) ApplicationContextHelper
            .getBean(OrgConnector.class);

    // 获得发起人的职位
    int initiatorLevel = orgConnector.getJobLevelByUserId(initiator);

    // 获得审批人的职位
    int assigneeLevel = orgConnector.getJobLevelByUserId(delegateTask
            .getAssignee());

    // 比较
    if (initiatorLevel >= assigneeLevel) {
        logger.info("skip task : {}", delegateTask.getId());
        logger.info("initiatorLevel : {}, assigneeLevel : {}",
                initiatorLevel, assigneeLevel);
        new CompleteTaskWithCommentCmd(delegateTask.getId(),
                Collections.<String, Object> emptyMap(), "高级职位自动跳过")
                .execute(Context.getCommandContext());
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:27,代码来源:SkipTaskListener.java


示例9: findInitiator

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 获得流程发起人.
 */
public String findInitiator(String processInstanceId) {
    String initiator = null;

    if (Context.getCommandContext() == null) {
        initiator = processEngine.getHistoryService()
                .createHistoricProcessInstanceQuery()
                .processInstanceId(processInstanceId).singleResult()
                .getStartUserId();
    } else {
        initiator = Context.getCommandContext()
                .getHistoricProcessInstanceEntityManager()
                .findHistoricProcessInstance(processInstanceId)
                .getStartUserId();
    }

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


示例10: execute

import org.activiti.engine.impl.context.Context; //导入依赖的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


示例11: createHumanTask

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 创建humanTask.
 */
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

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


示例12: processMultiInstance

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
 * 处理多实例.
 */
public void processMultiInstance() {
    logger.info("multiInstanceExecutionIds : {}", multiInstanceExecutionIds);

    for (String executionId : multiInstanceExecutionIds) {
        ExecutionEntity parent = Context.getCommandContext()
                .getExecutionEntityManager().findExecutionById(executionId);
        List<ExecutionEntity> children = Context.getCommandContext()
                .getExecutionEntityManager()
                .findChildExecutionsByParentExecutionId(parent.getId());

        for (ExecutionEntity executionEntity : children) {
            executionEntity.remove();
        }

        parent.remove();
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:RollbackTaskCmd.java


示例13: createSubTask

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void createSubTask(TaskEntity parentTask, String assignee) {
    TaskEntity task = TaskEntity.create(new Date());
    task.setProcessDefinitionId(parentTask.getProcessDefinitionId());
    // task.setId(historicTaskInstanceEntity.getId());
    task.setAssigneeWithoutCascade(assignee);
    task.setParentTaskIdWithoutCascade(parentTask.getId());
    task.setNameWithoutCascade(parentTask.getName());
    task.setTaskDefinitionKey(parentTask.getTaskDefinitionKey());
    task.setExecutionId(parentTask.getExecutionId());
    task.setPriority(parentTask.getPriority());
    task.setProcessInstanceId(parentTask.getProcessInstanceId());
    task.setDescriptionWithoutCascade(parentTask.getDescription());
    task.setCategory("subtask");

    Context.getCommandContext().getTaskEntityManager().insert(task);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:ChangeSubTaskCmd.java


示例14: execute

import org.activiti.engine.impl.context.Context; //导入依赖的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


示例15: createHumanTask

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public HumanTaskDTO createHumanTask(DelegateTask delegateTask,
        HistoricTaskInstanceEntity historicTaskInstanceEntity)
        throws Exception {
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = new HumanTaskBuilder().setDelegateTask(
            delegateTask).build();

    if ("发起流程".equals(historicTaskInstanceEntity.getDeleteReason())) {
        humanTaskDto.setCatalog(HumanTaskConstants.CATALOG_START);
    }

    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext()
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(
                    delegateTask.getProcessInstanceId());
    humanTaskDto
            .setProcessStarter(historicProcessInstance.getStartUserId());
    humanTaskDto = humanTaskConnector.saveHumanTask(humanTaskDto);

    return humanTaskDto;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:24,代码来源:WithdrawTaskCmd.java


示例16: initSource

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void initSource() {
    // source task
    this.jumpInfo.setSourceTaskId(this.taskId);

    TaskEntity sourceTask = Context.getCommandContext()
            .getTaskEntityManager().findTaskById(this.taskId);
    this.jumpInfo.setSourceTask(sourceTask);

    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration()
            .getDeploymentManager()
            .findDeployedProcessDefinitionById(
                    sourceTask.getProcessDefinitionId());
    // source activity
    this.jumpInfo.setSourceActivityId(sourceTask.getTaskDefinitionKey());
    this.jumpInfo.setSourceActivity(processDefinitionEntity
            .findActivity(this.jumpInfo.getSourceActivityId()));

    HistoricTaskInstanceEntity sourceHistoryTask = Context
            .getCommandContext().getHistoricTaskInstanceEntityManager()
            .findHistoricTaskInstanceById(this.jumpInfo.getSourceTaskId());
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:23,代码来源:RollbackCmd.java


示例17: deleteActiveTasks

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void deleteActiveTasks(String processInstanceId) {
    Context.getCommandContext().getTaskEntityManager()
            .deleteTasksByProcessInstanceId(processInstanceId, "退回", false);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    List<Map<String, Object>> list = jdbcTemplate
            .queryForList(
                    "select * from ACT_HI_ACTINST where proc_inst_id_=? and end_time_ is null",
                    processInstanceId);
    Date now = new Date();

    for (Map<String, Object> map : list) {
        Date startTime = (Date) map.get("start_time_");
        long duration = now.getTime() - startTime.getTime();
        jdbcTemplate
                .update("update ACT_HI_ACTINST set end_time_=?,duration_=? where id_=?",
                        now, duration, map.get("id_"));
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:21,代码来源:RollbackCmd.java


示例18: fetchHistoricActivityInstances

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
public void fetchHistoricActivityInstances() {
    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    // historicActivityInstanceQueryImpl.processInstanceId(processInstanceId)
    // .orderByHistoricActivityInstanceStartTime().asc();
    // TODO: 如果用了uuid会造成这样排序出问题
    // 但是如果用startTime,可能出现因为处理速度太快,时间一样,导致次序颠倒的问题
    historicActivityInstanceQueryImpl.processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceId().asc();

    Page page = new Page(0, 100);
    historicActivityInstances = Context
            .getCommandContext()
            .getHistoricActivityInstanceEntityManager()
            .findHistoricActivityInstancesByQueryCriteria(
                    historicActivityInstanceQueryImpl, page);
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:17,代码来源:ActivitiHistoryGraphBuilder.java


示例19: readResource

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
/**
     * 读取带跟踪的图片
     */
    @RequestMapping(value = "/process/trace/auto/{executionId}")
    public void readResource(@PathVariable("executionId") String executionId, HttpServletResponse response)
            throws Exception {
        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(executionId).singleResult();
        BpmnModel bpmnModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(executionId);
        // 不使用spring请使用下面的两行代码
//    ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
//    Context.setProcessEngineConfiguration(defaultProcessEngine.getProcessEngineConfiguration());

        // 使用spring注入引擎请使用下面的这行代码
        processEngineConfiguration = processEngine.getProcessEngineConfiguration();
        Context.setProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);

        ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
        InputStream imageStream = diagramGenerator.generateDiagram(bpmnModel, "png", activeActivityIds);

        // 输出资源内容到相应对象
        byte[] b = new byte[1024];
        int len;
        while ((len = imageStream.read(b, 0, 1024)) != -1) {
            response.getOutputStream().write(b, 0, len);
        }
    }
 
开发者ID:batizhao,项目名称:microservice,代码行数:28,代码来源:ActivitiController.java


示例20: notify

import org.activiti.engine.impl.context.Context; //导入依赖的package包/类
@Override
public void notify(DelegateExecution execution) {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    Object delegate = expression.getValue(execution);
    ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);

    if (delegate instanceof ExecutionListener) {
        Context.getProcessEngineConfiguration()
                .getDelegateInterceptor()
                .handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution));
    } else if (delegate instanceof JavaDelegate) {
        Context.getProcessEngineConfiguration()
                .getDelegateInterceptor()
                .handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
    } else {
        throw new ActivitiIllegalArgumentException("Delegate expression " + expression
                + " did not resolve to an implementation of " + ExecutionListener.class
                + " nor " + JavaDelegate.class);
    }
}
 
开发者ID:flowable,项目名称:flowable-engine,代码行数:22,代码来源:DelegateExpressionExecutionListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContextNotActiveException类代码示例发布时间:2022-05-21
下一篇:
Java Cluster类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap