@Override public ProcessEngine buildProcessEngine() { ProcessEngine processEngine = super.buildProcessEngine(); autoDeployResources(processEngine); return processEngine; }
/** * Deprecated: use {@link #getProcessEngines()} instead */ @Deprecated public CommandExecutor getCommandExecutor() { if(processEngines.isEmpty()) { return null; } else { return processEngines.get(0).getProcessEngineConfiguration().getCommandExecutorTxRequired(); } }
public static boolean isBatchWindowConfigured(CommandContext commandContext) { return commandContext.getProcessEngineConfiguration().getBatchWindowManager().isBatchWindowConfigured(commandContext.getProcessEngineConfiguration()); } }
protected void initializeExpressionManager() { if (processEngineConfiguration.getExpressionManager() == null && applicationContext != null) { processEngineConfiguration.setExpressionManager( new SpringExpressionManager(applicationContext, processEngineConfiguration.getBeans())); } }
public void fireHistoricCaseActivityInstanceUpdate() { ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration(); HistoryLevel historyLevel = configuration.getHistoryLevel(); if (historyLevel.isHistoryEventProduced(HistoryEventTypes.CASE_ACTIVITY_INSTANCE_UPDATE, this)) { CmmnHistoryEventProducer eventProducer = configuration.getCmmnHistoryEventProducer(); HistoryEventHandler eventHandler = configuration.getHistoryEventHandler(); HistoryEvent event = eventProducer.createCaseActivityInstanceUpdateEvt(this); eventHandler.handleEvent(event); } }
public static void clearUserOperationLog(ProcessEngineConfigurationImpl processEngineConfiguration) { if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) { HistoryService historyService = processEngineConfiguration.getHistoryService(); List<UserOperationLogEntry> logs = historyService.createUserOperationLogQuery().list(); for (UserOperationLogEntry log : logs) { historyService.deleteUserOperationLogEntry(log.getId()); } } }
protected AcquiredJobs acquireJobs() { JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor(); return processEngineConfiguration.getCommandExecutorTxRequired() .execute(new AcquireJobsCmd(jobExecutor)); }
@Test public void useDefaultLevelAudit() throws Exception { ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); // init the db with level=auto -> audit processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); // the history Level has been overwritten with audit assertThat(config.getHistoryLevel(), CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); // and this is written to the database HistoryLevel databaseLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(databaseLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }
private static ProcessEngineImpl createProcessEngineImpl(String databaseSchemaUpdate, boolean executeSchemaOperations) { ProcessEngineImpl processEngine = (ProcessEngineImpl) new CustomStandaloneInMemProcessEngineConfiguration() .setExecuteSchemaOperations(executeSchemaOperations) .setProcessEngineName("database-history-test-engine") .setDatabaseSchemaUpdate(databaseSchemaUpdate) .setHistory(ProcessEngineConfiguration.HISTORY_FULL) .setJdbcUrl("jdbc:h2:mem:DatabaseHistoryPropertyTest") .buildProcessEngine(); return processEngine; }
@Test public void testHistoryCleanupJobScheduled() throws ParseException { final ProcessEngineConfigurationImpl standaloneInMemProcessEngineConfiguration = (ProcessEngineConfigurationImpl)ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration(); standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowStartTime("23:00"); standaloneInMemProcessEngineConfiguration.setHistoryCleanupBatchWindowEndTime("01:00"); standaloneInMemProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:camunda" + getClass().getSimpleName() + "testHistoryCleanupJobScheduled"); ProcessEngine engine = standaloneInMemProcessEngineConfiguration .buildProcessEngine(); final List<Job> historyCleanupJobs = engine.getHistoryService().findHistoryCleanupJobs(); assertFalse(historyCleanupJobs.isEmpty()); final ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration(); for (Job historyCleanupJob : historyCleanupJobs) { assertEquals(processEngineConfiguration.getBatchWindowManager().getCurrentOrNextBatchWindow(ClockUtil.getCurrentTime(), processEngineConfiguration).getStart(), historyCleanupJob.getDuedate()); } closeProcessEngine(engine); }
@Test public void readLevelFullfromDB() throws Exception { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_FULL); // init the db with level=full processEngineImpl = (ProcessEngineImpl) config.buildProcessEngine(); HistoryLevel historyLevel = config.getCommandExecutorSchemaOperations().execute(new DetermineHistoryLevelCmd(config.getHistoryLevels())); assertThat(historyLevel, CoreMatchers.equalTo(HistoryLevel.HISTORY_LEVEL_FULL)); }
protected void setUp() throws Exception { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) ProcessEngineConfiguration .createProcessEngineConfigurationFromResource("org/camunda/bpm/engine/test/standalone/jpa/camunda.cfg.xml"); processEngineConfiguration.setJavaSerializationFormatEnabled(true); cachedProcessEngine = processEngineConfiguration.buildProcessEngine(); EntityManagerSessionFactory entityManagerSessionFactory = (EntityManagerSessionFactory) processEngineConfiguration .getSessionFactories() .get(EntityManagerSession.class); entityManagerFactory = entityManagerSessionFactory.getEntityManagerFactory(); }
public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory); xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD); xmlBeanDefinitionReader.loadBeanDefinitions(springResource); ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName); if (processEngineConfiguration.getBeans() == null) { processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory)); } return processEngineConfiguration; }
protected static ExpressionManager getExpressionManager() { return Context.getProcessEngineConfiguration().getExpressionManager(); }
private void hintJobExecutorIfNeeded(JobEntity jobEntity, Date duedate) { // Check if this timer fires before the next time the job executor will check for new timers to fire. // This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds) // and timers are usually set further in the future JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor(); int waitTimeInMillis = jobExecutor.getWaitTimeInMillis(); if (duedate.getTime() < (ClockUtil.getCurrentTime().getTime() + waitTimeInMillis)) { hintJobExecutor(jobEntity); } }
public static ProcessApplicationReference getTargetProcessApplication(String deploymentId) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager(); ProcessApplicationReference processApplicationForDeployment = processApplicationManager.getProcessApplicationForDeployment(deploymentId); return processApplicationForDeployment; }
public void testGetTableNameAsCamundaAdmin() { // given identityService.setAuthentication(userId, Collections.singletonList(Groups.CAMUNDA_ADMIN)); String tablePrefix = processEngineConfiguration.getDatabaseTablePrefix(); // when String tableName = managementService.getTableName(ProcessDefinitionEntity.class); // then assertEquals(tablePrefix + "ACT_RE_PROCDEF", tableName); }
@Test public void testHistoryConfigurationWhenBatchNotDefined() { ProcessEngineConfigurationImpl processEngineConfigurationImplMock = mock(ProcessEngineConfigurationImpl.class); when(processEngine.getProcessEngineConfiguration()).thenReturn(processEngineConfigurationImplMock); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowStartTime()).thenReturn(null); when(processEngineConfigurationImplMock.getHistoryCleanupBatchWindowEndTime()).thenReturn(null); when(processEngineConfigurationImplMock.getBatchWindowManager()).thenReturn(new DefaultBatchWindowManager()); given() .contentType(ContentType.JSON) .then().expect() .statusCode(Status.OK.getStatusCode()) .body("batchWindowStartTime", equalTo(null)) .body("batchWindowEndTime", equalTo(null)) .when() .get(CONFIGURATION_URL); }
protected boolean isHistoryEventProduced(HistoryEventType eventType, ExternalTask externalTask) { ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration(); HistoryLevel historyLevel = configuration.getHistoryLevel(); return historyLevel.isHistoryEventProduced(eventType, externalTask); }
@Test public void usesDefaultValueAuditWhenNoValueIsConfigured() { final ProcessEngineConfigurationImpl config = config("true", ProcessEngineConfiguration.HISTORY_AUTO); ProcessEngineImpl processEngine = buildEngine(config); final Integer level = config.getCommandExecutorSchemaOperations().execute(new Command<Integer>() { @Override public Integer execute(CommandContext commandContext) { return HistoryLevelSetupCommand.databaseHistoryLevel(commandContext); } }); assertThat(level, equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT.getId())); assertThat(processEngine.getProcessEngineConfiguration().getHistoryLevel(), equalTo(HistoryLevel.HISTORY_LEVEL_AUDIT)); }