List<Element> dayOffElementList = (List<Element>) dayOffRequestsElement.getChildren();
dayOffRequestList = new ArrayList<DayOffRequest>(dayOffElementList.size());
long id = 0L;
for (Element element : dayOffElementList) {
assertElementName(element, "DayOff");
DayOffRequest dayOffRequest = new DayOffRequest();
dayOffRequest.setId(id);
Element employeeElement = element.getChild("EmployeeID");
Employee employee = employeeMap.get(employeeElement.getText());
if (employee == null) {
throw new IllegalArgumentException("The shiftDate (" + employeeElement.getText()
+ ") of dayOffRequest (" + dayOffRequest + ") does not exist.");
}
dayOffRequest.setEmployee(employee);
Element dateElement = element.getChild("Date");
ShiftDate shiftDate = shiftDateMap.get(dateElement.getText());
if (shiftDate == null) {
throw new IllegalArgumentException("The date (" + dateElement.getText()
+ ") of dayOffRequest (" + dayOffRequest + ") does not exist.");
}
dayOffRequest.setShiftDate(shiftDate);
dayOffRequest.setWeight(element.getAttribute("weight").getIntValue());
dayOffRequestList.add(dayOffRequest);
employee.getDayOffRequestMap().put(shiftDate, dayOffRequest);
id++;
}