Package sg.edu.nus.iss.se07.common.exceptions

Examples of sg.edu.nus.iss.se07.common.exceptions.DataAccessException


                productValidator = new ProductValidator(dataObject);
                boolean valid = productValidator.validateProduct();
                if (valid) {
                        try {
                                productManager = new ProductManager();
                                ErrorList errorList = productManager.create(dataObject);
                                for (int i = 0; i < errorList.length(); i++) {
                                        Logger.getLogger(ProductTester.class.getName()).log(Level.INFO, errorList.getErrorMessage(i));
                                }
                        } catch (AppException ex) {
                                Logger.getLogger(ProductTester.class.getName()).log(Level.SEVERE, null, ex);
                        }
                } else {
                        ErrorList errorList = productValidator.getErrors();
                        if (errorList.hasError()) {
                                for (int i = 0; i < errorList.length(); i++) {
                                        Logger.getLogger(ProductTester.class.getName()).log(Level.SEVERE, errorList.getErrorMessage(i));
                                }
                        }
                }

                productManager = null;
View Full Code Here


                memberValidator = new MemberValidator(dataObject);
                boolean valid = memberValidator.validateMember();
                if (valid) {
                        try {
                                memberManager = new MemberManager();
                                ErrorList errorList = memberManager.create(dataObject);
                                for (int i = 0; i < errorList.length(); i++) {
                                        Logger.getLogger(MemberTester.class.getName()).log(Level.INFO, errorList.getErrorMessage(i));
                                }
                        } catch (AppException ex) {
                                Logger.getLogger(MemberTester.class.getName()).log(Level.SEVERE, null, ex);
                        }
                } else {
                        ErrorList errorList = memberValidator.getErrors();
                        if (errorList.hasError()) {
                                for (int i = 0; i < errorList.length(); i++) {
                                        Logger.getLogger(MemberTester.class.getName()).log(Level.SEVERE, errorList.getErrorMessage(i));
                                }
                        }
                }

                memberManager = null;
View Full Code Here

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

                MemberSet memberSet = null;
                try {
                        memberSet = list(member.getMemberID());
                } catch (AppException ex) {
                        errorList.addError("[MemberManager::create]", ex.getMessage());
                }

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

                try {
View Full Code Here

                return errorList;
        }

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

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

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

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

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

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

                                        Category category = new Category(categoryCode, categoryName);
                                        String data = category.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new AppException("Failed to create filename " + fileName, "[CategoryDA::writeDataSet]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::writeDataSet]", 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 AppException("Record not found.", "[CategoryDA::readData]", null);
                                } else {

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

                                        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 AppException("Unable to read record no " + (String.valueOf(i + 1)), "[CategoryDA::readData]", null);
                                                } 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 catCode = fields[0];
                                                                String catName = fields[1];
                                                                if (catCode == null) {
                                                                        catCode = "";
                                                                }

                                                                if (catName == null) {
                                                                        catName = "";
                                                                }

                                                                if (categoryCode.equalsIgnoreCase(catCode)) {
                                                                        dataObject = new Category();
                                                                        dataObject.setCategoryCode(catCode);
                                                                        dataObject.setCategoryName(catName);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new AppException("File not found.", "[CategoryDA::readData]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::readData]", 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 AppException("Record not found.", "[CategoryDA::readDataSet]", null);
                                } else {

                                        if (lines.length < 1) {
                                                throw new AppException("Record not found.", "[CategoryDA::readDataSet]", null);
                                        }

                                        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 AppException("Unable to read record no " + (String.valueOf(i + 1)), "[CategoryDA::readDataSet]", null);
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(CategoryDA.class.getName()).log(Level.SEVERE, "[CategoryDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {

                                                                //get the value from file and verify it
                                                                String catCode = fields[0];
                                                                String catName = fields[1];
                                                                if (catCode == null) {
                                                                        catCode = "";
                                                                }

                                                                if (catName == null) {
                                                                        catName = "";
                                                                }

                                                                //valid row
                                                                if (!"".equalsIgnoreCase(catCode) && !"".equalsIgnoreCase(catName)) {
                                                                        NameValue<String> categoryCode = new NameValue<String>("CategoryCode", catCode);
                                                                        NameValue<String> categoryName = new NameValue<String>("CategoryName", catName);
                                                                        dataObjectSet.add(new Tuple2<NameValue<String>, NameValue<String>>(categoryCode, categoryName));
                                                                }

                                                        }
                                                }
                                        }
                                }
                        } else {
                                throw new AppException("File not found.", "[CategoryDA::readDataSet]", null);
                        }
                } catch (IOException ex) {
                        throw new AppException(ex.getMessage(), "[CategoryDA::readDataSet]", ex);
                } finally {
                        if (br != null) {
                                try {
                                        br.close();
                                } catch (IOException ex) {
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.common.exceptions.DataAccessException

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.