Search in sources :

Example 91 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class SubmitStartFormCmd method execute.

@Override
public ProcessInstance execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    ensureNotNull("No process definition found for id = '" + processDefinitionId + "'", "processDefinition", processDefinition);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkCreateProcessInstance(processDefinition);
    }
    ExecutionEntity processInstance = null;
    if (businessKey != null) {
        processInstance = processDefinition.createProcessInstance(businessKey);
    } else {
        processInstance = processDefinition.createProcessInstance();
    }
    // see CAM-2828
    if (processDefinition.getInitial().isAsyncBefore()) {
        // avoid firing history events
        processInstance.setStartContext(new ProcessInstanceStartContext(processInstance.getActivity()));
        FormPropertyHelper.initFormPropertiesOnScope(variables, processInstance);
        processInstance.start();
    } else {
        processInstance.startWithFormProperties(variables);
    }
    return processInstance;
}
Also used : ProcessInstanceStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ProcessInstanceStartContext) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 92 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method fireFormPropertyHistoryEvents.

protected void fireFormPropertyHistoryEvents(VariableMap properties, VariableScope variableScope) {
    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    HistoryLevel historyLevel = processEngineConfiguration.getHistoryLevel();
    if (historyLevel.isHistoryEventProduced(HistoryEventTypes.FORM_PROPERTY_UPDATE, variableScope)) {
        // fire history events
        final ExecutionEntity executionEntity;
        final String taskId;
        if (variableScope instanceof ExecutionEntity) {
            executionEntity = (ExecutionEntity) variableScope;
            taskId = null;
        } else if (variableScope instanceof TaskEntity) {
            TaskEntity task = (TaskEntity) variableScope;
            executionEntity = task.getExecution();
            taskId = task.getId();
        } else {
            executionEntity = null;
            taskId = null;
        }
        if (executionEntity != null) {
            for (final String variableName : properties.keySet()) {
                final TypedValue value = properties.getValueTyped(variableName);
                // NOTE: SerializableValues are never stored as form properties
                if (!(value instanceof SerializableValue) && value.getValue() != null && value.getValue() instanceof String) {
                    final String stringValue = (String) value.getValue();
                    HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {

                        @Override
                        public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
                            return producer.createFormPropertyUpdateEvt(executionEntity, variableName, stringValue, taskId);
                        }
                    });
                }
            }
        }
    }
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) SerializableValue(org.camunda.bpm.engine.variable.value.SerializableValue) HistoryLevel(org.camunda.bpm.engine.impl.history.HistoryLevel) HistoryEventProcessor(org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor) HistoryEventProducer(org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer) HistoryEvent(org.camunda.bpm.engine.impl.history.event.HistoryEvent) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 93 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class DbIdentityServiceProvider method lockUser.

protected void lockUser(UserEntity user) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    int max = processEngineConfiguration.getLoginDelayMaxTime();
    int baseTime = processEngineConfiguration.getLoginDelayBase();
    int factor = processEngineConfiguration.getLoginDelayFactor();
    int attempts = user.getAttempts() + 1;
    long delay = (long) (baseTime * Math.pow(factor, attempts - 1));
    delay = Math.min(delay, max) * 1000;
    long currentTime = ClockUtil.getCurrentTime().getTime();
    Date lockExpirationTime = new Date(currentTime + delay);
    getIdentityInfoManager().updateUserLock(user, attempts, lockExpirationTime);
}
Also used : ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Date(java.util.Date)

Example 94 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class MigrateProcessInstanceBatchCmd method createBatch.

protected BatchEntity createBatch(CommandContext commandContext, MigrationPlan migrationPlan, Collection<String> processInstanceIds, ProcessDefinitionEntity sourceProcessDefinition) {
    ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
    BatchJobHandler<MigrationBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);
    MigrationBatchConfiguration configuration = new MigrationBatchConfiguration(new ArrayList<String>(processInstanceIds), migrationPlan, executionBuilder.isSkipCustomListeners(), executionBuilder.isSkipIoMappings());
    BatchEntity batch = new BatchEntity();
    batch.setType(batchJobHandler.getType());
    batch.setTotalJobs(calculateSize(processEngineConfiguration, configuration));
    batch.setBatchJobsPerSeed(processEngineConfiguration.getBatchJobsPerSeed());
    batch.setInvocationsPerBatchJob(processEngineConfiguration.getInvocationsPerBatchJob());
    batch.setConfigurationBytes(batchJobHandler.writeConfiguration(configuration));
    batch.setTenantId(sourceProcessDefinition.getTenantId());
    commandContext.getBatchManager().insert(batch);
    return batch;
}
Also used : BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 95 with ProcessEngineConfigurationImpl

use of org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl in project camunda-bpm-platform by camunda.

the class TestHelper method assertAndEnsureCleanDbAndCache.

/**
 * Ensures that the deployment cache and database is clean after a test. If not the cache
 * and database will be cleared.
 *
 * @param processEngine the {@link ProcessEngine} to test
 * @param fail if true the method will throw an {@link AssertionError} if the deployment cache or database is not clean
 * @throws AssertionError if the deployment cache or database was not clean
 */
public static String assertAndEnsureCleanDbAndCache(ProcessEngine processEngine, boolean fail) {
    ProcessEngineConfigurationImpl processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
    // clear user operation log in case some operations are
    // executed with an authenticated user
    clearUserOperationLog(processEngineConfiguration);
    LOG.debug("verifying that db is clean after test");
    PurgeReport purgeReport = ((ManagementServiceImpl) processEngine.getManagementService()).purge();
    String paRegistrationMessage = assertAndEnsureNoProcessApplicationsRegistered(processEngine);
    StringBuilder message = new StringBuilder();
    CachePurgeReport cachePurgeReport = purgeReport.getCachePurgeReport();
    if (!cachePurgeReport.isEmpty()) {
        message.append("Deployment cache is not clean:\n").append(cachePurgeReport.getPurgeReportAsString());
    } else {
        LOG.debug("Deployment cache was clean.");
    }
    DatabasePurgeReport databasePurgeReport = purgeReport.getDatabasePurgeReport();
    if (!databasePurgeReport.isEmpty()) {
        message.append("Database is not clean:\n").append(databasePurgeReport.getPurgeReportAsString());
    } else {
        LOG.debug("Database was clean.");
    }
    if (paRegistrationMessage != null) {
        message.append(paRegistrationMessage);
    }
    if (fail && message.length() > 0) {
        Assert.fail(message.toString());
    }
    return message.toString();
}
Also used : ManagementServiceImpl(org.camunda.bpm.engine.impl.ManagementServiceImpl) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) ProcessEngineImpl(org.camunda.bpm.engine.impl.ProcessEngineImpl) PurgeReport(org.camunda.bpm.engine.impl.management.PurgeReport) CachePurgeReport(org.camunda.bpm.engine.impl.persistence.deploy.cache.CachePurgeReport) DatabasePurgeReport(org.camunda.bpm.engine.impl.management.DatabasePurgeReport)

Aggregations

ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)161 Test (org.junit.Test)35 HistoryLevel (org.camunda.bpm.engine.impl.history.HistoryLevel)22 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)18 ProcessEngine (org.camunda.bpm.engine.ProcessEngine)17 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)17 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)13 HistoryEventProcessor (org.camunda.bpm.engine.impl.history.event.HistoryEventProcessor)12 HistoryEventProducer (org.camunda.bpm.engine.impl.history.producer.HistoryEventProducer)12 Before (org.junit.Before)11 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)8 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)8 After (org.junit.After)8 Date (java.util.Date)7 PooledDataSource (org.apache.ibatis.datasource.pooled.PooledDataSource)7 ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)7 DefaultDmnEngineConfiguration (org.camunda.bpm.dmn.engine.impl.DefaultDmnEngineConfiguration)7 IdentityService (org.camunda.bpm.engine.IdentityService)7 ProcessEngineImpl (org.camunda.bpm.engine.impl.ProcessEngineImpl)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)6