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.PartyBucketTransfer; 020import com.echothree.model.control.inventory.server.control.InventoryBucketTypeControl; 021import com.echothree.model.control.inventory.server.control.InventoryConditionControl; 022import com.echothree.model.control.item.server.control.ItemControl; 023import com.echothree.model.control.party.server.control.PartyControl; 024import com.echothree.model.control.uom.server.control.UomControl; 025import com.echothree.model.data.inventory.server.entity.PartyBucket; 026import com.echothree.model.data.user.server.entity.UserVisit; 027import javax.enterprise.context.RequestScoped; 028import javax.inject.Inject; 029 030@RequestScoped 031public class PartyBucketTransferCache 032 extends BaseInventoryTransferCache<PartyBucket, PartyBucketTransfer> { 033 034 @Inject 035 PartyControl partyControl; 036 037 @Inject 038 ItemControl itemControl; 039 040 @Inject 041 UomControl uomControl; 042 043 @Inject 044 InventoryConditionControl inventoryConditionControl; 045 046 @Inject 047 InventoryBucketTypeControl inventoryBucketTypeControl; 048 049 protected PartyBucketTransferCache() { 050 super(); 051 } 052 053 @Override 054 public PartyBucketTransfer getTransfer(UserVisit userVisit, PartyBucket partyBucket) { 055 var transfer = get(partyBucket); 056 057 if(transfer == null) { 058 var unitOfMeasureType = partyBucket.getUnitOfMeasureType(); 059 060 transfer = new PartyBucketTransfer( 061 partyControl.getPartyTransfer(userVisit, partyBucket.getParty()), 062 itemControl.getItemTransfer(userVisit, partyBucket.getItem()), 063 uomControl.getUnitOfMeasureTypeTransfer(userVisit, unitOfMeasureType), 064 inventoryConditionControl.getInventoryConditionTransfer(userVisit, partyBucket.getInventoryCondition()), 065 inventoryBucketTypeControl.getInventoryBucketTypeTransfer(userVisit, partyBucket.getInventoryBucketType()), 066 formatUnitOfMeasure(userVisit, unitOfMeasureType.getLastDetail().getUnitOfMeasureKind(), partyBucket.getQuantity())); 067 068 put(userVisit, partyBucket, transfer); 069 } 070 071 return transfer; 072 } 073 074}