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.control.user.purchase.server;
018
019import com.echothree.control.user.purchase.common.PurchaseRemote;
020import com.echothree.control.user.purchase.common.form.*;
021import com.echothree.control.user.purchase.server.command.*;
022import com.echothree.model.data.user.common.pk.UserVisitPK;
023import com.echothree.util.common.command.CommandResult;
024import javax.ejb.Stateless;
025import javax.enterprise.inject.spi.CDI;
026
027@Stateless
028public class PurchaseBean
029        extends PurchaseFormsImpl
030        implements PurchaseRemote, PurchaseLocal {
031    
032    // -------------------------------------------------------------------------
033    //   Testing
034    // -------------------------------------------------------------------------
035    
036    @Override
037    public String ping() {
038        return "PurchaseBean is alive!";
039    }
040
041    // --------------------------------------------------------------------------------
042    //   Purchase Orders
043    // --------------------------------------------------------------------------------
044
045    @Override
046    public CommandResult createPurchaseOrder(UserVisitPK userVisitPK, CreatePurchaseOrderForm form) {
047        return CDI.current().select(CreatePurchaseOrderCommand.class).get().run(userVisitPK, form);
048    }
049
050    @Override
051    public CommandResult getPurchaseOrderStatusChoices(UserVisitPK userVisitPK, GetPurchaseOrderStatusChoicesForm form) {
052        return CDI.current().select(GetPurchaseOrderStatusChoicesCommand.class).get().run(userVisitPK, form);
053    }
054
055    @Override
056    public CommandResult setPurchaseOrderStatus(UserVisitPK userVisitPK, SetPurchaseOrderStatusForm form) {
057        return CDI.current().select(SetPurchaseOrderStatusCommand.class).get().run(userVisitPK, form);
058    }
059
060    // --------------------------------------------------------------------------------
061    //   Purchase Invoices
062    // --------------------------------------------------------------------------------
063
064    @Override
065    public CommandResult createPurchaseInvoice(UserVisitPK userVisitPK, CreatePurchaseInvoiceForm form) {
066        return CDI.current().select(CreatePurchaseInvoiceCommand.class).get().run(userVisitPK, form);
067    }
068
069    @Override
070    public CommandResult getPurchaseInvoiceStatusChoices(UserVisitPK userVisitPK, GetPurchaseInvoiceStatusChoicesForm form) {
071        return CDI.current().select(GetPurchaseInvoiceStatusChoicesCommand.class).get().run(userVisitPK, form);
072    }
073
074    @Override
075    public CommandResult setPurchaseInvoiceStatus(UserVisitPK userVisitPK, SetPurchaseInvoiceStatusForm form) {
076        return CDI.current().select(SetPurchaseInvoiceStatusCommand.class).get().run(userVisitPK, form);
077    }
078
079    // --------------------------------------------------------------------------------
080    //   Purchase Invoice Lines
081    // --------------------------------------------------------------------------------
082    
083    @Override
084    public CommandResult createPurchaseInvoiceLine(UserVisitPK userVisitPK, CreatePurchaseInvoiceLineForm form) {
085        return CDI.current().select(CreatePurchaseInvoiceLineCommand.class).get().run(userVisitPK, form);
086    }
087
088}