Matthew Patterson has over 20 years of work experience. Matthew started their career in 1997 as a Junior Programmer at Motorola. Matthew then worked as an Imaging Systems Programmer and Computer Tech Level III at Walmart. In 1998 they worked as a Web Application Developer/DBA at Wolf Camera Inc. In 2000 they were a Senior Programmer/Team Lead at WolfXpress.com. From 2001 to 2008 they worked at Intervolve in various roles such as Software Architect/Lead Developer, Senior Programmer and Development Manager. From 2009 to 2015 they worked at PracticeAdmin as Chief Software Architect and at LocumsMart as CTO and Senior Software Architect.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.dao;
import com.mycompany.dto.Order;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
*
* @author apprentice
*/
public class OrderDaoImpl implements OrderDao {
private Map<Integer, Order> orders = new HashMap<>();
public static final String ORDER_FILE = "orders.txt";
public static final String DELIMITER = "::";
@Override
public Order create(Order order) {
Order newOrder = orders.put(order.getOrderNumber(), order);
writeOrder();
return newOrder;
}
@Override
public Order get(Integer orderNumber) {
return orders.get(orderNumber);
}
@Override
public void update(Order order) {
orders.put(order.getOrderNumber(), order);
writeOrder();
}
@Override
public void delete(Order order) {
orders.remove(order.getOrderNumber());
writeOrder();
}
@Override
public List<Order> list() {
return new ArrayList<Order>(orders.values());
}
private void loadOrder() {
Scanner scanner;
try {
scanner = new Scanner(new BufferedReader(new FileReader(ORDER_FILE)));
} catch (FileNotFoundException e) {
throw new PersistenceException("Could not load order data into memory", e);
}
String currentLine;
String[] currentTokens;
while (
Sign up to view 1 direct report
Get started