use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.
the class HandleCertificatesOp method execute.
/**
* we can now associate and persist the certs.
* @param context
*/
@Override
public boolean execute(BindContext context) {
if (!context.getConsumerType().isType(ConsumerTypeEnum.SHARE)) {
Map<String, Entitlement> ents = context.getEntitlementMap();
for (Entitlement ent : ents.values()) {
EntitlementCertificate cert = certs.get(ent.getPool().getId());
ent.getCertificates().add(cert);
cert.setEntitlement(ent);
}
ecCurator.saveAll(certs.values(), false, false);
eCurator.saveOrUpdateAll(ents.values(), false, false);
this.ecGenerator.regenerateCertificatesByEntitlementIds(modifyingEnts, true);
}
return true;
}
use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.
the class SubscriptionReconcilerTest method createEntitlementCertificate.
protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
EntitlementCertificate toReturn = new EntitlementCertificate();
CertificateSerial certSerial = new CertificateSerial(new Date());
certSerial.setCollected(true);
certSerial.setUpdated(new Date());
certSerial.setCreated(new Date());
toReturn.setKeyAsBytes(key.getBytes());
toReturn.setCertAsBytes(cert.getBytes());
toReturn.setSerial(certSerial);
return toReturn;
}
use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.
the class EntitlementImporterTest method createEntitlementCertificate.
protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
EntitlementCertificate toReturn = new EntitlementCertificate();
CertificateSerial certSerial = new CertificateSerial(new Date());
certSerial.setCollected(true);
certSerial.setUpdated(new Date());
certSerial.setCreated(new Date());
toReturn.setKeyAsBytes(key.getBytes());
toReturn.setCertAsBytes(cert.getBytes());
toReturn.setSerial(certSerial);
return toReturn;
}
use of org.candlepin.model.EntitlementCertificate in project candlepin by candlepin.
the class DatabaseTestFixture method createEntitlementCertificate.
protected EntitlementCertificate createEntitlementCertificate(String key, String cert) {
EntitlementCertificate toReturn = new EntitlementCertificate();
CertificateSerial certSerial = new CertificateSerial(new Date());
certSerialCurator.create(certSerial);
toReturn.setKeyAsBytes(key.getBytes());
toReturn.setCertAsBytes(cert.getBytes());
toReturn.setSerial(certSerial);
return toReturn;
}
use of org.candlepin.model.EntitlementCertificate 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;
}
Aggregations