org.activiti.engine.impl.context.Context Java Examples
The following examples show how to use
org.activiti.engine.impl.context.Context.
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 Project: activiti6-boot2 Author: dingziyang File: BpmnDeployer.java License: Apache License 2.0 | 6 votes |
/** * Creates new diagrams for process definitions if the deployment is new, the process definition in * question supports it, and the engine is configured to make new diagrams. * * When this method creates a new diagram, it also persists it via the ResourceEntityManager * and adds it to the resources of the deployment. */ protected void createAndPersistNewDiagramsIfNeeded(ParsedDeployment parsedDeployment) { final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); final DeploymentEntity deploymentEntity = parsedDeployment.getDeployment(); final ResourceEntityManager resourceEntityManager = processEngineConfiguration.getResourceEntityManager(); for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) { if (processDefinitionDiagramHelper.shouldCreateDiagram(processDefinition, deploymentEntity)) { ResourceEntity resource = processDefinitionDiagramHelper.createDiagramForProcessDefinition( processDefinition, parsedDeployment.getBpmnParseForProcessDefinition(processDefinition)); if (resource != null) { resourceEntityManager.insert(resource, false); deploymentEntity.addResource(resource); // now we'll find it if we look for the diagram name later. } } } }
Example #2
Source Project: flowable-engine Author: flowable File: DefaultHistoryManager.java License: Apache License 2.0 | 6 votes |
@Override public void recordVariableRemoved(VariableInstanceEntity variable) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricVariableInstanceEntity historicProcessVariable = getDbSqlSession() .findInCache(HistoricVariableInstanceEntity.class, variable.getId()); if (historicProcessVariable == null) { historicProcessVariable = Context.getCommandContext() .getHistoricVariableInstanceEntityManager() .findHistoricVariableInstanceByVariableInstanceId(variable.getId()); } if (historicProcessVariable != null) { Context.getCommandContext() .getHistoricVariableInstanceEntityManager() .delete(historicProcessVariable); } } }
Example #3
Source Project: flowable-engine Author: flowable File: ExecutionEntityManager.java License: Apache License 2.0 | 6 votes |
public void updateProcessInstanceLockTime(String processInstanceId) { CommandContext commandContext = Context.getCommandContext(); Date expirationTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime(); int lockMillis = commandContext.getProcessEngineConfiguration().getAsyncExecutorAsyncJobLockTimeInMillis(); GregorianCalendar lockCal = new GregorianCalendar(); lockCal.setTime(expirationTime); lockCal.add(Calendar.MILLISECOND, lockMillis); HashMap<String, Object> params = new HashMap<>(); params.put("id", processInstanceId); params.put("lockTime", lockCal.getTime()); params.put("expirationTime", expirationTime); int result = getDbSqlSession().update("updateProcessInstanceLockTime", params); if (result == 0) { throw new ActivitiOptimisticLockingException("Could not lock process instance"); } }
Example #4
Source Project: lemon Author: xuhuisheng File: SkipTaskListener.java License: Apache License 2.0 | 6 votes |
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()); } }
Example #5
Source Project: flowable-engine Author: flowable File: ExecutionEntity.java License: Apache License 2.0 | 6 votes |
@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 #6
Source Project: flowable-engine Author: flowable File: CommandContext.java License: Apache License 2.0 | 6 votes |
public void performOperation(AtomicOperation executionOperation, InterpretableExecution execution) { nextOperations.add(executionOperation); if (nextOperations.size() == 1) { try { Context.setExecutionContext(execution); while (!nextOperations.isEmpty()) { AtomicOperation currentOperation = nextOperations.removeFirst(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("AtomicOperation: {} on {}", currentOperation, this); } if (execution.getReplacedBy() == null) { currentOperation.execute(execution); } else { currentOperation.execute(execution.getReplacedBy()); } } } finally { Context.removeExecutionContext(); } } }
Example #7
Source Project: lemon Author: xuhuisheng File: FunctionEventListener.java License: Apache License 2.0 | 6 votes |
public void onActivityEnd(ActivitiActivityEvent event) { logger.debug("activity end {}", event); String processInstanceId = event.getProcessInstanceId(); ExecutionEntity executionEntity = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(processInstanceId); String businessKey = executionEntity.getBusinessKey(); String processDefinitionId = event.getProcessDefinitionId(); String activityId = event.getActivityId(); String activityName = this.findActivityName(activityId, processDefinitionId); int eventCode = 1; String eventName = "end"; String userId = Authentication.getAuthenticatedUserId(); this.invokeExpression(eventCode, eventName, businessKey, userId, activityId, activityName); }
Example #8
Source Project: flowable-engine Author: flowable File: ExecutionEntity.java License: Apache License 2.0 | 6 votes |
private void removeTasks(String reason) { if (reason == null) { reason = TaskEntity.DELETE_REASON_DELETED; } for (TaskEntity task : getTasks()) { if (replacedBy != null) { if (task.getExecution() == null || task.getExecution() != replacedBy) { // All tasks should have been moved when "replacedBy" has been set. Just in case tasks where added, // wo do an additional check here and move it task.setExecution(replacedBy); this.replacedBy.addTask(task); } } else { Context.getCommandContext() .getTaskEntityManager() .deleteTask(task, reason, false); } } }
Example #9
Source Project: flowable-engine Author: flowable File: ExecutionEntityManager.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public void deleteProcessInstancesByProcessDefinition(String processDefinitionId, String deleteReason, boolean cascade) { List<String> processInstanceIds = getDbSqlSession() .selectList("selectProcessInstanceIdsByProcessDefinitionId", processDefinitionId); for (String processInstanceId : processInstanceIds) { deleteProcessInstance(processInstanceId, deleteReason, cascade); } if (cascade) { Context .getCommandContext() .getHistoricProcessInstanceEntityManager() .deleteHistoricProcessInstanceByProcessDefinitionId(processDefinitionId); } }
Example #10
Source Project: flowable-engine Author: flowable File: TaskQueryImpl.java License: Apache License 2.0 | 6 votes |
protected void localize(Task task) { task.setLocalizedName(null); task.setLocalizedDescription(null); if (locale != null) { String processDefinitionId = task.getProcessDefinitionId(); if (processDefinitionId != null) { ObjectNode languageNode = Context.getLocalizationElementProperties(locale, task.getTaskDefinitionKey(), processDefinitionId, withLocalizationFallback); if (languageNode != null) { JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME); if (languageNameNode != null && !languageNameNode.isNull()) { task.setLocalizedName(languageNameNode.asText()); } JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION); if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) { task.setLocalizedDescription(languageDescriptionNode.asText()); } } } } }
Example #11
Source Project: lemon Author: xuhuisheng File: ActivitiHistoryGraphBuilder.java License: Apache License 2.0 | 6 votes |
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); }
Example #12
Source Project: activiti6-boot2 Author: dingziyang File: WebServiceActivityBehavior.java License: Apache License 2.0 | 6 votes |
protected AbstractDataAssociation createDataInputAssociation(DataAssociation dataAssociationElement) { if (dataAssociationElement.getAssignments().isEmpty()) { return new MessageImplicitDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef()); } else { SimpleDataInputAssociation dataAssociation = new SimpleDataInputAssociation(dataAssociationElement.getSourceRef(), dataAssociationElement.getTargetRef()); ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager(); for (org.activiti.bpmn.model.Assignment assignmentElement : dataAssociationElement.getAssignments()) { if (StringUtils.isNotEmpty(assignmentElement.getFrom()) && StringUtils.isNotEmpty(assignmentElement.getTo())) { Expression from = expressionManager.createExpression(assignmentElement.getFrom()); Expression to = expressionManager.createExpression(assignmentElement.getTo()); Assignment assignment = new Assignment(from, to); dataAssociation.addAssignment(assignment); } } return dataAssociation; } }
Example #13
Source Project: activiti6-boot2 Author: dingziyang File: BpmnDeploymentHelper.java License: Apache License 2.0 | 6 votes |
/** * Gets the persisted version of the already-deployed process definition. Note that this is * different from {@link #getMostRecentVersionOfProcessDefinition} as it looks specifically for * a process definition that is already persisted and attached to a particular deployment, * rather than the latest version across all deployments. */ public ProcessDefinitionEntity getPersistedInstanceOfProcessDefinition(ProcessDefinitionEntity processDefinition) { String deploymentId = processDefinition.getDeploymentId(); if (StringUtils.isEmpty(processDefinition.getDeploymentId())) { throw new IllegalStateException("Provided process definition must have a deployment id."); } ProcessDefinitionEntityManager processDefinitionManager = Context.getCommandContext().getProcessEngineConfiguration().getProcessDefinitionEntityManager(); ProcessDefinitionEntity persistedProcessDefinition = null; if (processDefinition.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKey(deploymentId, processDefinition.getKey()); } else { persistedProcessDefinition = processDefinitionManager.findProcessDefinitionByDeploymentAndKeyAndTenantId(deploymentId, processDefinition.getKey(), processDefinition.getTenantId()); } return persistedProcessDefinition; }
Example #14
Source Project: lemon Author: xuhuisheng File: CheckWithdrawTaskCmd.java License: Apache License 2.0 | 6 votes |
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; }
Example #15
Source Project: lemon Author: xuhuisheng File: RollbackCmd.java License: Apache License 2.0 | 6 votes |
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; }
Example #16
Source Project: activiti6-boot2 Author: dingziyang File: IntermediateCatchMessageEventActivityBehavior.java License: Apache License 2.0 | 6 votes |
public void execute(DelegateExecution execution) { CommandContext commandContext = Context.getCommandContext(); ExecutionEntity executionEntity = (ExecutionEntity) execution; String messageName = null; if (StringUtils.isNotEmpty(messageEventDefinition.getMessageRef())) { messageName = messageEventDefinition.getMessageRef(); } else { Expression messageExpression = commandContext.getProcessEngineConfiguration().getExpressionManager() .createExpression(messageEventDefinition.getMessageExpression()); messageName = messageExpression.getValue(execution).toString(); } commandContext.getEventSubscriptionEntityManager().insertMessageEvent(messageName, executionEntity); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher() .dispatchEvent(ActivitiEventBuilder.createMessageEvent(ActivitiEventType.ACTIVITY_MESSAGE_WAITING, executionEntity.getActivityId(), messageName, null, executionEntity.getId(), executionEntity.getProcessInstanceId(), executionEntity.getProcessDefinitionId())); } }
Example #17
Source Project: activiti6-boot2 Author: dingziyang File: TerminateEndEventActivityBehavior.java License: Apache License 2.0 | 6 votes |
protected void endAllHistoricActivities(String processInstanceId, String deleteReason) { if (!Context.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { return; } List<HistoricActivityInstanceEntity> historicActivityInstances = Context.getCommandContext().getHistoricActivityInstanceEntityManager() .findUnfinishedHistoricActivityInstancesByProcessInstanceId(processInstanceId); for (HistoricActivityInstanceEntity historicActivityInstance : historicActivityInstances) { historicActivityInstance.markEnded(deleteReason); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_ENDED, historicActivityInstance)); } } }
Example #18
Source Project: flowable-engine Author: flowable File: BpmnDeployer.java License: Apache License 2.0 | 6 votes |
protected void removeObsoleteTimers(ProcessDefinitionEntity processDefinition) { List<Job> jobsToDelete = null; if (processDefinition.getTenantId() != null && !ProcessEngineConfiguration.NO_TENANT_ID.equals(processDefinition.getTenantId())) { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager().findTimerJobsByTypeAndProcessDefinitionKeyAndTenantId( TimerStartEventJobHandler.TYPE, processDefinition.getKey(), processDefinition.getTenantId()); } else { jobsToDelete = Context.getCommandContext().getTimerJobEntityManager() .findTimerJobsByTypeAndProcessDefinitionKeyNoTenantId(TimerStartEventJobHandler.TYPE, processDefinition.getKey()); } if (jobsToDelete != null) { for (Job job : jobsToDelete) { new CancelJobsCmd(job.getId()).execute(Context.getCommandContext()); } } }
Example #19
Source Project: flowable-engine Author: flowable File: JobEntity.java License: Apache License 2.0 | 6 votes |
public void insert() { Context.getCommandContext() .getDbSqlSession() .insert(this); // add link to execution if (executionId != null) { ExecutionEntity execution = Context.getCommandContext() .getExecutionEntityManager() .findExecutionById(executionId); execution.addJob(this); // Inherit tenant if (if applicable) if (execution.getTenantId() != null) { setTenantId(execution.getTenantId()); } } if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, this)); Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, this)); } }
Example #20
Source Project: flowable-engine Author: flowable File: SaveTaskCmd.java License: Apache License 2.0 | 5 votes |
@Override public Void execute(CommandContext commandContext) { if (task == null) { throw new ActivitiIllegalArgumentException("task is null"); } if (task.getRevision() == 0) { task.insert(null, true); // Need to to be done here, we can't make it generic for standalone tasks // and tasks from a process, as the order of setting properties is // completely different. if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.TASK_CREATED, task)); if (task.getAssignee() != null) { // The assignment event is normally fired when calling setAssignee. However, this // doesn't work for standalone tasks as the commandcontext is not available. Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.TASK_ASSIGNED, task)); } } } else { task.update(); } return null; }
Example #21
Source Project: flowable-engine Author: flowable File: BpmnDeployer.java License: Apache License 2.0 | 5 votes |
protected void removeExistingSignalEventSubScription(ProcessDefinitionEntity processDefinition, ProcessDefinitionEntity latestProcessDefinition) { // remove all subscriptions for the previous version if (latestProcessDefinition != null) { CommandContext commandContext = Context.getCommandContext(); List<EventSubscriptionEntity> subscriptionsToDelete = commandContext .getEventSubscriptionEntityManager() .findEventSubscriptionsByTypeAndProcessDefinitionId(SignalEventHandler.EVENT_HANDLER_TYPE, latestProcessDefinition.getId(), latestProcessDefinition.getTenantId()); for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) { eventSubscriptionEntity.delete(); } } }
Example #22
Source Project: activiti6-boot2 Author: dingziyang File: CamelBehavior.java License: Apache License 2.0 | 5 votes |
public void execute(DelegateExecution execution) { setAppropriateCamelContext(execution); final ActivitiEndpoint endpoint = createEndpoint(execution); final Exchange exchange = createExchange(execution, endpoint); try { endpoint.process(exchange); } catch (Exception e) { throw new ActivitiException("Exception while processing exchange", e); } execution.setVariables(ExchangeUtils.prepareVariables(exchange, endpoint)); boolean isActiviti5Execution = false; if ((Context.getCommandContext() != null && Activiti5Util.isActiviti5ProcessDefinitionId(Context.getCommandContext(), execution.getProcessDefinitionId())) || (Context.getCommandContext() == null && Activiti5Util.getActiviti5CompatibilityHandler() != null)) { isActiviti5Execution = true; } if (!handleCamelException(exchange, execution, isActiviti5Execution)) { if (isActiviti5Execution) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.leaveExecution(execution); return; } leave(execution); } }
Example #23
Source Project: flowable-engine Author: flowable File: TaskEntity.java License: Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public void complete(Map variablesMap, boolean localScope, boolean fireEvents) { if (getDelegationState() != null && getDelegationState() == DelegationState.PENDING) { throw new ActivitiException("A delegated task cannot be completed, but should be resolved instead."); } if (fireEvents) { fireEvent(TaskListener.EVENTNAME_COMPLETE); } if (Authentication.getAuthenticatedUserId() != null && processInstanceId != null) { getProcessInstance().involveUser(Authentication.getAuthenticatedUserId(), IdentityLinkType.PARTICIPANT); } if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled() && fireEvents) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityWithVariablesEvent(FlowableEngineEventType.TASK_COMPLETED, this, variablesMap, localScope)); } Context .getCommandContext() .getTaskEntityManager() .deleteTask(this, TaskEntity.DELETE_REASON_COMPLETED, false); if (executionId != null) { ExecutionEntity execution = getExecution(); execution.removeTask(this); execution.signal(null, null); } }
Example #24
Source Project: activiti6-boot2 Author: dingziyang File: MuleSendActivitiBehavior.java License: Apache License 2.0 | 5 votes |
protected MuleContext getMuleContext() { if (this.muleContext == null) { Map<Object, Object> beans = Context.getProcessEngineConfiguration().getBeans(); this.muleContext = (MuleContext) beans.get("muleContext"); } return this.muleContext; }
Example #25
Source Project: activiti6-boot2 Author: dingziyang File: ExecutionEntityImpl.java License: Apache License 2.0 | 5 votes |
@Override protected VariableInstanceEntity getSpecificVariable(String variableName) { CommandContext commandContext = Context.getCommandContext(); if (commandContext == null) { throw new ActivitiException("lazy loading outside command context"); } VariableInstanceEntity variableInstance = commandContext.getVariableInstanceEntityManager().findVariableInstanceByExecutionAndName(id, variableName); return variableInstance; }
Example #26
Source Project: lemon Author: xuhuisheng File: TaskConfTaskListener.java License: Apache License 2.0 | 5 votes |
@Override public void onCreate(DelegateTask delegateTask) throws Exception { String businessKey = delegateTask.getExecution() .getProcessBusinessKey(); String taskDefinitionKey = delegateTask.getTaskDefinitionKey(); ExpressionManager expressionManager = Context .getProcessEngineConfiguration().getExpressionManager(); try { String sql = "select ASSIGNEE from BPM_TASK_CONF where BUSINESS_KEY=? and TASK_DEFINITION_KEY=?"; String assignee = jdbcTemplate.queryForObject(sql, String.class, businessKey, taskDefinitionKey); if ((assignee == null) || "".equals(assignee)) { return; } if ((assignee.indexOf("&&") != -1) || (assignee.indexOf("||") != -1)) { logger.info("assignee : {}", assignee); List<String> candidateUsers = new Expr().evaluate(assignee, this); logger.info("candidateUsers : {}", candidateUsers); delegateTask.addCandidateUsers(candidateUsers); } else { String value = expressionManager.createExpression(assignee) .getValue(delegateTask).toString(); delegateTask.setAssignee(value); } } catch (Exception ex) { logger.debug(ex.getMessage(), ex); } }
Example #27
Source Project: lemon Author: xuhuisheng File: RollbackTaskCmd.java License: Apache License 2.0 | 5 votes |
/** * 删除活动状态任务. */ public void deleteActiveTasks(String processInstanceId) { List<TaskEntity> taskEntities = Context.getCommandContext() .getTaskEntityManager() .findTasksByProcessInstanceId(processInstanceId); for (TaskEntity taskEntity : taskEntities) { this.deleteActiveTask(taskEntity); } }
Example #28
Source Project: flowable-engine Author: flowable File: ProcessDefinitionQueryImpl.java License: Apache License 2.0 | 5 votes |
public List<String> getAuthorizationGroups() { // Similar behaviour as the TaskQuery.taskCandidateUser() which includes the groups the candidate user is part of if (authorizationUserId != null) { IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(authorizationUserId).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; } return null; }
Example #29
Source Project: flowable-engine Author: flowable File: ExecutionEntity.java License: Apache License 2.0 | 5 votes |
@Override public void remove() { ensureParentInitialized(); if (parent != null) { parent.ensureExecutionsInitialized(); parent.executions.remove(this); } // delete all the variable instances ensureVariableInstancesInitialized(); deleteVariablesInstanceForLeavingScope(); // delete all the tasks removeTasks(null); // remove all jobs removeJobs(); // remove all event subscriptions for this scope, if the scope has event subscriptions: removeEventSubscriptions(); // remove event scopes: removeEventScopes(); // remove identity links removeIdentityLinks(); if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, this)); } // finally delete this execution Context.getCommandContext() .getDbSqlSession() .delete(this); }
Example #30
Source Project: activiti6-boot2 Author: dingziyang File: VariableScopeImpl.java License: Apache License 2.0 | 5 votes |
protected void deleteVariableInstanceForExplicitUserCall(VariableInstanceEntity variableInstance, ExecutionEntity sourceActivityExecution) { Context.getCommandContext().getVariableInstanceEntityManager().delete(variableInstance); variableInstance.setValue(null); // Record historic variable deletion Context.getCommandContext().getHistoryManager().recordVariableRemoved(variableInstance); // Record historic detail Context.getCommandContext().getHistoryManager().recordHistoricDetailVariableCreate(variableInstance, sourceActivityExecution, isActivityIdUsedForDetails()); }