public Boolean removeDiscount(ProductInStore p, Store s, User session) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.removeDiscount(session, p)); }
public Boolean addCouponDiscount(User session, Store s, String couponId, ProductInStore p, int percentage, String dueDate) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addNewCoupon(session, couponId, p, percentage, dueDate)); }
public Boolean removeCoupon(Store s, User session, String couponId) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.removeCoupon(session, s, couponId)); }
public Boolean addDiscount(ProductInStore p, int percentage, String dueDate, User session, Store s) { StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addDiscount(session, p, percentage, dueDate)); }
/* * return: * 0 on sucess the SaleID * -1 if user Not Login * -4 if don't have premition * -6 if illegal store id * -8 if illegal sale id * -9 database eror */ public int removeSaleFromStore(User session, int storeId, int saleId) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4); } return(sR.removeSaleFromStore(session, s, saleId)); }
//req 3.4 d public int removeManagerPermission(String permission, int storeId, String manager, User session) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4); //-4 if you do not have permissions } return(sR.removeManagerPermission(session, permission, s, manager)); }
//req 3.4 c /* * return: * 0 on sucess * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal store id * -4 if don't have premition * -5 database eror * -6 manager name doesn't exsist * -7 no such premition * -8 the mannager to add is not a manager in this store * -10 can't remove himself */ public int addManagerPermission(String permission, int storeId, String managerToAdd, User session) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4); //-4 if don't have premition } return(sR.addManagerPermission(session, permission, s, managerToAdd)); }
//req 3.4 a /* * return: * 0 on sucess * -1 if user Not Login * -2 if new manager name not exist * -3 if illegal store id * -4 if don't have premition * -5 database eror * -6 already owner or manneger */ public int addStoreManager(int sId, String newManager, User session) { Store s = StoreManagement.getInstance().getStore(sId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } return(sR.addStoreManager(session, s, newManager)); }
//req 3.3 b /* * return: * 0 on sucess * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount * -6 if illegal store id * -7 if illegal price * -8 if illegal product in store Id * -9 database eror * -10 can't remove himself * -11 not a owner * -12 if dealet creator */ public int removeStoreOwner(int sId, String oldOwner, User session) { Store s = StoreManagement.getInstance().getStore(sId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4); } return(sR.removeStoreOwner(session, s, oldOwner)); }
/* * return: * 0 on sucess the SaleID * -1 if user Not Login * -4 if don't have premition * -5 if illegal amount bigger then amount in stock * -6 if illegal store id * -7 if illegal price * -8 if illegal sale id * -9 database eror * -10 due date not good * -12 if illegal amount */ public int editSale(User session, int storeId, int saleId, int amount, String dueDate) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } return(sR.editSale(session, s, saleId, amount, dueDate)); }
public int removeNoCouponPolicyOnCountry(User session, int storeId, string country) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.removeNoCouponPolicyOnCountry(session, storeId, country)); }
public int removeNoCouponPolicyOnProductInStore(User session, int storeId, int productInStoreId) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.removeNoCouponPolicyOnProductInStore(session, storeId, productInStoreId)); }
public int setNoDiscountPolicyOnCountry(User session, int storeId, String country) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.setNoDiscountPolicyOnCategoty(session, storeId, country)); }
public int removeNoDiscountPolicyOnStore(User session, int storeId) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.removeNoDiscountPolicyOnStore(session, storeId)); }
public int setNoCouponsPolicyOnStore(User session, int storeId) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.setNoCouponsPolicyOnStore(session, storeId)); }
public int setAmountPolicyOnProductInStore(User session, int storeId, int productInStoreId, int minAmount, int maxAmount) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.setAmountPolicyOnProductInStore(session, storeId, productInStoreId, minAmount, maxAmount)); }
public int setAmountPolicyOnCountry(User session, int storeId, string country, int minAmount, int maxAmount) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.setAmountPolicyOnCountry(session, storeId, country, minAmount, maxAmount)); }
public Boolean addCouponDiscount(User session, String couponId, int productInStoreId, int type, string categoryOrProductName, int percentage, String dueDate, string restrictions, int storeId) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addNewCoupon(session, storeId, couponId, productInStoreId, type, categoryOrProductName, percentage, dueDate, restrictions)); }
public int addNewCoupons(User session, int storeId, String couponId, int type, List <int> pisId, List <string> catOrProductsNames , int percentage, string dueDate, string restrictions) { Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.addNewCoupons(session, storeId, couponId, type, pisId, catOrProductsNames, percentage , dueDate, restrictions)); }
//req 3.1 c /* * return: * 0 on sucess * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount * -6 if illegal store id * -7 if illegal price * -8 if illegal product in store Id * -9 database eror */ public int removeProductFromStore(int sId, int pisId, User session) { Store s = StoreManagement.getInstance().getStore(sId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } ProductInStore p = ProductManager.getInstance().getProductInStore(pisId); return(sR.removeProductFromStore(session, s, p)); }
//req 3.1 a /* * return: * 0 > on sucess return productInStoreId * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount * -6 if illegal store id * -7 if illegal price * */ public int addProductInStore(String productName, Double price, int amount, User session, int sId, string category) { if (session == null || !session.getState().isLogedIn() || productName == null || category == null) { return(-1);//-1 if user Not Login } Store s = StoreManagement.getInstance().getStore(sId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } return(sR.addProductInStore(session, s, productName, price, amount, category)); }
//req 3.4 b /* * return: * 0 on sucess * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal store id * -4 if don't have premition * -5 database eror * -6 old manager name doesn't exsist * -10 can't remove himself */ public int removeStoreManager(int sId, String oldManageruserName, User session) { Store s = StoreManagement.getInstance().getStore(sId); if (oldManageruserName == session.getUserName()) { return(-10);// -10 can't remove himself } StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-4);//-4 if don't have premition } return(sR.removeStoreManager(session, s, oldManageruserName)); }
/* * return: * 0 > on sucess the SaleID * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount bigger then amount in stock * -6 if illegal store id * -7 if illegal price * -8 if illegal product in store Id * -9 database eror * -10 due date not good * -11 illegal type of sale not * -12 if illegal amount * -13 product not in this store */ public int addSaleToStore(User session, int storeId, int productInStoreId, int typeOfSale, int amount, String dueDate) { Store s = StoreManagement.getInstance().getStore(storeId); if (session == null || !session.getState().isLogedIn()) { return(-1);//-1 if user Not Login } StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1);//-4 if don't have premition } return(sR.addSaleToStore(session, s, productInStoreId, typeOfSale, amount, dueDate)); }
//not implemented // new Addition for version 2 - need to handle addDiscount function // type: 1 for discount on productsInStore, 2 for discount on category, 3 for discount on entire product (in product archive) public int addDiscounts(User session, int storeId, List <int> productInStores, int type, int percentage, List <string> categorysOrProductsName, string dueDate, string restrictions) { if (type == 3) { return(DiscountsManager.getInstance().addNewDiscounts(type, productInStores, categorysOrProductsName, percentage, dueDate, restrictions)); } Store s = StoreManagement.getInstance().getStore(storeId); StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(-1); } return(sR.addDiscounts(session, storeId, productInStores, type, percentage, categorysOrProductsName , dueDate, restrictions)); }
//req 3.1 b /* * return: * 0 on sucess * -1 if user Not Login * -2 if Store Name already exist * -3 if illegal product name * -4 if don't have premition * -5 if illegal amount * -6 if illegal store id * -7 if illegal price * -8 if illegal product in store Id * -9 database eror */ public virtual int editProductInStore(User session, int sId, int pisId, int quantity, double price) { Store s = StoreManagement.getInstance().getStore(sId); StoreRole sR = StoreRole.getStoreRole(s, session); if (s == null) { return(-6); } if (sR == null) { return(-4);//-4 if don't have premition } ProductInStore p = ProductManager.getInstance().getProductInStore(pisId); return(sR.editProductInStore(session, p, quantity, price)); }
public void init() { WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB(); cDB.emptyDB(); ProductManager.restartInstance(); SalesManager.restartInstance(); StoreManagement.restartInstance(); UserManager.restartInstance(); UserCartsManager.restartInstance(); BuyHistoryManager.restartInstance(); CouponsManager.restartInstance(); DiscountsManager.restartInstance(); RaffleSalesManager.restartInstance(); StorePremissionsArchive.restartInstance(); us = userServices.getInstance(); ss = storeServices.getInstance(); partislav = us.startSession(); us.register(partislav, "partislav", "123456"); us.login(partislav, "partislav", "123456"); manager1 = us.startSession(); us.register(manager1, "manager1", "123456"); us.login(manager1, "manager1", "123456"); manager2 = us.startSession(); us.register(manager2, "manager2", "123456"); us.login(manager2, "manager2", "123456"); int sId = ss.createStore("makolet", partislav); int s2Id = ss.createStore("makolet", partislav); s = StoreManagement.getInstance().getStore(sId); s2 = StoreManagement.getInstance().getStore(s2Id); ownerRole = StoreRole.getStoreRole(s, partislav); ownerRole2 = StoreRole.getStoreRole(s, partislav); ownerRole.addStoreManager(partislav, s, "manager1"); ownerRole.addStoreManager(partislav, s, "manager2"); ownerRole.addStoreManager(partislav, s2, "manager1"); ownerRole.addStoreManager(partislav, s2, "manager2"); }
//req 3.3 a public Boolean addStoreOwner(int storeId, String newOwner, User session) { if (newOwner == null || session == null) { return(false); } User isExist = UserManager.getInstance().getUser(newOwner); Store s = StoreManagement.getInstance().getStore(storeId); if (isExist == null) { return(false); } StoreRole sR = StoreRole.getStoreRole(s, session); if (sR == null) { return(false); } return(sR.addStoreOwner(session, s, newOwner)); }