001// -------------------------------------------------------------------------------- 002// Copyright 2002-2025 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.associate.server.transfer; 018 019import com.echothree.model.control.associate.common.transfer.AssociateTransfer; 020import com.echothree.model.control.associate.server.control.AssociateControl; 021import com.echothree.model.control.core.server.control.MimeTypeControl; 022import com.echothree.model.control.party.server.control.PartyControl; 023import com.echothree.model.data.associate.server.entity.Associate; 024import com.echothree.model.data.user.server.entity.UserVisit; 025import com.echothree.util.server.persistence.Session; 026import javax.enterprise.context.RequestScoped; 027 028@RequestScoped 029public class AssociateTransferCache 030 extends BaseAssociateTransferCache<Associate, AssociateTransfer> { 031 032 AssociateControl associateControl = Session.getModelController(AssociateControl.class); 033 MimeTypeControl mimeTypeControl = Session.getModelController(MimeTypeControl.class); 034 PartyControl partyControl = Session.getModelController(PartyControl.class); 035 036 /** Creates a new instance of AssociateTransferCache */ 037 protected AssociateTransferCache() { 038 super(); 039 040 setIncludeEntityInstance(true); 041 } 042 043 @Override 044 public AssociateTransfer getTransfer(UserVisit userVisit, Associate associate) { 045 var associateTransfer = get(associate); 046 047 if(associateTransfer == null) { 048 var associateDetail = associate.getLastDetail(); 049 var associateProgram = associateControl.getAssociateProgramTransfer(userVisit, associateDetail.getAssociateProgram()); 050 var associateName = associateDetail.getAssociateName(); 051 var party = partyControl.getPartyTransfer(userVisit, associateDetail.getParty()); 052 var description = associateDetail.getDescription(); 053 var summaryMimeType = mimeTypeControl.getMimeTypeTransfer(userVisit, associateDetail.getSummaryMimeType()); 054 var summary = associateDetail.getSummary(); 055 056 associateTransfer = new AssociateTransfer(associateProgram, associateName, party, description, summaryMimeType, summary); 057 put(userVisit, associate, associateTransfer); 058 } 059 return associateTransfer; 060 } 061 062}