use of org.candlepin.model.SourceSubscription in project candlepin by candlepin.
the class PoolHelper method clonePool.
public static Pool clonePool(Pool sourcePool, Product product, String quantity, Map<String, String> attributes, String subKey, OwnerProductCurator curator, Entitlement sourceEntitlement, ProductCurator productCurator) {
Pool pool = createPool(product, sourcePool.getOwner(), quantity, sourcePool.getStartDate(), sourcePool.getEndDate(), sourcePool.getContractNumber(), sourcePool.getAccountNumber(), sourcePool.getOrderNumber(), new HashSet<>(), sourceEntitlement, sourcePool.hasSharedAncestor());
SourceSubscription srcSub = sourcePool.getSourceSubscription();
if (srcSub != null && srcSub.getSubscriptionId() != null) {
pool.setSourceSubscription(new SourceSubscription(srcSub.getSubscriptionId(), subKey));
}
copyProvidedProducts(sourcePool, pool, curator, productCurator);
// Add in the new attributes
for (Entry<String, String> entry : attributes.entrySet()) {
pool.setAttribute(entry.getKey(), entry.getValue());
}
for (Branding brand : sourcePool.getBranding()) {
pool.getBranding().add(new Branding(brand.getProductId(), brand.getType(), brand.getName()));
}
// Copy upstream fields
// Impl note/TODO:
// We are only doing this to facilitate marking pools derived from an upstream source/manifest
// as also from that same upstream source. A proper pool hierarchy would be a better solution
// here, but this will work for the interim.
pool.setUpstreamPoolId(sourcePool.getUpstreamPoolId());
pool.setUpstreamEntitlementId(sourcePool.getUpstreamEntitlementId());
pool.setUpstreamConsumerId(sourcePool.getUpstreamConsumerId());
return pool;
}
Aggregations