-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCsvScheduleWriter.java
More file actions
38 lines (35 loc) · 1.29 KB
/
Copy pathCsvScheduleWriter.java
File metadata and controls
38 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package mmis;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class CsvScheduleWriter {
public void writeSchedule(Path outputPath, List<ScheduledJob> scheduledJobs) throws IOException {
List<String> rows = new ArrayList<>();
rows.add("machine_id,job_id,start,end");
for (ScheduledJob scheduledJob : scheduledJobs) {
Job job = scheduledJob.getJob();
rows.add(String.format("%s,%s,%d,%d",
scheduledJob.getMachineId(),
job.getJobId(),
job.getStart(),
job.getEnd()));
}
Files.createDirectories(outputPath.getParent());
Files.write(outputPath, rows);
}
public void writeUnassigned(Path outputPath, List<Job> unassignedJobs) throws IOException {
List<String> rows = new ArrayList<>();
rows.add("job_id,start,end,reason");
for (Job job : unassignedJobs) {
rows.add(String.format("%s,%d,%d,%s",
job.getJobId(),
job.getStart(),
job.getEnd(),
"overlap_no_machine_available"));
}
Files.createDirectories(outputPath.getParent());
Files.write(outputPath, rows);
}
}