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

Examples of sg.edu.nus.iss.se07.bc.category.CategoryManager


         * @throws sg.edu.nus.iss.se07.common.exceptions.AppException
         */
        public ArrayList<Category> listCategories() throws AppException {
                ArrayList<Category> dataObjectSet = null;

                CategoryManager categoryManager = new CategoryManager();
                try {
                        dataObjectSet = categoryManager.listCategory();
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }

View Full Code Here


        public String printCategoryReport() throws AppException {
                boolean success = true;
                String reportfilename = "";

                CategoryReport categoryReport = new CategoryReport();
                try {
                        success = categoryReport.generateReport();
                        if (success) {
                                reportfilename = categoryReport.getFileOutputName();
                        }
                } catch (AppException ex) {
                        success = false;
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
View Full Code Here

        public String printTransactionReceipt(ArrayList<Tuple4<String, String, Integer, Date>> purchases, int finaldeem, String memberID, float totalAmt, int deempoint, float dis, float grandtotal) throws AppException {
                boolean success = true;
                String reportfilename = "";

                CheckoutReport checkoutReport = new CheckoutReport();
                try {
                        success = checkoutReport.generateReport(purchases, finaldeem, memberID, totalAmt, deempoint, dis, grandtotal);
                        if (success) {
                                reportfilename = checkoutReport.getFileOutputName();
                        }
                } catch (AppException ex) {
                        success = false;
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
View Full Code Here

                                for (int i = 0; i < memberSet.size(); i++) {

                                        String memberID = memberSet.get(i).getItem1().getValue();
                                        String memberName = memberSet.get(i).getItem2().getValue();
                                        int memberPoint = memberSet.get(i).getItem3().getValue();
                                        Member member = new Member(memberID, memberName, memberPoint);
                                        String data = member.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new DataAccessException("[MemberDA::writeData]Failed to create filename " + fileName);
                        }
View Full Code Here

         *
         * @param memberID
         * @return Member records in form Array List.
         */
        public Member readData(String memberID) throws DataAccessException {
                Member dataObject = null;
                BufferedReader br = null;

                try {
                        br = FileUtil.getBufferedReader(fileName);
                        if (br != null) {
                                String contents = FileUtil.getContents(br);
                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new DataAccessException("[MemberDA::readData]Record not found.");
                                } else {

                                        if (lines.length < 1) {
                                                throw new DataAccessException("[MemberDA::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(MemberDA.class.getName()).log(Level.SEVERE, "[MemberDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                        throw new DataAccessException("[MemberDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                } else {
                                                        if (fields.length != 3) {
                                                                Logger.getLogger(MemberDA.class.getName()).log(Level.SEVERE, "[MemberDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                //get all member value
                                                                String code = fields[0];
                                                                String name = fields[1];
                                                                int point = -1;
                                                                try {
                                                                        point = Integer.parseInt(fields[2]);
                                                                } catch (NumberFormatException nfx) {
                                                                        throw new DataAccessException(nfx.getMessage(), nfx);
                                                                }

                                                                //match
                                                                if (memberID.equalsIgnoreCase(code)) {
                                                                        dataObject = new Member();
                                                                        dataObject.setMemberID(code);
                                                                        dataObject.setMemberName(name);
                                                                        dataObject.setMemberPoint(point);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
View Full Code Here

        }

        public boolean addMember(String id, String name) throws AppException {
                boolean success = true;

                Member dataObject = new Member(id, name);
                MemberManager dataObjectManager = new MemberManager();

                try {
                        success = dataObjectManager.addMember(dataObject);
                        if (success) {
View Full Code Here

        public boolean updateMember(String id, String newName) throws AppException {

                boolean success = true;

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

                if (oldDataObject != null) {
                        Member newDataObject = new Member(id, newName, oldDataObject.getMemberPoint());
                        try {
                                success = dataObjectManager.updateMember(oldDataObject, newDataObject);
                                if (success) {
                                        //update to the cache
                                        Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
View Full Code Here

        public boolean updateMember(String id, int newPoint) throws AppException {
                boolean success = true;

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

                if (oldDataObject != null) {
                        Member newDataObject = new Member(id, oldDataObject.getMemberName(), newPoint);
                        try {
                                success = dataObjectManager.updateMember(oldDataObject, newDataObject);
                                if (success) {
                                        //update to the cache
                                        Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
View Full Code Here

        public int getMemberPoint(String id) throws AppException {
                int point = -99999;

                MemberManager dataObjectManager = new MemberManager();
                Member dataObject = null;
                try {
                        dataObject = dataObjectManager.selectMember(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }

                if (dataObject != null) {
                        point = dataObject.getMemberPoint();
                } else {
                        return point;
                }

                return point;
View Full Code Here

                return reportfilename;
        }

        public Member selectMember(String id) throws AppException {
                Member dataObject = null;

                MemberManager memberManager = new MemberManager();
                try {
                        dataObject = memberManager.selectMember(id);
                } catch (AppException ex) {
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.bc.category.CategoryManager

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.