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

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


                                contents = FileUtil.getContents(br);
                                if (contents == null) {
                                        return "";
                                }
                        } else {
                                throw new DataAccessException("[ViewReportPanel::loadData]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


                try {
                     
                        datfile = FileUtil.combinePath(this.dataDir, fileName);
                        return ReadDatFile(datfile);
                } catch (Exception ioEx) {
                        throw new DataAccessException("failed to read " + datfile, ioEx);
                }

        }
View Full Code Here

                        Integer transactionId = 0;
                        if ( lastLine != null & !lastLine.equals(""))
                        {
                          String[] chunks = lastLine.split(",");
                           if (chunks.length != 5) {
                                 throw new DataAccessException(
                                         new IOException("Line is invalid : " + lastLine));
                              }
                          transactionId = new Integer(chunks[0]);
                        }
                       
                       
                       // String[] chunks = lastLine.split(",");
                      

                        transactionId = transactionId + 1;
                        String lineEnd = System.getProperty("line.separator");
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

                        for (Tuple4<String, String, Integer, Date> purchasedProduct : purchases) {
                                BufferedWriter bw;

                                bw = new BufferedWriter(new FileWriter(datFile, true));
                                bw.write(String.format("%d,%s,%s,%d,%s%s",
                                        transactionId,
                                        purchasedProduct.getItem1(),
                                        purchasedProduct.getItem2(),
                                        purchasedProduct.getItem3(),
                                        formatter.format(purchasedProduct.getItem4()), lineEnd));
                                bw.close();
                        }

                } catch (IOException e) {
                        throw new DataAccessException(e);
                } catch (Exception e) {
                        throw new DataAccessException(e);
                }


        }
View Full Code Here

                                contents = FileUtil.getContents(br);
                                if (contents == null) {
                                        return "";
                                }
                        } else {
                                throw new DataAccessException("[ViewReportPanel::loadData]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

                String datfile = "";
                try {
                        datfile = ConfigReader.Get("DATA_FOLDER") + fileName;
                        return ReadDatFile(datfile);
                } catch (Exception ioEx) {
                        throw new DataAccessException("failed to read " + datfile, ioEx);
                }

        }
View Full Code Here

                        String lastLine = r.readNonEmptyLine();


                        String[] chunks = lastLine.split(",");
                        if (chunks.length != 5) {
                                throw new DataAccessException(
                                        new IOException("Line is invalid : " + lastLine));
                        }

                        Integer transactionId = new Integer(chunks[0]) + 1;
                        String lineEnd = System.getProperty("line.separator");
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

                        for (Tuple4<String, String, Integer, Date> purchasedProduct : purchases) {
                                BufferedWriter bw;

                                bw = new BufferedWriter(new FileWriter(datFile, true));
                                bw.write(String.format("%d,%s,%s,%d,%s%s",
                                        transactionId,
                                        purchasedProduct.getItem1(),
                                        purchasedProduct.getItem2(),
                                        purchasedProduct.getItem3(),
                                        formatter.format(purchasedProduct.getItem4()), lineEnd));
                                bw.close();
                        }

                } catch (IOException e) {
                        throw new DataAccessException(e);
                } catch (Exception e) {
                        throw new DataAccessException(e);
                }


        }
View Full Code Here

                                return errorList;
                        }
                }

                try {
                        memberDA = new MemberDA();
                        memberDA.writeData(member, true);
                        memberDA = null;
                } catch (AppException ex) {
                        Logger.getLogger(MemberFcd.class.getName()).log(Level.SEVERE, null, ex);
                        throw ex;
View Full Code Here

         * @throws sg.edu.nus.iss.se07.common.exceptions.AppException
         */
        public MemberSet list() throws AppException {
                MemberSet objectSet = new MemberSet();
                try {
                        memberDA = new MemberDA();
                        objectSet = memberDA.readDataSet();
                        memberDA = null;
                } catch (AppException ex) {
                        Logger.getLogger(MemberFcd.class.getName()).log(Level.SEVERE, null, ex);
                        throw ex;
View Full Code Here

         * @throws sg.edu.nus.iss.se07.common.exceptions.AppException
         */
        public MemberSet list(String memberID) throws AppException {
                MemberSet objectSet = new MemberSet();
                try {
                        memberDA = new MemberDA();
                        objectSet = memberDA.readDataSet(memberID);
                        memberDA = null;
                } catch (AppException ex) {
                        Logger.getLogger(MemberFcd.class.getName()).log(Level.SEVERE, null, ex);
                        throw ex;
View Full Code Here

        public MemberSet select() throws AppException {
                MemberSet objectSet = new MemberSet();
                ArrayList<Tuple3<NameValue<String>, NameValue<String>, NameValue<Integer>>> records = null;

                try {
                        memberDA = new MemberDA();
                        records = memberDA.readData();
                        if (records != null) {
                                for (int i = 0; i < records.size(); i++) {
                                        Tuple3<NameValue<String>, NameValue<String>, NameValue<Integer>> record = records.get(i);
                                        Member member = new Member();
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.