@POST @Path("holidays") public Response add(@Context UriInfo uriInfo, HolidayDocument request) { HolidayDocument result = getHolidayMaster().add(request); URI createdUri = DataHolidayResource.uriVersion(uriInfo.getBaseUri(), result.getUniqueId()); return responseCreatedFudge(createdUri, result); }
/** * Creates the output root data. * * @return the output root data, not null */ protected FlexiBean createRootData() { FlexiBean out = super.createRootData(); HolidayDocument latestDoc = data().getHoliday(); HolidayDocument versionedHoliday = data().getVersioned(); out.put("latestHolidayDoc", latestDoc); out.put("latestHoliday", latestDoc.getHoliday()); out.put("holidayDoc", versionedHoliday); out.put("holiday", versionedHoliday.getHoliday()); out.put("deleted", !latestDoc.isLatest()); List<Pair<Year, List<LocalDate>>> map = new ArrayList<Pair<Year, List<LocalDate>>>(); List<LocalDate> dates = versionedHoliday.getHoliday().getHolidayDates(); if (dates.size() > 0) { int year = dates.get(0).getYear(); int start = 0; int pos = 0; for (; pos < dates.size(); pos++) { if (dates.get(pos).getYear() == year) { continue; } map.add(Pair.of(Year.of(year), dates.subList(start, pos))); year = dates.get(pos).getYear(); start = pos; } map.add(Pair.of(Year.of(year), dates.subList(start, pos))); } out.put("holidayDatesByYear", map); return out; }