public ByteArrayEntity getByteArrayValue() { if ((byteArrayValue == null) && (byteArrayId != null)) { // no lazy fetching outside of command context if (Context.getCommandContext() != null) { byteArrayValue = Context.getCommandContext() .getDbEntityManager() .selectById(ByteArrayEntity.class, byteArrayId); } } return byteArrayValue; }
public void deleteHistoricProcessInstanceById(String historicProcessInstanceId) { if (historyLevel > ProcessEngineConfigurationImpl.HISTORYLEVEL_NONE) { CommandContext commandContext = Context.getCommandContext(); HistoricProcessInstanceEntity historicProcessInstance = findHistoricProcessInstance(historicProcessInstanceId); commandContext .getHistoricDetailManager() .deleteHistoricDetailsByProcessInstanceId(historicProcessInstanceId); commandContext .getHistoricVariableInstanceManager() .deleteHistoricVariableInstanceByProcessInstanceId(historicProcessInstanceId); commandContext .getHistoricActivityInstanceManager() .deleteHistoricActivityInstancesByProcessInstanceId(historicProcessInstanceId); commandContext .getHistoricTaskInstanceManager() .deleteHistoricTaskInstancesByProcessInstanceId(historicProcessInstanceId); getDbSqlSession().delete(historicProcessInstance); } }
/** @return true if the passed-in user is currently authenticated */ protected boolean isAuthenticatedUser(UserEntity user) { if (user.getId() == null) { return false; } return user.getId() .equals( org.camunda.bpm.engine.impl.context.Context.getCommandContext() .getAuthenticatedUserId()); }
protected void deleteTask(String taskId) { TaskEntity task = Context.getCommandContext().getTaskManager().findTaskById(taskId); if (task != null) { if (task.getExecutionId() != null) { throw new ProcessEngineException( "The task cannot be deleted because is part of a running process"); } String reason = (deleteReason == null || deleteReason.length() == 0) ? TaskEntity.DELETE_REASON_DELETED : deleteReason; task.delete(reason, cascade); } else if (cascade) { Context.getCommandContext() .getHistoricTaskInstanceManager() .deleteHistoricTaskInstanceById(taskId); } }
protected String getDnForUser(String userId) { LdapUserEntity user = (LdapUserEntity) createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext()) .userId(userId) .singleResult(); if (user == null) { return ""; } else { return user.getDn(); } }
protected String getDnForGroup(String groupId) { LdapGroupEntity group = (LdapGroupEntity) createGroupQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext()) .groupId(groupId) .singleResult(); if (group == null) { return ""; } else { return group.getDn(); } }
public void deleteByteArrayValue() { if (byteArrayId != null) { // the next apparently useless line is probably to ensure consistency in the DbSqlSession // cache, // but should be checked and docked here (or removed if it turns out to be unnecessary) getByteArrayValue(); Context.getCommandContext().getByteArrayManager().deleteByteArrayById(this.byteArrayId); byteArrayId = null; } }
public ProcessDefinitionEntity findDeployedLatestProcessDefinitionByKey( String processDefinitionKey) { ProcessDefinitionEntity processDefinition = Context.getCommandContext() .getProcessDefinitionManager() .findLatestProcessDefinitionByKey(processDefinitionKey); if (processDefinition == null) { throw new ProcessEngineException( "no processes deployed with key '" + processDefinitionKey + "'"); } processDefinition = resolveProcessDefinition(processDefinition); return processDefinition; }
public TaskEntity createTask(TaskDecorator taskDecorator) { TaskEntity task = TaskEntity.createAndInsert(this); setTask(task); taskDecorator.decorate(task, this); Context.getCommandContext().getHistoricTaskInstanceManager().createHistoricTask(task); // All properties set, now firing 'create' event task.fireEvent(TaskListener.EVENTNAME_CREATE); return task; }
protected Integer getJobDefinitionPriority( ExecutionEntity execution, JobDeclaration<?> jobDeclaration) { String jobDefinitionId = jobDeclaration.getJobDefinitionId(); if (jobDefinitionId != null) { JobDefinitionEntity jobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(jobDefinitionId); if (jobDefinition != null) { return jobDefinition.getJobPriority(); } } return null; }
public ProcessDefinitionEntity findDeployedProcessDefinitionById(String processDefinitionId) { if (processDefinitionId == null) { throw new ProcessEngineException("Invalid process definition id : null"); } ProcessDefinitionEntity processDefinition = Context.getCommandContext() .getProcessDefinitionManager() .findLatestProcessDefinitionById(processDefinitionId); if (processDefinition == null) { throw new ProcessEngineException( "no deployed process definition found with id '" + processDefinitionId + "'"); } processDefinition = resolveProcessDefinition(processDefinition); return processDefinition; }
public void setByteArrayValue(byte[] bytes) { deleteByteArrayValue(); ByteArrayEntity byteArrayValue = null; if (bytes != null) { byteArrayValue = new ByteArrayEntity(valueFields.getName(), bytes); Context.getCommandContext().getDbEntityManager().insert(byteArrayValue); } this.byteArrayValue = byteArrayValue; if (byteArrayValue != null) { this.byteArrayId = byteArrayValue.getId(); } else { this.byteArrayId = null; } }
public ProcessDefinitionEntity findDeployedProcessDefinitionByKeyAndVersion( String processDefinitionKey, Integer processDefinitionVersion) { ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) Context.getCommandContext() .getProcessDefinitionManager() .findProcessDefinitionByKeyAndVersion( processDefinitionKey, processDefinitionVersion); if (processDefinition == null) { throw new ProcessEngineException( "no processes deployed with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'"); } processDefinition = resolveProcessDefinition(processDefinition); return processDefinition; }
public void removeDeployment(String deploymentId) { // remove all process definitions for a specific deployment List<ProcessDefinition> allDefinitionsForDeployment = new ProcessDefinitionQueryImpl(Context.getCommandContext()) .deploymentId(deploymentId) .list(); for (ProcessDefinition processDefinition : allDefinitionsForDeployment) { try { removeProcessDefinition(processDefinition.getId()); } catch (Exception e) { LOGGER.log( Level.WARNING, "Could not remove process definition with id '" + processDefinition.getId() + "' from the cache.", e); } } }
/** customized insert behavior for HistoricVariableUpdateEventEntity */ protected void insertHistoricVariableUpdateEntity( HistoricVariableUpdateEventEntity historyEvent) { DbSqlSession dbSqlSession = getDbSqlSession(); // insert update only if history level = FULL int historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel(); if (historyLevel == ProcessEngineConfigurationImpl.HISTORYLEVEL_FULL) { // insert byte array entity (if applicable) byte[] byteValue = historyEvent.getByteValue(); if (byteValue != null) { ByteArrayEntity byteArrayEntity = new ByteArrayEntity(historyEvent.getVariableName(), byteValue); Context.getCommandContext().getDbSqlSession().insert(byteArrayEntity); historyEvent.setByteArrayId(byteArrayEntity.getId()); } dbSqlSession.insert(historyEvent); } // always insert/update HistoricProcessVariableInstance if (HistoryEvent.VARIABLE_EVENT_TYPE_CREATE.equals(historyEvent.getEventType())) { HistoricVariableInstanceEntity persistentObject = new HistoricVariableInstanceEntity(historyEvent); dbSqlSession.insert(persistentObject); } else if (HistoryEvent.VARIABLE_EVENT_TYPE_UPDATE.equals(historyEvent.getEventType())) { HistoricVariableInstanceEntity historicVariableInstanceEntity = dbSqlSession.selectById( HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); historicVariableInstanceEntity.updateFromEvent(historyEvent); } else if (HistoryEvent.VARIABLE_EVENT_TYPE_DELETE.equals(historyEvent.getEventType())) { HistoricVariableInstanceEntity historicVariableInstanceEntity = dbSqlSession.selectById( HistoricVariableInstanceEntity.class, historyEvent.getVariableInstanceId()); if (historicVariableInstanceEntity != null) { historicVariableInstanceEntity.delete(); } } }
public ProcessDefinitionEntity resolveProcessDefinition( ProcessDefinitionEntity processDefinition) { String processDefinitionId = processDefinition.getId(); String deploymentId = processDefinition.getDeploymentId(); processDefinition = processDefinitionCache.get(processDefinitionId); if (processDefinition == null) { DeploymentEntity deployment = Context.getCommandContext().getDeploymentManager().findDeploymentById(deploymentId); deployment.setNew(false); deploy(deployment); processDefinition = processDefinitionCache.get(processDefinitionId); if (processDefinition == null) { throw new ProcessEngineException( "deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache"); } } return processDefinition; }
public User findUserById(String userId) { return createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext()) .userId(userId) .singleResult(); }
public void delete() { byteArrayField.deleteByteArrayValue(); Context.getCommandContext().getDbEntityManager().delete(this); }
protected DbSqlSession getDbSqlSession() { return Context.getCommandContext().getDbSqlSession(); }
protected boolean isAuthorized(Permission permission, Resource resource, String resourceId) { return !ldapConfiguration.isAuthorizationCheckEnabled() || org.camunda.bpm.engine.impl.context.Context.getCommandContext() .getAuthorizationManager() .isAuthorized(permission, resource, resourceId); }
public Group findGroupById(String groupId) { return createGroupQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext()) .groupId(groupId) .singleResult(); }
public Session openSession() { return Context.getCommandContext().getDbSqlSession(); }
protected ExecutionEntity fetchExecutionEntity(String executionId) { return Context.getCommandContext().getExecutionManager().findExecutionById(executionId); }