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.time.missedpunch.MissedPunchServiceImpl.java
License:Educational Community License
protected MissedPunch addClockLogAndTimeBlocks(MissedPunch missedPunch, String ipAddress, String logEndId, String logBeginId) {/*from w w w . j ava2s .c o m*/ MissedPunch.Builder builder = MissedPunch.Builder.create(missedPunch); TimesheetDocument timesheetDocument = timesheetService .getTimesheetDocument(missedPunch.getTimesheetDocumentId()); AssignmentDescriptionKey assignmentDescriptionKey = new AssignmentDescriptionKey( missedPunch.getGroupKeyCode(), missedPunch.getJobNumber(), missedPunch.getWorkArea(), missedPunch.getTask()); Assignment assignment = HrServiceLocator.getAssignmentService().getAssignment(missedPunch.getPrincipalId(), assignmentDescriptionKey, missedPunch.getActionLocalDate()); CalendarEntry calendarEntry = timesheetDocument.getCalendarEntry(); String dateString = TKUtils.formatDateTimeShort(missedPunch.getActionFullDateTime()); String longDateString = TKUtils.formatDateTimeLong(missedPunch.getActionFullDateTime()); String timeString = TKUtils.formatTimeShort(longDateString); String userTimezone = HrServiceLocator.getTimezoneService().getUserTimezone(missedPunch.getPrincipalId()); DateTimeZone userTimeZone = DateTimeZone.forID(userTimezone); DateTime dateTimeWithUserZone = TKUtils.convertDateStringToDateTimeWithTimeZone(dateString, timeString, userTimeZone); DateTime userActionDateTime = missedPunch.getActionFullDateTime(); DateTime actionDateTime = dateTimeWithUserZone.withZone(TKUtils.getSystemDateTimeZone()); String clockAction = missedPunch.getClockAction(); String principalId = timesheetDocument.getPrincipalId(); ClockLog clockLog = clockLogService.processClockLog(principalId, timesheetDocument.getDocumentId(), actionDateTime, assignment, calendarEntry, ipAddress, LocalDate.now(), clockAction, false); clockLogService.saveClockLog(clockLog); builder.setActionFullDateTime(missedPunch.getActionFullDateTime()); builder.setTkClockLogId(clockLog.getTkClockLogId()); if (logEndId != null || logBeginId != null) { ClockLog endLog; ClockLog beginLog; if (logEndId != null) { endLog = clockLogService.getClockLog(logEndId); } else { endLog = clockLog; } if (logBeginId != null) { beginLog = clockLogService.getClockLog(logBeginId); } else { beginLog = clockLog; } if (beginLog != null && endLog != null && beginLog.getClockDateTime().isBefore(endLog.getClockDateTime())) { String earnCode = assignment.getJob().getPayTypeObj().getRegEarnCode(); buildTimeBlockRunRules(beginLog, endLog, timesheetDocument, assignment, earnCode, beginLog.getClockDateTime(), endLog.getClockDateTime()); } } return builder.build(); }
From source file:org.kuali.kpme.tklm.time.missedpunch.service.MissedPunchServiceImpl.java
License:Educational Community License
@Override public void addClockLog(MissedPunch missedPunch, String ipAddress) { TimesheetDocument timesheetDocument = getTimesheetService() .getTimesheetDocument(missedPunch.getTimesheetDocumentId()); AssignmentDescriptionKey assignmentDescriptionKey = new AssignmentDescriptionKey(missedPunch.getJobNumber(), missedPunch.getWorkArea(), missedPunch.getTask()); Assignment assignment = HrServiceLocator.getAssignmentService().getAssignment(assignmentDescriptionKey, timesheetDocument.getDocEndDate()); CalendarEntry calendarEntry = timesheetDocument.getCalendarEntry(); DateTime userActionDateTime = missedPunch.getActionFullDateTime(); DateTimeZone userTimeZone = HrServiceLocator.getTimezoneService().getUserTimezoneWithFallback(); DateTime actionDateTime = new DateTime(userActionDateTime, userTimeZone) .withZone(TKUtils.getSystemDateTimeZone()); String clockAction = missedPunch.getClockAction(); String principalId = timesheetDocument.getPrincipalId(); ClockLog clockLog = getClockLogService().processClockLog(actionDateTime, assignment, calendarEntry, ipAddress, LocalDate.now(), timesheetDocument, clockAction, false, principalId); clockLog = TkServiceLocator.getClockLogService().saveClockLog(clockLog); missedPunch.setActionFullDateTime(clockLog.getClockDateTime()); missedPunch.setTkClockLogId(clockLog.getTkClockLogId()); if (StringUtils.equals(clockLog.getClockAction(), TkConstants.CLOCK_OUT) || StringUtils.equals(clockLog.getClockAction(), TkConstants.LUNCH_OUT)) { ClockLog lastClockLog = getClockLogService().getLastClockLog(missedPunch.getPrincipalId()); String earnCode = assignment.getJob().getPayTypeObj().getRegEarnCode(); buildTimeBlockRunRules(lastClockLog, clockLog, timesheetDocument, assignment, earnCode, lastClockLog.getClockDateTime(), clockLog.getClockDateTime()); }//from w w w . j ava 2 s.c o m }
From source file:org.kuali.kpme.tklm.time.missedpunch.service.MissedPunchServiceImpl.java
License:Educational Community License
private void addClockLogAndTimeBlocks(MissedPunch missedPunch, String ipAddress, String logEndId, String logBeginId) {//www . jav a 2 s . c o m TimesheetDocument timesheetDocument = getTimesheetService() .getTimesheetDocument(missedPunch.getTimesheetDocumentId()); AssignmentDescriptionKey assignmentDescriptionKey = new AssignmentDescriptionKey(missedPunch.getJobNumber(), missedPunch.getWorkArea(), missedPunch.getTask()); Assignment assignment = HrServiceLocator.getAssignmentService().getAssignment(assignmentDescriptionKey, timesheetDocument.getDocEndDate()); CalendarEntry calendarEntry = timesheetDocument.getCalendarEntry(); DateTime userActionDateTime = missedPunch.getActionFullDateTime(); DateTimeZone userTimeZone = HrServiceLocator.getTimezoneService().getUserTimezoneWithFallback(); DateTime actionDateTime = new DateTime(userActionDateTime, userTimeZone) .withZone(TKUtils.getSystemDateTimeZone()); String clockAction = missedPunch.getClockAction(); String principalId = timesheetDocument.getPrincipalId(); ClockLog clockLog = getClockLogService().processClockLog(actionDateTime, assignment, calendarEntry, ipAddress, LocalDate.now(), timesheetDocument, clockAction, false, principalId); getClockLogService().saveClockLog(clockLog); missedPunch.setActionFullDateTime(clockLog.getClockDateTime()); missedPunch.setTkClockLogId(clockLog.getTkClockLogId()); if (logEndId != null || logBeginId != null) { ClockLog endLog = null; ClockLog beginLog = null; if (logEndId != null) { endLog = getClockLogService().getClockLog(logEndId); } else { endLog = clockLog; } if (logBeginId != null) { beginLog = getClockLogService().getClockLog(logBeginId); } else { beginLog = clockLog; } if (beginLog != null && endLog != null && beginLog.getClockTimestamp().before(endLog.getClockTimestamp())) { String earnCode = assignment.getJob().getPayTypeObj().getRegEarnCode(); buildTimeBlockRunRules(beginLog, endLog, timesheetDocument, assignment, earnCode, beginLog.getClockDateTime(), endLog.getClockDateTime()); } } }
From source file:org.kuali.kpme.tklm.time.missedpunch.validation.MissedPunchDocumentRule.java
License:Educational Community License
/** * Validates whether the MissedPunch has a valid time relative to the last Clock Log. * * @param missedPunch The Missed Punch to check * * @return true if the MissedPunch has a valid time relative to the last Clock Log, false otherwise *///from w ww . j a va2 s . c om protected boolean validateClockTime(MissedPunch missedPunch) { boolean valid = true; if (missedPunch.getActionFullDateTime() != null) { DateTime userActionDateTime = missedPunch.getActionFullDateTime(); DateTimeZone userTimeZone = HrServiceLocator.getTimezoneService().getUserTimezoneWithFallback(); DateTime actionDateTime = new DateTime(userActionDateTime, userTimeZone) .withZone(TKUtils.getSystemDateTimeZone()); if (actionDateTime.toLocalDate().isAfter(LocalDate.now())) { GlobalVariables.getMessageMap().putError("document.actionDate", "clock.mp.future.date"); valid = false; } if (actionDateTime.toLocalDate().isEqual(LocalDate.now()) && actionDateTime.isAfterNow()) { GlobalVariables.getMessageMap().putError("document.actionTime", "clock.mp.future.time"); valid = false; } ClockLog lastClockLog = TkServiceLocator.getClockLogService() .getLastClockLog(missedPunch.getPrincipalId()); if (lastClockLog != null) { DateTime clockLogDateTime = lastClockLog.getClockDateTime(); DateTime boundaryMax = clockLogDateTime.plusDays(1); if ((!StringUtils.equals(lastClockLog.getClockAction(), TkConstants.CLOCK_OUT) && actionDateTime.isAfter(boundaryMax)) || actionDateTime.isBefore(clockLogDateTime)) { GlobalVariables.getMessageMap().putError("document.actionTime", "clock.mp.invalid.datetime"); valid = false; } } } return valid; }
From source file:org.kuali.kpme.tklm.time.missedpunch.web.MissedPunchLookupableImpl.java
License:Educational Community License
private List<MissedPunch> filterByPrincipalId(List<MissedPunch> missedPunches, String principalId) { List<MissedPunch> results = new ArrayList<MissedPunch>(); for (MissedPunch missedPunch : missedPunches) { Job jobObj = HrServiceLocator.getJobService().getJob(principalId, missedPunch.getJobNumber(), LocalDate.now()); String department = jobObj != null ? jobObj.getDept() : null; Department departmentObj = jobObj != null ? HrServiceLocator.getDepartmentService().getDepartment(department, jobObj.getEffectiveLocalDate()) : null;/* w w w .ja va 2s . c o m*/ String location = departmentObj != null ? departmentObj.getLocation() : null; Map<String, String> roleQualification = new HashMap<String, String>(); roleQualification.put(KimConstants.AttributeConstants.PRINCIPAL_ID, GlobalVariables.getUserSession().getPrincipalId()); roleQualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department); roleQualification.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), location); if (!KimApiServiceLocator.getPermissionService().isPermissionDefinedByTemplate( KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), new HashMap<String, String>()) || KimApiServiceLocator.getPermissionService().isAuthorizedByTemplate(principalId, KPMENamespace.KPME_WKFLW.getNamespaceCode(), KPMEPermissionTemplate.VIEW_KPME_RECORD.getPermissionTemplateName(), new HashMap<String, String>(), roleQualification)) { results.add(missedPunch); } } return results; }
From source file:org.kuali.kpme.tklm.time.rules.clocklocation.dao.ClockLocationDaoOjbImpl.java
License:Educational Community License
@Override @SuppressWarnings("unchecked") public List<ClockLocationRule> getClockLocationRules(LocalDate fromEffdt, LocalDate toEffdt, String principalId, String jobNumber, String dept, String workArea, String active, String showHistory) { List<ClockLocationRule> results = new ArrayList<ClockLocationRule>(); Criteria root = new Criteria(); Criteria effectiveDateFilter = new Criteria(); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate()); }/* w w w . j a v a2 s . c o m*/ if (toEffdt != null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate()); } if (fromEffdt == null && toEffdt == null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate()); } root.addAndCriteria(effectiveDateFilter); if (StringUtils.isNotBlank(principalId)) { root.addLike("principalId", principalId); } if (StringUtils.isNotBlank(dept)) { root.addLike("dept", dept); } if (StringUtils.isNotBlank(jobNumber)) { root.addLike("jobNumber", jobNumber); } if (StringUtils.isNotBlank(dept)) { Criteria workAreaCriteria = new Criteria(); LocalDate asOfDate = toEffdt != null ? toEffdt : LocalDate.now(); Collection<WorkArea> workAreasForDept = HrServiceLocator.getWorkAreaService().getWorkAreas(dept, asOfDate); if (CollectionUtils.isNotEmpty(workAreasForDept)) { List<Long> longWorkAreas = new ArrayList<Long>(); for (WorkArea cwa : workAreasForDept) { longWorkAreas.add(cwa.getWorkArea()); } workAreaCriteria.addIn("workArea", longWorkAreas); } root.addAndCriteria(workAreaCriteria); } if (StringUtils.isNotBlank(workArea)) { OjbSubQueryUtil.addNumericCriteria(root, "workArea", workArea); } if (StringUtils.isNotBlank(active)) { Criteria activeFilter = new Criteria(); if (StringUtils.equals(active, "Y")) { activeFilter.addEqualTo("active", true); } else if (StringUtils.equals(active, "N")) { activeFilter.addEqualTo("active", false); } root.addAndCriteria(activeFilter); } if (StringUtils.equals(showHistory, "N")) { root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter( ClockLocationRule.class, effectiveDateFilter, ClockLocationRule.EQUAL_TO_FIELDS, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(ClockLocationRule.class, ClockLocationRule.EQUAL_TO_FIELDS, false)); } Query query = QueryFactory.newQuery(ClockLocationRule.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }
From source file:org.kuali.kpme.tklm.time.rules.lunch.department.dao.DepartmentLunchRuleDaoOjbImpl.java
License:Educational Community License
@Override @SuppressWarnings("unchecked") public List<DeptLunchRule> getDepartmentLunchRules(String dept, String workArea, String principalId, String jobNumber, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) { List<DeptLunchRule> results = new ArrayList<DeptLunchRule>(); Criteria root = new Criteria(); if (StringUtils.isNotBlank(dept)) { root.addLike("dept", dept); }/*from w w w . ja v a 2 s . c o m*/ if (StringUtils.isNotBlank(principalId)) { root.addLike("principalId", principalId); } if (StringUtils.isNotBlank(jobNumber)) { root.addLike("jobNumber", jobNumber); } if (StringUtils.isNotBlank(dept)) { Criteria workAreaCriteria = new Criteria(); LocalDate asOfDate = LocalDate.now(); Collection<WorkArea> workAreasForDept = HrServiceLocator.getWorkAreaService().getWorkAreas(dept, asOfDate); if (CollectionUtils.isNotEmpty(workAreasForDept)) { List<Long> longWorkAreas = new ArrayList<Long>(); for (WorkArea cwa : workAreasForDept) { longWorkAreas.add(cwa.getWorkArea()); } workAreaCriteria.addIn("workArea", longWorkAreas); } root.addAndCriteria(workAreaCriteria); } if (StringUtils.isNotBlank(workArea)) { OjbSubQueryUtil.addNumericCriteria(root, "workArea", workArea); } if (StringUtils.isNotBlank(active)) { Criteria activeFilter = new Criteria(); if (StringUtils.equals(active, "Y")) { activeFilter.addEqualTo("active", true); } else if (StringUtils.equals(active, "N")) { activeFilter.addEqualTo("active", false); } root.addAndCriteria(activeFilter); } Criteria effectiveDateFilter = new Criteria(); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate()); } if (toEffdt != null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate()); } if (fromEffdt == null && toEffdt == null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate()); } if (StringUtils.equals(showHistory, "N")) { root.addAndCriteria(effectiveDateFilter); } if (StringUtils.equals(showHistory, "N")) { root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(DeptLunchRule.class, effectiveDateFilter, DeptLunchRule.EQUAL_TO_FIELDS, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(DeptLunchRule.class, DeptLunchRule.EQUAL_TO_FIELDS, false)); } Query query = QueryFactory.newQuery(DeptLunchRule.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }
From source file:org.kuali.kpme.tklm.time.rules.lunch.sys.dao.SystemLunchRuleDaoOjbImpl.java
License:Educational Community License
@Override @SuppressWarnings("unchecked") public List<SystemLunchRule> getSystemLunchRules(LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) {//from w w w . j av a2 s . c o m List<SystemLunchRule> results = new ArrayList<SystemLunchRule>(); Criteria root = new Criteria(); Criteria effectiveDateFilter = new Criteria(); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate()); } if (toEffdt != null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate()); } if (fromEffdt == null && toEffdt == null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate()); } root.addAndCriteria(effectiveDateFilter); if (StringUtils.isNotBlank(active)) { Criteria activeFilter = new Criteria(); if (StringUtils.equals(active, "Y")) { activeFilter.addEqualTo("active", true); } else if (StringUtils.equals(active, "N")) { activeFilter.addEqualTo("active", false); } root.addAndCriteria(activeFilter); } if (StringUtils.equals(showHistory, "N")) { root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter( SystemLunchRule.class, effectiveDateFilter, Collections.EMPTY_LIST, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(SystemLunchRule.class, Collections.EMPTY_LIST, false)); } Query query = QueryFactory.newQuery(SystemLunchRule.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }
From source file:org.kuali.kpme.tklm.time.rules.lunch.sys.service.SystemLunchRuleServiceImpl.java
License:Educational Community License
@Override public boolean isShowLunchButton() { Boolean getShowLunchButton = false; SystemLunchRule systemLunchrule = TkServiceLocator.getSystemLunchRuleService() .getSystemLunchRule(LocalDate.now()); if (systemLunchrule != null) { getShowLunchButton = systemLunchrule.getShowLunchButton(); }//from w w w.j av a2 s.c o m return getShowLunchButton; }
From source file:org.kuali.kpme.tklm.time.rules.overtime.daily.dao.DailyOvertimeRuleDaoOjbImpl.java
License:Educational Community License
@Override public List<DailyOvertimeRule> getDailyOvertimeRules(String dept, String workArea, String location, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHist) { List<DailyOvertimeRule> results = new ArrayList<DailyOvertimeRule>(); Criteria root = new Criteria(); if (StringUtils.isNotBlank(dept)) { root.addLike("dept", dept); }//from w w w. j ava2 s . c o m if (StringUtils.isNotBlank(workArea)) { root.addLike("workArea", workArea); } if (StringUtils.isNotBlank(location)) { root.addLike("location", location); } Criteria effectiveDateFilter = new Criteria(); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate()); } if (toEffdt != null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate()); } if (fromEffdt == null && toEffdt == null) { effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate()); } root.addAndCriteria(effectiveDateFilter); if (StringUtils.isNotBlank(active)) { Criteria activeFilter = new Criteria(); if (StringUtils.equals(active, "Y")) { activeFilter.addEqualTo("active", true); } else if (StringUtils.equals(active, "N")) { activeFilter.addEqualTo("active", false); } root.addAndCriteria(activeFilter); } if (StringUtils.equals(showHist, "N")) { root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter( DailyOvertimeRule.class, effectiveDateFilter, DailyOvertimeRule.EQUAL_TO_FIELDS, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(DailyOvertimeRule.class, DailyOvertimeRule.EQUAL_TO_FIELDS, false)); } Query query = QueryFactory.newQuery(DailyOvertimeRule.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }