Package sg.edu.nus.iss.se07.bc

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


         * @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

         * 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

        }

        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

        }

        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

        }

        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

        }

        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

                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

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

                Product dataObject = new Product(id, name, description, quantity, price, barcode, reorderQty, orderQty);
                ProductManager dataObjectManager = new ProductManager();
                try {
                        success = dataObjectManager.addProduct(dataObject);
                } catch (AppException ex) {
                        //Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        //return false;
                }
View Full Code Here

        }

        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;
                }
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.bc.ProductManager

Copyright © 2018 www.massapicom. 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.