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

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


                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(MemberReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(),"[MemberReport::generateReport]", ex);
                } finally {
                        try {
                                bw.close();
                        } catch (IOException ex) {
                                Logger.getLogger(MemberReport.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here


                //validate whethere the same member id exist inside the system
                Member dataObject = selectMember(member.getMemberID());
                if (dataObject != null) {
                        success = false;
                        throw new AppException("The same Member ID has found on the system", "[MemberManager::addMember]", null);
                }

                try {
                        memberDA = new MemberDA(filename, format);
                        memberDA.writeData(member, true);
View Full Code Here

                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(ProductReport.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw new AppException(ex.getMessage(), "[ProducReport::generateReport]", ex);
                } finally {
                        try {
                                bw.close();
                        } catch (IOException ex) {
                                Logger.getLogger(ProductReport.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

                        transactionManager = new TransactionManager();
                        transactionSet = transactionManager.GetTransactions(TransactionComparisonMode.ProductId);
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } catch (DataAccessException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        transactionManager = null;
                }


                //String reportFormat = "%1$3d\t%2$4d\t%3$15s\t%4$20s\t%5$50s%6$50s\t%7$4d\t%8$20s\t%9$50s\n";
                BufferedWriter bw = null;
                try {
                        Calendar calendar = Calendar.getInstance();
                        Date date = calendar.getTime();

                        bw = FileUtil.getBufferedWriter(getFileOutputName(), false);
                        bw.write(getReportTitle());
                        bw.newLine();
                        bw.write("Report Date: " + new SimpleDateFormat("dd-MMM-yyyy").format(date));
                        bw.write("\n\n");

                        if (isShowHeader()) {
                                bw.newLine();
                                bw.write(getHeader());
                                bw.newLine();
                        } else {
                                bw.newLine();
                                bw.write(getDefaultHeader());
                                bw.newLine();
                        }
                        if (transactionSet != null) {

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

                                        Transaction transactionDataObject = transactionSet.get(i);
                                        int transactionID = transactionDataObject.getTransactionId();
                                        String productID = transactionDataObject.getProductId();
                                        String memberID = transactionDataObject.getMemberId();
                                        int quantity = transactionDataObject.getQuantity();

                                        Date transactionDate = transactionDataObject.getPurchasedDate();

                                        MemberManager memberDataObjectManager = new MemberManager();
                                        Member memberDataObject = memberDataObjectManager.selectMember(memberID);
                                        String memberName = "";
                                        if (memberDataObject != null) {
                                                memberName = memberDataObject.getMemberName();
                                        }

                                        ProductManager productDataObjectManager = new ProductManager();
                                        Product productDataObject = productDataObjectManager.selectProduct(productID);
                                        String productName = "";
                                        String productDesc = "";
                                        if (productDataObject != null) {
                                                productName = productDataObject.getProductName();
                                                productDesc = productDataObject.getProductDescription();
                                        }

                                        String output = String.format(TRANSACTION_REPORT_FORMAT, i + 1, transactionID, transactionDate, productID, productName, productDesc, quantity, memberID, memberName);
                                        bw.write(output);

                                //debugging purpose
                                //System.out.format(output);
                                }
                        }

                        bw.write("\n\n");
                        if (isShowFooter()) {
                                bw.write(getFooter());
                        } else {
                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        try {
                                bw.close();
                        } catch (IOException ex) {
                                Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(CategoryReport.class.getName()).log(Level.SEVERE,ex.getMessage(), ex);
                        throw new AppException(ex.getMessage(), "[CategoryReport::generateReport]", ex);
                } finally {
                        try {
                                bw.close();
                        } catch (IOException ex) {
                                Logger.getLogger(CategoryReport.class.getName()).log(Level.SEVERE,ex.getMessage(), ex);
View Full Code Here

                        transactionManager = new TransactionManager();
                        transactionSet = transactionManager.GetTransactions(TransactionComparisonMode.ProductId);
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } catch (DataAccessException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        transactionManager = null;
                }


                //String reportFormat = "%1$3d\t%2$4d\t%3$15s\t%4$20s\t%5$50s%6$50s\t%7$4d\t%8$20s\t%9$50s\n";
                BufferedWriter bw = null;
                try {
                        Calendar calendar = Calendar.getInstance();
                        Date date = calendar.getTime();

                        bw = FileUtil.getBufferedWriter(getFileOutputName(), false);
                        bw.write(getReportTitle());
                        bw.newLine();
                        bw.write("Report Date: " + new SimpleDateFormat("dd-MMM-yyyy").format(date));
                        bw.write("\n\n");

                        if (isShowHeader()) {
                                bw.newLine();
                                bw.write(getHeader());
                                bw.newLine();
                        } else {
                                bw.newLine();
                                bw.write(getDefaultHeader());
                                bw.newLine();
                        }
                        if (transactionSet != null) {

                                DateFormat df = new SimpleDateFormat(TRANSACTION_DATEFORMAT);
                               
                                //"%1$5s\t%2$4s\t%3$15s\t%4$20s\t%5$50s%6$50s\t%7$4s\t%8$20s\t%9$50s\n";
                                for (int i = 0; i < transactionSet.size(); i++) {

                                        String transactionSeq = String.valueOf(i+1);

                                        Transaction transactionDataObject = transactionSet.get(i);
                                        String transactionID = String.valueOf(transactionDataObject.getTransactionId());
                                        String productID = transactionDataObject.getProductId();
                                        String memberID = transactionDataObject.getMemberId();
                                        String quantity = String.valueOf(transactionDataObject.getQuantity());

                                        String transactionDate = df.format(transactionDataObject.getPurchasedDate());//String.valueOf(transactionDataObject.getPurchasedDate());

                                        MemberManager memberDataObjectManager = new MemberManager();
                                        Member memberDataObject = memberDataObjectManager.selectMember(memberID);
                                        String memberName = "";
                                        if (memberDataObject != null) {
                                                memberName = memberDataObject.getMemberName();
                                        }

                                        ProductManager productDataObjectManager = new ProductManager();
                                        Product productDataObject = productDataObjectManager.selectProduct(productID);
                                        String productName = "";
                                        String productDesc = "";
                                        if (productDataObject != null) {
                                                productName = productDataObject.getProductName();
                                                productDesc = productDataObject.getProductDescription();
                                        }

                                        String output = String.format(TRANSACTION_REPORT_FORMAT, transactionSeq, transactionID, transactionDate, productID, productName, productDesc, quantity, memberID, memberName);
                                        bw.write(output);

                                        //debugging purpose
                                        //System.out.format(output);
                                       
                                        memberDataObject = null;
                                        productDataObjectManager = null;
                                        transactionDataObject = null;
                                }
                        }

                        bw.write("\n\n");
                        if (isShowFooter()) {
                                bw.write(getFooter());
                        } else {
                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        try {
                                if (bw!=null) {
                                        bw.flush();
                                        bw.close();
View Full Code Here

                        transactionManager = new TransactionManager();
                        transactionSet = transactionManager.GetTransactions(start, finish);
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } catch (DataAccessException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        transactionManager = null;
                }


                //String reportFormat = "%1$3d\t%2$4d\t%3$15s\t%4$20s\t%5$50s%6$50s\t%7$4d\t%8$20s\t%9$50s\n";
                BufferedWriter bw = null;
                try {
                        Calendar calendar = Calendar.getInstance();
                        Date date = calendar.getTime();

                        bw = FileUtil.getBufferedWriter(getFileOutputName(), false);
                        bw.write(getReportTitle());
                        bw.newLine();
                        bw.write("Report Date: " + new SimpleDateFormat("dd-MMM-yyyy").format(date));
                        bw.write("\n\n");

                        if (isShowHeader()) {
                                bw.newLine();
                                bw.write(getHeader());
                                bw.newLine();
                        } else {
                                bw.newLine();
                                bw.write(getDefaultHeader());
                                bw.newLine();
                        }
                        if (transactionSet != null) {

                                DateFormat df = new SimpleDateFormat(TRANSACTION_DATEFORMAT);
                               
                                //"%1$5s\t%2$4s\t%3$15s\t%4$20s\t%5$50s%6$50s\t%7$4s\t%8$20s\t%9$50s\n";
                                for (int i = 0; i < transactionSet.size(); i++) {

                                        String transactionSeq = String.valueOf(i+1);

                                        Transaction transactionDataObject = transactionSet.get(i);
                                        String transactionID = String.valueOf(transactionDataObject.getTransactionId());
                                        String productID = transactionDataObject.getProductId();
                                        String memberID = transactionDataObject.getMemberId();
                                        String quantity = String.valueOf(transactionDataObject.getQuantity());

                                        //String transactionDate = String.valueOf(transactionDataObject.getPurchasedDate());
                                        String transactionDate = df.format(transactionDataObject.getPurchasedDate());//String.valueOf(transactionDataObject.getPurchasedDate());

                                        MemberManager memberDataObjectManager = new MemberManager();
                                        Member memberDataObject = memberDataObjectManager.selectMember(memberID);
                                        String memberName = "";
                                        if (memberDataObject != null) {
                                                memberName = memberDataObject.getMemberName();
                                        }

                                        ProductManager productDataObjectManager = new ProductManager();
                                        Product productDataObject = productDataObjectManager.selectProduct(productID);
                                        String productName = "";
                                        String productDesc = "";
                                        if (productDataObject != null) {
                                                productName = productDataObject.getProductName();
                                                productDesc = productDataObject.getProductDescription();
                                        }

                                        String output = String.format(TRANSACTION_REPORT_FORMAT, transactionSeq, transactionID, transactionDate, productID, productName, productDesc, quantity, memberID, memberName);
                                        bw.write(output);

                                        //debugging purpose
                                        //System.out.format(output);
                                       
                                        memberDataObject = null;
                                        productDataObjectManager = null;
                                        transactionDataObject = null;
                                }
                        }

                        bw.write("\n\n");
                        if (isShowFooter()) {
                                bw.write(getFooter());
                        } else {
                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(TransactionReport.class.getName()).log(Level.SEVERE, null, ex);
                        throw new AppException(ex.getMessage(), "[TransactionReport::generateReport]", ex);
                } finally {
                        try {
                                if (bw!=null) {
                                        bw.flush();
                                        bw.close();
View Full Code Here

                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(CategoryReport.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw new AppException(ex.getMessage(), "[CategoryReport::generateReport]", ex);
                } finally {
                        try {
                                if (bw!=null) {
                                        bw.flush();
                                        bw.close();
View Full Code Here

                //validate whethere the same member id exist inside the system
                Member dataObject = selectMember(member.getMemberID());
                if (dataObject != null) {
                        success = false;
                        throw new AppException("The same Member ID has found on the system", "[MemberManager::addMember]", null);
                }

                try {
                        memberDA = new MemberDA(filename, format);
                        memberDA.writeData(member, true);
View Full Code Here

                                bw.write(getDefaultFooter());
                        }
                } catch (IOException ex) {
                        result = false;
                        Logger.getLogger(ProductReport.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw new AppException(ex.getMessage(), "[ProducReport::generateReport]", ex);
                } finally {
                        try {
                                if (bw!=null) {
                                        bw.flush();
                                        bw.close();
View Full Code Here

TOP

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

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.