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.util.HrContext.java

License:Educational Community License

public static boolean isTargetActiveEmployee() {
    return CollectionUtils.isNotEmpty(
            HrServiceLocator.getAssignmentService().getAssignments(getTargetPrincipalId(), LocalDate.now()));
}

From source file:org.kuali.kpme.core.util.ValidationUtils.java

License:Educational Community License

/**
 * Checks for date not more than one year in the future or current date
 * /*from   w  w  w  .  j a  v a  2 s .  c o  m*/
 */

public static boolean validateOneYearFutureDate(LocalDate date) {
    LocalDate startDate = LocalDate.now().minusDays(1);
    LocalDate endDate = LocalDate.now().plusYears(1); // One year after the current date
    return date.compareTo(startDate) * date.compareTo(endDate) <= 0;
}

From source file:org.kuali.kpme.core.util.ValidationUtils.java

License:Educational Community License

/**
 * Checks for date not more than one year in the future and does not consider past date
 * /*ww w . j a v  a2 s .  c  om*/
 */

public static boolean validateOneYearFutureEffectiveDate(LocalDate date) {
    LocalDate startDate = LocalDate.now().plusYears(1); // One year after the current date
    return date.compareTo(startDate) <= 0;
}

From source file:org.kuali.kpme.core.util.ValidationUtils.java

License:Educational Community License

/**
 * Checks for date in the future// ww w. jav a  2  s  .c  o  m
 * 
 */

public static boolean validateFutureDate(LocalDate date) {
    LocalDate startDate = LocalDate.now();
    return date.compareTo(startDate) > 0;
}

From source file:org.kuali.kpme.core.workarea.dao.WorkAreaDaoOjbImpl.java

License:Educational Community License

@Override
@SuppressWarnings("unchecked")
public List<WorkArea> getWorkAreas(String dept, String workArea, String description, LocalDate fromEffdt,
        LocalDate toEffdt, String active, String showHistory) {
    List<WorkArea> results = new ArrayList<WorkArea>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(dept)) {
        root.addLike("dept", dept);
    }//from   www .  j av a 2  s.c  om

    if (StringUtils.isNotBlank(workArea)) {
        OjbSubQueryUtil.addNumericCriteria(root, "workArea", workArea);
    }

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

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

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

    return results;
}

From source file:org.kuali.kpme.core.workarea.web.WorkAreaInquirableKradImpl.java

License:Educational Community License

@Override
@SuppressWarnings("rawtypes")
public WorkAreaBo retrieveDataObject(Map fieldValues) {
    WorkAreaBo workAreaObj = null;//from  ww  w  .j a  va 2  s .c  om

    if (StringUtils.isNotBlank((String) fieldValues.get("tkWorkAreaId"))) {
        workAreaObj = HrServiceLocatorInternal.getWorkAreaInternalService()
                .getWorkArea((String) fieldValues.get("tkWorkAreaId"));
    } else if (fieldValues.containsKey("workArea") && fieldValues.containsKey("effectiveDate")) {
        String workAreaVal = (String) fieldValues.get("workArea");
        Long workArea = workAreaVal != null ? Long.valueOf(workAreaVal) : null;
        String effDate = (String) fieldValues.get("effectiveDate");
        LocalDate effectiveDate = StringUtils.isBlank(effDate) ? LocalDate.now()
                : TKUtils.formatDateString(effDate);
        workAreaObj = HrServiceLocatorInternal.getWorkAreaInternalService().getWorkArea(workArea,
                effectiveDate);
    } else {
        workAreaObj = (WorkAreaBo) super.retrieveDataObject(fieldValues);
    }

    return workAreaObj;
}

From source file:org.kuali.kpme.pm.classification.web.ClassificationMaintainableImpl.java

License:Educational Community License

@Override
protected boolean performAddLineValidation(ViewModel viewModel, Object newLine, String collectionId,
        String collectionPath) {// ww w . ja v  a2s.c om

    boolean isValid = super.performAddLineValidation(viewModel, newLine, collectionId, collectionPath);
    if (viewModel instanceof MaintenanceDocumentForm) {
        MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) viewModel;
        MaintenanceDocument document = maintenanceForm.getDocument();
        LocalDate asOfDate = LocalDate.now();
        if (document.getNewMaintainableObject().getDataObject() instanceof ClassificationBo) {
            ClassificationBo classificationObj = (ClassificationBo) document.getNewMaintainableObject()
                    .getDataObject();
            if (classificationObj.getEffectiveDate() != null) {
                asOfDate = classificationObj.getEffectiveLocalDate();
            }
            if (newLine instanceof ClassificationQualificationBo) {
                ClassificationQualificationBo cQualification = (ClassificationQualificationBo) newLine;
                PstnQlfrTypeContract qType = PmServiceLocator.getPstnQlfrTypeService()
                        .getPstnQlfrTypeById(cQualification.getQualificationType());
                if (qType == null || !qType.isActive()) {
                    GlobalVariables.getMessageMap().putError(
                            "newCollectionLines['document.newMaintainableObject.dataObject.qualificationList'].qualificationType",
                            "error.existence",
                            "Qualification Type '" + cQualification.getQualificationValue() + "'");
                    isValid = false;
                    return isValid;
                }
            } else if (newLine instanceof ClassificationFlagBo) {
                ClassificationFlagBo classificationFlag = (ClassificationFlagBo) newLine;
                List<String> flagNames = classificationFlag.getNames();
                String categoryNm = classificationFlag.getCategory();
                for (String flagName : flagNames) {
                    List<? extends PositionFlagContract> pFlags = PmServiceLocator.getPositionFlagService()
                            .getAllActivePositionFlags(categoryNm, flagName, asOfDate);
                    if (pFlags == null || CollectionUtils.isEmpty(pFlags)) {
                        GlobalVariables.getMessageMap().putError(
                                "newCollectionLines['document.newMaintainableObject.dataObject.flagList'].names",
                                "error.existence", "Flag '" + flagName + "'");
                        isValid = false;
                        return isValid;
                    }

                }
            }
        }
    }
    return isValid;
}

From source file:org.kuali.kpme.pm.position.dao.PositionDaoObjImpl.java

License:Educational Community License

@Override
public List<Position> getPositions(String positionNum, String description, LocalDate fromEffdt,
        LocalDate toEffdt, String active, String showHistory) {
    List<Position> results = new ArrayList<Position>();

    Criteria root = new Criteria();

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

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

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

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

    return results;
}

From source file:org.kuali.kpme.pm.pstnqlfrtype.dao.PstnQlfrTypeDaoObjImpl.java

License:Educational Community License

@Override
public List<PstnQlfrTypeBo> getAllActivePstnQlfrTypes(LocalDate asOfDate) {
    List<PstnQlfrTypeBo> aList = new ArrayList<PstnQlfrTypeBo>();
    Criteria root = new Criteria();
    if (asOfDate == null) {
        asOfDate = LocalDate.now();
    }//from w  w  w  . j a v  a  2  s . c o  m
    root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQuery(PstnQlfrTypeBo.class, asOfDate,
            PstnQlfrTypeBo.BUSINESS_KEYS, false));
    root.addEqualTo("timestamp",
            OjbSubQueryUtil.getTimestampSubQuery(PstnQlfrTypeBo.class, PstnQlfrTypeBo.BUSINESS_KEYS, false));
    root.addEqualTo("active", true);
    Query query = QueryFactory.newQuery(PstnQlfrTypeBo.class, root);

    Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
    if (!c.isEmpty())
        aList.addAll(c);

    return aList;
}

From source file:org.kuali.kpme.pm.util.PstnQlfrTypeKeyValueFinder.java

License:Educational Community License

@Override
public List<KeyValue> getKeyValues() {
    List<KeyValue> keyValues = new ArrayList<KeyValue>();
    List<? extends PstnQlfrTypeContract> typeList = PmServiceLocator.getPstnQlfrTypeService()
            .getAllActivePstnQlfrTypes(LocalDate.now());
    keyValues.add(new ConcreteKeyValue("", ""));
    if (CollectionUtils.isNotEmpty(typeList)) {
        for (PstnQlfrTypeContract aType : typeList) {
            keyValues.add(new ConcreteKeyValue((String) aType.getPmPstnQlfrTypeId(), (String) aType.getType()));
        }//from   w  ww  .  j a  v a  2  s.  c o  m
    }
    return keyValues;
}