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.communication.server.transfer; 018 019import com.echothree.model.control.communication.common.transfer.CommunicationEmailSourceTransfer; 020import com.echothree.model.control.communication.server.control.CommunicationControl; 021import com.echothree.model.control.core.common.transfer.ServerTransfer; 022import com.echothree.model.control.core.server.control.CoreControl; 023import com.echothree.model.control.selector.common.transfer.SelectorTransfer; 024import com.echothree.model.control.selector.server.control.SelectorControl; 025import com.echothree.model.control.workeffort.common.transfer.WorkEffortScopeTransfer; 026import com.echothree.model.control.workeffort.server.control.WorkEffortControl; 027import com.echothree.model.data.communication.server.entity.CommunicationEmailSource; 028import com.echothree.model.data.selector.server.entity.Selector; 029import com.echothree.model.data.user.server.entity.UserVisit; 030import com.echothree.util.server.persistence.Session; 031 032public class CommunicationEmailSourceTransferCache 033 extends BaseCommunicationTransferCache<CommunicationEmailSource, CommunicationEmailSourceTransfer> { 034 035 CoreControl coreControl; 036 SelectorControl selectorControl; 037 WorkEffortControl workEffortControl; 038 039 /** Creates a new instance of CommunicationEmailSourceTransferCache */ 040 public CommunicationEmailSourceTransferCache(UserVisit userVisit, CommunicationControl communicationControl) { 041 super(userVisit, communicationControl); 042 043 coreControl = Session.getModelController(CoreControl.class); 044 selectorControl = Session.getModelController(SelectorControl.class); 045 workEffortControl = Session.getModelController(WorkEffortControl.class); 046 } 047 048 public CommunicationEmailSourceTransfer getCommunicationEmailSourceTransfer(CommunicationEmailSource communicationEmailSource) { 049 CommunicationEmailSourceTransfer communicationEmailSourceTransfer = get(communicationEmailSource); 050 051 if(communicationEmailSourceTransfer == null) { 052 ServerTransfer servertTransfer = coreControl.getServerTransfer(userVisit, communicationEmailSource.getServer()); 053 String username = communicationEmailSource.getUsername(); 054 String password = communicationControl.decodeCommunicationEmailSourcePassword(communicationEmailSource); 055 WorkEffortScopeTransfer receiveWorkEffortScopeTransfer = workEffortControl.getWorkEffortScopeTransfer(userVisit, communicationEmailSource.getReceiveWorkEffortScope()); 056 WorkEffortScopeTransfer sendWorkEffortScopeTransfer = workEffortControl.getWorkEffortScopeTransfer(userVisit, communicationEmailSource.getSendWorkEffortScope()); 057 Selector reviewEmployeeSelector = communicationEmailSource.getReviewEmployeeSelector(); 058 SelectorTransfer reviewEmployeeSelectorTransfer = reviewEmployeeSelector == null? null: selectorControl.getSelectorTransfer(userVisit, reviewEmployeeSelector); 059 060 communicationEmailSourceTransfer = new CommunicationEmailSourceTransfer(servertTransfer, username, password, 061 receiveWorkEffortScopeTransfer, sendWorkEffortScopeTransfer, reviewEmployeeSelectorTransfer); 062 put(communicationEmailSource, communicationEmailSourceTransfer); 063 } 064 065 return communicationEmailSourceTransfer; 066 } 067 068}