diff --git a/Leos/.classpath b/Leos/.classpath index 91ee9a5..931e580 100644 --- a/Leos/.classpath +++ b/Leos/.classpath @@ -1,6 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Leos/lib/commons-codec-1.10.jar b/Leos/lib/commons-codec-1.10.jar new file mode 100644 index 0000000..1d7417c Binary files /dev/null and b/Leos/lib/commons-codec-1.10.jar differ diff --git a/Leos/lib/commons-collections4-4.1.jar b/Leos/lib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/Leos/lib/commons-collections4-4.1.jar differ diff --git a/Leos/lib/commons-logging-1.2.jar b/Leos/lib/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/Leos/lib/commons-logging-1.2.jar differ diff --git a/Leos/lib/curvesapi-1.04.jar b/Leos/lib/curvesapi-1.04.jar new file mode 100644 index 0000000..f097d0b Binary files /dev/null and b/Leos/lib/curvesapi-1.04.jar differ diff --git a/Leos/lib/junit-4.12.jar b/Leos/lib/junit-4.12.jar new file mode 100644 index 0000000..3a7fc26 Binary files /dev/null and b/Leos/lib/junit-4.12.jar differ diff --git a/Leos/lib/log4j-1.2.17.jar b/Leos/lib/log4j-1.2.17.jar new file mode 100644 index 0000000..1d425cf Binary files /dev/null and b/Leos/lib/log4j-1.2.17.jar differ diff --git a/Leos/lib/poi-3.15.jar b/Leos/lib/poi-3.15.jar new file mode 100644 index 0000000..ab368bd Binary files /dev/null and b/Leos/lib/poi-3.15.jar differ diff --git a/Leos/lib/poi-examples-3.15.jar b/Leos/lib/poi-examples-3.15.jar new file mode 100644 index 0000000..093946c Binary files /dev/null and b/Leos/lib/poi-examples-3.15.jar differ diff --git a/Leos/lib/poi-excelant-3.15.jar b/Leos/lib/poi-excelant-3.15.jar new file mode 100644 index 0000000..65a5ad0 Binary files /dev/null and b/Leos/lib/poi-excelant-3.15.jar differ diff --git a/Leos/lib/poi-ooxml-3.15.jar b/Leos/lib/poi-ooxml-3.15.jar new file mode 100644 index 0000000..6de9956 Binary files /dev/null and b/Leos/lib/poi-ooxml-3.15.jar differ diff --git a/Leos/lib/poi-ooxml-schemas-3.15.jar b/Leos/lib/poi-ooxml-schemas-3.15.jar new file mode 100644 index 0000000..f3ed205 Binary files /dev/null and b/Leos/lib/poi-ooxml-schemas-3.15.jar differ diff --git a/Leos/lib/poi-scratchpad-3.15.jar b/Leos/lib/poi-scratchpad-3.15.jar new file mode 100644 index 0000000..f68ae81 Binary files /dev/null and b/Leos/lib/poi-scratchpad-3.15.jar differ diff --git a/Leos/lib/xmlbeans-2.6.0.jar b/Leos/lib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/Leos/lib/xmlbeans-2.6.0.jar differ diff --git a/Leos/src/AvailabilityTime.java b/Leos/src/AvailabilityTime.java new file mode 100644 index 0000000..5798973 --- /dev/null +++ b/Leos/src/AvailabilityTime.java @@ -0,0 +1,32 @@ +import java.sql.Time;; + +public class AvailabilityTime { + WorkingTime start; + WorkingTime end; + + public AvailabilityTime() { + this.start = null; + this.end = null; + } + + public AvailabilityTime(WorkingTime start, WorkingTime end) { + this.start = start; + this.end = end; + } + + public WorkingTime getStart() { + return start; + } + + public void setStart(WorkingTime start) { + this.start = start; + } + + public WorkingTime getEnd() { + return end; + } + + public void setEnd(WorkingTime end) { + this.end = end; + } +} diff --git a/Leos/src/Employee.java b/Leos/src/Employee.java new file mode 100644 index 0000000..b8b78db --- /dev/null +++ b/Leos/src/Employee.java @@ -0,0 +1,110 @@ +import java.util.HashMap; + +import javax.management.timer.Timer; + +import org.omg.PortableServer.ServantActivator; + +import java.security.spec.ECPrivateKeySpec; +import java.sql.Time; +import java.time.*; + +public class Employee { + private String name; + private boolean canWorkMonday = false; + private boolean canWorkTuesday = false; + private boolean canWorkWednesday = false; + private boolean canWorkThursday = false; + private boolean canWorkFriday = false; + private boolean canWorkSaturday = false; + private boolean canWorkOvernight = false; + private HashMap availability; + + public Employee(String name, String availablility) { + this.name = name; + String[] days = availablility.split(", "); + for(String day: days){ + if(day.contains("-")){ + parseRange(); + } else { + String[] b = day.split(" "); + parseAvailability(b); + } + } + } + + public void parseRange(){ + canWorkMonday = true; + canWorkTuesday = true; + canWorkWednesday = true; + canWorkThursday = true; + canWorkFriday = true; + } + + public void parseAvailability(String[] a){ + DayOfWeek day = null; + for (int i = 0; i < a.length; i++){ + switch (a[i]){ + case "Monday": + canWorkMonday = true; + break; + case "Tuesday": + canWorkTuesday = true; + break; + case "Wednesday": + canWorkWednesday = true; + break; + case "Thursday": + canWorkThursday = true; + break; + case "Friday": + canWorkFriday = true; + break; + case "Saturday": + canWorkSaturday = true; + break; + default: + checkOvernight(a[i]); + break; + } + } + } + + private void checkOvernight(String a){ + if(a.equals("overnight")){ + canWorkOvernight = true; + } else if (a.equals("no")) { + canWorkOvernight = false; + } + } + + public boolean isCanWorkMonday() { + return canWorkMonday; + } + + public boolean isCanWorkTuesday() { + return canWorkTuesday; + } + + public boolean isCanWorkWednesday() { + return canWorkWednesday; + } + + public boolean isCanWorkThursday() { + return canWorkThursday; + } + + public boolean isCanWorkFriday() { + return canWorkFriday; + } + + public boolean isCanWorkSaturday() { + return canWorkSaturday; + } + + public boolean isCanWorkOvernight() { + return canWorkOvernight; + } + + public static void main(String[] args){ + } +} diff --git a/Leos/src/GUI.java b/Leos/src/GUI.java index 135bf25..6f652b6 100644 --- a/Leos/src/GUI.java +++ b/Leos/src/GUI.java @@ -1,4 +1,152 @@ +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; -public class GUI { - +@SuppressWarnings("serial") +public class GUI extends JFrame{ + private JTextArea textArea; + private JMenuItem importEmployees; + private JMenuItem importStock; + private JMenuItem exportStock; + private JMenuItem exportEmployees; + private JMenuItem viewEmployees; + private JMenuItem viewStock; + private JButton notificationButton; + + public GUI() + { + textArea = new JTextArea(); + importEmployees = new JMenuItem("Employees"); + importStock = new JMenuItem("Stock"); + exportStock = new JMenuItem("Stock"); + exportEmployees = new JMenuItem("Employees"); + viewStock = new JMenuItem("Stock"); + viewEmployees = new JMenuItem("Employees"); + notificationButton = new JButton(); + + JMenuBar menu = new JMenuBar(); + JMenu fileMenu = new JMenu("File"); + JMenu viewMenu = new JMenu("View"); + JMenu importMenu = new JMenu("Import"); + JMenu exportMenu = new JMenu("Export"); + + menu.add(fileMenu); + menu.add(viewMenu); + fileMenu.add(importMenu); + fileMenu.add(exportMenu); + importMenu.add(importEmployees); + importMenu.add(importStock); + exportMenu.add(exportEmployees); + exportMenu.add(exportStock); + viewMenu.add(viewEmployees); + viewMenu.add(viewStock); + + this.setSize(600, 400); + + JSplitPane pane = new JSplitPane(); + pane.setOrientation(JSplitPane.VERTICAL_SPLIT); + pane.setDividerSize(1); + System.out.println(); + pane.setDividerLocation((int)(this.getHeight()*0.75)); + pane.setTopComponent(textArea); + pane.setBottomComponent(notificationButton); + + notificationButton.setSize(50, 50); + pane.setEnabled(false); + textArea.setEditable(false); + + this.setJMenuBar(menu); + this.add(pane); + + this.setVisible(true); + } + + private File saveFile(String title) + { + JFileChooser fileSaver = new JFileChooser(); + fileSaver.setDialogTitle(title); + fileSaver.setDialogType(JFileChooser.SAVE_DIALOG); + fileSaver.setFileFilter(new FileNameExtensionFilter("Comma Seperated Values (.csv)", "csv")); + if (fileSaver.showSaveDialog(fileSaver) == JFileChooser.APPROVE_OPTION) { + return fileSaver.getSelectedFile(); + } + else + { + return null; + } + } + + private File getFile(String title) + { + JFileChooser fileFinder = new JFileChooser(); + fileFinder.setDialogTitle(title); + fileFinder.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileFinder.setDialogType(JFileChooser.OPEN_DIALOG); + fileFinder.setFileFilter(new FileNameExtensionFilter("Microsoft Word Document(.docx)", "docx")); + if (fileFinder.showOpenDialog(fileFinder) == JFileChooser.APPROVE_OPTION) { + return fileFinder.getSelectedFile(); + } + else + { + return null; + } + } + + private void setUpButtons() + { + importEmployees.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + File file = getFile("Import Employee"); + if(file == null) return; + textArea.append(file.getName() + " has been imported to the employee list. \n"); + } + }); + importStock.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + File file = getFile("Import Stock"); + if(file == null) return; + textArea.append(file.getName() + " has been imported to the stock. \n"); + } + }); + exportEmployees.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + File file = saveFile("Export Employees"); + try { + file.createNewFile(); + } catch (IOException e1) { + e1.printStackTrace(); + } + if(file == null) return; + textArea.append(file.getName() + " has been exported. \n"); + } + }); + exportStock.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + File file = saveFile("Export Employees"); + if(file == null) return; + textArea.append(file.getName() + " has been exported. \n"); + } + }); + } + + public static void main(String args[]) + { + GUI gui = new GUI(); + gui.setUpButtons(); + } } diff --git a/Leos/src/Item.java b/Leos/src/Item.java new file mode 100644 index 0000000..fe250dd --- /dev/null +++ b/Leos/src/Item.java @@ -0,0 +1,63 @@ +import java.text.DateFormat; +import java.text.ParseException; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.text.SimpleDateFormat; + + + +/** + * Items in the store + * @author dan + * + */ +public class Item { + private String name; + private LocalDate expirydate; + private int quantity; + private int popularity; + + public Item(String name, String expirydate, int quantity){ + this(name,expirydate); + this.quantity = quantity; + this.popularity = 0; + } + + public Item(String name, String expirydate){ + this.name = name; + this.expirydate = convertDate(expirydate); + this.popularity = 0; + } + public Item(){} + private LocalDate convertDate(String date){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM d, yyyy"); + formatter = formatter.withLocale(Locale.US); + LocalDate d = LocalDate.parse(date, formatter); + return d; + } + + public LocalDate getExpirydate() { + return expirydate; + } + + public void setExpirydate(LocalDate expirydate) { + this.expirydate = expirydate; + } + + public int getQuantity() { + return quantity; + } + + public void decrementQuantity() { + quantity--; + popularity++; + } + + public static void main(String args[]){ + //Item t = new Item(); + //LocalDate d = t.convertDate("Jun 16, 2018"); + //System.out.println(d); + } +} \ No newline at end of file diff --git a/Leos/src/Parser.java b/Leos/src/Parser.java new file mode 100644 index 0000000..32d43f3 --- /dev/null +++ b/Leos/src/Parser.java @@ -0,0 +1,98 @@ +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.xwpf.usermodel.XWPFDocument; +import org.apache.poi.xwpf.usermodel.XWPFTable; +import org.apache.poi.xwpf.usermodel.XWPFTableCell; +import org.apache.poi.xwpf.usermodel.XWPFTableRow; + +public class Parser { + + + public ArrayList parseEmployee() throws IOException { + ArrayList employees = new ArrayList<>(); + FileInputStream fis = new FileInputStream("./Programming Employee List (1).docx"); + String tempName = ""; + String tempDate = ""; + String test=""; + int n = -1; + + XWPFDocument doc = new XWPFDocument(fis); + List tables = doc.getTables(); + for ( XWPFTable table : tables ) { + for ( XWPFTableRow row : table.getRows() ) { + for ( XWPFTableCell cell : row.getTableCells()) { + test = cell.getText(); + if(n >= 1) { + if(n == 1) { + tempName = cell.getText(); + } else { + n = 0; + tempDate = cell.getText(); + } + + } + n++; + } + employees.add(new Employee(tempName,tempDate)); + + } + } + return employees; + } + + + public ArrayList parseItems() throws IOException{ + ArrayList items = new ArrayList<>(); + FileInputStream fis = new FileInputStream("./Programming Food List (1).docx"); + String tempName = ""; + int tempQuantity = 0; + String tempDate = ""; + String test=""; + int n = -2; + + XWPFDocument doc = new XWPFDocument(fis); + List tables = doc.getTables(); + for ( XWPFTable table : tables ) { + for ( XWPFTableRow row : table.getRows() ) { + for ( XWPFTableCell cell : row.getTableCells()) { + test = cell.getText(); + if(n >= 1) { + if(n == 1) { + tempName = cell.getText(); + + } else if(n == 2) { + tempDate = cell.getText(); + + } else { + n = 0; + tempQuantity = Integer.parseInt(cell.getText().replaceAll("[^0-9]","")); + } + + } + n++; + } + items.add(new Item(tempName,tempDate , tempQuantity)); + + } + } + return items; + } + + public static void main(String args[]) { + Parser p = new Parser(); + try { + p.parseItems(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} + diff --git a/Leos/src/Scheduler.java b/Leos/src/Scheduler.java new file mode 100644 index 0000000..20cfd20 --- /dev/null +++ b/Leos/src/Scheduler.java @@ -0,0 +1,23 @@ +import java.util.*; + +public class Scheduler { + private List employees; + private Parser parser; + + public Scheduler() { + this.employees = new ArrayList(); + this.parser = new Parser(); + } + + public void add(Employee e){ + this.employees.add(e); + } + + public void remove(Employee e){ + this.employees.remove(e); + } + + public void schedule(){ + + } +}