001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 Echo Three, LLC 003// 004// Licensed under the Apache License, Version 2.0 (the "License"); 005// you may not use this file except in compliance with the License. 006// You may obtain a copy of the License at 007// 008// http://www.apache.org/licenses/LICENSE-2.0 009// 010// Unless required by applicable law or agreed to in writing, software 011// distributed under the License is distributed on an "AS IS" BASIS, 012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013// See the License for the specific language governing permissions and 014// limitations under the License. 015// -------------------------------------------------------------------------------- 016 017package com.echothree.model.control.wishlist.server.transfer; 018 019import javax.inject.Inject; 020import com.echothree.model.control.associate.common.transfer.AssociateReferralTransfer; 021import com.echothree.model.control.inventory.server.control.InventoryControl; 022import com.echothree.model.control.item.server.control.ItemControl; 023import com.echothree.model.control.offer.server.control.OfferUseControl; 024import com.echothree.model.control.uom.server.control.UomControl; 025import com.echothree.model.control.wishlist.common.transfer.WishlistLineTransfer; 026import com.echothree.model.control.wishlist.server.control.WishlistControl; 027import com.echothree.model.data.order.server.entity.OrderLine; 028import com.echothree.model.data.user.server.entity.UserVisit; 029import com.echothree.util.server.string.AmountUtils; 030import javax.enterprise.context.RequestScoped; 031 032@RequestScoped 033public class WishlistLineTransferCache 034 extends BaseWishlistTransferCache<OrderLine, WishlistLineTransfer> { 035 036 @Inject 037 InventoryControl inventoryControl; 038 039 @Inject 040 ItemControl itemControl; 041 042 @Inject 043 OfferUseControl offerUseControl; 044 045 @Inject 046 UomControl uomControl; 047 048 @Inject 049 WishlistControl wishlistControl; 050 051 /** Creates a new instance of WishlistLineTransferCache */ 052 protected WishlistLineTransferCache() { 053 super(); 054 055 setIncludeEntityInstance(true); 056 } 057 058 public WishlistLineTransfer getWishlistLineTransfer(UserVisit userVisit, OrderLine orderLine) { 059 var wishlistLineTransfer = get(orderLine); 060 061 if(wishlistLineTransfer == null) { 062 var orderLineDetail = orderLine.getLastDetail(); 063 var wishlistLine = wishlistControl.getWishlistLine(orderLine); 064 var order = orderLineDetail.getOrder(); 065 var wishlist = wishlistControl.getWishlistTransfer(userVisit, order); 066 var orderLineSequence = orderLineDetail.getOrderLineSequence(); 067 var item = itemControl.getItemTransfer(userVisit, orderLineDetail.getItem()); 068 var inventoryCondition = inventoryControl.getInventoryConditionTransfer(userVisit, orderLineDetail.getInventoryCondition()); 069 var unitOfMeasureType = uomControl.getUnitOfMeasureTypeTransfer(userVisit, orderLineDetail.getUnitOfMeasureType()); 070 var quantity = orderLineDetail.getQuantity(); 071 var unformattedUnitAmount = orderLineDetail.getUnitAmount(); 072 var unitAmount = AmountUtils.getInstance().formatPriceLine(order.getLastDetail().getCurrency(), unformattedUnitAmount); 073 var description = orderLineDetail.getDescription(); 074 var offerUse = offerUseControl.getOfferUseTransfer(userVisit, wishlistLine.getOfferUse()); 075 var wishlistPriority = wishlistControl.getWishlistPriorityTransfer(userVisit, wishlistLine.getWishlistPriority()); 076 AssociateReferralTransfer associateReferral = null; // TODO 077 var comment = wishlistLine.getComment(); 078 079 wishlistLineTransfer = new WishlistLineTransfer(wishlist, orderLineSequence, item, inventoryCondition, unitOfMeasureType, quantity, 080 unformattedUnitAmount, unitAmount, description, offerUse, wishlistPriority, associateReferral, comment); 081 put(userVisit, orderLine, wishlistLineTransfer); 082 } 083 084 return wishlistLineTransfer; 085 } 086 087}