use of com.autentia.tnt.manager.activity.OccupationManager in project TNTConcept by autentia.
the class AvailabilityBean method fillAvailability.
private void fillAvailability(User user, OcupationModel model) {
Calendar calendarFirstDayOfMonth = Calendar.getInstance();
Calendar calendarLastDayOfMonth = Calendar.getInstance();
Date firstDayOfMonth = DateUtils.getFirstDayOfMonth(selectedDate);
Date lastDayOfMonth = DateUtils.getLastDayOfMonth(selectedDate);
calendarFirstDayOfMonth.setTime(firstDayOfMonth);
calendarLastDayOfMonth.setTime(lastDayOfMonth);
calendarFirstDayOfMonth.add(Calendar.MONTH, -1);
calendarLastDayOfMonth.add(Calendar.MONTH, 1);
OccupationManager ocManager = OccupationManager.getDefault();
OccupationSearch ocSearch = new OccupationSearch();
ocSearch.setStartOccupationDate(calendarFirstDayOfMonth.getTime());
ocSearch.setEndOccupationDate(calendarLastDayOfMonth.getTime());
ocSearch.setUser(user);
for (Occupation oc : ocManager.getAllEntities(ocSearch, null)) {
OcupationEntryImpl oce = new OcupationEntryImpl();
oce.setStart(DateUtils.minHourInDate(oc.getStartDate()));
oce.setEnd(DateUtils.maxHourInDate(oc.getEndDate()));
oce.setVacances(false);
oce.setDescription(oc.getProject().getName() + "(" + oc.getProject().getClient().getName() + "). " + oc.getDescription());
oce.setDuration(oc.getDuration());
model.addOcupationEntry(oce);
}
}
Aggregations