001// -------------------------------------------------------------------------------- 002// Copyright 2002-2024 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.order.server.transfer; 018 019import com.echothree.model.control.contact.common.transfer.PartyContactMechanismTransfer; 020import com.echothree.model.control.contact.server.control.ContactControl; 021import com.echothree.model.control.item.common.transfer.ItemDeliveryTypeTransfer; 022import com.echothree.model.control.item.server.control.ItemControl; 023import com.echothree.model.control.order.common.transfer.OrderShipmentGroupTransfer; 024import com.echothree.model.control.shipping.common.transfer.ShippingMethodTransfer; 025import com.echothree.model.control.shipping.server.control.ShippingControl; 026import com.echothree.model.data.contact.server.entity.PartyContactMechanism; 027import com.echothree.model.data.order.server.entity.OrderShipmentGroup; 028import com.echothree.model.data.order.server.entity.OrderShipmentGroupDetail; 029import com.echothree.model.data.shipping.server.entity.ShippingMethod; 030import com.echothree.model.data.user.server.entity.UserVisit; 031import com.echothree.util.server.persistence.Session; 032 033public class OrderShipmentGroupTransferCache 034 extends BaseOrderTransferCache<OrderShipmentGroup, OrderShipmentGroupTransfer> { 035 036 ContactControl contactControl = Session.getModelController(ContactControl.class);; 037 ItemControl itemControl = Session.getModelController(ItemControl.class);; 038 ShippingControl shippingControl = Session.getModelController(ShippingControl.class);; 039 040 /** Creates a new instance of OrderShipmentGroupTransferCache */ 041 public OrderShipmentGroupTransferCache(UserVisit userVisit) { 042 super(userVisit); 043 044 setIncludeEntityInstance(true); 045 } 046 047 public OrderShipmentGroupTransfer getOrderShipmentGroupTransfer(OrderShipmentGroup orderShipmentGroup) { 048 OrderShipmentGroupTransfer orderShipmentGroupTransfer = get(orderShipmentGroup); 049 050 if(orderShipmentGroupTransfer == null) { 051 OrderShipmentGroupDetail orderShipmentGroupDetail = orderShipmentGroup.getLastDetail(); 052 Integer orderShipmentGroupSequence = orderShipmentGroupDetail.getOrderShipmentGroupSequence(); 053 ItemDeliveryTypeTransfer itemDeliveryTypeTransfer = itemControl.getItemDeliveryTypeTransfer(userVisit, orderShipmentGroupDetail.getItemDeliveryType()); 054 Boolean isDefault = orderShipmentGroupDetail.getIsDefault(); 055 PartyContactMechanism partyContactMechanism = orderShipmentGroupDetail.getPartyContactMechanism(); 056 PartyContactMechanismTransfer partyContactMechanismTransfer = partyContactMechanism == null ? null : contactControl.getPartyContactMechanismTransfer(userVisit, partyContactMechanism); 057 ShippingMethod shippingMethod = orderShipmentGroupDetail.getShippingMethod(); 058 ShippingMethodTransfer shippingMethodTransfer = shippingMethod == null ? null : shippingControl.getShippingMethodTransfer(userVisit, shippingMethod); 059 Boolean holdUntilComplete = orderShipmentGroupDetail.getHoldUntilComplete(); 060 061 orderShipmentGroupTransfer = new OrderShipmentGroupTransfer(orderShipmentGroupSequence, itemDeliveryTypeTransfer, isDefault, 062 partyContactMechanismTransfer, shippingMethodTransfer, holdUntilComplete); 063 put(orderShipmentGroup, orderShipmentGroupTransfer); 064 } 065 066 return orderShipmentGroupTransfer; 067 } 068 069}