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.user.server.transfer; 018 019 020import com.echothree.model.control.party.common.transfer.PartyRelationshipTransfer; 021import com.echothree.model.control.party.common.transfer.PartyTransfer; 022import com.echothree.model.control.party.server.control.PartyControl; 023import com.echothree.model.control.user.common.transfer.UserKeyTransfer; 024import com.echothree.model.control.user.server.control.UserControl; 025import com.echothree.model.data.party.server.entity.Party; 026import com.echothree.model.data.party.server.entity.PartyRelationship; 027import com.echothree.model.data.user.server.entity.UserKey; 028import com.echothree.model.data.user.server.entity.UserKeyDetail; 029import com.echothree.model.data.user.server.entity.UserVisit; 030import com.echothree.util.server.persistence.Session; 031 032public class UserKeyTransferCache 033 extends BaseUserTransferCache<UserKey, UserKeyTransfer> { 034 035 PartyControl partyControl; 036 037 /** Creates a new instance of UserKeyTransferCache */ 038 public UserKeyTransferCache(UserVisit userVisit, UserControl userControl) { 039 super(userVisit, userControl); 040 041 partyControl = Session.getModelController(PartyControl.class); 042 } 043 044 public UserKeyTransfer getUserKeyTransfer(UserKey userKey) { 045 UserKeyTransfer userKeyTransfer = get(userKey); 046 047 if(userKeyTransfer == null) { 048 UserKeyDetail userKeyDetail = userKey.getLastDetail(); 049 String userKeyName = userKeyDetail.getUserKeyName(); 050 Party party = userKeyDetail.getParty(); 051 PartyTransfer partyTransfer = party == null? null: partyControl.getPartyTransfer(userVisit, party); 052 PartyRelationship partyRelationship = userKeyDetail.getPartyRelationship(); 053 PartyRelationshipTransfer partyRelationshipTransfer = partyRelationship == null? null: partyControl.getPartyRelationshipTransfer(userVisit, partyRelationship); 054 055 userKeyTransfer = new UserKeyTransfer(userKeyName, partyTransfer, partyRelationshipTransfer); 056 put(userKey, userKeyTransfer); 057 } 058 059 return userKeyTransfer; 060 } 061 062}