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.selector.server.transfer; 018 019import com.echothree.model.control.selector.common.transfer.SelectorNodeTransfer; 020import com.echothree.model.control.selector.common.transfer.SelectorNodeTypeTransfer; 021import com.echothree.model.control.selector.common.transfer.SelectorTransfer; 022import com.echothree.model.control.selector.server.control.SelectorControl; 023import com.echothree.model.data.selector.server.entity.SelectorNode; 024import com.echothree.model.data.selector.server.entity.SelectorNodeDetail; 025import com.echothree.model.data.user.server.entity.UserVisit; 026 027public class SelectorNodeTransferCache 028 extends BaseSelectorTransferCache<SelectorNode, SelectorNodeTransfer> { 029 030 /** Creates a new instance of SelectorNodeTransferCache */ 031 public SelectorNodeTransferCache(UserVisit userVisit, SelectorControl selectorControl) { 032 super(userVisit, selectorControl); 033 } 034 035 public SelectorNodeTransfer getSelectorNodeTransfer(SelectorNode selectorNode) { 036 SelectorNodeTransfer selectorNodeTransfer = get(selectorNode); 037 038 if(selectorNodeTransfer == null) { 039 SelectorNodeDetail selectorNodeDetail = selectorNode.getLastDetail(); 040 SelectorTransferCache selectorTransferCache = selectorControl.getSelectorTransferCaches(userVisit).getSelectorTransferCache(); 041 SelectorTransfer selector = selectorTransferCache.getSelectorTransfer(selectorNodeDetail.getSelector()); 042 String selectorNodeName = selectorNodeDetail.getSelectorNodeName(); 043 Boolean isRootSelectorNode = selectorNodeDetail.getIsRootSelectorNode(); 044 SelectorNodeTypeTransferCache selectorNodeTypeTransferCache = selectorControl.getSelectorTransferCaches(userVisit).getSelectorNodeTypeTransferCache(); 045 SelectorNodeTypeTransfer selectorNodeType = selectorNodeTypeTransferCache.getSelectorNodeTypeTransfer(selectorNodeDetail.getSelectorNodeType()); 046 Boolean negate = selectorNodeDetail.getNegate(); 047 String description = selectorControl.getBestSelectorNodeDescription(selectorNode, getLanguage()); 048 049 selectorNodeTransfer = new SelectorNodeTransfer(selector, selectorNodeName, isRootSelectorNode, selectorNodeType, 050 negate, description); 051 put(selectorNode, selectorNodeTransfer); 052 } 053 054 return selectorNodeTransfer; 055 } 056 057}