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 019import com.echothree.model.control.party.common.transfer.PartyRelationshipTransfer; 020import com.echothree.model.control.party.common.transfer.PartyTransfer; 021import com.echothree.model.control.party.server.control.PartyControl; 022import com.echothree.model.control.user.common.transfer.UserSessionTransfer; 023import com.echothree.model.control.user.common.transfer.UserVisitTransfer; 024import com.echothree.model.control.user.server.control.UserControl; 025import com.echothree.model.data.party.server.entity.PartyRelationship; 026import com.echothree.model.data.user.server.entity.UserSession; 027import com.echothree.model.data.user.server.entity.UserVisit; 028import com.echothree.util.server.persistence.Session; 029 030public class UserSessionTransferCache 031 extends BaseUserTransferCache<UserSession, UserSessionTransfer> { 032 033 PartyControl partyControl; 034 035 /** Creates a new instance of UserSessionTransferCache */ 036 public UserSessionTransferCache(UserVisit userVisit, UserControl userControl) { 037 super(userVisit, userControl); 038 039 partyControl = Session.getModelController(PartyControl.class); 040 } 041 042 public UserSessionTransfer getUserSessionTransfer(UserSession userSession) { 043 UserSessionTransfer userSessionTransfer = get(userSession); 044 045 if(userSessionTransfer == null) { 046 UserVisitTransfer userVisitTransfer = userControl.getUserVisitTransfer(userVisit, userSession.getUserVisit()); 047 PartyTransfer partyTransfer = partyControl.getPartyTransfer(userVisit, userSession.getParty()); 048 PartyRelationship partyRelationship = userSession.getPartyRelationship(); 049 PartyRelationshipTransfer partyRelationshipTransfer = partyRelationship == null ? null : partyControl.getPartyRelationshipTransfer(userVisit, partyRelationship); 050 Long unformattedIdentityVerifiedTime = userSession.getIdentityVerifiedTime(); 051 String identityVerifiedTime = unformattedIdentityVerifiedTime == null ? null : formatTypicalDateTime(unformattedIdentityVerifiedTime); 052 053 userSessionTransfer = new UserSessionTransfer(userVisitTransfer, partyTransfer, partyRelationshipTransfer, unformattedIdentityVerifiedTime, 054 identityVerifiedTime); 055 put(userSession, userSessionTransfer); 056 } 057 058 return userSessionTransfer; 059 } 060 061}