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.training.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.training.common.transfer.TrainingClassPageTransfer; 023import com.echothree.model.control.training.common.transfer.TrainingClassPageTranslationTransfer; 024import com.echothree.model.control.training.server.control.TrainingControl; 025import com.echothree.model.data.training.server.entity.TrainingClassPageTranslation; 026import com.echothree.model.data.user.server.entity.UserVisit; 027import com.echothree.util.server.persistence.Session; 028 029public class TrainingClassPageTranslationTransferCache 030 extends BaseTrainingDescriptionTransferCache<TrainingClassPageTranslation, TrainingClassPageTranslationTransfer> { 031 032 CoreControl coreControl = Session.getModelController(CoreControl.class); 033 034 /** Creates a new instance of TrainingClassPageTranslationTransferCache */ 035 public TrainingClassPageTranslationTransferCache(UserVisit userVisit, TrainingControl trainingControl) { 036 super(userVisit, trainingControl); 037 } 038 039 public TrainingClassPageTranslationTransfer getTrainingClassPageTranslationTransfer(TrainingClassPageTranslation trainingClassPageTranslation) { 040 TrainingClassPageTranslationTransfer trainingClassPageTranslationTransfer = get(trainingClassPageTranslation); 041 042 if(trainingClassPageTranslationTransfer == null) { 043 LanguageTransfer languageTransfer = partyControl.getLanguageTransfer(userVisit, trainingClassPageTranslation.getLanguage()); 044 TrainingClassPageTransfer trainingClassPageTransfer = trainingControl.getTrainingClassPageTransfer(userVisit, trainingClassPageTranslation.getTrainingClassPage()); 045 String description = trainingClassPageTranslation.getDescription(); 046 MimeTypeTransfer pageMimeTypeTransfer = coreControl.getMimeTypeTransfer(userVisit, trainingClassPageTranslation.getPageMimeType()); 047 String page = trainingClassPageTranslation.getPage(); 048 049 trainingClassPageTranslationTransfer = new TrainingClassPageTranslationTransfer(trainingClassPageTransfer, languageTransfer, description, 050 pageMimeTypeTransfer, page); 051 put(trainingClassPageTranslation, trainingClassPageTranslationTransfer); 052 } 053 054 return trainingClassPageTranslationTransfer; 055 } 056 057}