@Override public <G extends OrderAttribute> CreateResponse<G> createOrRetrieveCopyInstance(MultiTenantCopyContext context) throws CloneNotSupportedException { CreateResponse<G> createResponse = context.createOrRetrieveCopyInstance(this); if (createResponse.isAlreadyPopulated()) { return createResponse; } OrderAttribute cloned = createResponse.getClone(); cloned.setName(name); cloned.setValue(value); //dont clone cloned.setOrder(order); return createResponse; } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!getClass().isAssignableFrom(obj.getClass())) return false; if (value == null) { return false; } return value.equals(((OrderAttribute) obj).getValue()); }
if (StringUtils.isNotEmpty(channel)) { OrderAttribute channelAttribute = new OrderAttributeImpl(); channelAttribute.setName("channel"); channelAttribute.setValue(channel); channelAttribute.setOrder(cart); cart.getOrderAttributes().put(channelAttribute.getName(), channelAttribute); cart.setName(channel);
OrderAttribute clonedAttribute = entry.getValue().createOrRetrieveCopyInstance(context).getClone(); clonedAttribute.setOrder(cloned); cloned.getOrderAttributes().put(entry.getKey(),clonedAttribute);
@Override public void addOrderAttributeToOrder(Long orderId, String orderAttributeKey, String orderAttributeValue) throws PaymentException { Order currentCart = CartState.getCart(); Long currentCartId = currentCart.getId(); if (orderId != null && !currentCartId.equals(orderId)) { logWarningIfCartMismatch(currentCartId, orderId); currentCart = orderService.findOrderById(orderId); } OrderAttribute orderAttribute = new OrderAttributeImpl(); orderAttribute.setName(orderAttributeKey); orderAttribute.setValue(orderAttributeValue); orderAttribute.setOrder(currentCart); currentCart.getOrderAttributes().put(orderAttributeKey, orderAttribute); try { orderService.save(currentCart, false); } catch (PricingException e) { throw new PaymentException(e); } }
@Override public String retrieveOrderAttributeFromOrder(Long orderId, String orderAttributeKey) { Order currentCart = CartState.getCart(); Long currentCartId = currentCart.getId(); if (orderId != null && !currentCartId.equals(orderId)) { logWarningIfCartMismatch(currentCartId, orderId); currentCart = orderService.findOrderById(orderId); } if (currentCart.getOrderAttributes().containsKey(orderAttributeKey)) { return currentCart.getOrderAttributes().get(orderAttributeKey).getValue(); } return null; }