Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getId()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ExecutionEntity#getId() .
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 File: CtrlrServlet.java From oneops with Apache License 2.0 | 6 votes |
/** * Test. * * @return the string */ @RequestMapping(method=RequestMethod.GET, value="/resumeall") @ResponseBody public String test() { logger.info("Resuming crashed processes!!!"); List<ProcessInstance> processes = runtimeService.createProcessInstanceQuery().active().list(); for (ProcessInstance process : processes) { ExecutionEntity exec = (ExecutionEntity)process; if (exec.isActive() && exec.getActivityId().equals("ackStart")) { exec.getId(); runtimeService.signal(exec.getId()); } } return "Resumed all processes"; }
Example 2
Source File: LogMDC.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void putMDCExecution(ExecutionEntity e) { if (e.getId() != null) MDC.put(LOG_MDC_EXECUTION_ID, e.getId()); if (e.getProcessDefinitionId() != null) MDC.put(LOG_MDC_PROCESSDEFINITION_ID, e.getProcessDefinitionId()); if (e.getProcessInstanceId() != null) MDC.put(LOG_MDC_PROCESSINSTANCE_ID, e.getProcessInstanceId()); if (e.getProcessInstanceBusinessKey() != null) MDC.put(LOG_MDC_BUSINESS_KEY, e.getProcessInstanceBusinessKey()); }
Example 3
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void recordActivityStart(ExecutionEntity executionEntity) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { if (executionEntity.getActivity() != null) { IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); String processDefinitionId = executionEntity.getProcessDefinitionId(); String processInstanceId = executionEntity.getProcessInstanceId(); String executionId = executionEntity.getId(); HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(processDefinitionId); historicActivityInstance.setProcessInstanceId(processInstanceId); historicActivityInstance.setExecutionId(executionId); historicActivityInstance.setActivityId(executionEntity.getActivityId()); historicActivityInstance.setActivityName((String) executionEntity.getActivity().getProperty("name")); historicActivityInstance.setActivityType((String) executionEntity.getActivity().getProperty("type")); historicActivityInstance.setStartTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); // Inherit tenant id (if applicable) if (executionEntity.getTenantId() != null) { historicActivityInstance.setTenantId(executionEntity.getTenantId()); } getDbSqlSession().insert(historicActivityInstance); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance)); } } } }
Example 4
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected HistoricActivityInstanceEntity findActivityInstance(ExecutionEntity execution, String activityId, boolean checkPersistentStore) { String executionId = execution.getId(); // search for the historic activity instance in the dbsqlsession cache List<HistoricActivityInstanceEntity> cachedHistoricActivityInstances = getDbSqlSession() .findInCache(HistoricActivityInstanceEntity.class); for (HistoricActivityInstanceEntity cachedHistoricActivityInstance : cachedHistoricActivityInstances) { if (executionId.equals(cachedHistoricActivityInstance.getExecutionId()) && activityId != null && (activityId.equals(cachedHistoricActivityInstance.getActivityId())) && (cachedHistoricActivityInstance.getEndTime() == null)) { return cachedHistoricActivityInstance; } } List<HistoricActivityInstance> historicActivityInstances = null; if (checkPersistentStore) { historicActivityInstances = new HistoricActivityInstanceQueryImpl(Context.getCommandContext()) .executionId(executionId) .activityId(activityId) .unfinished() .listPage(0, 1); } if (historicActivityInstances != null && !historicActivityInstances.isEmpty()) { return (HistoricActivityInstanceEntity) historicActivityInstances.get(0); } if (execution.getParentId() != null) { return findActivityInstance(execution.getParent(), activityId, checkPersistentStore); } return null; }
Example 5
Source File: DefaultHistoryManager.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public HistoricActivityInstanceEntity findActivityInstance(ExecutionEntity execution, String activityId, boolean createOnNotFound, boolean endTimeMustBeNull) { // No use looking for the HistoricActivityInstance when no activityId is provided. if (activityId == null) { return null; } String executionId = execution.getId(); // Check the cache HistoricActivityInstanceEntity historicActivityInstanceEntityFromCache = getHistoricActivityInstanceFromCache(executionId, activityId, endTimeMustBeNull); if (historicActivityInstanceEntityFromCache != null) { return historicActivityInstanceEntityFromCache; } // If the execution was freshly created, there is no need to check the database, // there can never be an entry for a historic activity instance with this execution id. if (!execution.isInserted() && !execution.isProcessInstanceType()) { // Check the database List<HistoricActivityInstanceEntity> historicActivityInstances = getHistoricActivityInstanceEntityManager() .findUnfinishedHistoricActivityInstancesByExecutionAndActivityId(executionId, activityId); if (historicActivityInstances.size() > 0) { return historicActivityInstances.get(0); } } if (execution.getParentId() != null) { HistoricActivityInstanceEntity historicActivityInstanceFromParent = findActivityInstance((ExecutionEntity) execution.getParent(), activityId, false, endTimeMustBeNull); // always false for create, we only check if it can be found if (historicActivityInstanceFromParent != null) { return historicActivityInstanceFromParent; } } if (createOnNotFound && activityId != null && ( (execution.getCurrentFlowElement() != null && execution.getCurrentFlowElement() instanceof FlowNode) || execution.getCurrentFlowElement() == null)) { return createHistoricActivityInstanceEntity(execution); } return null; }
Example 6
Source File: DefaultHistoryManager.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public void recordProcessInstanceStart(ExecutionEntity processInstance) { if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity(processInstance); // Insert historic process-instance getDbSqlSession().insert(historicProcessInstance); // Fire event ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance)); } // Also record the start-event manually, as there is no "start" activity history listener for this IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator(); String processDefinitionId = processInstance.getProcessDefinitionId(); String processInstanceId = processInstance.getProcessInstanceId(); String executionId = processInstance.getId(); HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity(); historicActivityInstance.setId(idGenerator.getNextId()); historicActivityInstance.setProcessDefinitionId(processDefinitionId); historicActivityInstance.setProcessInstanceId(processInstanceId); historicActivityInstance.setExecutionId(executionId); historicActivityInstance.setActivityId(processInstance.getActivityId()); historicActivityInstance.setActivityName((String) processInstance.getActivity().getProperty("name")); historicActivityInstance.setActivityType((String) processInstance.getActivity().getProperty("type")); Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime(); historicActivityInstance.setStartTime(now); // Inherit tenant id (if applicable) if (processInstance.getTenantId() != null) { historicActivityInstance.setTenantId(processInstance.getTenantId()); } getDbSqlSession().insert(historicActivityInstance); // Fire event if (config != null && config.getEventDispatcher().isEnabled()) { config.getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance)); } } }
Example 7
Source File: UpdateProcessInstanceNameEventListener.java From lemon with Apache License 2.0 | 4 votes |
protected void onInitialized(ActivitiEvent event) { if (!(event instanceof ActivitiEntityEventImpl)) { return; } ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event; Object entity = activitiEntityEventImpl.getEntity(); if (!(entity instanceof ExecutionEntity)) { return; } ActivitiEventType activitiEventType = activitiEntityEventImpl.getType(); if (activitiEventType != ActivitiEventType.ENTITY_INITIALIZED) { return; } ExecutionEntity executionEntity = (ExecutionEntity) entity; if (!executionEntity.isProcessInstanceType()) { return; } String processInstanceId = executionEntity.getId(); String processDefinitionId = executionEntity.getProcessDefinitionId(); CommandContext commandContext = Context.getCommandContext(); ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); // {流程标题:title}-{发起人:startUser}-{发起时间:startTime} String processDefinitionName = processDefinition.getName(); if (processDefinitionName == null) { processDefinitionName = processDefinition.getKey(); } String userId = Authentication.getAuthenticatedUserId(); String displayName = userConnector.findById(userId).getDisplayName(); String processInstanceName = processDefinitionName + "-" + displayName + "-" + new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()); // runtime executionEntity.setName(processInstanceName); // history HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); historicProcessInstanceEntity.setName(processInstanceName); }