List of usage examples for org.joda.time LocalDate now
public static LocalDate now()
ISOChronology
in the default time zone. From source file:org.jobscheduler.dashboard.security.CustomPersistentRememberMeServices.java
License:Apache License
/** * Validate the token and return it.// w ww. ja va 2 s .co m */ private PersistentToken getPersistentToken(String[] cookieTokens) { if (cookieTokens.length != 2) { throw new InvalidCookieException("Cookie token did not contain " + 2 + " tokens, but contained '" + Arrays.asList(cookieTokens) + "'"); } final String presentedSeries = cookieTokens[0]; final String presentedToken = cookieTokens[1]; PersistentToken token = persistentTokenRepository.findOne(presentedSeries); if (token == null) { // No series match, so we can't authenticate using this cookie throw new RememberMeAuthenticationException( "No persistent token found for series id: " + presentedSeries); } // We have a match for this user/series combination log.info("presentedToken={} / tokenValue={}", presentedToken, token.getTokenValue()); if (!presentedToken.equals(token.getTokenValue())) { // Token doesn't match series value. Delete this session and throw an exception. persistentTokenRepository.delete(token); throw new CookieTheftException( "Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack."); } if (token.getTokenDate().plusDays(TOKEN_VALIDITY_DAYS).isBefore(LocalDate.now())) { persistentTokenRepository.delete(token); throw new RememberMeAuthenticationException("Remember-me login has expired"); } return token; }
From source file:org.jw.service.entity.Contact.java
@Transient public String getAge() { if (this.birthdate == null) return "<No Birthdate>"; LocalDate dob = LocalDate.fromDateFields(birthdate); LocalDate now = LocalDate.now(); Period period = new Period(dob, now, PeriodType.yearMonthDay()); return String.format("%d years & %d months", period.getYears(), period.getMonths()); }
From source file:org.kuali.kpme.core.accrualcategory.dao.AccrualCategoryDaoOjbImpl.java
License:Educational Community License
@Override @SuppressWarnings("unchecked") public List<AccrualCategory> getAccrualCategories(String accrualCategory, String descr, String leavePlan, String accrualEarnInterval, String unitOfTime, String minPercentWorked, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory) { List<AccrualCategory> results = new ArrayList<AccrualCategory>(); Criteria root = new Criteria(); if (StringUtils.isNotBlank(accrualCategory)) { root.addLike("accrualCategory", accrualCategory); }//from w w w .j a v a2 s . co m if (StringUtils.isNotBlank(descr)) { root.addLike("descr", descr); } if (StringUtils.isNotBlank(leavePlan)) { root.addLike("leavePlan", leavePlan); } if (StringUtils.isNotBlank(accrualEarnInterval)) { root.addLike("accrualEarnInterval", accrualEarnInterval); } if (StringUtils.isNotBlank(unitOfTime)) { root.addLike("unitOfTime", unitOfTime); } if (StringUtils.isNotBlank(minPercentWorked)) { root.addLike("minPercentWorked", minPercentWorked); } 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( AccrualCategory.class, effectiveDateFilter, AccrualCategory.EQUAL_TO_FIELDS, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(AccrualCategory.class, AccrualCategory.EQUAL_TO_FIELDS, false)); } Query query = QueryFactory.newQuery(AccrualCategory.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }
From source file:org.kuali.kpme.core.api.cache.KpmeCacheKeyUtils.java
License:Educational Community License
public static String dateTimeAtStartOfDate(DateTime dateTime) { if (dateTime == null) { return LocalDate.now().toDateTimeAtStartOfDay().toString(); }//ww w. j a v a 2 s .c o m return dateTime.toLocalDate().toDateTimeAtStartOfDay().toString(); }
From source file:org.kuali.kpme.core.assignment.Assignment.java
License:Educational Community License
public String getDept() { if (this.getJobNumber() != null) { if (this.getJob() == null || !this.getJobNumber().equals(this.getJob().getJobNumber())) { if (this.getEffectiveDate() != null) { this.setJob(HrServiceLocator.getJobService().getJob(this.getPrincipalId(), this.getJobNumber(), this.getEffectiveLocalDate(), false)); } else { this.setJob(HrServiceLocator.getJobService().getJob(this.getPrincipalId(), this.getJobNumber(), LocalDate.now(), false)); }/*from www .j a v a2 s . c o m*/ } setDept((this.getJob() != null) ? this.getJob().getDept() : ""); } return dept; }
From source file:org.kuali.kpme.core.assignment.AssignmentBo.java
License:Educational Community License
public String getDept() { if (this.getJobNumber() != null) { if (this.getJob() == null || !this.getJobNumber().equals(this.getJob().getJobNumber()) || !this.getPrincipalId().equals(this.getJob().getPrincipalId())) { if (this.getEffectiveDate() != null) { this.setJob(JobBo.from(HrServiceLocator.getJobService().getJob(this.getPrincipalId(), this.getJobNumber(), this.getEffectiveLocalDate(), false))); } else { this.setJob(JobBo.from(HrServiceLocator.getJobService().getJob(this.getPrincipalId(), this.getJobNumber(), LocalDate.now(), false))); }//from w w w . j a v a 2s.co m } setDept((this.getJob() != null) ? this.getJob().getDept() : ""); } return dept; }
From source file:org.kuali.kpme.core.assignment.dao.AssignmentDaoOjbImpl.java
License:Educational Community License
@Override @SuppressWarnings("unchecked") public List<Assignment> searchAssignments(LocalDate fromEffdt, LocalDate toEffdt, String principalId, String jobNumber, String dept, String workArea, String active, String showHistory) { List<Assignment> results = new ArrayList<Assignment>(); Criteria root = new Criteria(); Criteria effectiveDateFilter = new Criteria(); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate()); }//from w ww.j a va 2 s . com 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(principalId)) { root.addLike("principalId", principalId); } if (StringUtils.isNotBlank(jobNumber)) { root.addLike("jobNumber", jobNumber); } if (StringUtils.isNotBlank(dept)) { Criteria workAreaCriteria = new Criteria(); LocalDate asOfDate = toEffdt != null ? toEffdt : LocalDate.now(); Collection<WorkArea> workAreasForDept = HrServiceLocator.getWorkAreaService().getWorkAreas(dept, asOfDate); if (CollectionUtils.isNotEmpty(workAreasForDept)) { List<Long> longWorkAreas = new ArrayList<Long>(); for (WorkArea cwa : workAreasForDept) { longWorkAreas.add(cwa.getWorkArea()); } workAreaCriteria.addIn("workArea", longWorkAreas); } root.addAndCriteria(workAreaCriteria); } if (StringUtils.isNotBlank(workArea)) { OjbSubQueryUtil.addNumericCriteria(root, "workArea", workArea); } 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(Assignment.class, effectiveDateFilter, Assignment.EQUAL_TO_FIELDS, false)); root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(Assignment.class, Assignment.EQUAL_TO_FIELDS, false)); } Query query = QueryFactory.newQuery(Assignment.class, root); results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query)); return results; }
From source file:org.kuali.kpme.core.assignment.service.AssignmentServiceImpl.java
License:Educational Community License
@Override public List<Assignment> getAssignments(String principalId, LocalDate asOfDate) { List<Assignment> assignments; if (asOfDate == null) { asOfDate = LocalDate.now(); }//from w w w . java2s. c om assignments = assignmentDao.findAssignments(principalId, asOfDate); for (Assignment assignment : assignments) { populateAssignment(assignment, asOfDate); } return assignments; }
From source file:org.kuali.kpme.core.assignment.validation.AssignmentRule.java
License:Educational Community License
protected boolean validateEarnCode(AssignmentAccount assignmentAccount) { boolean valid = false; LOG.debug("Validating EarnCode: " + assignmentAccount.getEarnCode()); EarnCode earnCode = HrServiceLocator.getEarnCodeService().getEarnCode(assignmentAccount.getEarnCode(), LocalDate.now()); if (earnCode != null) { valid = true;/* w w w. jav a2 s . co m*/ LOG.debug("found earnCode."); } else { this.putGlobalError("error.existence", "earn code '" + assignmentAccount.getEarnCode() + "'"); } return valid; }
From source file:org.kuali.kpme.core.bo.dao.KpmeHrBusinessObjectLookupDaoOjbImpl.java
License:Educational Community License
@SuppressWarnings({ "rawtypes", "unchecked" }) private void injectSubQueries(Criteria root, Class<? extends HrBusinessObjectContract> hrBOClass, Map formProps) {//from w w w . j a v a 2 s.c o m // create the effective date filter criteria Criteria effectiveDateFilter = new Criteria(); LocalDate fromEffdt = TKUtils .formatDateString(TKUtils.getFromDateString((String) formProps.get(EFFECTIVE_DATE))); LocalDate toEffdt = TKUtils .formatDateString(TKUtils.getToDateString((String) formProps.get(EFFECTIVE_DATE))); if (fromEffdt != null) { effectiveDateFilter.addGreaterOrEqualThan(EFFECTIVE_DATE, fromEffdt.toDate()); } if (toEffdt != null) { effectiveDateFilter.addLessOrEqualThan(EFFECTIVE_DATE, toEffdt.toDate()); } if (fromEffdt == null && toEffdt == null) { effectiveDateFilter.addLessOrEqualThan(EFFECTIVE_DATE, LocalDate.now().toDate()); } List<String> businessKeys = new ArrayList<String>(); try { businessKeys = (List<String>) hrBOClass.getDeclaredField(BUSINESS_KEYS_VAR_NAME).get(hrBOClass); } catch (NoSuchFieldException e) { LOG.warn(hrBOClass.getName() + DOES_NOT_CONTAIN_BUSINESS_KEYS_MESSAGE); } catch (IllegalAccessException e) { LOG.warn(hrBOClass.getName() + DOES_NOT_CONTAIN_BUSINESS_KEYS_MESSAGE); } // inject the subqueries root.addEqualTo(EFFECTIVE_DATE, OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(hrBOClass, effectiveDateFilter, businessKeys, false)); root.addEqualTo(TIMESTAMP, OjbSubQueryUtil.getTimestampSubQuery(hrBOClass, businessKeys, false)); }