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.ItemUnitLimitTransfer; 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.ItemUnitLimit; 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 ItemUnitLimitTransferCache 031 extends BaseItemTransferCache<ItemUnitLimit, ItemUnitLimitTransfer> { 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 ItemUnitLimitTransferCache */ 038 protected ItemUnitLimitTransferCache() { 039 super(); 040 } 041 042 @Override 043 public ItemUnitLimitTransfer getTransfer(UserVisit userVisit, ItemUnitLimit itemUnitLimit) { 044 var itemUnitLimitTransfer = get(itemUnitLimit); 045 046 if(itemUnitLimitTransfer == null) { 047 var item = itemControl.getItemTransfer(userVisit, itemUnitLimit.getItem()); 048 var inventoryCondition = inventoryControl.getInventoryConditionTransfer(userVisit, itemUnitLimit.getInventoryCondition()); 049 var unitOfMeasureType = uomControl.getUnitOfMeasureTypeTransfer(userVisit, itemUnitLimit.getUnitOfMeasureType()); 050 var longMinimumQuantity = itemUnitLimit.getMinimumQuantity(); 051 var minimumQuantity = longMinimumQuantity == null ? null : longMinimumQuantity.toString(); 052 var longMaximumQuantity = itemUnitLimit.getMaximumQuantity(); 053 var maximumQuantity = longMaximumQuantity == null ? null : longMaximumQuantity.toString(); 054 055 itemUnitLimitTransfer = new ItemUnitLimitTransfer(item, inventoryCondition, unitOfMeasureType, minimumQuantity, maximumQuantity); 056 put(userVisit, itemUnitLimit, itemUnitLimitTransfer); 057 } 058 059 return itemUnitLimitTransfer; 060 } 061 062}