use of org.candlepin.model.Pool in project candlepin by candlepin.
the class TestUtil method clone.
/**
* @param pool source pool
* @return pool the clone pool
*/
public static Pool clone(Pool pool) {
Pool p = new Pool(pool.getOwner(), pool.getProduct(), new HashSet<>(pool.getProvidedProducts()), pool.getQuantity(), pool.getStartDate(), pool.getEndDate(), pool.getContractNumber(), pool.getAccountNumber(), pool.getOrderNumber());
p.setSourceSubscription(new SourceSubscription(pool.getSubscriptionId(), pool.getSubscriptionSubKey()));
// Copy sub-product data if there is any:
p.setDerivedProduct(pool.getDerivedProduct());
for (Branding b : pool.getBranding()) {
p.getBranding().add(new Branding(b.getProductId(), b.getType(), b.getName()));
}
return p;
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class TestUtil method copyFromSub.
/**
* Returns a pool which will look like it was created from the given subscription
* during refresh pools.
*
* @param sub source subscription
* @return pool for subscription
*/
public static Pool copyFromSub(Subscription sub) {
Product product = createProduct((ProductData) sub.getProduct());
Product derivedProduct = createProduct((ProductData) sub.getDerivedProduct());
List<Product> providedProducts = new LinkedList<>();
if (sub.getProvidedProducts() != null) {
for (ProductData pdata : sub.getProvidedProducts()) {
if (pdata != null) {
providedProducts.add(TestUtil.createProduct(pdata));
}
}
}
List<Product> derivedProvidedProducts = new LinkedList<>();
if (sub.getDerivedProvidedProducts() != null) {
for (ProductData pdata : sub.getDerivedProvidedProducts()) {
if (pdata != null) {
derivedProvidedProducts.add(TestUtil.createProduct(pdata));
}
}
}
Pool pool = new Pool(sub.getOwner(), product, providedProducts, sub.getQuantity(), sub.getStartDate(), sub.getEndDate(), sub.getContractNumber(), sub.getAccountNumber(), sub.getOrderNumber());
pool.setDerivedProduct(derivedProduct);
pool.setDerivedProvidedProducts(derivedProvidedProducts);
if (sub.getId() != null) {
pool.setSourceSubscription(new SourceSubscription(sub.getId(), "master"));
}
pool.setUpstreamPoolId(sub.getUpstreamPoolId());
pool.setUpstreamConsumerId(sub.getUpstreamConsumerId());
pool.setUpstreamEntitlementId(sub.getUpstreamEntitlementId());
for (Branding branding : sub.getBranding()) {
pool.getBranding().add(new Branding(branding.getProductId(), branding.getType(), branding.getName()));
}
return pool;
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class DatabaseTestFixture method createPool.
protected Pool createPool(Owner owner, Product product, Long quantity, Date startDate, Date endDate, String contractNr, String subscriptionId) {
Pool pool = createPool(owner, product, quantity, subscriptionId, "master", startDate, endDate);
pool.setContractNumber(contractNr);
return poolCurator.merge(pool);
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class EntitlementTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public EntitlementDTO populate(ModelTranslator modelTranslator, Entitlement source, EntitlementDTO dest) {
dest = super.populate(modelTranslator, source, dest);
dest.setId(source.getId());
dest.setQuantity(source.getQuantity());
dest.setDeletedFromPool(source.deletedFromPool());
dest.setStartDate(source.getStartDate());
dest.setEndDate(source.getEndDate());
if (modelTranslator != null) {
Owner owner = source.getOwner();
dest.setOwner(owner != null ? modelTranslator.translate(owner, OwnerDTO.class) : null);
Pool pool = source.getPool();
dest.setPool(pool != null ? modelTranslator.translate(pool, PoolDTO.class) : null);
Consumer consumer = source.getConsumer();
dest.setConsumer(consumer != null ? modelTranslator.translate(consumer, ConsumerDTO.class) : null);
Set<EntitlementCertificate> certs = source.getCertificates();
if (certs != null && !certs.isEmpty()) {
for (Certificate cert : certs) {
if (cert != null) {
dest.addCertificate(modelTranslator.translate(cert, CertificateDTO.class));
}
}
} else {
dest.setCertificates(Collections.emptySet());
}
}
return dest;
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class EntitlementTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public EntitlementDTO populate(ModelTranslator modelTranslator, Entitlement source, EntitlementDTO dest) {
if (source == null) {
throw new IllegalArgumentException("source is null");
}
if (dest == null) {
throw new IllegalArgumentException("destination is null");
}
dest.setId(source.getId());
dest.setQuantity(source.getQuantity());
dest.setStartDate(source.getStartDate());
dest.setEndDate(source.getEndDate());
if (modelTranslator != null) {
Pool pool = source.getPool();
dest.setPool(pool != null ? modelTranslator.translate(pool, PoolDTO.class) : null);
}
return dest;
}
Aggregations