Example usage for org.joda.time LocalDate fromDateFields

List of usage examples for org.joda.time LocalDate fromDateFields

Introduction

In this page you can find the example usage for org.joda.time LocalDate fromDateFields.

Prototype

@SuppressWarnings("deprecation")
public static LocalDate fromDateFields(Date date) 

Source Link

Document

Constructs a LocalDate from a java.util.Date using exactly the same field values.

Usage

From source file:org.kuali.kpme.tklm.leave.block.web.LeaveBlockHistoryLookupableHelperServiceImpl.java

License:Educational Community License

@Override
protected Collection<?> executeSearch(Map<String, String> searchCriteria,
        List<String> wildcardAsLiteralSearchCriteria, boolean bounded, Integer searchResultsLimit) {
    // TODO Auto-generated method stub
    if (searchCriteria.containsKey(BEGIN_DATE_ID)) {
        //beginDate = searchCriteria.get(BEGIN_DATE);
        searchCriteria.put(BEGIN_TIMESTAMP, searchCriteria.get(BEGIN_DATE_ID));
        searchCriteria.remove(BEGIN_DATE_ID);
    }/*from  w w w .ja  va  2  s  .  c om*/

    String documentId = searchCriteria.get(DOC_ID);
    String principalId = searchCriteria.get("principalId");
    String userPrincipalId = searchCriteria.get("userPrincipalId");
    String leaveBlockType = searchCriteria.get("leaveBlockType");

    LocalDate fromDate = null;
    LocalDate toDate = null;
    if (StringUtils.isNotBlank(searchCriteria.get(BEGIN_TIMESTAMP))) {
        String fromDateString = TKUtils.getFromDateString(searchCriteria.get(BEGIN_TIMESTAMP));
        String toDateString = TKUtils.getToDateString(searchCriteria.get(BEGIN_TIMESTAMP));
        Range range = SearchExpressionUtils.parseRange(searchCriteria.get(BEGIN_TIMESTAMP));
        boolean invalid = false;
        if (range.getLowerBoundValue() != null && range.getUpperBoundValue() != null) {
            fromDate = TKUtils.formatDateString(fromDateString);
            if (fromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }

            toDate = TKUtils.formatDateString(toDateString);
            if (toDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        } else if (range.getLowerBoundValue() != null) {
            fromDate = TKUtils.formatDateString(fromDateString);
            if (fromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }
        } else if (range.getUpperBoundValue() != null) {
            toDate = TKUtils.formatDateString(toDateString);
            if (toDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        }
        if (invalid) {
            return new ArrayList<LeaveBlockHistory>();
        }
    }

    LocalDate modifiedFromDate = null;
    LocalDate modifiedToDate = null;
    if (StringUtils.isNotBlank(searchCriteria.get("timestamp"))) {
        String fromDateString = TKUtils.getFromDateString(searchCriteria.get("timestamp"));
        String toDateString = TKUtils.getToDateString(searchCriteria.get("timestamp"));
        Range range = SearchExpressionUtils.parseRange(searchCriteria.get("timestamp"));
        boolean invalid = false;
        if (range.getLowerBoundValue() != null && range.getUpperBoundValue() != null) {
            modifiedFromDate = TKUtils.formatDateString(fromDateString);
            if (modifiedFromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }

            modifiedToDate = TKUtils.formatDateString(toDateString);
            if (modifiedToDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        } else if (range.getLowerBoundValue() != null) {
            modifiedFromDate = TKUtils.formatDateString(fromDateString);
            if (modifiedFromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }
        } else if (range.getUpperBoundValue() != null) {
            modifiedToDate = TKUtils.formatDateString(toDateString);
            if (modifiedToDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        }
        if (invalid) {
            return new ArrayList<LeaveBlockHistory>();
        }
    }

    //Could also simply use super.getSearchResults for an initial object list, then invoke LeaveBlockService with the relevant query params.
    //List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForLookup(documentId, principalId, userPrincipalId, fromDate, toDate, leaveBlockType);
    List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForLookup(
            documentId, principalId, userPrincipalId, fromDate, toDate, leaveBlockType);
    List<LeaveBlockHistory> objectList = new ArrayList<LeaveBlockHistory>();

    for (LeaveBlock leaveBlock : leaveBlockList) {
        List<LeaveBlockHistory> histories = LmServiceLocator.getLeaveBlockHistoryService()
                .getLeaveBlockHistoryByLmLeaveBlockId(leaveBlock.getLmLeaveBlockId());
        for (LeaveBlockHistory history : histories) {

            boolean addToResults = false;
            if (modifiedFromDate != null && modifiedToDate != null) {
                if (history.getTimestamp().compareTo(modifiedFromDate.toDate()) >= 0
                        && history.getTimestamp().compareTo(modifiedToDate.toDate()) <= 0) {
                    addToResults = true;
                }
            } else if (modifiedFromDate != null) {
                if (history.getTimestamp().compareTo(modifiedFromDate.toDate()) >= 0) {
                    addToResults = true;
                }
            } else if (modifiedToDate != null) {
                if (history.getTimestamp().compareTo(modifiedToDate.toDate()) <= 0) {
                    addToResults = true;
                }
            } else {
                addToResults = true;
            }
            if (addToResults) {
                LeaveCalendarDocumentHeader lcHeader = LmServiceLocator.getLeaveCalendarDocumentHeaderService()
                        .getDocumentHeader(history.getDocumentId());

                if (lcHeader != null) {
                    if (StringUtils.isNotBlank(searchCriteria.get(DOC_STATUS_ID))) {
                        //only add if doc status is one of those specified
                        if (searchCriteria.get(DOC_STATUS_ID).contains("category")) {
                            //format for categorical statuses is "category:Q" where 'Q' is one of "P,S,U".
                            //which category was selected, and is the time block on a timesheet with this status.
                            if (searchCriteria.get(DOC_STATUS_ID).contains("P")) {
                                //pending statuses
                                if ("I,S,R,E".contains(lcHeader.getDocumentStatus())) {
                                    objectList.add(history);
                                }
                            } else if (searchCriteria.get(DOC_STATUS_ID).contains("S")) {
                                //successful statuses
                                if ("P,F".contains(lcHeader.getDocumentStatus())) {
                                    objectList.add(history);
                                }
                            } else if (searchCriteria.get(DOC_STATUS_ID).contains("U")) {
                                //unsuccessful statuses
                                if ("X,D".contains(lcHeader.getDocumentStatus())) {
                                    objectList.add(history);
                                }
                            }
                        } else if (searchCriteria.get(DOC_STATUS_ID).contains(lcHeader.getDocumentStatus())) {
                            //match the specific doc status
                            objectList.add(history);
                        }
                    } else {
                        //no status specified, add regardless of status
                        objectList.add(history);
                    }

                } else if (StringUtils.isBlank(searchCriteria.get(DOC_STATUS_ID))) {
                    //can't match doc status with a non existent header
                    //only add to list if no status was selected
                    objectList.add(history);
                }
            }

        }
    }
    if (!objectList.isEmpty()) {
        Iterator<? extends BusinessObject> itr = objectList.iterator();

        //TODO - performance  -- need to get roles outside of loop for user, and check inside... too many db calls
        while (itr.hasNext()) {
            LeaveBlockHistory tb = (LeaveBlockHistory) itr.next();

            Long workArea = tb.getWorkArea();

            JobContract job = HrServiceLocator.getJobService().getJob(tb.getPrincipalId(), tb.getJobNumber(),
                    LocalDate.fromDateFields(tb.getLeaveDate()), false);
            String department = job != null ? job.getDept() : null;
            String groupKeyCode = job != null ? job.getGroupKeyCode() : null;
            Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department,
                    groupKeyCode, LocalDate.fromDateFields(tb.getLeaveDate()));
            String location = departmentObj != null ? departmentObj.getGroupKey().getLocationId() : null;
            DateTime date = LocalDate.now().toDateTimeAtStartOfDay();
            boolean valid = false;
            if (HrServiceLocator.getKPMEGroupService()
                    .isMemberOfSystemAdministratorGroup(HrContext.getPrincipalId(), date)
                    || HrServiceLocator.getKPMEGroupService()
                            .isMemberOfSystemViewOnlyGroup(HrContext.getPrincipalId(), date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(),
                            KPMERole.APPROVER.getRoleName(), workArea, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_DEPARTMENT_ADMINISTRATOR.getRoleName(), department, groupKeyCode,
                            date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_DEPARTMENT_ADMINISTRATOR.getRoleName(), department, groupKeyCode,
                            date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_LOCATION_ADMINISTRATOR.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_LOCATION_ADMINISTRATOR.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_LOCATION_VIEW_ONLY.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_DEPARTMENT_VIEW_ONLY.getRoleName(), location, groupKeyCode, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_DEPARTMENT_VIEW_ONLY.getRoleName(), location, groupKeyCode, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_LOCATION_VIEW_ONLY.getRoleName(), location, date)) {
                valid = true;
            }

            if (!valid) {

                itr.remove();
                continue;
            }
        }

    }
    return objectList;
}

From source file:org.kuali.kpme.tklm.leave.block.web.LeaveBlockLookupableHelperServiceImpl.java

License:Educational Community License

@Override
protected Collection<?> executeSearch(Map<String, String> searchCriteria,
        List<String> wildcardAsLiteralSearchCriteria, boolean bounded, Integer searchResultsLimit) {
    // TODO Auto-generated method stub
    if (searchCriteria.containsKey(BEGIN_DATE_ID)) {
        //beginDate = searchCriteria.get(BEGIN_DATE);
        searchCriteria.put(BEGIN_TIMESTAMP, searchCriteria.get(BEGIN_DATE_ID));
        searchCriteria.remove(BEGIN_DATE_ID);
    }/*from w  w  w. j  av a  2 s  . c  om*/

    String documentId = searchCriteria.get(DOC_ID);
    String principalId = searchCriteria.get("principalId");
    String userPrincipalId = searchCriteria.get("userPrincipalId");
    String leaveBlockType = searchCriteria.get("leaveBlockType");
    String affectPay = searchCriteria.get("affectPay");
    String fromDateString = TKUtils.getFromDateString(searchCriteria.get(BEGIN_TIMESTAMP));
    String toDateString = TKUtils.getToDateString(searchCriteria.get(BEGIN_TIMESTAMP));

    LocalDate fromDate = null;
    LocalDate toDate = null;
    if (StringUtils.isNotBlank(searchCriteria.get(BEGIN_TIMESTAMP))) {
        Range range = SearchExpressionUtils.parseRange(searchCriteria.get(BEGIN_TIMESTAMP));
        boolean invalid = false;
        if (range.getLowerBoundValue() != null && range.getUpperBoundValue() != null) {
            fromDate = TKUtils.formatDateString(fromDateString);
            if (fromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }

            toDate = TKUtils.formatDateString(toDateString);
            if (toDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        } else if (range.getLowerBoundValue() != null) {
            fromDate = TKUtils.formatDateString(fromDateString);
            if (fromDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[rangeLowerBoundKeyPrefix_beginDate]",
                        "error.invalidLookupDate", range.getLowerBoundValue());
                invalid = true;
            }
        } else if (range.getUpperBoundValue() != null) {
            toDate = TKUtils.formatDateString(toDateString);
            if (toDate == null) {
                GlobalVariables.getMessageMap().putError("lookupCriteria[beginDate]", "error.invalidLookupDate",
                        range.getUpperBoundValue());
                invalid = true;
            }
        }
        if (invalid) {
            return new ArrayList<LeaveBlockBo>();
        }
    }

    //Could also simply use super.getSearchResults for an initial object list, then invoke LeaveBlockService with the relevant query params.
    List<LeaveBlock> leaveBlockList = LmServiceLocator.getLeaveBlockService().getLeaveBlocksForLookup(
            documentId, principalId, userPrincipalId, fromDate, toDate, leaveBlockType);
    List<LeaveBlockBo> objectList = new ArrayList<LeaveBlockBo>();

    for (LeaveBlock lBlock : leaveBlockList) {
        LeaveCalendarDocumentHeader lcHeader = LmServiceLocator.getLeaveCalendarDocumentHeaderService()
                .getDocumentHeader(lBlock.getDocumentId());

        if (lcHeader != null) {
            if (StringUtils.isNotBlank(searchCriteria.get(DOC_STATUS_ID))) {
                //only add if doc status is one of those specified
                if (searchCriteria.get(DOC_STATUS_ID).contains("category")) {
                    //format for categorical statuses is "category:Q" where 'Q' is one of "P,S,U".
                    //which category was selected, and is the time block on a timesheet with this status.
                    if (searchCriteria.get(DOC_STATUS_ID).contains("P")) {
                        //pending statuses
                        if ("I,S,R,E".contains(lcHeader.getDocumentStatus())) {
                            objectList.add(LeaveBlockBo.from(lBlock));
                        }
                    } else if (searchCriteria.get(DOC_STATUS_ID).contains("S")) {
                        //successful statuses
                        if ("P,F".contains(lcHeader.getDocumentStatus())) {
                            objectList.add(LeaveBlockBo.from(lBlock));
                        }
                    } else if (searchCriteria.get(DOC_STATUS_ID).contains("U")) {
                        //unsuccessful statuses
                        if ("X,D".contains(lcHeader.getDocumentStatus())) {
                            objectList.add(LeaveBlockBo.from(lBlock));
                        }
                    }
                } else if (searchCriteria.get(DOC_STATUS_ID).contains(lcHeader.getDocumentStatus())) {
                    //match the specific doc status
                    objectList.add(LeaveBlockBo.from(lBlock));
                }
            } else {
                //no status specified, add regardless of status
                objectList.add(LeaveBlockBo.from(lBlock));
            }

        } else if (StringUtils.isBlank(searchCriteria.get(DOC_STATUS_ID))) {
            //can't match doc status with a non existent header
            //only add to list if no status was selected
            objectList.add(LeaveBlockBo.from(lBlock));
        }
    }

    if (!objectList.isEmpty()) {
        Iterator<? extends BusinessObject> itr = objectList.iterator();
        DateTime date = LocalDate.now().toDateTimeAtStartOfDay();
        while (itr.hasNext()) {
            LeaveBlockBo lb = (LeaveBlockBo) itr.next();

            Long workArea = lb.getWorkArea();

            JobContract job = HrServiceLocator.getJobService().getJob(lb.getPrincipalId(), lb.getJobNumber(),
                    LocalDate.fromDateFields(lb.getLeaveDate()), false);
            String department = job != null ? job.getDept() : null;
            String groupKeyCode = job != null ? job.getGroupKeyCode() : null;
            Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department,
                    groupKeyCode, LocalDate.fromDateFields(lb.getLeaveDate()));
            String location = departmentObj != null ? departmentObj.getGroupKey().getLocationId() : null;

            boolean valid = false;
            if (HrServiceLocator.getKPMEGroupService()
                    .isMemberOfSystemAdministratorGroup(HrContext.getPrincipalId(), date)
                    || HrServiceLocator.getKPMEGroupService()
                            .isMemberOfSystemViewOnlyGroup(HrContext.getPrincipalId(), date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_HR.getNamespaceCode(),
                            KPMERole.APPROVER.getRoleName(), workArea, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_DEPARTMENT_ADMINISTRATOR.getRoleName(), department, groupKeyCode,
                            date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_DEPARTMENT_ADMINISTRATOR.getRoleName(), department, groupKeyCode,
                            date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_LOCATION_ADMINISTRATOR.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_LOCATION_ADMINISTRATOR.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_LOCATION_VIEW_ONLY.getRoleName(), location, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_LM.getNamespaceCode(),
                            KPMERole.LEAVE_DEPARTMENT_VIEW_ONLY.getRoleName(), department, groupKeyCode, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_DEPARTMENT_VIEW_ONLY.getRoleName(), department, groupKeyCode, date)
                    || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(
                            HrContext.getPrincipalId(), KPMENamespace.KPME_TK.getNamespaceCode(),
                            KPMERole.TIME_LOCATION_VIEW_ONLY.getRoleName(), location, date)) {
                valid = true;
            }

            if (!valid) {
                itr.remove();
                continue;
            } else {
                // check for affects pay
                if (affectPay != null && !affectPay.isEmpty()) {
                    EarnCodeContract earnCodeObj = HrServiceLocator.getEarnCodeService()
                            .getEarnCode(lb.getEarnCode(), lb.getLeaveLocalDate());
                    if (!(earnCodeObj != null && affectPay.equalsIgnoreCase(earnCodeObj.getAffectPay()))) {
                        itr.remove();
                        continue;
                    }
                }
            }
        }

    }
    return objectList;
}

From source file:org.kuali.kpme.tklm.leave.calendar.LeaveCalendar.java

License:Educational Community License

public LeaveCalendar(String principalId, CalendarEntry calendarEntry, List<String> assignmentKeys) {
    super(calendarEntry);

    DateTime currentDisplayDateTime = getBeginDateTime();
    DateTime endDisplayDateTime = getEndDateTime();

    // Fill in the days if the first day or end day is in the middle of the week
    if (currentDisplayDateTime.getDayOfWeek() != DateTimeConstants.SUNDAY) {
        currentDisplayDateTime = currentDisplayDateTime.minusDays(currentDisplayDateTime.getDayOfWeek());
    }/*from  ww w.j a v  a  2s. c om*/
    if (endDisplayDateTime.getDayOfWeek() != DateTimeConstants.SATURDAY) {
        endDisplayDateTime = endDisplayDateTime
                .plusDays(DateTimeConstants.SATURDAY - endDisplayDateTime.getDayOfWeek());
    }

    LeaveCalendarWeek leaveCalendarWeek = new LeaveCalendarWeek();
    Integer dayNumber = 0;
    List<LeaveBlock> blocks = LmServiceLocator.getLeaveBlockService().getLeaveBlocks(principalId,
            calendarEntry.getBeginPeriodFullDateTime().toLocalDate(),
            calendarEntry.getEndPeriodFullDateTime().toLocalDate());
    Map<String, List<LeaveBlock>> leaveBlockMap = new HashMap<String, List<LeaveBlock>>();
    for (LeaveBlock lb : blocks) {
        String key = lb.getLeaveLocalDate().toString();
        if (leaveBlockMap.containsKey(key)) {
            leaveBlockMap.get(key).add(lb);
        } else {
            leaveBlockMap.put(key, createNewLeaveBlockList(lb));
        }
    }

    //KPME-2560 If leave calendar document is final status, then User wont be able to add leave blocks to the calendar. 
    Boolean dayEditableFlag = true;
    LeaveCalendarDocumentHeader header = LmServiceLocator.getLeaveCalendarDocumentHeaderService()
            .getDocumentHeader(principalId, calendarEntry.getBeginPeriodFullDateTime(),
                    calendarEntry.getEndPeriodFullDateTime());
    if (header != null && header.getDocumentStatus().equals(HrConstants.ROUTE_STATUS.FINAL))
        dayEditableFlag = false;

    while (currentDisplayDateTime.isBefore(endDisplayDateTime)
            || currentDisplayDateTime.isEqual(endDisplayDateTime)) {
        LeaveCalendarDay leaveCalendarDay = new LeaveCalendarDay();

        // If the day is not within the current pay period, mark them as read only (gray)
        if (currentDisplayDateTime.isBefore(getBeginDateTime())
                || currentDisplayDateTime.isEqual(getEndDateTime())
                || currentDisplayDateTime.isAfter(getEndDateTime())) {
            leaveCalendarDay.setGray(true);
        } else {
            // This is for the div id of the days on the calendar.
            // It creates a day id like day_11/01/2011 which will make day parsing easier in the javascript.
            //                leaveCalendarDay.setDayNumberDelta(currDateTime.toString(HrConstants.DT_BASIC_DATE_FORMAT));
            //                leaveCalendarDay.setDayNumberDelta(currDateTime.getDayOfMonth());
            leaveCalendarDay.setDayNumberDelta(dayNumber);

            LocalDate leaveDate = currentDisplayDateTime.toLocalDate();
            List<LeaveBlock> lbs = leaveBlockMap.get(currentDisplayDateTime.toLocalDate().toString());
            if (lbs == null) {
                lbs = Collections.emptyList();
            }
            // use given assignmentKeys to control leave blocks displayed on the calendar
            if (CollectionUtils.isNotEmpty(lbs) && CollectionUtils.isNotEmpty(assignmentKeys)) {
                List<LeaveBlock> leaveBlocks = LmServiceLocator.getLeaveBlockService()
                        .filterLeaveBlocksForLeaveCalendar(lbs, assignmentKeys);
                leaveCalendarDay.setLeaveBlocks(leaveBlocks);
            } else {
                leaveCalendarDay.setLeaveBlocks(lbs);
            }

            if (HrServiceLocator.getHRPermissionService().canViewLeaveTabsWithNEStatus()) {
                TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService()
                        .getDocumentHeaderForDate(principalId, leaveDate.toDateTimeAtStartOfDay());
                if (tdh != null) {
                    if (DateUtils.isSameDay(leaveDate.toDate(), tdh.getEndDate())
                            || leaveDate.isAfter(LocalDate.fromDateFields(tdh.getEndDate()))) {
                        leaveCalendarDay.setDayEditable(true);
                    }
                } else {
                    leaveCalendarDay.setDayEditable(true);
                }
            } else {
                leaveCalendarDay.setDayEditable(true);
            }
            //KPME-2560 If leave calendar document is final status, then User wont be able to add leave blocks to the calendar. 
            if (!dayEditableFlag)
                leaveCalendarDay.setDayEditable(false);

            dayNumber++;
        }
        leaveCalendarDay.setDayNumberString(currentDisplayDateTime.dayOfMonth().getAsShortText());
        leaveCalendarDay.setDateString(currentDisplayDateTime.toString(HrConstants.DT_BASIC_DATE_FORMAT));

        leaveCalendarWeek.getDays().add(leaveCalendarDay);

        if (leaveCalendarWeek.getDays().size() == DateTimeConstants.DAYS_PER_WEEK) {
            getWeeks().add(leaveCalendarWeek);
            leaveCalendarWeek = new LeaveCalendarWeek();
        }

        currentDisplayDateTime = currentDisplayDateTime.plusDays(1);
    }

    if (!leaveCalendarWeek.getDays().isEmpty()) {
        getWeeks().add(leaveCalendarWeek);
    }

    boolean isPlanningCal = LmServiceLocator.getLeaveCalendarService().isLeavePlanningCalendar(principalId,
            calendarEntry.getBeginPeriodFullDateTime().toLocalDate(),
            calendarEntry.getEndPeriodFullDateTime().toLocalDate());
    Map<String, String> earnCodes = HrServiceLocator.getEarnCodeService().getEarnCodesForDisplay(principalId,
            isPlanningCal);
    setEarnCodeList(earnCodes);
}

From source file:org.kuali.kpme.tklm.leave.payout.web.LeavePayoutForm.java

License:Educational Community License

public EarnCode getPayoutEarnCodeObj() {
    return HrServiceLocator.getEarnCodeService().getEarnCode(earnCode, LocalDate.fromDateFields(effectiveDate));
}

From source file:org.kuali.kpme.tklm.leave.payout.web.LeavePayoutForm.java

License:Educational Community License

public AccrualCategory getDebitedAccrualCategory() {
    return HrServiceLocator.getAccrualCategoryService().getAccrualCategory(fromAccrualCategory,
            LocalDate.fromDateFields(effectiveDate));
}

From source file:org.kuali.kpme.tklm.leave.timeoff.SystemScheduledTimeOff.java

License:Educational Community License

public LocalDate getAccruedLocalDate() {
    return accruedDate != null ? LocalDate.fromDateFields(accruedDate) : null;
}

From source file:org.kuali.kpme.tklm.leave.timeoff.SystemScheduledTimeOff.java

License:Educational Community License

public LocalDate getScheduledTimeOffLocalDate() {
    return scheduledTimeOffDate != null ? LocalDate.fromDateFields(scheduledTimeOffDate) : null;
}

From source file:org.kuali.kpme.tklm.leave.transfer.web.BalanceTransferForm.java

License:Educational Community License

public AccrualCategory getCreditedAccrualCategory() {
    return HrServiceLocator.getAccrualCategoryService().getAccrualCategory(toAccrualCategory,
            LocalDate.fromDateFields(effectiveDate));
}

From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunch.java

License:Educational Community License

public Date getActionDate() {
    return actionDateTime != null ? LocalDate.fromDateFields(actionDateTime).toDate() : null;
}

From source file:org.kuali.kpme.tklm.time.missedpunch.MissedPunch.java

License:Educational Community License

public void setActionDate(Date actionDate) {
    LocalDate localDate = actionDate != null ? LocalDate.fromDateFields(actionDate) : null;
    LocalTime localTime = actionDateTime != null ? LocalTime.fromDateFields(actionDateTime)
            : LocalTime.MIDNIGHT;
    actionDateTime = localDate != null ? localDate.toDateTime(localTime).toDate() : null;
}