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.item.server.transfer; 018 019 020import com.echothree.model.control.inventory.server.control.InventoryControl; 021import com.echothree.model.control.item.common.transfer.ItemKitMemberTransfer; 022import com.echothree.model.control.item.server.control.ItemControl; 023import com.echothree.model.control.uom.server.control.UomControl; 024import com.echothree.model.data.item.server.entity.ItemKitMember; 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 ItemKitMemberTransferCache 031 extends BaseItemTransferCache<ItemKitMember, ItemKitMemberTransfer> { 032 033 InventoryControl inventoryControl = Session.getModelController(InventoryControl.class); 034 ItemControl itemControl = Session.getModelController(ItemControl.class); 035 UomControl uomControl = Session.getModelController(UomControl.class); 036 037 /** Creates a new instance of ItemKitMemberTransferCache */ 038 protected ItemKitMemberTransferCache() { 039 super(); 040 } 041 042 @Override 043 public ItemKitMemberTransfer getTransfer(UserVisit userVisit, ItemKitMember itemKitMember) { 044 var itemKitMemberTransfer = get(itemKitMember); 045 046 if(itemKitMemberTransfer == null) { 047 var item = itemControl.getItemTransfer(userVisit, itemKitMember.getItem()); 048 var inventoryCondition = inventoryControl.getInventoryConditionTransfer(userVisit, itemKitMember.getInventoryCondition()); 049 var unitOfMeasureType = uomControl.getUnitOfMeasureTypeTransfer(userVisit, itemKitMember.getUnitOfMeasureType()); 050 var memberItem = itemControl.getItemTransfer(userVisit, itemKitMember.getMemberItem()); 051 var memberInventoryCondition = inventoryControl.getInventoryConditionTransfer(userVisit, itemKitMember.getMemberInventoryCondition()); 052 var memberUnitOfMeasureType = uomControl.getUnitOfMeasureTypeTransfer(userVisit, itemKitMember.getMemberUnitOfMeasureType()); 053 var quantity = itemKitMember.getQuantity().toString(); 054 055 itemKitMemberTransfer = new ItemKitMemberTransfer(item, inventoryCondition, unitOfMeasureType, memberItem, memberInventoryCondition, 056 memberUnitOfMeasureType, quantity); 057 put(userVisit, itemKitMember, itemKitMemberTransfer); 058 } 059 060 return itemKitMemberTransfer; 061 } 062 063}