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.geo.server.transfer; 018 019import com.echothree.model.control.geo.common.transfer.GeoCodeScopeTransfer; 020import com.echothree.model.control.geo.server.control.GeoControl; 021import com.echothree.model.data.geo.server.entity.GeoCodeScope; 022import com.echothree.model.data.geo.server.entity.GeoCodeScopeDetail; 023import com.echothree.model.data.user.server.entity.UserVisit; 024 025public class GeoCodeScopeTransferCache 026 extends BaseGeoTransferCache<GeoCodeScope, GeoCodeScopeTransfer> { 027 028 /** Creates a new instance of GeoCodeScopeTransferCache */ 029 public GeoCodeScopeTransferCache(UserVisit userVisit, GeoControl geoControl) { 030 super(userVisit, geoControl); 031 032 setIncludeEntityInstance(true); 033 } 034 035 public GeoCodeScopeTransfer getGeoCodeScopeTransfer(GeoCodeScope geoCodeScope) { 036 GeoCodeScopeTransfer geoCodeScopeTransfer = get(geoCodeScope); 037 038 if(geoCodeScopeTransfer == null) { 039 GeoCodeScopeDetail geoCodeScopeDetail = geoCodeScope.getLastDetail(); 040 String geoCodeScopeName = geoCodeScopeDetail.getGeoCodeScopeName(); 041 Boolean isDefault = geoCodeScopeDetail.getIsDefault(); 042 Integer sortOrder = geoCodeScopeDetail.getSortOrder(); 043 String description = geoControl.getBestGeoCodeScopeDescription(geoCodeScope, getLanguage()); 044 045 geoCodeScopeTransfer = new GeoCodeScopeTransfer(geoCodeScopeName, isDefault, sortOrder, description); 046 put(geoCodeScope, geoCodeScopeTransfer); 047 } 048 049 return geoCodeScopeTransfer; 050 } 051 052}