use of org.broadleafcommerce.core.offer.domain.Adjustment in project BroadleafCommerce by BroadleafCommerce.
the class OfferServiceImpl method getUniqueOffersFromOrder.
@Override
@SuppressWarnings("unchecked")
public Set<Offer> getUniqueOffersFromOrder(Order order) {
HashSet<Offer> result = new HashSet<Offer>();
Transformer adjustmentToOfferTransformer = new Transformer() {
@Override
public Object transform(Object input) {
return ((Adjustment) input).getOffer();
}
};
result.addAll(CollectionUtils.collect(order.getOrderAdjustments(), adjustmentToOfferTransformer));
if (order.getOrderItems() != null) {
for (OrderItem item : order.getOrderItems()) {
result.addAll(CollectionUtils.collect(item.getOrderItemAdjustments(), adjustmentToOfferTransformer));
// record usage for price details on the item as well
if (item.getOrderItemPriceDetails() != null) {
for (OrderItemPriceDetail detail : item.getOrderItemPriceDetails()) {
result.addAll(CollectionUtils.collect(detail.getOrderItemPriceDetailAdjustments(), adjustmentToOfferTransformer));
}
}
}
}
if (order.getFulfillmentGroups() != null) {
for (FulfillmentGroup fg : order.getFulfillmentGroups()) {
result.addAll(CollectionUtils.collect(fg.getFulfillmentGroupAdjustments(), adjustmentToOfferTransformer));
}
}
return result;
}
Aggregations