Examples of StoreKeeper


Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

                        if (bw != null) {
                                for (int i = 0; i < storekeeperSet.size(); i++) {

                                        String storekeeperName = storekeeperSet.get(i).getItem1().getValue();
                                        String storekeeperPassword = storekeeperSet.get(i).getItem2().getValue();
                                        StoreKeeper storekeeper = new StoreKeeper(storekeeperName, storekeeperPassword);
                                        String data = storekeeper.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new DataAccessException("[StoreKeeperDA::writeData]Failed to create filename " + fileName);
                        }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

         *
         * @param storekeeperName
         * @return StoreKeeper records in form Array List.
         */
        public StoreKeeper readData(String storekeeperName) throws DataAccessException {
                StoreKeeper 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("[StoreKeeperDA::readData]Record not found.");
                                } else {

                                        if (lines.length < 1) {
                                                throw new DataAccessException("[StoreKeeperDA::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(StoreKeeperDA.class.getName()).log(Level.SEVERE, "[StoreKeeperDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                        throw new DataAccessException("[StoreKeeperDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                } else {
                                                        if (fields.length != 2) {
                                                                Logger.getLogger(StoreKeeperDA.class.getName()).log(Level.SEVERE, "[StoreKeeperDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                String name = fields[0];
                                                                String password = fields[1];
                                                                if (storekeeperName.equalsIgnoreCase(name)) {
                                                                        dataObject = new StoreKeeper();
                                                                        dataObject.setStorekeeperName(name);
                                                                        dataObject.setStorekeeperPassword(password);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

         * @return True is success LogIn, False if failed to LogIn
         */
        public boolean doLogin(String username, String password) {
                boolean success = true;

                StoreKeeper dataObject = new StoreKeeper(username, password);
                StoreKeeperManager dataObjectManager = new StoreKeeperManager();
                success = dataObjectManager.validateLogin(dataObject);

                return success;
        }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

                                        BufferedReader br = new BufferedReader(read);
                                        String s;
                                        try {
                                                while ((s = br.readLine()) != null) {
                                                        String[] stStoreKeeper = s.split(",");
                                                        StoreKeeper v = new StoreKeeper(stStoreKeeper[0], stStoreKeeper[1]);
                                                        content.add(v);
                                                        //destroy Object StoreKeeper
                                                        v = null;

                                                }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

                                        BufferedReader br = new BufferedReader(read);
                                        String s;
                                        try {
                                                while ((s = br.readLine()) != null) {
                                                        String[] stStoreKeeper = s.split(",");
                                                        StoreKeeper v = new StoreKeeper(stStoreKeeper[0], stStoreKeeper[1]);
                                                        content.add(v);
                                                        //destroy Object StoreKeeper
                                                        v = null;

                                                }
View Full Code Here

Examples of sg.edu.nus.iss.se07.bc.StoreKeeper

        }

        public boolean doLogin(String username, String password) {
                boolean success = true;

                StoreKeeper dataObject = new StoreKeeper(username, password);
                StoreKeeperManager dataObjectManager = new StoreKeeperManager();
                success = dataObjectManager.validateLogin(dataObject);

                return success;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.