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