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


Java Context类代码示例

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


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


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