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.bo.derived.HrKeyedBusinessObjectDerived.java

License:Educational Community License

@Override
public HrGroupKeyBo getGroupKey() {

    LocalDate asOfDate = LocalDate.now();
    if (this.getEffectiveLocalDateOfOwner() != null) {
        asOfDate = this.getEffectiveLocalDateOfOwner();
    }/*from w ww .j  av a2 s. c o m*/

    if (groupKey == null) {
        groupKey = HrGroupKeyBo
                .from(HrServiceLocator.getHrGroupKeyService().getHrGroupKey(getGroupKeyCode(), asOfDate));
    }

    return groupKey;
}

From source file:org.kuali.kpme.core.bo.HrBusinessObjectMaintainableImpl.java

License:Educational Community License

@Override
public void saveBusinessObject() {
    HrBusinessObject hrObj = (HrBusinessObject) this.getBusinessObject();
    if (hrObj.getId() != null) {
        HrBusinessObject oldHrObj = this.getObjectById(hrObj.getId());
        if (oldHrObj != null) {
            //if the effective dates are the same do not create a new row just inactivate the old one
            if (hrObj.getEffectiveDate().equals(oldHrObj.getEffectiveDate())) {
                oldHrObj.setActive(false);
                oldHrObj.setTimestamp(TKUtils
                        .subtractOneSecondFromTimestamp(new Timestamp(LocalDate.now().toDate().getTime())));
            } else {
                //if effective dates not the same add a new row that inactivates the old entry based on the new effective date
                oldHrObj.setTimestamp(TKUtils
                        .subtractOneSecondFromTimestamp(new Timestamp(LocalDate.now().toDate().getTime())));
                oldHrObj.setEffectiveDate(hrObj.getEffectiveDate());
                oldHrObj.setActive(false);
                oldHrObj.setId(null);/*  ww  w  . ja  v a2 s  .  c o m*/
            }
            KRADServiceLocator.getBusinessObjectService().save(oldHrObj);
        }
    }
    hrObj.setTimestamp(new Timestamp(System.currentTimeMillis()));
    hrObj.setId(null);

    customSaveLogic(hrObj);
    KRADServiceLocator.getBusinessObjectService().save(hrObj);

    //cache clearing?!?!
    try {
        List<String> cacheNames = (List<String>) hrObj.getClass().getDeclaredField("CACHE_FLUSH").get(hrObj);
        CacheUtils.flushCaches(cacheNames);
    } catch (NoSuchFieldException e) {
        try {
            String cacheName = (String) hrObj.getClass().getDeclaredField("CACHE_NAME").get(hrObj);
            CacheUtils.flushCache(cacheName);
        } catch (NoSuchFieldException ex) {
            // no cache name found
            LOG.warn("No cache name found for object: " + hrObj.getClass().getName());
        } catch (IllegalAccessException ex) {
            LOG.warn("No cache name found for object: " + hrObj.getClass().getName());
        }
        // no cache name found
        //LOG.warn("No cache name found for object: " + hrObj.getClass().getName());
    } catch (IllegalAccessException e) {
        LOG.warn("No caches found for object: " + hrObj.getClass().getName());
    }
}

From source file:org.kuali.kpme.core.bo.HrEffectiveDateActiveLookupableHelper.java

License:Educational Community License

@SuppressWarnings("unchecked")
@Override/*from  w w  w . j  a  va 2s.c  o  m*/
/**
 * Core HR Effective dating lookup logic
 * alter at your own risk
 */
public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
    if (fieldValues.containsKey("workArea") && StringUtils.equals(fieldValues.get("workArea"), "%")) {
        fieldValues.put("workArea", "");
    }
    if (fieldValues.containsKey("jobNumber") && StringUtils.equals(fieldValues.get("jobNumber"), "%")) {
        fieldValues.put("jobNumber", "");
    }
    if (fieldValues.containsKey("dept") && StringUtils.equals(fieldValues.get("dept"), "%")) {
        fieldValues.put("dept", "");
    }
    if (fieldValues.containsKey("principalId") && StringUtils.equals(fieldValues.get("principalId"), "%")) {
        fieldValues.put("principalId", "");
    }
    String showHistory = "Y";
    if (fieldValues.containsKey("history")) {
        showHistory = fieldValues.get("history");
        fieldValues.remove("history");
    }
    String active = "";
    if (fieldValues.containsKey("active")) {
        active = fieldValues.get("active");
        fieldValues.put("active", "");
    }

    List<HrBusinessObject> hrObjList = (List<HrBusinessObject>) super.getSearchResults(fieldValues);
    //Create a principalId+jobNumber map as this is the unique key for results
    Map<String, List<HrBusinessObject>> hrBusinessMap = new HashMap<String, List<HrBusinessObject>>();

    for (HrBusinessObject hrObj : hrObjList) {
        String key = hrObj.getUniqueKey();

        //If no key exists for this business object return full collection
        if (StringUtils.isEmpty(key)) {
            return hrObjList;
        }
        if (hrBusinessMap.get(key) != null) {
            List<HrBusinessObject> lstHrBusinessList = hrBusinessMap.get(key);
            lstHrBusinessList.add(hrObj);
        } else {
            List<HrBusinessObject> lstHrBusinessObj = new ArrayList<HrBusinessObject>();
            lstHrBusinessObj.add(hrObj);
            hrBusinessMap.put(key, lstHrBusinessObj);
        }
    }

    List<BusinessObject> finalBusinessObjectList = new ArrayList<BusinessObject>();

    for (List<HrBusinessObject> lstHrBusinessObj : hrBusinessMap.values()) {
        Collections.sort(lstHrBusinessObj, new EffectiveDateTimestampCompare());
        Collections.reverse(lstHrBusinessObj);
    }

    LocalDate currDate = LocalDate.now();
    //Active = Both and Show History = Yes
    //return all results
    if (StringUtils.isEmpty(active) && StringUtils.equals("Y", showHistory)) {
        return hrObjList;
    }
    //Active = Both and show history = No
    //return the most effective results from today and any future rows
    else if (StringUtils.isEmpty(active) && StringUtils.equals("N", showHistory)) {
        for (List<HrBusinessObject> lstHrBusiness : hrBusinessMap.values()) {
            for (HrBusinessObject hrBus : lstHrBusiness) {
                if (hrBus.getEffectiveLocalDate().isBefore(currDate)) {
                    finalBusinessObjectList.add(hrBus);
                    break;
                } else {
                    finalBusinessObjectList.add(hrBus);
                }
            }
        }
    }
    //Active = Yes and Show History = No
    //return all active records as of today and any active future rows
    //if there is an inactive record before the active one then do not show the results as this record is inactive
    else if (StringUtils.equals(active, "Y") && StringUtils.equals("N", showHistory)) {
        for (List<HrBusinessObject> lstHrBus : hrBusinessMap.values()) {
            for (HrBusinessObject hrBusinessObject : lstHrBus) {
                if (!hrBusinessObject.isActive()
                        && hrBusinessObject.getEffectiveLocalDate().isBefore(currDate)) {
                    break;
                } else {
                    if (hrBusinessObject.getEffectiveLocalDate().isBefore(currDate)) {
                        finalBusinessObjectList.add(hrBusinessObject);
                        break;
                    } else {
                        if (hrBusinessObject.isActive()) {
                            finalBusinessObjectList.add(hrBusinessObject);
                        }
                    }
                }
            }
        }
    }
    //Active = Yes and Show History = Yes
    //return all active records from database
    //if there is an inactive record before the active one then do not show the results as this record is inactive
    else if (StringUtils.equals(active, "Y") && StringUtils.equals("Y", showHistory)) {
        for (List<HrBusinessObject> lstHrBus : hrBusinessMap.values()) {
            for (HrBusinessObject hrBus : lstHrBus) {
                if (!hrBus.isActive() && hrBus.getEffectiveLocalDate().isBefore(currDate)) {
                    break;
                } else if (hrBus.isActive()) {
                    finalBusinessObjectList.add(hrBus);
                }
            }
        }
    }
    //Active = No and Show History = Yes
    //return all inactive records in the database
    else if (StringUtils.equals(active, "N") && StringUtils.equals(showHistory, "Y")) {
        for (List<HrBusinessObject> lstHrBus : hrBusinessMap.values()) {
            for (HrBusinessObject hrBus : lstHrBus) {
                if (!hrBus.isActive()) {
                    finalBusinessObjectList.add(hrBus);
                }
            }
        }
    }
    //Active = No and Show History = No
    //return the most effective inactive rows if there are no active rows <= the curr date
    else if (StringUtils.equals(active, "N") && StringUtils.equals(showHistory, "N")) {
        for (List<HrBusinessObject> lstHrBusiness : hrBusinessMap.values()) {
            for (HrBusinessObject hrBus : lstHrBusiness) {
                if (hrBus.getEffectiveLocalDate().isBefore(currDate)) {
                    if (!hrBus.isActive()) {
                        finalBusinessObjectList.add(hrBus);
                    }
                    break;
                } else {
                    if (!hrBus.isActive()) {
                        finalBusinessObjectList.add(hrBus);
                    }
                }
            }
        }
    }

    Integer searchResultsLimit = LookupUtils.getSearchResultsLimit(businessObjectClass);

    Long matchingResultsCount = Long.valueOf(finalBusinessObjectList.size());

    if (matchingResultsCount.intValue() <= searchResultsLimit.intValue()) {

        matchingResultsCount = Long.valueOf(0);

    }

    return new CollectionIncomplete(finalBusinessObjectList, matchingResultsCount);

}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBeginPeriodTime(Time beginPeriodTime) {
    LocalDate localDate = beginPeriodDateTime != null ? LocalDate.fromDateFields(beginPeriodDateTime)
            : LocalDate.now();
    LocalTime localTime = beginPeriodTime != null ? LocalTime.fromDateFields(beginPeriodTime) : null;
    beginPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;/*from  www. j  a  v a 2s.  c o m*/
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setEndPeriodTime(Time endPeriodTime) {
    LocalDate localDate = endPeriodDateTime != null ? LocalDate.fromDateFields(endPeriodDateTime)
            : LocalDate.now();
    LocalTime localTime = endPeriodTime != null ? LocalTime.fromDateFields(endPeriodTime) : null;
    endPeriodDateTime = localTime != null ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;/*from w w w. j  a v a 2 s .  c o m*/
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBatchInitiateTime(Time batchInitiateTime) {
    LocalDate localDate = batchInitiateDateTime != null ? LocalDate.fromDateFields(batchInitiateDateTime)
            : LocalDate.now();
    LocalTime localTime = batchInitiateTime != null ? LocalTime.fromDateFields(batchInitiateTime) : null;
    batchInitiateDateTime = localTime != null
            ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;//from www.  ja  v  a 2 s  .  co m
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBatchEndPayPeriodTime(Time batchEndPayPeriodTime) {
    LocalDate localDate = batchEndPayPeriodDateTime != null
            ? LocalDate.fromDateFields(batchEndPayPeriodDateTime)
            : LocalDate.now();
    LocalTime localTime = batchEndPayPeriodTime != null ? LocalTime.fromDateFields(batchEndPayPeriodTime)
            : null;/*from  w  ww. jav  a  2s .c  o m*/
    batchEndPayPeriodDateTime = localTime != null
            ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBatchEmployeeApprovalTime(Time batchEmployeeApprovalTime) {
    LocalDate localDate = batchEmployeeApprovalDateTime != null
            ? LocalDate.fromDateFields(batchEmployeeApprovalDateTime)
            : LocalDate.now();
    LocalTime localTime = batchEmployeeApprovalTime != null
            ? LocalTime.fromDateFields(batchEmployeeApprovalTime)
            : null;// w ww  .  jav  a 2s. c  om
    batchEmployeeApprovalDateTime = localTime != null
            ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntry.java

License:Educational Community License

public void setBatchSupervisorApprovalTime(Time batchSupervisorApprovalTime) {
    LocalDate localDate = batchSupervisorApprovalDateTime != null
            ? LocalDate.fromDateFields(batchSupervisorApprovalDateTime)
            : LocalDate.now();
    LocalTime localTime = batchSupervisorApprovalTime != null
            ? LocalTime.fromDateFields(batchSupervisorApprovalTime)
            : null;//  w  w w  .ja  v a2 s  .co m
    batchSupervisorApprovalDateTime = localTime != null
            ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;
}

From source file:org.kuali.kpme.core.calendar.entry.CalendarEntryBo.java

License:Educational Community License

public void setBatchPayrollApprovalTime(Time batchPayrollApprovalTime) {
    LocalDate localDate = batchPayrollApprovalDateTime != null
            ? LocalDate.fromDateFields(batchPayrollApprovalDateTime)
            : LocalDate.now();
    LocalTime localTime = batchPayrollApprovalTime != null ? LocalTime.fromDateFields(batchPayrollApprovalTime)
            : null;//from w  w  w  . j  av a2  s.c o  m
    batchPayrollApprovalDateTime = localTime != null
            ? localTime.toDateTime(localDate.toDateTimeAtStartOfDay()).toDate()
            : null;
}