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.enterprise.inject.spi.CDI; 029import javax.inject.Inject; 030 031@ApplicationScoped 032public class SalesOrderTimeLogic 033 extends BaseLogic { 034 035 protected SalesOrderTimeLogic() { 036 super(); 037 } 038 039 public static SalesOrderTimeLogic getInstance() { 040 return CDI.current().select(SalesOrderTimeLogic.class).get(); 041 } 042 043 @Inject 044 OrderTimeLogic orderTimeLogic; 045 046 @Inject 047 SalesOrderLogic salesOrderLogic; 048 049 public void createOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final Long time, final BasePK createdBy) { 050 var order = salesOrderLogic.getOrderByName(eea, orderName); 051 052 if(eea == null || !eea.hasExecutionErrors()) { 053 createOrderTime(eea, order, orderTimeTypeName, time, createdBy); 054 } 055 } 056 057 public void createOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final Long time, final BasePK createdBy) { 058 // TODO: Check Order's status. 059 060 orderTimeLogic.createOrderTime(eea, order, orderTimeTypeName, time, createdBy); 061 } 062 063 public void updateOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final Long time, final BasePK updatedBy) { 064 var order = salesOrderLogic.getOrderByName(eea, orderName); 065 066 if(eea == null || !eea.hasExecutionErrors()) { 067 updateOrderTime(eea, order, orderTimeTypeName, time, updatedBy); 068 } 069 } 070 071 public void updateOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final Long time, final BasePK updatedBy) { 072 // TODO: Check Order's status. 073 074 orderTimeLogic.updateOrderTime(eea, order, orderTimeTypeName, time, updatedBy); 075 } 076 077 public OrderTimeTransfer getOrderTimeTransfer(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final String orderName, final String orderTimeTypeName) { 078 var order = salesOrderLogic.getOrderByName(eea, orderName); 079 OrderTimeTransfer result = null; 080 081 if(eea == null || !eea.hasExecutionErrors()) { 082 result = getOrderTimeTransfer(eea, userVisit, order, orderTimeTypeName); 083 } 084 085 return result; 086 } 087 088 public OrderTimeTransfer getOrderTimeTransfer(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final Order order, final String orderTimeTypeName) { 089 return orderTimeLogic.getOrderTimeTransfer(eea, userVisit, order, orderTimeTypeName); 090 } 091 092 public List<OrderTimeTransfer> getOrderTimeTransfersByOrder(final ExecutionErrorAccumulator eea, final UserVisit userVisit, final String orderName) { 093 var order = salesOrderLogic.getOrderByName(eea, orderName); 094 095 return orderTimeLogic.getOrderTimeTransfersByOrder(eea, userVisit, order); 096 } 097 098 public void deleteOrderTime(final ExecutionErrorAccumulator eea, final String orderName, final String orderTimeTypeName, final BasePK deletedBy) { 099 var order = salesOrderLogic.getOrderByName(eea, orderName); 100 101 if(eea == null || !eea.hasExecutionErrors()) { 102 deleteOrderTime(eea, order, orderTimeTypeName, deletedBy); 103 } 104 } 105 106 public void deleteOrderTime(final ExecutionErrorAccumulator eea, final Order order, final String orderTimeTypeName, final BasePK deletedBy) { 107 // TODO: Check Order's status. 108 109 orderTimeLogic.deleteOrderTime(eea, order, orderTimeTypeName, deletedBy); 110 } 111 112}