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.TrainingClassSectionTransfer; 023import com.echothree.model.control.training.common.transfer.TrainingClassSectionTranslationTransfer; 024import com.echothree.model.control.training.server.control.TrainingControl; 025import com.echothree.model.data.core.server.entity.MimeType; 026import com.echothree.model.data.training.server.entity.TrainingClassSectionTranslation; 027import com.echothree.model.data.user.server.entity.UserVisit; 028import com.echothree.util.server.persistence.Session; 029 030public class TrainingClassSectionTranslationTransferCache 031 extends BaseTrainingDescriptionTransferCache<TrainingClassSectionTranslation, TrainingClassSectionTranslationTransfer> { 032 033 CoreControl coreControl = Session.getModelController(CoreControl.class); 034 035 /** Creates a new instance of TrainingClassSectionTranslationTransferCache */ 036 public TrainingClassSectionTranslationTransferCache(UserVisit userVisit, TrainingControl trainingControl) { 037 super(userVisit, trainingControl); 038 } 039 040 public TrainingClassSectionTranslationTransfer getTrainingClassSectionTranslationTransfer(TrainingClassSectionTranslation trainingClassSectionTranslation) { 041 TrainingClassSectionTranslationTransfer trainingClassSectionTranslationTransfer = get(trainingClassSectionTranslation); 042 043 if(trainingClassSectionTranslationTransfer == null) { 044 LanguageTransfer languageTransfer = partyControl.getLanguageTransfer(userVisit, trainingClassSectionTranslation.getLanguage()); 045 TrainingClassSectionTransfer trainingClassSectionTransfer = trainingControl.getTrainingClassSectionTransfer(userVisit, trainingClassSectionTranslation.getTrainingClassSection()); 046 String description = trainingClassSectionTranslation.getDescription(); 047 MimeType overviewMimeType = trainingClassSectionTranslation.getOverviewMimeType(); 048 MimeTypeTransfer overviewMimeTypeTransfer = overviewMimeType == null? null: coreControl.getMimeTypeTransfer(userVisit, overviewMimeType); 049 String overview = trainingClassSectionTranslation.getOverview(); 050 MimeType introductionMimeType = trainingClassSectionTranslation.getIntroductionMimeType(); 051 MimeTypeTransfer introductionMimeTypeTransfer = introductionMimeType == null? null: coreControl.getMimeTypeTransfer(userVisit, introductionMimeType); 052 String introduction = trainingClassSectionTranslation.getIntroduction(); 053 054 trainingClassSectionTranslationTransfer = new TrainingClassSectionTranslationTransfer(trainingClassSectionTransfer, languageTransfer, description, 055 overviewMimeTypeTransfer, overview, introductionMimeTypeTransfer, introduction); 056 put(trainingClassSectionTranslation, trainingClassSectionTranslationTransfer); 057 } 058 059 return trainingClassSectionTranslationTransfer; 060 } 061 062}