Search in sources :

Example 1 with AccountEventsStreams

use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.

the class TestEntitlementUtils method computeFutureBlockingStatesForAssociatedAddonsViaAccount.

private Collection<BlockingState> computeFutureBlockingStatesForAssociatedAddonsViaAccount(final DefaultEntitlement baseEntitlement) throws EntitlementApiException {
    final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(internalCallContext);
    final EventsStream eventsStream = Iterables.<EventsStream>find(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()), new Predicate<EventsStream>() {

        @Override
        public boolean apply(final EventsStream input) {
            return input.getSubscriptionBase().getId().equals(baseEntitlement.getId());
        }
    });
    return eventsStream.computeAddonsBlockingStatesForFutureSubscriptionBaseEvents();
}
Also used : EventsStream(org.killbill.billing.entitlement.EventsStream) AccountEventsStreams(org.killbill.billing.entitlement.AccountEventsStreams)

Example 2 with AccountEventsStreams

use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.

the class DefaultEntitlementApiBase method getAllEntitlementsForAccount.

public AccountEntitlements getAllEntitlementsForAccount(final InternalTenantContext tenantContext) throws EntitlementApiException {
    final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(tenantContext);
    final Map<UUID, Collection<Entitlement>> entitlementsPerBundle = new HashMap<UUID, Collection<Entitlement>>();
    for (final UUID bundleId : accountEventsStreams.getEventsStreams().keySet()) {
        if (entitlementsPerBundle.get(bundleId) == null) {
            entitlementsPerBundle.put(bundleId, new LinkedList<Entitlement>());
        }
        for (final EventsStream eventsStream : accountEventsStreams.getEventsStreams().get(bundleId)) {
            final Entitlement entitlement = new DefaultEntitlement(eventsStream, eventsStreamBuilder, entitlementApi, pluginExecution, blockingStateDao, subscriptionInternalApi, checker, notificationQueueService, entitlementUtils, dateHelper, clock, securityApi, tenantContext, internalCallContextFactory);
            entitlementsPerBundle.get(bundleId).add(entitlement);
        }
    }
    return new DefaultAccountEntitlements(accountEventsStreams, entitlementsPerBundle);
}
Also used : HashMap(java.util.HashMap) EventsStream(org.killbill.billing.entitlement.EventsStream) DefaultEntitlement(org.killbill.billing.entitlement.api.DefaultEntitlement) Collection(java.util.Collection) AccountEventsStreams(org.killbill.billing.entitlement.AccountEventsStreams) UUID(java.util.UUID) DefaultEntitlement(org.killbill.billing.entitlement.api.DefaultEntitlement) Entitlement(org.killbill.billing.entitlement.api.Entitlement)

Example 3 with AccountEventsStreams

use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.

the class DefaultEntitlementApi method getAllEntitlementsForAccountId.

@Override
public List<Entitlement> getAllEntitlementsForAccountId(final UUID accountId, final TenantContext tenantContext) throws EntitlementApiException {
    final EntitlementApi entitlementApi = this;
    final InternalTenantContext context = internalCallContextFactory.createInternalTenantContext(accountId, tenantContext);
    final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(context);
    final List<EventsStream> eventsStreams = ImmutableList.<EventsStream>copyOf(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()));
    return Lists.<EventsStream, Entitlement>transform(eventsStreams, new Function<EventsStream, Entitlement>() {

        @Override
        public Entitlement apply(final EventsStream eventsStream) {
            return new DefaultEntitlement(eventsStream, eventsStreamBuilder, entitlementApi, pluginExecution, blockingStateDao, subscriptionBaseInternalApi, checker, notificationQueueService, entitlementUtils, dateHelper, clock, securityApi, context, internalCallContextFactory);
        }
    });
}
Also used : EventsStream(org.killbill.billing.entitlement.EventsStream) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) AccountEventsStreams(org.killbill.billing.entitlement.AccountEventsStreams) EntitlementLoggingHelper.logPauseResumeEntitlement(org.killbill.billing.entitlement.logging.EntitlementLoggingHelper.logPauseResumeEntitlement) EntitlementLoggingHelper.logTransferEntitlement(org.killbill.billing.entitlement.logging.EntitlementLoggingHelper.logTransferEntitlement)

Example 4 with AccountEventsStreams

use of org.killbill.billing.entitlement.AccountEventsStreams in project killbill by killbill.

the class TestEntitlementUtils method computeBlockingStatesForAssociatedAddonsViaAccount.

private Collection<BlockingState> computeBlockingStatesForAssociatedAddonsViaAccount(final DefaultEntitlement baseEntitlement, final DateTime effectiveDate) throws EntitlementApiException {
    final AccountEventsStreams accountEventsStreams = eventsStreamBuilder.buildForAccount(internalCallContext);
    final EventsStream eventsStream = Iterables.<EventsStream>find(Iterables.<EventsStream>concat(accountEventsStreams.getEventsStreams().values()), new Predicate<EventsStream>() {

        @Override
        public boolean apply(final EventsStream input) {
            return input.getSubscriptionBase().getId().equals(baseEntitlement.getId());
        }
    });
    return eventsStream.computeAddonsBlockingStatesForNextSubscriptionBaseEvent(effectiveDate);
}
Also used : EventsStream(org.killbill.billing.entitlement.EventsStream) AccountEventsStreams(org.killbill.billing.entitlement.AccountEventsStreams)

Aggregations

AccountEventsStreams (org.killbill.billing.entitlement.AccountEventsStreams)4 EventsStream (org.killbill.billing.entitlement.EventsStream)4 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)1 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)1 Entitlement (org.killbill.billing.entitlement.api.Entitlement)1 EntitlementLoggingHelper.logPauseResumeEntitlement (org.killbill.billing.entitlement.logging.EntitlementLoggingHelper.logPauseResumeEntitlement)1 EntitlementLoggingHelper.logTransferEntitlement (org.killbill.billing.entitlement.logging.EntitlementLoggingHelper.logTransferEntitlement)1