本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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");
}
示例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;
}
示例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);
}
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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;
}