List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:org.kuali.kpme.tklm.leave.batch.web.CarryOverBatchJobAction.java
License:Educational Community License
public ActionForward runCarryOverBatchJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { CarryOverBatchJobActionForm cobjaf = (CarryOverBatchJobActionForm) form; LeavePlan leavePlan = HrServiceLocator.getLeavePlanService().getLeavePlan(cobjaf.getLeavePlan(), LocalDate.now()); DateTime scheduleDate = new DateTime(); TkServiceLocator.getBatchJobService().scheduleLeaveCarryOverJobs(leavePlan, scheduleDate); return mapping.findForward("basic"); }
From source file:org.kuali.kpme.tklm.leave.block.LeaveBlock.java
License:Educational Community License
public String getAssignmentTitle() { StringBuilder b = new StringBuilder(); if (this.workArea != null) { WorkArea wa = HrServiceLocator.getWorkAreaService().getWorkArea(this.workArea, LocalDate.now()); if (wa != null) { b.append(wa.getDescription()); }//from w w w .j ava2 s . co m Task task = HrServiceLocator.getTaskService().getTask(this.getTask(), this.getLeaveLocalDate()); if (task != null) { // do not display task description if the task is the default // one // default task is created in getTask() of TaskService if (!task.getDescription().equals(HrConstants.TASK_DEFAULT_DESP)) { b.append("-" + task.getDescription()); } } } return b.toString(); }
From source file:org.kuali.kpme.tklm.leave.block.LeaveBlock.java
License:Educational Community License
public String getCalendarId() { PrincipalHRAttributes principalHRAttributes = HrServiceLocator.getPrincipalHRAttributeService() .getPrincipalCalendar(this.principalId, LocalDate.now()); Calendar pcal = null;//from ww w.j a v a 2s.c o m if (principalHRAttributes != null) { //pcal = principalHRAttributes.getCalendar() != null ? principalHRAttributes.getCalendar() : principalHRAttributes.getLeaveCalObj() ; pcal = principalHRAttributes.getLeaveCalObj() != null ? principalHRAttributes.getLeaveCalObj() : principalHRAttributes.getCalendar(); if (pcal != null) { CalendarEntry calEntries = HrServiceLocator.getCalendarEntryService() .getCurrentCalendarEntryByCalendarId(pcal.getHrCalendarId(), getLeaveLocalDate().toDateTimeAtStartOfDay()); if (calEntries != null) { this.calendarId = calEntries.getHrCalendarEntryId(); } } } return calendarId; }
From source file:org.kuali.kpme.tklm.leave.block.LeaveBlockBo.java
License:Educational Community License
public String getAssignmentTitle() { StringBuilder b = new StringBuilder(); if (this.workArea != null) { WorkArea wa = HrServiceLocator.getWorkAreaService().getWorkArea(this.workArea, LocalDate.now()); if (wa != null) { b.append(wa.getDescription()); }//from w w w .ja v a 2s .co m TaskContract task = HrServiceLocator.getTaskService().getTask(this.getTask(), this.getLeaveLocalDate()); if (task != null) { // do not display task description if the task is the default // one // default task is created in getTask() of TaskService if (!task.getDescription().equals(HrConstants.TASK_DEFAULT_DESP)) { b.append("-").append(task.getDescription()); } } } return b.toString(); }
From source file:org.kuali.kpme.tklm.leave.block.LeaveBlockHistory.java
License:Educational Community License
public String getAssignmentTitle() { StringBuilder b = new StringBuilder(); LeaveBlock lb = LmServiceLocator.getLeaveBlockService().getLeaveBlock(super.getLmLeaveBlockId()); if (lb != null) { if (lb.getWorkArea() != null) { WorkArea wa = HrServiceLocator.getWorkAreaService().getWorkArea(lb.getWorkArea(), LocalDate.now()); if (wa != null) { b.append(wa.getDescription()); }//www .j a v a2 s .com Task task = HrServiceLocator.getTaskService().getTask(this.getTask(), this.getLeaveLocalDate()); if (task != null) { // do not display task description if the task is the default // one // default task is created in getTask() of TaskService if (!task.getDescription().equals(HrConstants.TASK_DEFAULT_DESP)) { b.append("-" + task.getDescription()); } } } } return b.toString(); }
From source file:org.kuali.kpme.tklm.leave.block.web.LeaveBlockDisplayAction.java
License:Educational Community License
@Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionForward forward = super.execute(mapping, form, request, response); LeaveBlockDisplayForm lbdf = (LeaveBlockDisplayForm) form; PrincipalHRAttributes principalHRAttributes = HrServiceLocator.getPrincipalHRAttributeService() .getPrincipalCalendar(HrContext.getTargetPrincipalId(), LocalDate.now()); String leavePlan = (principalHRAttributes != null) ? principalHRAttributes.getLeavePlan() : null; if (lbdf.getNavString() == null) { lbdf.setYear(LocalDate.now().getYear()); } else if (lbdf.getNavString().equals("NEXT")) { lbdf.setYear(lbdf.getYear() + 1); } else if (lbdf.getNavString().equals("PREV")) { lbdf.setYear(lbdf.getYear() - 1); }//from ww w. j a va 2 s . com LocalDate beginDate = new LocalDate(lbdf.getYear(), 1, 1); LocalDate serviceDate = (principalHRAttributes != null) ? principalHRAttributes.getServiceLocalDate() : beginDate; LocalDate endDate = new LocalDate(lbdf.getYear(), 12, 31); lbdf.setAccrualCategories(getAccrualCategories(leavePlan)); lbdf.setLeaveEntries(getLeaveEntries(HrContext.getTargetPrincipalId(), serviceDate, beginDate, endDate, lbdf.getAccrualCategories())); List<LeaveBlockHistory> correctedLeaveEntries = LmServiceLocator.getLeaveBlockHistoryService() .getLeaveBlockHistoriesForLeaveDisplay(HrContext.getTargetPrincipalId(), beginDate, endDate, Boolean.TRUE); if (correctedLeaveEntries != null) { for (LeaveBlockHistory leaveBlockHistory : correctedLeaveEntries) { if (leaveBlockHistory.getAction() != null && leaveBlockHistory.getAction().equalsIgnoreCase(HrConstants.ACTION.DELETE)) { leaveBlockHistory.setPrincipalIdModified(leaveBlockHistory.getPrincipalIdDeleted()); leaveBlockHistory.setTimestamp(leaveBlockHistory.getTimestampDeleted()); } // Set Description if (leaveBlockHistory.getDescription() == null || leaveBlockHistory.getDescription().trim().isEmpty()) { leaveBlockHistory.setDescription( this.retrieveDescriptionAccordingToLeaveType(leaveBlockHistory.getLeaveBlockType())); } } } lbdf.setCorrectedLeaveEntries(correctedLeaveEntries); List<LeaveBlockHistory> inActiveLeaveEntries = LmServiceLocator.getLeaveBlockHistoryService() .getLeaveBlockHistoriesForLeaveDisplay(HrContext.getTargetPrincipalId(), beginDate, endDate, Boolean.FALSE); List<LeaveBlockHistory> leaveEntries = null; if (inActiveLeaveEntries != null) { leaveEntries = new ArrayList<LeaveBlockHistory>(); for (LeaveBlockHistory leaveBlockHistory : inActiveLeaveEntries) { if (leaveBlockHistory.getAccrualGenerated() == null || !leaveBlockHistory.getAccrualGenerated()) { if (leaveBlockHistory.getAction() != null) { if (leaveBlockHistory.getAction().equalsIgnoreCase(HrConstants.ACTION.DELETE)) { leaveBlockHistory.setPrincipalIdModified(leaveBlockHistory.getPrincipalIdDeleted()); leaveBlockHistory.setTimestamp(leaveBlockHistory.getTimestampDeleted()); } else if (leaveBlockHistory.getAction().equalsIgnoreCase(HrConstants.ACTION.MODIFIED)) { leaveBlockHistory.setPrincipalIdModified(leaveBlockHistory.getPrincipalIdDeleted()); } } this.assignDocumentStatusToLeaveBlock(leaveBlockHistory); // if it is not generated by accrual then add it to the inactivelist // Set Description if (leaveBlockHistory.getDescription() == null || leaveBlockHistory.getDescription().trim().isEmpty()) { leaveBlockHistory.setDescription(this .retrieveDescriptionAccordingToLeaveType(leaveBlockHistory.getLeaveBlockType())); } if (StringUtils.isNotBlank(leaveBlockHistory.getRequestStatus())) { leaveBlockHistory.setRequestStatus( HrConstants.REQUEST_STATUS_STRINGS.get(leaveBlockHistory.getRequestStatus())); } leaveEntries.add(leaveBlockHistory); } } } lbdf.setInActiveLeaveEntries(leaveEntries); return forward; }
From source file:org.kuali.kpme.tklm.leave.block.web.LeaveBlockDisplayAction.java
License:Educational Community License
private List<AccrualCategory> getAccrualCategories(String leavePlan) { List<AccrualCategory> accrualCategories = new ArrayList<AccrualCategory>(); List<AccrualCategory> allAccrualCategories = HrServiceLocator.getAccrualCategoryService() .getActiveAccrualCategoriesForLeavePlan(leavePlan, LocalDate.now()); if (allAccrualCategories != null) { for (AccrualCategory ac : allAccrualCategories) { if (StringUtils.equalsIgnoreCase(ac.getShowOnGrid(), "Y")) { accrualCategories.add(ac); }/*from www . j a v a 2s. com*/ } Collections.sort(accrualCategories, new Comparator<AccrualCategory>() { @Override public int compare(AccrualCategory o1, AccrualCategory o2) { return ObjectUtils.compare(o1.getAccrualCategory(), o2.getAccrualCategory()); } }); } return accrualCategories; }
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 ww .j a v a 2s .c o m 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); }/* ww w .ja va 2s . 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.service.LeaveCalendarServiceImpl.java
License:Educational Community License
public boolean isLeavePlanningCalendar(String principalId, LocalDate beginDate, LocalDate endDate) { LocalDate today = LocalDate.now(); List<Job> jobs = HrServiceLocator.getJobService().getJobs(principalId, endDate); for (Job job : jobs) { // Check for Leave eligibility. if (job.isEligibleForLeave()) { // Check for Time (FLSA nonexempt) jobs. If one exists, then the Leave Calendar is always a Leave Planning Calendar if (job.getFlsaStatus().equalsIgnoreCase(HrConstants.FLSA_STATUS_NON_EXEMPT)) { return true; } else { // If leave eligible and FLSA exempt, then report leave in the Leave Calendar. Use the date to determine Planning vs Recording Calendars. if (beginDate.isAfter(today)) { // future period, this is a Planning Calendar. return true; } else { // not a future period, this is a Reporting Calendar. return false; }/*w w w.j ava2 s .c o m*/ } } else { // not leave eligible return false; } } return false; }