/** * Set bit to '1' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '1' (right first bit starting at 1). */ public static int setBitOn(final int value, final int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value | MASKS[bitNumber - 1]; }
public void setCachedEntityState(int cachedEntityState) { this.cachedEntityState = cachedEntityState; // Check for flags that are down. These lists can be safely initialized as // empty, preventing // additional queries that end up in an empty list anyway if (jobs == null && !BitMaskUtil.isBitOn(cachedEntityState, JOBS_STATE_BIT)) { jobs = new ArrayList<>(); } if (tasks == null && !BitMaskUtil.isBitOn(cachedEntityState, TASKS_STATE_BIT)) { tasks = new ArrayList<>(); } if (eventSubscriptions == null && !BitMaskUtil.isBitOn(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT)) { eventSubscriptions = new ArrayList<>(); } if (incidents == null && !BitMaskUtil.isBitOn(cachedEntityState, INCIDENT_STATE_BIT)) { incidents = new ArrayList<>(); } if (!variableStore.isInitialized() && !BitMaskUtil.isBitOn(cachedEntityState, VARIABLES_STATE_BIT)) { variableStore.setVariablesProvider(VariableCollectionProvider.<VariableInstanceEntity>emptyVariables()); variableStore.forceInitialization(); } if (externalTasks == null && !BitMaskUtil.isBitOn(cachedEntityState, EXTERNAL_TASKS_BIT)) { externalTasks = new ArrayList<>(); } shouldQueryForSubprocessInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT); shouldQueryForSubCaseInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT); }
public int getCachedEntityState() { cachedEntityState = 0; // Only mark a flag as false when the list is not-null and empty. If null, // we can't be sure there are no entries in it since // the list hasn't been initialized/queried yet. cachedEntityState = BitMaskUtil.setBit(cachedEntityState, TASKS_STATE_BIT, (tasks == null || tasks.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT, (eventSubscriptions == null || eventSubscriptions.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, JOBS_STATE_BIT, (jobs == null || jobs.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, INCIDENT_STATE_BIT, (incidents == null || incidents.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, VARIABLES_STATE_BIT, (!variableStore.isInitialized() || !variableStore.isEmpty())); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT, shouldQueryForSubprocessInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT, shouldQueryForSubCaseInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EXTERNAL_TASKS_BIT, (externalTasks == null || externalTasks.size() > 0)); return cachedEntityState; }
/** * Set bit to '0' or '1' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '0' or '1' (right first bit starting at 1). * @param bitValue if true, bit set to '1'. If false, '0'. */ public static int setBit(int value, int bitNumber, boolean bitValue) { if(bitValue) { return setBitOn(value, bitNumber); } else { return setBitOff(value, bitNumber); } }
@Deployment public void testExecutionTasksMi() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(0, processInstance.getCachedEntityStateRaw()); List<Execution> executions = runtimeService.createExecutionQuery().activityId("userTask").list(); for (Execution execution : executions) { int cachedEntityStateRaw = ((ExecutionEntity) execution).getCachedEntityStateRaw(); if(!((ExecutionEntity)execution).isScope()) { assertEquals( BitMaskUtil.getMaskForBit(ExecutionEntity.TASKS_STATE_BIT) | BitMaskUtil.getMaskForBit(ExecutionEntity.VARIABLES_STATE_BIT) , cachedEntityStateRaw); } else { assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.VARIABLES_STATE_BIT), cachedEntityStateRaw); } } }
/** * Set bit to '0' or '1' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '0' or '1' (right first bit starting at 1). * @param bitValue if true, bit set to '1'. If false, '0'. */ public static int setBit(int value, int bitNumber, boolean bitValue) { if(bitValue) { return setBitOn(value, bitNumber); } else { return setBitOff(value, bitNumber); } }
@Deployment public void testProcessInstanceEventSubscriptions() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.EVENT_SUBSCRIPTIONS_STATE_BIT), processInstance.getCachedEntityStateRaw()); }
/** * Set bit to '0' or '1' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '0' or '1' (right first bit starting at 1). * @param bitValue if true, bit set to '1'. If false, '0'. */ public static int setBit(int value, int bitNumber, boolean bitValue) { if(bitValue) { return setBitOn(value, bitNumber); } else { return setBitOff(value, bitNumber); } }
/** * Set bit to '1' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '1' (right first bit starting at 1). */ public static int setBitOn(final int value, final int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value | MASKS[bitNumber - 1]; }
@Deployment public void testProcessInstanceTasks() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.TASKS_STATE_BIT), processInstance.getCachedEntityStateRaw()); }
public int getCachedEntityState() { cachedEntityState = 0; // Only mark a flag as false when the list is not-null and empty. If null, // we can't be sure there are no entries in it since // the list hasn't been initialized/queried yet. cachedEntityState = BitMaskUtil.setBit(cachedEntityState, TASKS_STATE_BIT, (tasks == null || tasks.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT, (eventSubscriptions == null || eventSubscriptions.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, JOBS_STATE_BIT, (jobs == null || jobs.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, INCIDENT_STATE_BIT, (incidents == null || incidents.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, VARIABLES_STATE_BIT, (!variableStore.isInitialized() || !variableStore.isEmpty())); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT, shouldQueryForSubprocessInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT, shouldQueryForSubCaseInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EXTERNAL_TASKS_BIT, (externalTasks == null || externalTasks.size() > 0)); return cachedEntityState; }
public void setCachedEntityState(int cachedEntityState) { this.cachedEntityState = cachedEntityState; // Check for flags that are down. These lists can be safely initialized as // empty, preventing // additional queries that end up in an empty list anyway if (jobs == null && !BitMaskUtil.isBitOn(cachedEntityState, JOBS_STATE_BIT)) { jobs = new ArrayList<>(); } if (tasks == null && !BitMaskUtil.isBitOn(cachedEntityState, TASKS_STATE_BIT)) { tasks = new ArrayList<>(); } if (eventSubscriptions == null && !BitMaskUtil.isBitOn(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT)) { eventSubscriptions = new ArrayList<>(); } if (incidents == null && !BitMaskUtil.isBitOn(cachedEntityState, INCIDENT_STATE_BIT)) { incidents = new ArrayList<>(); } if (!variableStore.isInitialized() && !BitMaskUtil.isBitOn(cachedEntityState, VARIABLES_STATE_BIT)) { variableStore.setVariablesProvider(VariableCollectionProvider.<VariableInstanceEntity>emptyVariables()); variableStore.forceInitialization(); } if (externalTasks == null && !BitMaskUtil.isBitOn(cachedEntityState, EXTERNAL_TASKS_BIT)) { externalTasks = new ArrayList<>(); } shouldQueryForSubprocessInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT); shouldQueryForSubCaseInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT); }
/** * Check if the bit is set to '1' * @param value integer to check bit * @param number of bit to check (right first bit starting at 1) */ public static boolean isBitOn(int value, int bitNumber) { ensureBitRange(bitNumber); return ((value & MASKS[bitNumber - 1]) == MASKS[bitNumber - 1]); }
@Deployment public void testProcessInstanceJobs() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.JOBS_STATE_BIT), processInstance.getCachedEntityStateRaw()); }
public int getCachedEntityState() { cachedEntityState = 0; // Only mark a flag as false when the list is not-null and empty. If null, // we can't be sure there are no entries in it since // the list hasn't been initialized/queried yet. cachedEntityState = BitMaskUtil.setBit(cachedEntityState, TASKS_STATE_BIT, (tasks == null || tasks.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT, (eventSubscriptions == null || eventSubscriptions.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, JOBS_STATE_BIT, (jobs == null || jobs.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, INCIDENT_STATE_BIT, (incidents == null || incidents.size() > 0)); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, VARIABLES_STATE_BIT, (!variableStore.isInitialized() || !variableStore.isEmpty())); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT, shouldQueryForSubprocessInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT, shouldQueryForSubCaseInstance); cachedEntityState = BitMaskUtil.setBit(cachedEntityState, EXTERNAL_TASKS_BIT, (externalTasks == null || externalTasks.size() > 0)); return cachedEntityState; }
public void setCachedEntityState(int cachedEntityState) { this.cachedEntityState = cachedEntityState; // Check for flags that are down. These lists can be safely initialized as // empty, preventing // additional queries that end up in an empty list anyway if (jobs == null && !BitMaskUtil.isBitOn(cachedEntityState, JOBS_STATE_BIT)) { jobs = new ArrayList<JobEntity>(); } if (tasks == null && !BitMaskUtil.isBitOn(cachedEntityState, TASKS_STATE_BIT)) { tasks = new ArrayList<TaskEntity>(); } if (eventSubscriptions == null && !BitMaskUtil.isBitOn(cachedEntityState, EVENT_SUBSCRIPTIONS_STATE_BIT)) { eventSubscriptions = new ArrayList<EventSubscriptionEntity>(); } if (incidents == null && !BitMaskUtil.isBitOn(cachedEntityState, INCIDENT_STATE_BIT)) { incidents = new ArrayList<IncidentEntity>(); } if (!variableStore.isInitialized() && !BitMaskUtil.isBitOn(cachedEntityState, VARIABLES_STATE_BIT)) { variableStore.setVariablesProvider(VariableCollectionProvider.<VariableInstanceEntity>emptyVariables()); variableStore.forceInitialization(); } if (externalTasks == null && !BitMaskUtil.isBitOn(cachedEntityState, EXTERNAL_TASKS_BIT)) { externalTasks = new ArrayList<ExternalTaskEntity>(); } shouldQueryForSubprocessInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_PROCESS_INSTANCE_STATE_BIT); shouldQueryForSubCaseInstance = BitMaskUtil.isBitOn(cachedEntityState, SUB_CASE_INSTANCE_STATE_BIT); }
/** * Set bit to '0' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '0' (right first bit starting at 1). */ public static int setBitOff(int value, int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value &~MASKS[bitNumber - 1]; }
@Deployment public void testExecutionExternalTask() { runtimeService.startProcessInstanceByKey("oneExternalTaskProcess"); ExecutionEntity execution = (ExecutionEntity) runtimeService .createExecutionQuery() .activityId("externalTask") .singleResult(); assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.EXTERNAL_TASKS_BIT), execution.getCachedEntityStateRaw()); }
/** * Set bit to '0' in the given int. * @param current integer value * @param bitNumber number of the bit to set to '0' (right first bit starting at 1). */ public static int setBitOff(int value, int bitNumber) { ensureBitRange(bitNumber); // To turn on, OR with the correct mask return value &~MASKS[bitNumber - 1]; }
@Deployment public void testExecutionEventSubscriptionsMi() { runtimeService.startProcessInstanceByKey("testProcess"); ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult(); assertEquals(0, processInstance.getCachedEntityStateRaw()); List<Execution> executions = runtimeService.createExecutionQuery().activityId("ReceiveTask_1").list(); for (Execution execution : executions) { int cachedEntityStateRaw = ((ExecutionEntity) execution).getCachedEntityStateRaw(); if(!((ExecutionEntity)execution).isScope()) { assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.VARIABLES_STATE_BIT), cachedEntityStateRaw); } else { assertEquals( BitMaskUtil.getMaskForBit(ExecutionEntity.EVENT_SUBSCRIPTIONS_STATE_BIT), cachedEntityStateRaw); } } }