void saveNewJobsByDate(String folderPath, String printerName) throws ClientProtocolException, IOException, ParseJobException { List<JobDetail> toSave = new ArrayList<JobDetail>(); int getJobsFrom; String latestLog = LogFiles.getMostRecentLogFileName(folderPath, printerName); if (latestLog != null) { JobDetailCSV l2csv = new JobDetailCSV(latestLog); // We'll be resaving the latest csv as it may have new jobs toSave = l2csv.readCSV(); getJobsFrom = LogFiles.getLastSavedJob(folderPath, printerName).getJobNumber(); } else { getJobsFrom = 0; } List<JobDetail> newJobs = printer.getJobsSinceJobNumber(getJobsFrom); toSave.addAll(newJobs); LogFiles.sortJobsByNumber(toSave); TreeMap<LocalDate, List<JobDetail>> sorted = LogFiles.splitJobsByDate(toSave); for (LocalDate day : sorted.keySet()) { JobDetailCSV jd = new JobDetailCSV(csvFolder + "/" + printer.getPrinterName() + day.toString()); jd.write(sorted.get(day)); } }
public void go() throws ClientProtocolException, IOException, ParseJobException { saveNewJobsByDate(csvFolder, printer.getPrinterName()); }