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.communication.server.transfer; 018 019import javax.inject.Inject; 020import com.echothree.model.control.communication.common.transfer.CommunicationEventTransfer; 021import com.echothree.model.control.communication.server.control.CommunicationControl; 022import com.echothree.model.control.contact.server.control.ContactControl; 023import com.echothree.model.control.document.server.control.DocumentControl; 024import com.echothree.model.data.communication.server.entity.CommunicationEvent; 025import com.echothree.model.data.user.server.entity.UserVisit; 026import javax.enterprise.context.RequestScoped; 027 028@RequestScoped 029public class CommunicationEventTransferCache 030 extends BaseCommunicationTransferCache<CommunicationEvent, CommunicationEventTransfer> { 031 032 @Inject 033 CommunicationControl communicationControl; 034 035 @Inject 036 ContactControl contactControl; 037 038 @Inject 039 DocumentControl documentControl; 040 041 /** Creates a new instance of CommunicationEventTransferCache */ 042 protected CommunicationEventTransferCache() { 043 super(); 044 045 setIncludeEntityInstance(true); 046 } 047 048 public CommunicationEventTransfer getCommunicationEventTransfer(UserVisit userVisit, CommunicationEvent communicationEvent) { 049 var communicationEventTransfer = get(communicationEvent); 050 051 if(communicationEventTransfer == null) { 052 var communicationEventDetail = communicationEvent.getLastDetail(); 053 var communicationEventName = communicationEventDetail.getCommunicationEventName(); 054 var communicationEventTypeTransfer = communicationControl.getCommunicationEventTypeTransfer(userVisit, 055 communicationEventDetail.getCommunicationEventType()); 056 var communicationSourceTransfer = communicationControl.getCommunicationSourceTransfer(userVisit, 057 communicationEventDetail.getCommunicationSource()); 058 var communicationEventPurposeTransfer = communicationControl.getCommunicationEventPurposeTransfer(userVisit, 059 communicationEventDetail.getCommunicationEventPurpose()); 060 var originalCommunicationEvent = communicationEventDetail.getOriginalCommunicationEvent(); 061 var originalCommunicationEventTransfer = originalCommunicationEvent == null? null: communicationControl.getCommunicationEventTransfer(userVisit, originalCommunicationEvent); 062 var parentCommunicationEvent = communicationEventDetail.getParentCommunicationEvent(); 063 var parentCommunicationEventTransfer = parentCommunicationEvent == null? null: communicationControl.getCommunicationEventTransfer(userVisit, parentCommunicationEvent); 064 var partyContactMechanismTransfer = contactControl.getPartyContactMechanismTransfer(userVisit, communicationEventDetail.getPartyContactMechanism()); 065 var documentTransfer = documentControl.getDocumentTransfer(userVisit, communicationEventDetail.getDocument()); 066 067 communicationEventTransfer = new CommunicationEventTransfer(communicationEventName, communicationEventTypeTransfer, 068 communicationSourceTransfer, communicationEventPurposeTransfer, originalCommunicationEventTransfer, 069 parentCommunicationEventTransfer, partyContactMechanismTransfer, documentTransfer); 070 put(userVisit, communicationEvent, communicationEventTransfer); 071 setupOwnedWorkEfforts(userVisit, communicationEvent, null, communicationEventTransfer); 072 } 073 074 return communicationEventTransfer; 075 } 076 077}