Examples of ProductManager


Examples of sg.edu.nus.iss.se07.bc.ProductManager

        public boolean addProduct(String categorycode, String id, String name, String description, int quantity, float price, String barcode, int reorderQty, int orderQty) throws AppException {
                boolean success = true;

                String productid = categorycode + "/" + id;
                Product dataObject = new Product(productid, name, description, quantity, price, barcode, reorderQty, orderQty);
                ProductManager dataObjectManager = new ProductManager();
                try {
                        //add product to the file
                        success = dataObjectManager.addProduct(dataObject);
                        if (success) {
                                //update caching
                                Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                if (categoryDataSet != null) {
                                        dataObject.setCategory(categoryDataSet.get(categorycode));
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public boolean updateProduct(String id, String name, String description, Integer quantity, Float price, String barcode, Integer reorderQty, Integer orderQty) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product oldDataObject = null;
                try {
                        oldDataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }

                if (oldDataObject != null) {
                        Product newDataObject = new Product(id, name, description, quantity, price, barcode, reorderQty, orderQty);
                        try {
                                success = dataObjectManager.updateProduct(oldDataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public int getProductQty(String id) throws AppException {
                int qty = -99999;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        //Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);                        return qty;
                }

                if (dataObject != null) {
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

         * @throws AppException
         */
        public boolean increaseProductQty(String id, int amount) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        return false;
                }

                if (dataObject != null) {

                        int currQty = dataObject.getQuantityAvailable();
                        int newQty = currQty + amount;

                        Product newDataObject = new Product();
                        newDataObject.setProductID(dataObject.getProductID());
                        newDataObject.setProductName(dataObject.getProductName());
                        newDataObject.setProductDescription(dataObject.getProductDescription());
                        newDataObject.setQuantityAvailable(newQty);
                        newDataObject.setProductPrice(dataObject.getProductPrice());
                        newDataObject.setBarcodeNumber(dataObject.getBarcodeNumber());
                        newDataObject.setReorderQuantity(dataObject.getReorderQuantity());
                        newDataObject.setOrderQuantity(dataObject.getOrderQuantity());

                        try {
                                success = dataObjectManager.updateProduct(dataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

         * TO DO : Please do necessary change and test it !!!
         */
        public boolean decreaseProductQty(String id, int amount) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                }

                if (dataObject != null) {

                        int currQty = dataObject.getQuantityAvailable();
                        int newQty = currQty - amount;

                        Product newDataObject = new Product();
                        newDataObject.setProductID(dataObject.getProductID());
                        newDataObject.setProductName(dataObject.getProductName());
                        newDataObject.setProductDescription(dataObject.getProductDescription());
                        newDataObject.setQuantityAvailable(newQty);
                        newDataObject.setProductPrice(dataObject.getProductPrice());
                        newDataObject.setBarcodeNumber(dataObject.getBarcodeNumber());
                        newDataObject.setReorderQuantity(dataObject.getReorderQuantity());
                        newDataObject.setOrderQuantity(dataObject.getOrderQuantity());

                        try {
                                success = dataObjectManager.updateProduct(dataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public ArrayList<Product> getProductBelowThreshold() throws AppException {
                ArrayList<Product> dataObjectSet = null;

                ProductManager productManager = new ProductManager();
                try {
                        dataObjectSet = productManager.getProductBelowThreshold();
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public Product getProductByBarcode(String barcode) throws AppException {
                Product dataObject = null;

                ProductManager productManager = new ProductManager();
                try {
                        dataObject = productManager.getProductByBarcode(barcode);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public ArrayList<Product> listProducts() throws AppException {
                ArrayList<Product> dataObjectSet = null;

                ProductManager productManager = new ProductManager();
                try {
                        dataObjectSet = productManager.listProducts();
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

        }

        public boolean removeProduct(String id) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                try {
                        success = dataObjectManager.deleteProduct(id);
                        if (success) {
                                //update caching
                                Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                if (productDataSet != null) {
                                        Product dataObject = productDataSet.get(id);
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.ProductManager

                productDB = datafolder;
                productReport = reportfolder;
        }

        public void testDataEntry() {
                ProductManager dataObjectManager = new ProductManager(productDB, productDBFormat);

                //create new product
                Product dataObject1 = new Product("CLO/1","Centenary Jumper","A really nice momento",315,(float) 21.45,"1234",10,100);
                try {
                        dataObjectManager.addProduct(dataObject1);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }

                Product dataObject2 = new Product("MUG/1","Centenary Mug","A really nice mug this time",525,(float) 10.25,"9876",25,150);
                try {
                        dataObjectManager.addProduct(dataObject2);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }

                Product dataObject3 = new Product("STA/1","NUS Pen","A really cute blue pen",768,(float) 5.75,"123459876",50,250);
                try {
                        dataObjectManager.addProduct(dataObject3);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }
               
                Product dataObject4 = new Product("STA/2","NUS Notepad","Great notepad for those lectures",1000,(float) 3.15,"6789",25,75);
                try {
                        dataObjectManager.addProduct(dataObject3);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }               

                dataObjectManager = null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.