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.tax.server.transfer; 018 019import com.echothree.model.control.core.common.transfer.MimeTypeTransfer; 020import com.echothree.model.control.core.server.control.CoreControl; 021import com.echothree.model.control.party.common.transfer.LanguageTransfer; 022import com.echothree.model.control.tax.common.transfer.TaxClassificationTransfer; 023import com.echothree.model.control.tax.common.transfer.TaxClassificationTranslationTransfer; 024import com.echothree.model.control.tax.server.control.TaxControl; 025import com.echothree.model.data.core.server.entity.MimeType; 026import com.echothree.model.data.tax.server.entity.TaxClassificationTranslation; 027import com.echothree.model.data.user.server.entity.UserVisit; 028import com.echothree.util.server.persistence.Session; 029 030public class TaxClassificationTranslationTransferCache 031 extends BaseTaxDescriptionTransferCache<TaxClassificationTranslation, TaxClassificationTranslationTransfer> { 032 033 CoreControl coreControl = Session.getModelController(CoreControl.class); 034 035 /** Creates a new instance of TaxClassificationTranslationTransferCache */ 036 public TaxClassificationTranslationTransferCache(UserVisit userVisit, TaxControl taxControl) { 037 super(userVisit, taxControl); 038 } 039 040 @Override 041 public TaxClassificationTranslationTransfer getTransfer(TaxClassificationTranslation taxClassificationTranslation) { 042 TaxClassificationTranslationTransfer taxClassificationTranslationTransfer = get(taxClassificationTranslation); 043 044 if(taxClassificationTranslationTransfer == null) { 045 TaxClassificationTransfer taxClassificationTransfer = taxControl.getTaxClassificationTransfer(userVisit, taxClassificationTranslation.getTaxClassification()); 046 LanguageTransfer languageTransfer = partyControl.getLanguageTransfer(userVisit, taxClassificationTranslation.getLanguage()); 047 String description = taxClassificationTranslation.getDescription(); 048 MimeType overviewMimeType = taxClassificationTranslation.getOverviewMimeType(); 049 MimeTypeTransfer overviewMimeTypeTransfer = overviewMimeType == null? null: coreControl.getMimeTypeTransfer(userVisit, overviewMimeType); 050 String overview = taxClassificationTranslation.getOverview(); 051 052 taxClassificationTranslationTransfer = new TaxClassificationTranslationTransfer(languageTransfer, 053 taxClassificationTransfer, description, overviewMimeTypeTransfer, overview); 054 put(taxClassificationTranslation, taxClassificationTranslationTransfer); 055 } 056 057 return taxClassificationTranslationTransfer; 058 } 059 060}