001// -------------------------------------------------------------------------------- 002// Copyright 2002-2025 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.printer.server.transfer; 018 019import com.echothree.model.control.core.server.control.EntityInstanceControl; 020import com.echothree.model.control.document.server.control.DocumentControl; 021import com.echothree.model.control.printer.common.transfer.PrinterGroupJobTransfer; 022import com.echothree.model.control.printer.common.workflow.PrinterGroupJobStatusConstants; 023import com.echothree.model.control.printer.server.control.PrinterControl; 024import com.echothree.model.control.workflow.server.control.WorkflowControl; 025import com.echothree.model.data.printer.server.entity.PrinterGroupJob; 026import com.echothree.model.data.user.server.entity.UserVisit; 027import com.echothree.util.server.persistence.Session; 028import javax.enterprise.context.RequestScoped; 029 030@RequestScoped 031public class PrinterGroupJobTransferCache 032 extends BasePrinterTransferCache<PrinterGroupJob, PrinterGroupJobTransfer> { 033 034 DocumentControl documentControl = Session.getModelController(DocumentControl.class); 035 EntityInstanceControl entityInstanceControl = Session.getModelController(EntityInstanceControl.class); 036 PrinterControl printerControl = Session.getModelController(PrinterControl.class); 037 WorkflowControl workflowControl = Session.getModelController(WorkflowControl.class); 038 039 /** Creates a new instance of PrinterGroupJobTransferCache */ 040 protected PrinterGroupJobTransferCache() { 041 super(); 042 043 setIncludeEntityInstance(true); 044 } 045 046 public PrinterGroupJobTransfer getPrinterGroupJobTransfer(UserVisit userVisit, PrinterGroupJob printerGroupJob) { 047 var printerGroupJobTransfer = get(printerGroupJob); 048 049 if(printerGroupJobTransfer == null) { 050 var printerGroupJobDetail = printerGroupJob.getLastDetail(); 051 var printerGroupJobName = printerGroupJobDetail.getPrinterGroupJobName(); 052 var printerGroupTransfer = printerControl.getPrinterGroupTransfer(userVisit, printerGroupJobDetail.getPrinterGroup()); 053 var documentTransfer = documentControl.getDocumentTransfer(userVisit, printerGroupJobDetail.getDocument()); 054 var copies = printerGroupJobDetail.getCopies(); 055 var priority = printerGroupJobDetail.getPriority(); 056 057 var entityInstance = entityInstanceControl.getEntityInstanceByBasePK(printerGroupJob.getPrimaryKey()); 058 var printerGroupJobStatusTransfer = workflowControl.getWorkflowEntityStatusTransferByEntityInstanceUsingNames(userVisit, 059 PrinterGroupJobStatusConstants.Workflow_PRINTER_GROUP_JOB_STATUS, entityInstance); 060 061 printerGroupJobTransfer = new PrinterGroupJobTransfer(printerGroupJobName, printerGroupTransfer, documentTransfer, copies, priority, 062 printerGroupJobStatusTransfer); 063 put(userVisit, printerGroupJob, printerGroupJobTransfer); 064 } 065 066 return printerGroupJobTransfer; 067 } 068 069}