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.letter.server.transfer; 018 019import com.echothree.model.control.chain.common.transfer.ChainInstanceTransfer; 020import com.echothree.model.control.chain.server.control.ChainControl; 021import com.echothree.model.control.letter.common.transfer.LetterTransfer; 022import com.echothree.model.control.letter.common.transfer.QueuedLetterTransfer; 023import com.echothree.model.control.letter.server.control.LetterControl; 024import com.echothree.model.data.letter.server.entity.QueuedLetter; 025import com.echothree.model.data.user.server.entity.UserVisit; 026import com.echothree.util.server.persistence.Session; 027 028public class QueuedLetterTransferCache 029 extends BaseLetterTransferCache<QueuedLetter, QueuedLetterTransfer> { 030 031 ChainControl chainControl; 032 033 /** Creates a new instance of QueuedLetterTransferCache */ 034 public QueuedLetterTransferCache(UserVisit userVisit, LetterControl letterControl) { 035 super(userVisit, letterControl); 036 037 chainControl = Session.getModelController(ChainControl.class); 038 } 039 040 public QueuedLetterTransfer getQueuedLetterTransfer(QueuedLetter queuedLetter) { 041 QueuedLetterTransfer queuedLetterTransfer = get(queuedLetter); 042 043 if(queuedLetterTransfer == null) { 044 ChainInstanceTransfer chainInstance = chainControl.getChainInstanceTransfer(userVisit, queuedLetter.getChainInstance()); 045 LetterTransfer letter = letterControl.getLetterTransfer(userVisit, queuedLetter.getLetter()); 046 047 queuedLetterTransfer = new QueuedLetterTransfer(chainInstance, letter); 048 put(queuedLetter, queuedLetterTransfer); 049 } 050 051 return queuedLetterTransfer; 052 } 053 054}