use of org.killbill.billing.entitlement.api.DefaultBlockingTransitionInternalEvent in project killbill by killbill.
the class DefaultBlockingStateDao method recordBusOrFutureNotificationFromTransaction.
private void recordBusOrFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final UUID blockingStateId, final DateTime effectiveDate, final UUID blockableId, final BlockingStateType type, final String stateName, final String serviceName, final boolean blockingStateInserted, final BlockingAggregator previousState, final BlockingAggregator currentState, final InternalCallContext context) {
final boolean isTransitionToBlockedBilling = !previousState.isBlockBilling() && currentState.isBlockBilling();
final boolean isTransitionToUnblockedBilling = previousState.isBlockBilling() && !currentState.isBlockBilling();
final boolean isTransitionToBlockedEntitlement = !previousState.isBlockEntitlement() && currentState.isBlockEntitlement();
final boolean isTransitionToUnblockedEntitlement = previousState.isBlockEntitlement() && !currentState.isBlockEntitlement();
if (effectiveDate.compareTo(clock.getUTCNow()) > 0) {
// Add notification entry to send the bus event at the effective date
final NotificationEvent notificationEvent = new BlockingTransitionNotificationKey(blockingStateId, blockableId, stateName, serviceName, effectiveDate, type, isTransitionToBlockedBilling, isTransitionToUnblockedBilling, isTransitionToBlockedEntitlement, isTransitionToUnblockedEntitlement);
recordFutureNotificationFromTransaction(entitySqlDaoWrapperFactory, effectiveDate, notificationEvent, context);
} else {
if (blockingStateInserted) {
final BusEvent event = new DefaultBlockingTransitionInternalEvent(blockableId, stateName, serviceName, effectiveDate, type, isTransitionToBlockedBilling, isTransitionToUnblockedBilling, isTransitionToBlockedEntitlement, isTransitionToUnblockedEntitlement, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken());
notifyBusFromTransaction(entitySqlDaoWrapperFactory, event);
} else {
log.debug("Skipping event for service {} and blockableId {} (previousState={}, currentState={})", serviceName, blockableId, previousState, currentState);
}
}
}
Aggregations