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