Java Code Examples for org.flowable.common.engine.impl.interceptor.CommandContext#getSession()

The following examples show how to use org.flowable.common.engine.impl.interceptor.CommandContext#getSession() . 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: TaskQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addCachedVariableForQueryById(CommandContext commandContext, List<Task> results, boolean local) {
    for (Task task : results) {
        if (Objects.equals(taskId, task.getId())) {

            EntityCache entityCache = commandContext.getSession(EntityCache.class);
            List<VariableInstanceEntity> cachedVariableEntities = entityCache.findInCache(VariableInstanceEntity.class);
            for (VariableInstanceEntity cachedVariableEntity : cachedVariableEntities) {

                if (local) {
                    if (task.getId().equals(cachedVariableEntity.getTaskId())) {
                        ((TaskEntity) task).getQueryVariables().add(cachedVariableEntity);
                    }
                } else {
                    if (task.getProcessInstanceId().equals(cachedVariableEntity.getProcessInstanceId())) {
                        ((TaskEntity) task).getQueryVariables().add(cachedVariableEntity);
                    }
                }
            }

        }
    }
}
 
Example 2
Source File: HistoricTaskInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addCachedVariableForQueryById(CommandContext commandContext, List<HistoricTaskInstance> results, boolean local) {
    for (HistoricTaskInstance task : results) {
        if (Objects.equals(taskId, task.getId())) {

            EntityCache entityCache = commandContext.getSession(EntityCache.class);
            List<HistoricVariableInstanceEntity> cachedVariableEntities = entityCache.findInCache(HistoricVariableInstanceEntity.class);
            for (HistoricVariableInstanceEntity cachedVariableEntity : cachedVariableEntities) {

                if (local) {
                    if (task.getId().equals(cachedVariableEntity.getTaskId())) {
                        ((HistoricTaskInstanceEntity) task).getQueryVariables().add(cachedVariableEntity);
                    }
                } else {
                    if (task.getProcessInstanceId().equals(cachedVariableEntity.getProcessInstanceId())) {
                        ((HistoricTaskInstanceEntity) task).getQueryVariables().add(cachedVariableEntity);
                    }
                }
            }

        }
    }
}
 
Example 3
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void addCachedVariableForQueryById(CommandContext commandContext, List<HistoricProcessInstance> results) {

        // Unlike the ExecutionEntityImpl, variables are not stored on the HistoricExecutionEntityImpl.
        // The solution for the non-historical entity is to use the variable cache on the entity, inspect the variables
        // of the current transaction and add them if necessary.
        // For the historical entity, we need to detect this use case specifically (i.e. byId is used) and check the entityCache.

        for (HistoricProcessInstance historicProcessInstance : results) {
            if (Objects.equals(processInstanceId, historicProcessInstance.getId())) {

                EntityCache entityCache = commandContext.getSession(EntityCache.class);
                List<HistoricVariableInstanceEntity> cachedVariableEntities = entityCache.findInCache(HistoricVariableInstanceEntity.class);
                for (HistoricVariableInstanceEntity cachedVariableEntity : cachedVariableEntities) {

                    if (historicProcessInstance.getId().equals(cachedVariableEntity.getProcessInstanceId())) {

                        // Variables from the cache have precedence
                        ((HistoricProcessInstanceEntity) historicProcessInstance).getQueryVariables().add(cachedVariableEntity);

                    }

                }

            }
        }
    }
 
Example 4
Source File: DefaultJobManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void createAsyncHistoryHintListeners(HistoryJobEntity historyJobEntity) {
    CommandContext commandContext = CommandContextUtil.getCommandContext();
    AsyncHistorySession asyncHistorySession = commandContext.getSession(AsyncHistorySession.class);
    if (asyncHistorySession != null) {
        TransactionContext transactionContext = asyncHistorySession.getTransactionContext();
        if (transactionContext != null) {
            transactionContext.addTransactionListener(TransactionState.COMMITTED, new TriggerAsyncHistoryExecutorTransactionListener(commandContext, historyJobEntity)); 
        }
    }
}
 
Example 5
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static EntityCache getEntityCache(CommandContext commandContext) {
    return commandContext.getSession(EntityCache.class);
}
 
Example 6
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 7
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 8
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static EntityCache getEntityCache(CommandContext commandContext) {
    return commandContext.getSession(EntityCache.class);
}
 
Example 9
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 10
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static FlowableEngineAgenda getAgenda(CommandContext commandContext) {
    return commandContext.getSession(FlowableEngineAgenda.class);
}
 
Example 11
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 12
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 13
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 14
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static EntityCache getEntityCache(CommandContext commandContext) {
    return commandContext.getSession(EntityCache.class);
}
 
Example 15
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 16
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 17
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 18
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 19
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DbSqlSession getDbSqlSession(CommandContext commandContext) {
    return commandContext.getSession(DbSqlSession.class);
}
 
Example 20
Source File: CommandContextUtil.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public static DmnEngineAgenda getAgenda(CommandContext commandContext) {
    return commandContext.getSession(DmnEngineAgenda.class);
}