org.activiti.engine.impl.db.DbSqlSession Java Examples
The following examples show how to use
org.activiti.engine.impl.db.DbSqlSession.
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: TaskEntity.java From flowable-engine with Apache License 2.0 | 6 votes |
public void update() { // Needed to make history work: the setter will also update the historic task setOwner(this.getOwner()); setAssignee(this.getAssignee(), true, false); setDelegationState(this.getDelegationState()); setName(this.getName()); setDescription(this.getDescription()); setPriority(this.getPriority()); setCategory(this.getCategory()); setCreateTime(this.getCreateTime()); setDueDate(this.getDueDate()); setParentTaskId(this.getParentTaskId()); setFormKey(formKey); CommandContext commandContext = Context.getCommandContext(); DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.update(this); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, this)); } }
Example #2
Source File: TaskEntity.java From flowable-engine with Apache License 2.0 | 6 votes |
public void insert(ExecutionEntity execution, boolean fireEvents) { CommandContext commandContext = Context.getCommandContext(); DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.insert(this); // Inherit tenant id (if applicable) if (execution != null && execution.getTenantId() != null) { setTenantId(execution.getTenantId()); } if (execution != null) { execution.addTask(this); } commandContext.getHistoryManager().recordTaskCreated(this, execution); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled() && fireEvents) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, this)); commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, this)); } }
Example #3
Source File: MetaDataTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testMetaData() { ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration(); activiti5ProcessEngineConfig.getCommandExecutor().execute(new Command<Object>() { public Object execute(CommandContext commandContext) { // PRINT THE TABLE NAMES TO CHECK IF WE CAN USE METADATA INSTEAD // THIS IS INTENDED FOR TEST THAT SHOULD RUN ON OUR QA INFRASTRUCTURE TO SEE IF METADATA // CAN BE USED INSTEAD OF PERFORMING A QUERY THAT MIGHT FAIL try { SqlSession sqlSession = commandContext.getSession(DbSqlSession.class).getSqlSession(); ResultSet tables = sqlSession.getConnection().getMetaData().getTables(null, null, null, null); while (tables.next()) { ResultSetMetaData resultSetMetaData = tables.getMetaData(); int columnCount = resultSetMetaData.getColumnCount(); for (int i = 1; i <= columnCount; i++) { LOGGER.info("result set column {}|{}|{}|{}", i, resultSetMetaData.getColumnName(i), resultSetMetaData.getColumnLabel(i), tables.getString(i)); } LOGGER.info("-------------------------------------------------------"); } } catch (Exception e) { e.printStackTrace(); } return null; } }); }
Example #4
Source File: AbstractMuleTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb(ProcessEngine processEngine) throws Exception { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngine.getProcessEngineConfiguration().getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); CommandConfig config = new CommandConfig().transactionNotSupported(); commandExecutor.execute(config, new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); Assert.fail(outputMessage.toString()); } else { log.info("database was clean"); } }
Example #5
Source File: GetAttachmentContentCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public InputStream execute(CommandContext commandContext) { DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); AttachmentEntity attachment = dbSqlSession.selectById(AttachmentEntity.class, attachmentId); String contentId = attachment.getContentId(); if (contentId == null) { return null; } ByteArrayEntity byteArray = dbSqlSession.selectById(ByteArrayEntity.class, contentId); byte[] bytes = byteArray.getBytes(); return new ByteArrayInputStream(bytes); }
Example #6
Source File: DbUpgradeStep52To53InsertPropertyHistoryLevel.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(DbSqlSession dbSqlSession) throws Exception { // As of 5.11, the history-setting is no longer stored in the database, so inserting it in this upgrade and removing // in in a 5.10->5.11 upgrade is useless... // int historyLevel = Context.getProcessEngineConfiguration().getHistoryLevel(); // PropertyEntity property = new PropertyEntity("historyLevel", Integer.toString(historyLevel)); // dbSqlSession.insert(property); }
Example #7
Source File: ProcessDefinitionInfoEntityManager.java From flowable-engine with Apache License 2.0 | 5 votes |
public void updateProcessDefinitionInfo(ProcessDefinitionInfoEntity updatedProcessDefinitionInfo) { CommandContext commandContext = Context.getCommandContext(); DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.update(updatedProcessDefinitionInfo); if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, updatedProcessDefinitionInfo)); } }
Example #8
Source File: HistoricDetailEntity.java From flowable-engine with Apache License 2.0 | 5 votes |
public void delete() { DbSqlSession dbSqlSession = Context .getCommandContext() .getDbSqlSession(); dbSqlSession.delete(this); }
Example #9
Source File: ModelEntityManager.java From flowable-engine with Apache License 2.0 | 5 votes |
public void updateModel(ModelEntity updatedModel) { CommandContext commandContext = Context.getCommandContext(); updatedModel.setLastUpdateTime(Context.getProcessEngineConfiguration().getClock().getCurrentTime()); DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.update(updatedModel); if (Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, updatedModel)); } }
Example #10
Source File: TestHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. * After a test method executed, this method scans all tables to see if the DB is completely clean. * It throws AssertionFailed in case the DB is not clean. * If the DB is not clean, it is cleaned by performing a create a drop. */ public static void assertAndEnsureCleanDb(ProcessEngine processEngine) { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableName)) { Long count = tableCounts.get(tableName); if (count!=0L) { outputMessage.append(" ").append(tableName).append(": ").append(count).append(" record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); ((ProcessEngineImpl)processEngine) .getProcessEngineConfiguration().getCommandExecutor() .execute(new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.dbSchemaDrop(); dbSqlSession.dbSchemaCreate(); return null; } }); throw new AssertionError(outputMessage.toString()); } }
Example #11
Source File: BaseSpringRestTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb() throws Throwable { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = managementService.getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngineConfiguration.getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); commandExecutor.execute(new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); if (exception != null) { throw exception; } else { Assert.fail(outputMessage.toString()); } } else { log.info("database was clean"); } }
Example #12
Source File: BaseJPARestTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb() throws Throwable { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = managementService.getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngineConfiguration.getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); commandExecutor.execute(new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); if (exception != null) { throw exception; } else { Assert.fail(outputMessage.toString()); } } else { log.info("database was clean"); } }
Example #13
Source File: TestHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ public static void assertAndEnsureCleanDb(ProcessEngine processEngine) { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableName)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" ").append(tableName).append(": ").append(count).append(" record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor().execute(new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.dbSchemaDrop(); dbSqlSession.dbSchemaCreate(); return null; } }); throw new AssertionError(outputMessage.toString()); } }
Example #14
Source File: AbstractMuleTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb(ProcessEngine processEngine) throws Exception { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngine.getProcessEngineConfiguration().getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); CommandConfig config = new CommandConfig().transactionNotSupported(); commandExecutor.execute(config, new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getSession(DbSqlSession.class); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); Assert.fail(outputMessage.toString()); } else { log.info("database was clean"); } }
Example #15
Source File: DbUpgradeStep52To53InsertPropertyHistoryLevel.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void execute(DbSqlSession dbSqlSession) throws Exception { // As of 5.11, the history-setting is no longer stored in the database, // so inserting it in this upgrade and removing // in in a 5.10->5.11 upgrade is useless... // int historyLevel = // Context.getProcessEngineConfiguration().getHistoryLevel(); // PropertyEntity property = new PropertyEntity("historyLevel", // Integer.toString(historyLevel)); // dbSqlSession.insert(property); }
Example #16
Source File: SchemaOperationsProcessEngineBuild.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public Object execute(CommandContext commandContext) { DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); if (dbSqlSession != null) { dbSqlSession.performSchemaOperationsProcessEngineBuild(); } return null; }
Example #17
Source File: ManagementServiceImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public String databaseSchemaUpgrade(final Connection connection, final String catalog, final String schema) { CommandConfig config = commandExecutor.getDefaultConfig().transactionNotSupported(); return commandExecutor.execute(config, new Command<String>() { public String execute(CommandContext commandContext) { DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSession.class); DbSqlSession dbSqlSession = new DbSqlSession(dbSqlSessionFactory, commandContext.getEntityCache(), connection, catalog, schema); commandContext.getSessions().put(DbSqlSession.class, dbSqlSession); return dbSqlSession.dbSchemaUpdate(); } }); }
Example #18
Source File: AbstractDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected List<EntityImpl> getListFromCache(CachedEntityMatcher<EntityImpl> entityMatcher, Object parameter) { Collection<CachedEntity> cachedObjects = getEntityCache().findInCacheAsCachedObjects(getManagedEntityClass()); DbSqlSession dbSqlSession = getDbSqlSession(); List<EntityImpl> result = new ArrayList<EntityImpl>(cachedObjects.size()); if (cachedObjects != null && entityMatcher != null) { for (CachedEntity cachedObject : cachedObjects) { EntityImpl cachedEntity = (EntityImpl) cachedObject.getEntity(); if (entityMatcher.isRetained(null, cachedObjects, cachedEntity, parameter) && !dbSqlSession.isEntityToBeDeleted(cachedEntity)) { result.add(cachedEntity); } } } if (getManagedEntitySubClasses() != null && entityMatcher != null) { for (Class<? extends EntityImpl> entitySubClass : getManagedEntitySubClasses()) { Collection<CachedEntity> subclassCachedObjects = getEntityCache().findInCacheAsCachedObjects(entitySubClass); if (subclassCachedObjects != null) { for (CachedEntity subclassCachedObject : subclassCachedObjects) { EntityImpl cachedSubclassEntity = (EntityImpl) subclassCachedObject.getEntity(); if (entityMatcher.isRetained(null, cachedObjects, cachedSubclassEntity, parameter) && !dbSqlSession.isEntityToBeDeleted(cachedSubclassEntity)) { result.add(cachedSubclassEntity); } } } } } return result; }
Example #19
Source File: CreateAttachmentCmd.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public Attachment execute(CommandContext commandContext) { verifyParameters(commandContext); AttachmentEntity attachment = new AttachmentEntity(); attachment.setName(attachmentName); attachment.setDescription(attachmentDescription); attachment.setType(attachmentType); attachment.setTaskId(taskId); attachment.setProcessInstanceId(processInstanceId); attachment.setUrl(url); attachment.setUserId(Authentication.getAuthenticatedUserId()); attachment.setTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime()); DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); dbSqlSession.insert(attachment); if (content != null) { byte[] bytes = IoUtil.readInputStream(content, attachmentName); ByteArrayEntity byteArray = ByteArrayEntity.createAndInsert(bytes); attachment.setContentId(byteArray.getId()); attachment.setContent(byteArray); } commandContext.getHistoryManager() .createAttachmentComment(taskId, processInstanceId, attachmentName, true); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right process definition String processDefinitionId = null; if (attachment.getProcessInstanceId() != null) { ExecutionEntity process = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, attachment, processInstanceId, processInstanceId, processDefinitionId)); commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, attachment, processInstanceId, processInstanceId, processDefinitionId)); } return attachment; }
Example #20
Source File: StandaloneMybatisTransactionContext.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected DbSqlSession getDbSqlSession() { return commandContext.getDbSqlSession(); }
Example #21
Source File: AbstractManager.java From flowable-engine with Apache License 2.0 | 4 votes |
protected DbSqlSession getDbSqlSession() { return getSession(DbSqlSession.class); }
Example #22
Source File: CommandContext.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public DbSqlSession getDbSqlSession() { return getSession(DbSqlSession.class); }
Example #23
Source File: TableDataManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected DbSqlSession getDbSqlSession() { return getSession(DbSqlSession.class); }
Example #24
Source File: TableDataManagerImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Override public List<String> getTablesPresentInDatabase() { List<String> tableNames = new ArrayList<String>(); Connection connection = null; try { connection = getDbSqlSession().getSqlSession().getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet tables = null; try { log.debug("retrieving activiti tables from jdbc metadata"); String databaseTablePrefix = getDbSqlSession().getDbSqlSessionFactory().getDatabaseTablePrefix(); String tableNameFilter = databaseTablePrefix + "ACT_%"; if ("postgres".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { tableNameFilter = databaseTablePrefix + "act_%"; } if ("oracle".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { tableNameFilter = databaseTablePrefix + "ACT" + databaseMetaData.getSearchStringEscape() + "_%"; } String catalog = null; if (getProcessEngineConfiguration().getDatabaseCatalog() != null && getProcessEngineConfiguration().getDatabaseCatalog().length() > 0) { catalog = getProcessEngineConfiguration().getDatabaseCatalog(); } String schema = null; if (getProcessEngineConfiguration().getDatabaseSchema() != null && getProcessEngineConfiguration().getDatabaseSchema().length() > 0) { if ("oracle".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { schema = getProcessEngineConfiguration().getDatabaseSchema().toUpperCase(); } else { schema = getProcessEngineConfiguration().getDatabaseSchema(); } } tables = databaseMetaData.getTables(catalog, schema, tableNameFilter, DbSqlSession.JDBC_METADATA_TABLE_TYPES); while (tables.next()) { String tableName = tables.getString("TABLE_NAME"); tableName = tableName.toUpperCase(); tableNames.add(tableName); log.debug(" retrieved activiti table name {}", tableName); } } finally { tables.close(); } } catch (Exception e) { throw new ActivitiException("couldn't get activiti table names using metadata: " + e.getMessage(), e); } return tableNames; }
Example #25
Source File: AbstractDataManager.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected DbSqlSession getDbSqlSession() { return getSession(DbSqlSession.class); }
Example #26
Source File: CommandContext.java From flowable-engine with Apache License 2.0 | 4 votes |
public DbSqlSession getDbSqlSession() { return getSession(DbSqlSession.class); }
Example #27
Source File: StandaloneMybatisTransactionContext.java From flowable-engine with Apache License 2.0 | 4 votes |
protected DbSqlSession getDbSqlSession() { return commandContext.getSession(DbSqlSession.class); }
Example #28
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** Each test is assumed to clean up all DB content it entered. * After a test method executed, this method scans all tables to see if the DB is completely clean. * It throws AssertionFailed in case the DB is not clean. * If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb() throws Throwable { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = managementService.getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngineConfiguration.getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count!=0L) { outputMessage.append(" ").append(tableName).append(": ").append(count).append(" record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getCommandExecutor(); CommandConfig config = new CommandConfig().transactionNotSupported(); commandExecutor.execute(config, new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); if (exception!=null) { throw exception; } else { Assert.fail(outputMessage.toString()); } } else { log.info("database was clean"); } }
Example #29
Source File: AbstractActivitiTestCase.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb() throws Throwable { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = managementService.getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngineConfiguration.getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" ").append(tableName).append(": ").append(count).append(" record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); CommandConfig config = new CommandConfig().transactionNotSupported(); commandExecutor.execute(config, new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); if (exception != null) { throw exception; } else { Assert.fail(outputMessage.toString()); } } else { log.info("database was clean"); } }
Example #30
Source File: DbUpgradeStep.java From flowable-engine with Apache License 2.0 | votes |
void execute(DbSqlSession dbSqlSession) throws Exception;