Search in sources :

Example 1 with OccupationSearch

use of com.autentia.tnt.dao.search.OccupationSearch 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);
    }
}
Also used : Occupation(com.autentia.tnt.businessobject.Occupation) Calendar(java.util.Calendar) Date(java.util.Date) OccupationManager(com.autentia.tnt.manager.activity.OccupationManager) OccupationSearch(com.autentia.tnt.dao.search.OccupationSearch)

Aggregations

Occupation (com.autentia.tnt.businessobject.Occupation)1 OccupationSearch (com.autentia.tnt.dao.search.OccupationSearch)1 OccupationManager (com.autentia.tnt.manager.activity.OccupationManager)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1