Search in sources :

Example 31 with SourceSubscription

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;
}
Also used : SourceSubscription(org.candlepin.model.SourceSubscription) Pool(org.candlepin.model.Pool) Branding(org.candlepin.model.Branding)

Aggregations

Pool (org.candlepin.model.Pool)31 SourceSubscription (org.candlepin.model.SourceSubscription)31 Product (org.candlepin.model.Product)23 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)19 Owner (org.candlepin.model.Owner)19 Subscription (org.candlepin.model.dto.Subscription)18 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)15 LinkedList (java.util.LinkedList)14 PoolType (org.candlepin.model.Pool.PoolType)10 Entitlement (org.candlepin.model.Entitlement)9 HashSet (java.util.HashSet)8 List (java.util.List)7 Branding (org.candlepin.model.Branding)7 HashMap (java.util.HashMap)6 Consumer (org.candlepin.model.Consumer)6 Matchers.anyList (org.mockito.Matchers.anyList)6 Map (java.util.Map)5 Date (java.util.Date)4 CandlepinQuery (org.candlepin.model.CandlepinQuery)4