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.core.calendar.entry.service.CalendarEntryServiceImpl.java

License:Educational Community License

@Override
public List<CalendarEntry> getAllCalendarEntriesForCalendarIdUpToPlanningMonths(String hrCalendarId,
        String principalId) {/*from   ww w . j  ava 2 s. c om*/
    int planningMonths = 0;
    PrincipalHRAttributes principalHRAttributes = HrServiceLocator.getPrincipalHRAttributeService()
            .getPrincipalCalendar(principalId, LocalDate.now());
    if (principalHRAttributes != null && principalHRAttributes.getLeavePlan() != null) {
        LeavePlan lp = HrServiceLocator.getLeavePlanService().getLeavePlan(principalHRAttributes.getLeavePlan(),
                LocalDate.now());
        if (lp != null && lp.getPlanningMonths() != null) {
            planningMonths = Integer.parseInt(lp.getPlanningMonths());
        }
    }
    List<CalendarEntry> futureCalEntries = getFutureCalendarEntries(hrCalendarId,
            LocalDate.now().toDateTimeAtStartOfDay(), planningMonths);
    CalendarEntry futureCalEntry = null;
    if (futureCalEntries != null && !futureCalEntries.isEmpty()) {
        futureCalEntry = futureCalEntries.get(futureCalEntries.size() - 1);
    }
    DateTime cutOffTime;
    if (futureCalEntry != null) {
        cutOffTime = futureCalEntry.getEndPeriodFullDateTime();
    } else {
        CalendarEntry currentCE = getCurrentCalendarEntryByCalendarId(hrCalendarId,
                LocalDate.now().toDateTimeAtStartOfDay());
        cutOffTime = currentCE.getEndPeriodFullDateTime();
    }
    return getAllCalendarEntriesForCalendarIdUpToCutOffTime(hrCalendarId, cutOffTime);
}

From source file:org.kuali.kpme.core.department.web.DepartmentInquirableKradImpl.java

License:Educational Community License

@Override
@SuppressWarnings("rawtypes")
public DepartmentContract retrieveDataObject(Map fieldValues) {
    DepartmentBo departmentObj = null;/*from w w  w  .j a  va2 s .c  o  m*/

    if (StringUtils.isNotBlank((String) fieldValues.get("hrDeptId"))) {
        departmentObj = HrServiceLocatorInternal.getDepartmentInternalService()
                .getDepartmentWithRoleData((String) fieldValues.get("hrDeptId"));
    } else if (fieldValues.containsKey("dept") && fieldValues.containsKey("effectiveDate")
            && fieldValues.containsKey("groupKeyCode")) {
        String department = (String) fieldValues.get("dept");
        String effDate = (String) fieldValues.get("effectiveDate");
        String groupKeyCode = (String) fieldValues.get("groupKeyCode");
        LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now()
                : TKUtils.formatDateString(effDate);

        departmentObj = HrServiceLocatorInternal.getDepartmentInternalService()
                .getDepartmentWithRoleData(department, groupKeyCode, effectiveDate);

    } else {
        departmentObj = (DepartmentBo) super.retrieveDataObject(fieldValues);
    }

    return departmentObj;

}

From source file:org.kuali.kpme.core.document.calendar.rules.CalendarDocumentFactBuilderServiceImpl.java

License:Educational Community License

public void addFacts(Facts.Builder factsBuilder, Object factsObject, String contextId, String namespace) {
    CalendarDocument document = (CalendarDocument) factsObject;
    addObjectMembersAsFacts(factsBuilder, document, contextId, namespace);
    factsBuilder.addFact(new Term("payrollProcessorApproval"), Boolean.FALSE);
    if (document != null) {
        CalendarEntry ce = document.getCalendarEntry();
        LocalDate asOfDate = ce != null ? ce.getEndPeriodLocalDateTime().toLocalDate() : LocalDate.now();
        Set<String> workAreas = new HashSet<String>();
        Set<String> depts = new HashSet<String>();

        for (Assignment a : document.getAllAssignments()) {
            workAreas.add(String.valueOf(a.getWorkArea()));
            depts.add(a.getDept());//from w w w.  jav a  2  s  . c o m
            Department department = HrServiceLocator.getDepartmentService().getDepartment(a.getDept(),
                    a.getGroupKeyCode(), asOfDate);
            if (department != null && department.isPayrollApproval()) {
                factsBuilder.addFact(new Term("payrollProcessorApproval"), Boolean.TRUE);
            }
        }
        if (CollectionUtils.isNotEmpty(depts)) {
            factsBuilder.addFact("department", depts);
        }
        if (CollectionUtils.isNotEmpty(workAreas)) {
            factsBuilder.addFact("workarea", workAreas);
        }

        if (document instanceof Assignable) {
            factsBuilder.addFact(Assignable.ASSIGNABLE_TERM_NAME, document);
        }
    }
}

From source file:org.kuali.kpme.core.earncode.dao.EarnCodeDaoOjbImpl.java

License:Educational Community License

@Override
@SuppressWarnings("unchecked")
public List<EarnCode> getEarnCodes(String earnCode, String ovtEarnCode, String descr, String leavePlan,
        String accrualCategory, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) {
    List<EarnCode> results = new ArrayList<EarnCode>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(earnCode)) {
        root.addLike("earnCode", earnCode);
    }/*ww w. ja v  a 2s . com*/

    if (StringUtils.isNotBlank(ovtEarnCode)) {
        root.addEqualTo("ovtEarnCode", ovtEarnCode);
    }

    if (StringUtils.isNotBlank(descr)) {
        root.addLike("description", descr);
    }

    if (StringUtils.isNotBlank(leavePlan)) {
        root.addLike("leavePlan", leavePlan);
    }

    if (StringUtils.isNotBlank(accrualCategory)) {
        root.addLike("accrualCategory", accrualCategory);
    }

    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(EarnCode.class,
                effectiveDateFilter, EarnCode.EQUAL_TO_FIELDS, false));
        root.addEqualTo("timestamp",
                OjbSubQueryUtil.getTimestampSubQuery(EarnCode.class, EarnCode.EQUAL_TO_FIELDS, false));
    }

    Query query = QueryFactory.newQuery(EarnCode.class, root);
    results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));

    return results;
}

From source file:org.kuali.kpme.core.earncode.group.dao.EarnCodeGroupDaoOjbImpl.java

License:Educational Community License

public List<EarnCode> getEarnCodeGroups(String earnCodeGroup, String descr, LocalDate fromEffdt,
        LocalDate toEffdt, String active, String showHist) {
    List<EarnCode> results = new ArrayList<EarnCode>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(earnCodeGroup)) {
        root.addLike("earnCodeGroup", earnCodeGroup);
    }/*from  ww w  .j a  va  2 s  .  c  om*/

    if (StringUtils.isNotBlank(descr)) {
        root.addLike("description", descr);
    }

    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(EarnCodeGroup.class,
                effectiveDateFilter, EarnCodeGroup.EQUAL_TO_FIELDS, false));
        root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(EarnCodeGroup.class,
                EarnCodeGroup.EQUAL_TO_FIELDS, false));
    }

    Query query = QueryFactory.newQuery(EarnCodeGroup.class, root);
    results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));

    return results;
}

From source file:org.kuali.kpme.core.earncode.group.EarnCodeGroupDefinition.java

License:Educational Community License

public String getEarnCodeDesc() {
    EarnCode earnCode = HrServiceLocator.getEarnCodeService().getEarnCode(this.earnCode, LocalDate.now());

    if (earnCode != null && StringUtils.isNotBlank(earnCode.getDescription())) {
        return earnCode.getDescription();
    }//www. ja v a 2s. c  o m
    return "";
}

From source file:org.kuali.kpme.core.earncode.group.EarnCodeGroupDefinitionBo.java

License:Educational Community License

public String getEarnCodeDesc() {
    if (this.earnCode != null) {
        EarnCodeContract earnCode = getEarnCodeService().getEarnCode(this.earnCode, LocalDate.now());

        if (earnCode != null && StringUtils.isNotBlank(earnCode.getDescription())) {
            return earnCode.getDescription();
        }/*from  w w  w  .  ja v a  2  s .  c o  m*/
    }
    return "";
}

From source file:org.kuali.kpme.core.earncode.group.web.EarnCodeGroupInquirableKradImpl.java

License:Educational Community License

@Override
public EarnCodeGroupBo retrieveDataObject(Map fieldValues) {
    EarnCodeGroupBo ec = null;//from   w w w  . ja v a 2 s  .  com
    if (StringUtils.isNotBlank((String) fieldValues.get("hrEarnCodeGroupId"))) {
        ec = EarnCodeGroupBo.from(HrServiceLocator.getEarnCodeGroupService()
                .getEarnCodeGroup((String) fieldValues.get("hrEarnCodeGroupId")));

    } else if (StringUtils.isNotBlank((String) fieldValues.get("earnCodeGroup"))
            && StringUtils.isNotBlank((String) fieldValues.get("effectiveDate"))) {
        String earnCodeGroup = (String) fieldValues.get("earnCodeGroup");
        String effDate = (String) fieldValues.get("effectiveDate");
        LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now()
                : TKUtils.formatDateString(effDate);
        ec = EarnCodeGroupBo.from(
                HrServiceLocator.getEarnCodeGroupService().getEarnCodeGroup(earnCodeGroup, effectiveDate));
    } else {
        ec = (EarnCodeGroupBo) super.retrieveDataObject(fieldValues);
    }

    return ec;
}

From source file:org.kuali.kpme.core.earncode.security.dao.EarnCodeSecurityDaoOjbImpl.java

License:Educational Community License

@Override
@SuppressWarnings("unchecked")
public List<EarnCodeSecurity> searchEarnCodeSecurities(String dept, String salGroup, String earnCode,
        String location, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) {

    List<EarnCodeSecurity> results = new ArrayList<EarnCodeSecurity>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(dept)) {
        root.addLike("dept", dept);
    }//from  w w  w  .java2 s .c o m

    if (StringUtils.isNotBlank(salGroup)) {
        root.addLike("hrSalGroup", salGroup);
    }

    if (StringUtils.isNotBlank(earnCode)) {
        root.addLike("earnCode", earnCode);
    }

    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(showHistory, "N")) {
        root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(
                EarnCodeSecurity.class, effectiveDateFilter, EarnCodeSecurity.EQUAL_TO_FIELDS, false));
        root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(EarnCodeSecurity.class,
                EarnCodeSecurity.EQUAL_TO_FIELDS, false));
    }

    Query query = QueryFactory.newQuery(EarnCodeSecurity.class, root);
    results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));

    return results;
}

From source file:org.kuali.kpme.core.earncode.security.validation.EarnCodeSecurityRule.java

License:Educational Community License

private boolean validateDepartmentCurrentUser(EarnCodeSecurity departmentEarnCode) {
    boolean isValid = true;

    String principalId = GlobalVariables.getUserSession().getPrincipalId();
    String department = departmentEarnCode.getDept();
    Department departmentObj = HrServiceLocator.getDepartmentService().getDepartment(department,
            LocalDate.now());
    String location = departmentObj != null ? departmentObj.getLocation() : null;

    if (!HrContext.isSystemAdmin()
            && !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())) {
        this.putFieldError("dept", "error.department.permissions", department);
        isValid = false;//from  w  ww.  ja  va2  s.  c om
    }

    return isValid;
}