001// -------------------------------------------------------------------------------- 002// Copyright 2002-2026 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.sales.server.logic; 018 019import com.echothree.model.control.order.common.transfer.OrderTimeTransfer; 020import com.echothree.model.control.order.server.logic.OrderTimeLogic; 021import com.echothree.model.data.order.server.entity.Order; 022import com.echothree.model.data.user.server.entity.UserVisit; 023import com.echothree.util.common.persistence.BasePK; 024import com.echothree.util.server.control.BaseLogic; 025import com.echothree.util.server.message.ExecutionErrorAccumulator; 026import java.util.List; 027import javax.enterprise.context.ApplicationScoped; 028import javax.inject.Inject; 029 030@ApplicationScoped 031public class SalesOrderTimeLogic 032 extends BaseLogic { 033 034 @Inject 035 OrderTimeLogic orderTimeLogic; 036 037 @Inject 038 SalesOrderLogic salesOrderLogic; 039 040 protected SalesOrderTimeLogic() { 041 super(); 042 } 043 044 public void createOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final Long time, final BasePK createdBy) { 045 var order = salesOrderLogic.getOrderByName(eea, orderName); 046 047 if(eea == null || !eea.hasExecutionErrors()) { 048 createOrderTime(eea, order, orderTimeTypeName, time, createdBy); 049 } 050 } 051 052 public void createOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final Long time, final BasePK createdBy) { 053 // TODO: Check Order's status. 054 055 orderTimeLogic.createOrderTime(eea, order, orderTimeTypeName, time, createdBy); 056 } 057 058 public void updateOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final Long time, final BasePK updatedBy) { 059 var order = salesOrderLogic.getOrderByName(eea, orderName); 060 061 if(eea == null || !eea.hasExecutionErrors()) { 062 updateOrderTime(eea, order, orderTimeTypeName, time, updatedBy); 063 } 064 } 065 066 public void updateOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final Long time, final BasePK updatedBy) { 067 // TODO: Check Order's status. 068 069 orderTimeLogic.updateOrderTime(eea, order, orderTimeTypeName, time, updatedBy); 070 } 071 072 public OrderTimeTransfer getOrderTimeTransfer(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final String orderName, final String orderTimeTypeName) { 073 var order = salesOrderLogic.getOrderByName(eea, orderName); 074 OrderTimeTransfer result = null; 075 076 if(eea == null || !eea.hasExecutionErrors()) { 077 result = getOrderTimeTransfer(eea, userVisit, order, orderTimeTypeName); 078 } 079 080 return result; 081 } 082 083 public OrderTimeTransfer getOrderTimeTransfer(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final Order order, final String orderTimeTypeName) { 084 return orderTimeLogic.getOrderTimeTransfer(eea, userVisit, order, orderTimeTypeName); 085 } 086 087 public List<OrderTimeTransfer> getOrderTimeTransfersByOrder(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final String orderName) { 088 var order = salesOrderLogic.getOrderByName(eea, orderName); 089 090 return orderTimeLogic.getOrderTimeTransfersByOrder(eea, userVisit, order); 091 } 092 093 public void deleteOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final BasePK deletedBy) { 094 var order = salesOrderLogic.getOrderByName(eea, orderName); 095 096 if(eea == null || !eea.hasExecutionErrors()) { 097 deleteOrderTime(eea, order, orderTimeTypeName, deletedBy); 098 } 099 } 100 101 public void deleteOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final BasePK deletedBy) { 102 // TODO: Check Order's status. 103 104 orderTimeLogic.deleteOrderTime(eea, order, orderTimeTypeName, deletedBy); 105 } 106 107}