use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class DatabaseTableSchemaTest method testTablePresentWithSchemaAndPrefix.
public void testTablePresentWithSchemaAndPrefix() throws SQLException {
PooledDataSource pooledDataSource = new PooledDataSource(ReflectUtil.getClassLoader(), "org.h2.Driver", "jdbc:h2:mem:DatabaseTablePrefixTest;DB_CLOSE_DELAY=1000", "sa", "");
Connection connection = pooledDataSource.getConnection();
connection.createStatement().execute("drop schema if exists " + SCHEMA_NAME);
connection.createStatement().execute("create schema " + SCHEMA_NAME);
connection.createStatement().execute("create table " + SCHEMA_NAME + "." + PREFIX_NAME + "SOME_TABLE(id varchar(64));");
connection.close();
ProcessEngineConfigurationImpl config1 = createCustomProcessEngineConfiguration().setProcessEngineName("DatabaseTablePrefixTest-engine1").setDataSource(pooledDataSource).setDatabaseSchemaUpdate("NO_CHECK");
config1.setDatabaseTablePrefix(SCHEMA_NAME + "." + PREFIX_NAME);
config1.setDatabaseSchema(SCHEMA_NAME);
config1.setDbMetricsReporterActivate(false);
ProcessEngine engine = config1.buildProcessEngine();
CommandExecutor commandExecutor = config1.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
DbSqlSession sqlSession = commandContext.getSession(DbSqlSession.class);
assertTrue(sqlSession.isTablePresent("SOME_TABLE"));
return null;
}
});
engine.close();
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class CaseExecutionEntity method remove.
// delete/remove ///////////////////////////////////////////////////////
@SuppressWarnings({ "unchecked", "rawtypes" })
public void remove() {
super.remove();
for (VariableInstanceEntity variableInstance : variableStore.getVariables()) {
invokeVariableLifecycleListenersDelete(variableInstance, this, Arrays.<VariableInstanceLifecycleListener<CoreVariableInstance>>asList((VariableInstanceLifecycleListener) VariableInstanceEntityPersistenceListener.INSTANCE));
variableStore.removeVariable(variableInstance.getName());
}
CommandContext commandContext = Context.getCommandContext();
for (CaseSentryPartEntity sentryPart : getCaseSentryParts()) {
commandContext.getCaseSentryPartManager().deleteSentryPart(sentryPart);
}
// finally delete this execution
commandContext.getCaseExecutionManager().deleteCaseExecution(this);
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class HistoryCleanupBatch method performCleanup.
public void performCleanup() {
final CommandContext commandContext = Context.getCommandContext();
if (historicProcessInstanceIds.size() > 0) {
commandContext.getHistoricProcessInstanceManager().deleteHistoricProcessInstanceByIds(historicProcessInstanceIds);
recordValue(Metrics.HISTORY_CLEANUP_REMOVED_PROCESS_INSTANCES, historicProcessInstanceIds.size());
}
if (historicDecisionInstanceIds.size() > 0) {
commandContext.getHistoricDecisionInstanceManager().deleteHistoricDecisionInstanceByIds(historicDecisionInstanceIds);
recordValue(Metrics.HISTORY_CLEANUP_REMOVED_DECISION_INSTANCES, historicDecisionInstanceIds.size());
}
if (historicCaseInstanceIds.size() > 0) {
commandContext.getHistoricCaseInstanceManager().deleteHistoricCaseInstancesByIds(historicCaseInstanceIds);
recordValue(Metrics.HISTORY_CLEANUP_REMOVED_CASE_INSTANCES, historicCaseInstanceIds.size());
}
if (historicBatchIds.size() > 0) {
commandContext.getHistoricBatchManager().deleteHistoricBatchesByIds(historicBatchIds);
recordValue(Metrics.HISTORY_CLEANUP_REMOVED_BATCH_OPERATIONS, historicBatchIds.size());
}
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class MigratingInstanceParser method parse.
public MigratingProcessInstance parse(String processInstanceId, MigrationPlan migrationPlan, MigratingProcessInstanceValidationReportImpl processInstanceReport) {
CommandContext commandContext = Context.getCommandContext();
List<EventSubscriptionEntity> eventSubscriptions = fetchEventSubscriptions(commandContext, processInstanceId);
List<ExecutionEntity> executions = fetchExecutions(commandContext, processInstanceId);
List<ExternalTaskEntity> externalTasks = fetchExternalTasks(commandContext, processInstanceId);
List<IncidentEntity> incidents = fetchIncidents(commandContext, processInstanceId);
List<JobEntity> jobs = fetchJobs(commandContext, processInstanceId);
List<TaskEntity> tasks = fetchTasks(commandContext, processInstanceId);
List<VariableInstanceEntity> variables = fetchVariables(commandContext, processInstanceId);
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
processInstance.restoreProcessInstance(executions, eventSubscriptions, variables, tasks, jobs, incidents, externalTasks);
ProcessDefinitionEntity targetProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(migrationPlan.getTargetProcessDefinitionId());
List<JobDefinitionEntity> targetJobDefinitions = fetchJobDefinitions(commandContext, targetProcessDefinition.getId());
final MigratingInstanceParseContext parseContext = new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);
ActivityInstance activityInstance = engine.getRuntimeService().getActivityInstance(processInstanceId);
ActivityInstanceWalker activityInstanceWalker = new ActivityInstanceWalker(activityInstance);
activityInstanceWalker.addPreVisitor(new TreeVisitor<ActivityInstance>() {
@Override
public void visit(ActivityInstance obj) {
activityInstanceHandler.handle(parseContext, obj);
}
});
activityInstanceWalker.walkWhile();
CompensationEventSubscriptionWalker compensateSubscriptionsWalker = new CompensationEventSubscriptionWalker(parseContext.getMigratingActivityInstances());
compensateSubscriptionsWalker.addPreVisitor(new TreeVisitor<EventSubscriptionEntity>() {
@Override
public void visit(EventSubscriptionEntity obj) {
compensationInstanceHandler.handle(parseContext, obj);
}
});
compensateSubscriptionsWalker.walkWhile();
for (IncidentEntity incidentEntity : incidents) {
incidentHandler.handle(parseContext, incidentEntity);
}
parseContext.validateNoEntitiesLeft(processInstanceReport);
return parseContext.getMigratingProcessInstance();
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class StatisticsManager method checkReadDecisionRequirementsDefinition.
protected void checkReadDecisionRequirementsDefinition(HistoricDecisionInstanceStatisticsQueryImpl query) {
CommandContext commandContext = getCommandContext();
if (isAuthorizationEnabled() && getCurrentAuthentication() != null && commandContext.isAuthorizationCheckEnabled()) {
String decisionRequirementsDefinitionId = query.getDecisionRequirementsDefinitionId();
DecisionRequirementsDefinition definition = getDecisionRequirementsDefinitionManager().findDecisionRequirementsDefinitionById(decisionRequirementsDefinitionId);
ensureNotNull("no deployed decision requirements definition found with id '" + decisionRequirementsDefinitionId + "'", "decisionRequirementsDefinition", definition);
getAuthorizationManager().checkAuthorization(READ, DECISION_REQUIREMENTS_DEFINITION, definition.getKey());
}
}
Aggregations