use of org.killbill.billing.usage.DryRunTenantContext in project killbill by killbill.
the class DefaultInternalUserApi method getRawUsageForAccount.
@Override
public List<RawUsageRecord> getRawUsageForAccount(final LocalDate startDate, final LocalDate endDate, @Nullable final DryRunInfo dryRunInfo, final InternalTenantContext internalTenantContext) {
log.info("GetRawUsageForAccount startDate='{}', endDate='{}'", startDate, endDate);
final TenantContext tenantContext = internalCallContextFactory.createTenantContext(internalTenantContext);
final TenantContext tenantContextWithHint = dryRunInfo != null ? new DryRunTenantContext(dryRunInfo, tenantContext) : tenantContext;
final List<RawUsageRecord> resultFromPlugin = getAccountUsageFromPlugin(startDate, endDate, tenantContextWithHint);
if (resultFromPlugin != null) {
return resultFromPlugin;
}
final List<RolledUpUsageModelDao> usage = rolledUpUsageDao.getRawUsageForAccount(startDate, endDate, internalTenantContext);
return ImmutableList.copyOf(Iterables.transform(usage, new Function<RolledUpUsageModelDao, RawUsageRecord>() {
@Override
public RawUsageRecord apply(final RolledUpUsageModelDao input) {
return new DefaultRawUsage(input.getSubscriptionId(), input.getRecordDate(), input.getUnitType(), input.getAmount(), input.getTrackingId());
}
}));
}
Aggregations