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 /** instance of the process which should be started by this action. */ 015 private SaleProcess process; 016 017 private DataBasket basket; 018 019 020 /** 021 * Constructs a new action to start the process. 022 * @param process - {@link sale.SaleProcess} which should be started by this action. 023 */ 024 public RunProcessAction(SaleProcess process) { 025 this.process = process; 026 } 027 028 /** 029 * Constructs a new action to start the process. 030 * @param process - {@link sale.SaleProcess} which should be started by this action. 031 * @param basket - {@link data.ooimpl.DataBasket} attached to the process. 032 */ 033 public RunProcessAction(SaleProcess process, DataBasket basket) 034 { 035 this.process = process; 036 this.basket = basket; 037 } 038 039 /** 040 * Applies the action and start the given process. 041 * @param saleProcess - current {@link sale.SaleProecess} 042 * @param salePoint - current {@link sale.SalesPoint} 043 */ 044 public void doAction(SaleProcess saleProcess, SalesPoint salePoint) throws Throwable { 045 if(basket != null) 046 salePoint.runProcess(process, basket); 047 else 048 salePoint.runProcess(process); 049 } 050 051 }