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

Examples of sg.edu.nus.iss.se07.bc.member.MemberManager


                                        Category category = new Category(categoryCode, categoryName);
                                        String data = category.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new DataAccessException("[CategoryDA::writeData]Failed to create filename " + fileName);
                        }
                } catch (IOException ex) {
                        throw new DataAccessException(ex.getMessage(), ex);
                } finally {
                        try {
                                if (bw != null) {
                                        bw.close();
                                }
View Full Code Here


                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new DataAccessException("[CategoryDA::readData]Record not found.");
                                } else {

                                        if (lines.length < 1) {
                                                throw new DataAccessException("[CategoryDA::readData]Record not found.");
                                        }

                                        for (int i = 0; i < lines.length; i++) {
                                                String record = lines[i];
                                                String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
                                                if (fields == null) {
                                                        Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                        throw new DataAccessException("[CategoryDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                String code = fields[0];
                                                                String name = fields[1];
                                                                if (categoryCode.equalsIgnoreCase(code)) {
                                                                        dataObject = new Category();
                                                                        dataObject.setCategoryCode(code);
                                                                        dataObject.setCategoryName(name);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new DataAccessException("[CategoryDA::readData]File not found.");
                        }
                } catch (IOException ex) {
                        throw new DataAccessException(ex.getMessage(), ex);
                } finally {
                        if (br != null) {
                                try {
                                        br.close();
                                } catch (IOException ex) {
View Full Code Here

                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new DataAccessException("[CategoryDA::readData]Record not found.");
                                } else {

                                        if (lines.length < 1) {
                                                throw new DataAccessException("[CategoryDA::readData]Record not found.");
                                        }

                                        dataObjectSet = new ArrayList<Tuple2<NameValue<String>, NameValue<String>>>();
                                        for (int i = 0; i < lines.length; i++) {
                                                String record = lines[i];
                                                String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
                                                if (fields == null) {
                                                        throw new DataAccessException("[CategoryDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                NameValue<String> categoryCode = new NameValue<String>("CategoryCode", fields[0]);
                                                                NameValue<String> categoryName = new NameValue<String>("CategoryName", fields[1]);
                                                                dataObjectSet.add(new Tuple2<NameValue<String>, NameValue<String>>(categoryCode, categoryName));
                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new DataAccessException("[CategoryDA::readData]File not found.");
                        }
                } catch (IOException ex) {
                        throw new DataAccessException(ex.getMessage(), ex);
                } finally {
                        if (br != null) {
                                try {
                                        br.close();
                                } catch (IOException ex) {
View Full Code Here

         * @param product
         * @return
         * @throws AppException
         */
        public ErrorList create(Product product) throws AppException {
                ErrorList errorList = new ErrorList();

                ProductSet productSet = null;
                try {
                        productSet = list(product.getProductID());
                } catch (AppException ex) {
                        errorList.addError("[ProductManager::create]", ex.getMessage());
                }

                if (productSet != null) {
                        if (productSet.length() != 0) {
                                //means product code is exist, do not allow duplicate product code
                                errorList.addError(MEMBER_DUPLICATE_ENTRY);
                                return errorList;
                        }
                }

                try {
View Full Code Here

                return errorList;
        }

        public ErrorList update(Product newCategory, Product oldCategory) {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

                ErrorList errorList = new ErrorList();
                return errorList;
        }

        public ErrorList delete(Product product) throws AppException {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

                ErrorList errorList = new ErrorList();
                return errorList;
        }

        public ErrorList delete(String productID) throws AppException {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

         * @param product
         * @return
         * @throws AppException
         */
        public ErrorList create(Product product) throws AppException {
                ErrorList errorList = new ErrorList();

                ProductSet productSet = null;
                try {
                        productSet = list(product.getProductID());
                } catch (AppException ex) {
                        errorList.addError("[ProductManager::create]", ex.getMessage());
                }

                if (productSet != null) {
                        if (productSet.length() != 0) {
                                //means product code is exist, do not allow duplicate product code
                                errorList.addError(MEMBER_DUPLICATE_ENTRY);
                                return errorList;
                        }
                }

                try {
View Full Code Here

                return errorList;
        }

        public ErrorList update(Product newCategory, Product oldCategory) {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

                ErrorList errorList = new ErrorList();
                return errorList;
        }

        public ErrorList delete(Product product) throws AppException {
                ErrorList errorList = new ErrorList();
                return errorList;
        }
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.bc.member.MemberManager

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.