use of org.killbill.billing.catalog.dao.CatalogOverrideUsageDefinitionModelDao in project killbill by killbill.
the class DefaultOverriddenPlanCache method getUsagePriceOverrides.
List<UsagePriceOverride> getUsagePriceOverrides(PlanPhase curPhase, CatalogOverridePhaseDefinitionModelDao overriddenPhase, final InternalTenantContext context) {
final List<UsagePriceOverride> usagePriceOverrides = new ArrayList<UsagePriceOverride>();
final List<CatalogOverrideUsageDefinitionModelDao> usageDefs = overrideDao.getOverriddenPhaseUsages(overriddenPhase.getRecordId(), context);
for (int i = 0; i < curPhase.getUsages().length; i++) {
final Usage curUsage = curPhase.getUsages()[i];
final CatalogOverrideUsageDefinitionModelDao overriddenUsage = Iterables.tryFind(usageDefs, new Predicate<CatalogOverrideUsageDefinitionModelDao>() {
@Override
public boolean apply(final CatalogOverrideUsageDefinitionModelDao input) {
return input.getParentUsageName().equals(curUsage.getName());
}
}).orNull();
if (overriddenUsage != null) {
List<TierPriceOverride> tierPriceOverrides = getTierPriceOverrides(curUsage, overriddenUsage, context);
usagePriceOverrides.add(new DefaultUsagePriceOverride(overriddenUsage.getParentUsageName(), curUsage.getUsageType(), tierPriceOverrides));
}
}
return usagePriceOverrides;
}
Aggregations