use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class ModelEntityManager method updateModel.
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(ActivitiEventType.ENTITY_UPDATED, updatedModel));
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class UserEntityManager method updateUser.
public void updateUser(User updatedUser) {
CommandContext commandContext = Context.getCommandContext();
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.update((PersistentObject) updatedUser);
if (getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, updatedUser));
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class TimerEventCompatibilityTest method changeConfigurationToPlainText.
protected void changeConfigurationToPlainText(JobEntity job) {
String activityId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
final JobEntity finalJob = job;
CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor();
CommandConfig config = new CommandConfig().transactionNotSupported();
final String finalActivityId = activityId;
commandExecutor.execute(config, new Command<Object>() {
public Object execute(CommandContext commandContext) {
DbSqlSession session = commandContext.getSession(DbSqlSession.class);
session.delete(finalJob);
session.flush();
session.commit();
return null;
}
});
commandExecutor.execute(config, new Command<Object>() {
public Object execute(CommandContext commandContext) {
DbSqlSession session = commandContext.getSession(DbSqlSession.class);
finalJob.setJobHandlerConfiguration(finalActivityId);
finalJob.setId(null);
session.insert(finalJob);
session.flush();
session.commit();
return null;
}
});
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class AbstractActivitiTestCase 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() 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 {
fail(outputMessage.toString());
}
} else {
log.info("database was clean");
}
}
use of org.activiti.engine.impl.db.DbSqlSession in project Activiti by Activiti.
the class AbstractDataManager method getListFromCache.
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;
}
Aggregations