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