Example usage for org.joda.time LocalDate now

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

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:org.kuali.kpme.tklm.time.service.mobile.TkMobileServiceImpl.java

License:Educational Community License

@Override
public String getClockEntryInfo(String principalId) {
    ClockEntryInfo clockEntryInfo = new ClockEntryInfo();
    ClockLog lastClockLog = TkServiceLocator.getClockLogService().getLastClockLog(principalId);
    if (lastClockLog != null) {
        clockEntryInfo.setLastClockLogDescription(getLastClockLogDescription(principalId));
    }/*from  w w w .  j  av  a  2  s. c o  m*/
    List<Assignment> assignments = HrServiceLocator.getAssignmentService().getAssignments(principalId,
            LocalDate.now());

    for (Assignment assignment : assignments) {
        TimeCollectionRule tcr = TkServiceLocator.getTimeCollectionRuleService()
                .getTimeCollectionRule(assignment.getDept(), assignment.getWorkArea(), LocalDate.now());
        if (tcr == null || tcr.isClockUserFl()) {
            String key = new AssignmentDescriptionKey(assignment).toAssignmentKeyString();
            String desc = assignment.getAssignmentDescription();
            clockEntryInfo.getAssignKeyToAssignmentDescriptions().put(key, desc);
        }
    }
    List<String> clockActions = getClockActions(principalId);
    clockEntryInfo.setClockActions(clockActions);
    return new Gson().toJson(clockEntryInfo);
}

From source file:org.kuali.kpme.tklm.time.service.mobile.TkMobileServiceImpl.java

License:Educational Community License

@Override
public Map<String, List<String>> addClockAction(String principalId, String assignmentKey, String clockAction,
        String ipAddress) {//from   ww w  . j  av a  2  s. c  o m
    HashMap<String, List<String>> errorWarningMap = new HashMap<String, List<String>>();

    Assignment assignment = HrServiceLocator.getAssignmentService()
            .getAssignment(AssignmentDescriptionKey.get(assignmentKey), LocalDate.now());
    // Set person on the context
    // This is primary for getting the assignment, since we get the assignment by using the target principal id on the context
    HrContext.setTargetPrincipalId(principalId);

    CalendarEntry calendarEntry = HrServiceLocator.getCalendarEntryService()
            .getCurrentCalendarDates(principalId, new LocalDate().toDateTimeAtStartOfDay());
    TimesheetDocument td;
    try {
        td = TkServiceLocator.getTimesheetService().openTimesheetDocument(principalId, calendarEntry);
    } catch (WorkflowException e) {
        throw new RuntimeException("Could not open timesheet");
    }

    // processClockLog is the correct method to use. It creates and persists a clock log and a time block if necessary.
    // buildClockLog just creates a clock log object.
    TkServiceLocator.getClockLogService().processClockLog(new DateTime(), assignment, td.getCalendarEntry(),
            ipAddress, LocalDate.now(), td, getCurrentClockAction(), true, principalId);

    // TODO: not sure what we want to return for the errorWarningMap

    return errorWarningMap;
}

From source file:org.kuali.kpme.tklm.time.service.permission.TKPermissionServiceImpl.java

License:Educational Community License

@Override
public boolean canEditOvertimeEarnCode(TimeBlock timeBlock) {
    String principalId = GlobalVariables.getUserSession().getPrincipalId();
    Long workArea = timeBlock.getWorkArea();
    WorkArea workAreaObj = HrServiceLocator.getWorkAreaService().getWorkArea(workArea,
            timeBlock.getEndDateTime().toLocalDate());
    String department = workAreaObj.getDept();
    Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department,
            LocalDate.now());
    String location = departmentObj != null ? departmentObj.getLocation() : null;

    if (StringUtils.equals(workAreaObj.getOvertimeEditRole(), "Employee")) {
        return true;
    } else if (StringUtils.equals(workAreaObj.getOvertimeEditRole(), KPMERole.APPROVER.getRoleName())
            || StringUtils.equals(workAreaObj.getOvertimeEditRole(),
                    KPMERole.APPROVER_DELEGATE.getRoleName())) {
        return HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(principalId,
                KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER_DELEGATE.getRoleName(), workArea,
                new DateTime())
                || HrServiceLocator.getKPMERoleService().principalHasRoleInWorkArea(principalId,
                        KPMENamespace.KPME_HR.getNamespaceCode(), KPMERole.APPROVER.getRoleName(), workArea,
                        new DateTime());
    } else {/*w  ww  . j  a va2  s.  c  o m*/
        return HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(principalId,
                KPMENamespace.KPME_TK.getNamespaceCode(), KPMERole.TIME_DEPARTMENT_ADMINISTRATOR.getRoleName(),
                department, new DateTime())
                || HrServiceLocator.getKPMERoleService().principalHasRoleInDepartment(principalId,
                        KPMENamespace.KPME_LM.getNamespaceCode(),
                        KPMERole.LEAVE_DEPARTMENT_ADMINISTRATOR.getRoleName(), department, new DateTime())
                || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(principalId,
                        KPMENamespace.KPME_TK.getNamespaceCode(),
                        KPMERole.TIME_LOCATION_ADMINISTRATOR.getRoleName(), location, new DateTime())
                || HrServiceLocator.getKPMERoleService().principalHasRoleInLocation(principalId,
                        KPMENamespace.KPME_LM.getNamespaceCode(),
                        KPMERole.LEAVE_LOCATION_ADMINISTRATOR.getRoleName(), location, new DateTime());
    }
}

From source file:org.kuali.kpme.tklm.time.timeblock.web.TimeBlockHistoryLookupableHelperServiceImpl.java

License:Educational Community License

private List<TimeBlockHistory> filterByPrincipalId(List<TimeBlockHistory> timeBlockHistories,
        String principalId) {//  w  ww.j  a  v a 2s  .  c  o m
    List<TimeBlockHistory> results = new ArrayList<TimeBlockHistory>();

    for (TimeBlockHistory timeBlockHistory : timeBlockHistories) {
        Job jobObj = HrServiceLocator.getJobService().getJob(timeBlockHistory.getPrincipalId(),
                timeBlockHistory.getJobNumber(), LocalDate.now(), false);
        String department = jobObj != null ? jobObj.getDept() : null;

        Department departmentObj = jobObj != null
                ? HrServiceLocator.getDepartmentService().getDepartment(department,
                        jobObj.getEffectiveLocalDate())
                : null;
        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(timeBlockHistory);
        }
    }

    return results;
}

From source file:org.kuali.kpme.tklm.time.timeblock.web.TimeBlockLookupableHelperServiceImpl.java

License:Educational Community License

@Override
public List<? extends BusinessObject> getSearchResults(java.util.Map<String, String> fieldValues) {
    if (fieldValues.containsKey(BEGIN_DATE_ID)) {
        //beginDate = fieldValues.get(BEGIN_DATE);
        fieldValues.put(BEGIN_TIMESTAMP, fieldValues.get(BEGIN_DATE_ID));
        fieldValues.remove(BEGIN_DATE_ID);
    }/*from ww  w  . j a  va  2s.c o m*/

    List<TimeBlock> objectList = (List<TimeBlock>) super.getSearchResults(fieldValues);

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

        while (itr.hasNext()) {
            TimeBlock tb = (TimeBlock) itr.next();

            Long workArea = tb.getWorkArea();

            Job job = HrServiceLocator.getJobService().getJob(tb.getPrincipalIdModified(), tb.getJobNumber(),
                    LocalDate.now(), false);
            String department = job != null ? job.getDept() : null;

            Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department,
                    LocalDate.now());
            String location = departmentObj != null ? departmentObj.getLocation() : null;

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

            if (!valid) {
                itr.remove();
                continue;
            }
        }

        // Fetch list from time hour detail and convert it into TimeBlock
        if (!objectList.isEmpty()) {
            List<TimeBlock> timeBlocks = new ArrayList<TimeBlock>(objectList);
            for (TimeBlock tb : timeBlocks) {
                List<TimeHourDetail> timeHourDetails = tb.getTimeHourDetails();
                for (TimeHourDetail thd : timeHourDetails) {
                    if (!thd.getEarnCode().equalsIgnoreCase(tb.getEarnCode())) {
                        TimeBlock timeBlock = tb.copy();
                        timeBlock.setEarnCode(thd.getEarnCode());
                        timeBlock.setHours(thd.getHours());
                        timeBlock.setAmount(thd.getAmount());
                        objectList.add(timeBlock);
                    }
                } // inner for ends
            } // outer for ends
        } // if ends

    }

    return objectList;
}

From source file:org.kuali.kpme.tklm.time.timeblock.web.TimeBlockRenderer.java

License:Educational Community License

public String getTitle() {
    StringBuilder b = new StringBuilder();

    WorkArea wa = HrServiceLocator.getWorkAreaService().getWorkArea(timeBlock.getWorkArea(), LocalDate.now());
    if (wa != null) {
        b.append(wa.getDescription());// w  w  w. j av  a2s  .  c  o  m
    }
    Task task = HrServiceLocator.getTaskService().getTask(timeBlock.getTask(),
            timeBlock.getBeginDateTime().toLocalDate());
    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.time.timehourdetail.TimeHourDetailRenderer.java

License:Educational Community License

public TimeHourDetailRenderer(TimeHourDetail d) {
    this.timeHourDetail = d;

    TimeBlock tb = TkServiceLocator.getTimeBlockService().getTimeBlock(timeHourDetail.getTkTimeBlockId());
    if (tb != null) {
        List<? extends EarnCodeContract> overtimeEarnCodeObjs = HrServiceLocator.getEarnCodeService()
                .getOvertimeEarnCodes(LocalDate.now());
        List<String> overtimeEarnCodeStrings = HrServiceLocator.getEarnCodeService()
                .getOvertimeEarnCodesStrs(tb.getBeginDateTime().toLocalDate());
        List<String> eligibleOvertimeEarnCodeListStrings = new ArrayList<String>();

        JobContract job = HrServiceLocator.getJobService().getJob(HrContext.getTargetPrincipalId(),
                tb.getJobNumber(), tb.getEndDateTime().toLocalDate());
        if (job != null) {
            for (EarnCodeContract earnCode : overtimeEarnCodeObjs) {
                String employee = HrContext.isActiveEmployee() ? "Y" : null;
                String approver = HrContext.isApprover() ? "Y" : null;
                String payrollProcessor = HrContext.isPayrollProcessor() ? "Y" : null;

                List<? extends EarnCodeSecurityContract> securityList = HrServiceLocator
                        .getEarnCodeSecurityService()
                        .getEarnCodeSecurityList(job.getDept(), job.getHrSalGroup(), earnCode.getEarnCode(),
                                employee, approver, payrollProcessor, "Y", tb.getEndDateTime().toLocalDate(),
                                job.getGroupKey().getGroupKeyCode());
                if (CollectionUtils.isNotEmpty(securityList)) {
                    eligibleOvertimeEarnCodeListStrings.add(earnCode.getEarnCode());
                }/* w ww  .j ava 2 s.  c om*/
            }
        }

        /*
        KPME-3029 checks to see if user can make a change to the overtime earncode before flagging it as overtime,
        by either having > 1 earncode opt or having an opt that is different than the timeHourDetail earncode
        */
        if ((CollectionUtils.isNotEmpty(eligibleOvertimeEarnCodeListStrings)
                && CollectionUtils.isNotEmpty(overtimeEarnCodeStrings))
                && overtimeEarnCodeStrings.contains(d.getEarnCode())
                && (eligibleOvertimeEarnCodeListStrings.size() > 1
                        || !eligibleOvertimeEarnCodeListStrings.contains(d.getEarnCode()))) {
            setOvertimeEarnCode(true);
        }
    }
}

From source file:org.kuali.kpme.tklm.time.timesheet.service.TimesheetServiceImpl.java

License:Educational Community License

public boolean isSynchronousUser() {
    List<Assignment> assignments = HrServiceLocator.getAssignmentService()
            .getAssignments(HrContext.getTargetPrincipalId(), LocalDate.now());
    boolean isSynchronousUser = true;
    for (Assignment assignment : assignments) {
        TimeCollectionRule tcr = TkServiceLocator.getTimeCollectionRuleService()
                .getTimeCollectionRule(assignment.getDept(), assignment.getWorkArea(), LocalDate.now());
        isSynchronousUser &= tcr == null || tcr.isClockUserFl();
    }//from   w ww.  j av a 2  s. co m
    return isSynchronousUser;
}

From source file:org.kuali.kpme.tklm.time.timesheet.TimesheetDocument.java

License:Educational Community License

public Map<String, String> getAssignmentDescriptions(boolean clockOnlyAssignments) {
    Map<String, String> assignmentDescriptions = new LinkedHashMap<String, String>();

    for (Assignment assignment : assignments) {
        String principalId = GlobalVariables.getUserSession().getPrincipalId();

        if (HrServiceLocator.getHRPermissionService().canViewCalendarDocumentAssignment(principalId, this,
                assignment)) {//w ww  .j  a va 2 s .c  o m
            TimeCollectionRule tcr = TkServiceLocator.getTimeCollectionRuleService().getTimeCollectionRule(
                    assignment.getJob().getDept(), assignment.getWorkArea(), LocalDate.now());
            boolean isSynchronous = tcr == null || tcr.isClockUserFl();
            if (!clockOnlyAssignments || isSynchronous) {
                assignmentDescriptions.putAll(TKUtils.formatAssignmentDescription(assignment));
            }
        }
    }

    return assignmentDescriptions;
}

From source file:org.kuali.kpme.tklm.time.util.TkContext.java

License:Educational Community License

public static boolean isSynchronous() {
    boolean isSynchronous = false;

    List<Assignment> assignments = HrServiceLocator.getAssignmentService().getAssignments(getPrincipalId(),
            LocalDate.now());

    for (Assignment assignment : assignments) {
        TimeCollectionRule tcr = TkServiceLocator.getTimeCollectionRuleService()
                .getTimeCollectionRule(assignment.getDept(), assignment.getWorkArea(), LocalDate.now());
        if (tcr == null || tcr.isClockUserFl()) {
            isSynchronous = true;//from  w  ww .java  2s . c  om
            break;
        }
    }

    return isSynchronous;
}