use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class AbstractMuleTest method assertAndEnsureCleanDb.
/** 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");
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class HistoricDetailEntity method delete.
public void delete() {
DbSqlSession dbSqlSession = Context.getCommandContext().getDbSqlSession();
dbSqlSession.delete(this);
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class ProcessDefinitionInfoEntityManager method updateProcessDefinitionInfo.
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(ActivitiEventType.ENTITY_UPDATED, updatedProcessDefinitionInfo));
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class TaskEntity method update.
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(ActivitiEventType.ENTITY_UPDATED, this));
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class TaskEntity method insert.
public void insert(ExecutionEntity execution) {
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()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, this));
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, this));
}
}
Aggregations