use of org.killbill.billing.catalog.StandaloneCatalog in project killbill by killbill.
the class DefaultCatalogUserApi method addSimplePlan.
@Override
public void addSimplePlan(final SimplePlanDescriptor descriptor, @Nullable final DateTime effectiveDate, final CallContext callContext) throws CatalogApiException {
try {
final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContextWithoutAccountRecordId(callContext);
final StandaloneCatalog currentCatalog = getCurrentStandaloneCatalogForTenant(internalTenantContext);
final CatalogUpdater catalogUpdater = (currentCatalog != null) ? new CatalogUpdater(currentCatalog) : new CatalogUpdater(getSafeFirstCatalogEffectiveDate(effectiveDate, callContext), descriptor.getCurrency());
catalogUpdater.addSimplePlanDescriptor(descriptor);
tenantApi.updateTenantKeyValue(TenantKey.CATALOG.toString(), catalogUpdater.getCatalogXML(internalTenantContext), callContext);
catalogCache.clearCatalog(internalTenantContext);
} catch (TenantApiException e) {
throw new CatalogApiException(e);
}
}
use of org.killbill.billing.catalog.StandaloneCatalog in project killbill by killbill.
the class StandaloneCatalogMapper method toStandaloneCatalog.
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog) {
final StandaloneCatalog result = new StandaloneCatalog();
result.setCatalogName(catalogName);
result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate());
result.setProducts(toDefaultProducts(pluginCatalog.getProducts()));
result.setPlans(toDefaultPlans(result, pluginCatalog.getPlans()));
result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList()));
result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies()));
result.setUnits(toDefaultUnits(pluginCatalog.getUnits()));
result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules()));
for (final Product cur : pluginCatalog.getProducts()) {
final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName());
if (target != null) {
((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable()));
((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded()));
}
}
result.initialize(result);
return result;
}
Aggregations