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.inventory.server.transfer; 018 019import com.echothree.model.control.inventory.common.transfer.InventoryLocationBucketTransfer; 020import com.echothree.model.control.inventory.server.control.InventoryBucketTypeControl; 021import com.echothree.model.control.inventory.server.control.InventoryLocationControl; 022import com.echothree.model.data.inventory.server.entity.InventoryLocationBucket; 023import com.echothree.model.data.user.server.entity.UserVisit; 024import javax.enterprise.context.RequestScoped; 025import javax.inject.Inject; 026 027@RequestScoped 028public class InventoryLocationBucketTransferCache 029 extends BaseInventoryTransferCache<InventoryLocationBucket, InventoryLocationBucketTransfer> { 030 031 @Inject 032 InventoryLocationControl inventoryLocationControl; 033 034 @Inject 035 InventoryBucketTypeControl inventoryBucketTypeControl; 036 037 protected InventoryLocationBucketTransferCache() { 038 super(); 039 } 040 041 @Override 042 public InventoryLocationBucketTransfer getTransfer(UserVisit userVisit, InventoryLocationBucket inventoryLocationBucket) { 043 var transfer = get(inventoryLocationBucket); 044 045 if(transfer == null) { 046 var inventoryLocation = inventoryLocationBucket.getInventoryLocation(); 047 048 transfer = new InventoryLocationBucketTransfer( 049 inventoryLocationControl.getInventoryLocationTransfer(userVisit, inventoryLocation), 050 inventoryBucketTypeControl.getInventoryBucketTypeTransfer(userVisit, 051 inventoryLocationBucket.getInventoryBucketType()), 052 formatUnitOfMeasure(userVisit, 053 inventoryLocation.getUnitOfMeasureType().getLastDetail().getUnitOfMeasureKind(), 054 inventoryLocationBucket.getQuantity())); 055 put(userVisit, inventoryLocationBucket, transfer); 056 } 057 058 return transfer; 059 } 060 061}