001    package videoautomat.contentcreator.stdactions;
002    import sale.Action;
003    import sale.SaleProcess;
004    import sale.SalesPoint;
005    import data.DataBasket;
006    
007    /**
008     * Standart action to start an {@link sale.SaleProcess}.
009     *
010     * @author Tobias Ruch
011     */
012    public class RunProcessAction implements Action {
013    
014        /**
015             * ID for Serialization.
016             */
017            private static final long serialVersionUID = -8681932162005178429L;
018    
019       /** instance of the process which should be started by this action. */
020       private SaleProcess process;
021       
022       private DataBasket basket;
023       
024       
025       /**
026        * Constructs a new action to start the process.
027        * @param process - {@link sale.SaleProcess} which should be started by this action.
028        */
029       public RunProcessAction(SaleProcess process) {
030          this.process = process;
031       }
032       
033       /**
034        * Constructs a new action to start the process.
035        * @param process - {@link sale.SaleProcess} which should be started by this action.
036        * @param basket - {@link data.ooimpl.DataBasket} attached to the process.
037        */
038       public RunProcessAction(SaleProcess process, DataBasket basket)
039       {
040           this.process = process;
041           this.basket = basket;
042       }
043    
044       /**
045        * Applies the action and start the given process.
046        * @param saleProcess - current {@link sale.SaleProecess}
047        * @param salePoint   - current {@link sale.SalesPoint}
048        */
049       public void doAction(SaleProcess saleProcess, SalesPoint salePoint) throws Throwable {
050          if(basket != null)
051              salePoint.runProcess(process, basket);
052          else
053              salePoint.runProcess(process);
054       }
055    
056    }