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.earncode.service.EarnCodeServiceImpl.java

License:Educational Community License

@Override
public Map<String, String> getEarnCodesForDisplay(String principalId, boolean isLeavePlanningCalendar) {
    return getEarnCodesForDisplayWithEffectiveDate(principalId, LocalDate.now(), isLeavePlanningCalendar);
}

From source file:org.kuali.kpme.core.earncode.service.EarnCodeServiceImpl.java

License:Educational Community License

@Override
public Map<String, String> getEarnCodesForDisplayWithEffectiveDate(String principalId, LocalDate asOfDate,
        boolean isLeavePlanningCalendar) {
    List<EarnCode> earnCodes = this.getEarnCodesForPrincipal(principalId, asOfDate, isLeavePlanningCalendar);

    boolean futureDate = asOfDate.isAfter(LocalDate.now());
    List<EarnCode> copyList = new ArrayList<EarnCode>();
    copyList.addAll(earnCodes);/*  w  ww  . ja v a 2  s  .com*/
    for (EarnCode earnCode : copyList) {
        if (futureDate && !earnCode.getAllowScheduledLeave().equalsIgnoreCase("Y")) {
            earnCodes.remove(earnCode);
        }
    }
    Comparator<EarnCode> earnCodeComparator = new Comparator<EarnCode>() {
        @Override
        public int compare(EarnCode ec1, EarnCode ec2) {
            return ec1.getEarnCode().compareToIgnoreCase(ec2.getEarnCode());
        }
    };
    // Order by leaveCode ascending
    Ordering<EarnCode> ordering = Ordering.from(earnCodeComparator);

    Map<String, String> earnCodesForDisplay = new LinkedHashMap<String, String>();
    for (EarnCode earnCode : ordering.sortedCopy(earnCodes)) {
        earnCodesForDisplay.put(earnCode.getEarnCodeKeyForDisplay(), earnCode.getEarnCodeValueForDisplay());
    }
    return earnCodesForDisplay;
}

From source file:org.kuali.kpme.core.groupkey.HrGroupKeyServiceImpl.java

License:Educational Community License

@Override
public List<HrGroupKey> getAllActiveHrGroupKeys(LocalDate asOfDate) {
    if (asOfDate == null) {
        asOfDate = LocalDate.now();
    }/*from  w ww  .  j a v a 2 s .co  m*/

    return ModelObjectUtils.transform(hrGroupKeyDao.getAllActiveHrGroupKeys(asOfDate),
            HrGroupKeyBo.toImmutable);
}

From source file:org.kuali.kpme.core.groupkey.HrGroupKeyServiceImpl.java

License:Educational Community License

@Override
public List<HrGroupKey> getHrGroupKeysWithInstitution(String institutionCode, LocalDate asOfDate) {
    if (asOfDate == null) {
        asOfDate = LocalDate.now();
    }/*w  w w  .j  a  v  a  2  s  . com*/

    return ModelObjectUtils.transform(hrGroupKeyDao.getHrGroupKeysWithInstitution(institutionCode, asOfDate),
            HrGroupKeyBo.toImmutable);
}

From source file:org.kuali.kpme.core.groupkey.HrGroupKeyServiceImpl.java

License:Educational Community License

@Override
public List<HrGroupKey> getHrGroupKeysWithLocation(String locationId, LocalDate asOfDate) {
    if (asOfDate == null) {
        asOfDate = LocalDate.now();
    }// w ww  .  j  av a 2s .c om

    return ModelObjectUtils.transform(hrGroupKeyDao.getHrGroupKeysWithLocation(locationId, asOfDate),
            HrGroupKeyBo.toImmutable);
}

From source file:org.kuali.kpme.core.groupkey.HrGroupKeyServiceImpl.java

License:Educational Community License

@Override
public List<HrGroupKey> getHrGroupKeysForLocations(List<String> locations, LocalDate asOfDate) {
    if (asOfDate == null) {
        asOfDate = LocalDate.now();
    }//from w  w w.j  av  a  2s. com

    return ModelObjectUtils.transform(hrGroupKeyDao.getHrGroupKeysWithLocations(locations, asOfDate),
            HrGroupKeyBo.toImmutable);
}

From source file:org.kuali.kpme.core.institution.web.InstitutionInquirableImpl.java

License:Educational Community License

@Override
@SuppressWarnings("rawtypes")
public BusinessObject getBusinessObject(Map fieldValues) {
    InstitutionBo institutionObj = null;
    if (StringUtils.isNotBlank((String) fieldValues.get("pmInstitutionId"))) {
        institutionObj = InstitutionBo.from(HrServiceLocator.getInstitutionService()
                .getInstitutionById((String) fieldValues.get("pmInstitutionId")));
    } else if (fieldValues.containsKey("institutionCode") && fieldValues.containsKey("effectiveDate")) {
        String effDate = (String) fieldValues.get("effectiveDate");
        LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now()
                : TKUtils.formatDateString(effDate);

        institutionObj = InstitutionBo.from(HrServiceLocator.getInstitutionService()
                .getInstitution((String) fieldValues.get("institutionCode"), effectiveDate));
    } else {/*from  w  ww.j  ava2s  .co m*/
        if (fieldValues.get("institutionCode") != null
                && !ValidationUtils.isWildCard(fieldValues.get("institutionCode").toString())) {
            institutionObj = (InstitutionBo) super.getBusinessObject(fieldValues);
        }
    }
    return institutionObj;
}

From source file:org.kuali.kpme.core.job.dao.JobDaoOjbImpl.java

License:Educational Community License

@Override
@SuppressWarnings("unchecked")
public List<Job> getJobs(String principalId, String jobNumber, String dept, String positionNumber,
        String hrPayType, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) {

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

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(principalId)) {
        root.addLike("principalId", principalId);
    }/* w  w w .  java 2  s  .com*/

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

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

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

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

    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")) {
        ImmutableList<String> fields = new ImmutableList.Builder<String>().add("principalId").add("jobNumber")
                .add("dept").add("positionNumber").add("hrPayType").build();
        root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(Job.class,
                effectiveDateFilter, Job.EQUAL_TO_FIELDS, false));
        root.addEqualTo("timestamp",
                OjbSubQueryUtil.getTimestampSubQuery(Job.class, Job.EQUAL_TO_FIELDS, false));
    }

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

    return results;
}

From source file:org.kuali.kpme.core.job.validation.JobValidation.java

License:Educational Community License

boolean validatePrimaryIndicator(Job job, Job oldJob) {
    boolean valid = true;
    if (job.getPrimaryIndicator()) {
        //do not block editing of previous primary job
        if (oldJob != null && oldJob.getPrimaryIndicator() != null && oldJob.getPrimaryIndicator()) {
            return valid;
        }/*from  w ww  .j  a va 2  s  . c  o  m*/
        Job existingJob = HrServiceLocator.getJobService().getPrimaryJob(job.getPrincipalId(), LocalDate.now());
        if (existingJob != null && existingJob.getPrimaryIndicator()) {
            this.putFieldError("primaryIndicator", "error.primary.job.already.exist", job.getPrincipalId());
            valid = false;
        }
    }
    return valid;
}

From source file:org.kuali.kpme.core.job.web.JobInquirableImpl.java

License:Educational Community License

@Override
@SuppressWarnings("rawtypes")
public BusinessObject getBusinessObject(Map fieldValues) {
    JobBo jobObj = null;/*w w  w .ja  va2 s  .co  m*/

    if (StringUtils.isNotBlank((String) fieldValues.get("hrJobId"))) {
        jobObj = JobBo.from(HrServiceLocator.getJobService().getJob((String) fieldValues.get("hrJobId")));
    } else if (fieldValues.containsKey("jobNumber") && fieldValues.containsKey("effectiveDate")
            && fieldValues.containsKey("principalId")) {
        String jobNumberVal = (String) fieldValues.get("jobNumber");
        Long jobNumber = jobNumberVal != null ? Long.valueOf(jobNumberVal) : null;
        String principalId = (String) fieldValues.get("principalId");
        String effDate = (String) fieldValues.get("effectiveDate");
        LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now()
                : TKUtils.formatDateString(effDate);
        jobObj = JobBo.from(HrServiceLocator.getJobService().getJob(principalId, jobNumber, effectiveDate));
    } else {
        jobObj = (JobBo) super.getBusinessObject(fieldValues);
    }

    return jobObj;
}