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.accounting.server.control.AccountingControl; 021import com.echothree.model.control.offer.server.control.OfferUseControl; 022import com.echothree.model.control.order.server.control.OrderTypeControl; 023import com.echothree.model.control.wishlist.common.transfer.WishlistTransfer; 024import com.echothree.model.control.wishlist.server.control.WishlistControl; 025import com.echothree.model.data.order.server.entity.Order; 026import com.echothree.model.data.user.server.entity.UserVisit; 027import javax.enterprise.context.RequestScoped; 028 029@RequestScoped 030public class WishlistTransferCache 031 extends BaseWishlistTransferCache<Order, WishlistTransfer> { 032 033 @Inject 034 AccountingControl accountingControl; 035 036 @Inject 037 OfferUseControl offerUseControl; 038 039 @Inject 040 OrderTypeControl orderTypeControl; 041 042 @Inject 043 WishlistControl wishlistControl; 044 045 /** Creates a new instance of WishlistTransferCache */ 046 protected WishlistTransferCache() { 047 super(); 048 049 setIncludeEntityInstance(true); 050 } 051 052 public WishlistTransfer getWishlistTransfer(UserVisit userVisit, Order order) { 053 var wishlistTransfer = get(order); 054 055 if(wishlistTransfer == null) { 056 var orderDetail = order.getActiveDetail(); 057 var wishlist = wishlistControl.getWishlist(order); 058 var orderType = orderTypeControl.getOrderTypeTransfer(userVisit, orderDetail.getOrderType()); 059 var orderName = orderDetail.getOrderName(); 060 var currency = accountingControl.getCurrencyTransfer(userVisit, orderDetail.getCurrency()); 061 var offerUse = offerUseControl.getOfferUseTransfer(userVisit, wishlist.getOfferUse()); 062 var wishlistType = wishlistControl.getWishlistTypeTransfer(userVisit, wishlist.getWishlistType()); 063 064 wishlistTransfer = new WishlistTransfer(orderType, orderName, currency, offerUse, wishlistType); 065 put(userVisit, order, wishlistTransfer); 066 } 067 068 return wishlistTransfer; 069 } 070 071}