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