List of usage examples for org.joda.time DateTime toLocalDate
public LocalDate toLocalDate()
LocalDate
with the same date and chronology. From source file:org.killbill.billing.plugin.bitcoin.osgi.http.PaymentRequestServlet.java
License:Apache License
private UUID createSubscription(final Account account, final Plan plan, final String externalKey, final String priceList, final PhaseType phaseType, final DateTime now, final CallContext callContext) throws EntitlementApiException, TagApiException, CustomFieldApiException { final PlanPhaseSpecifier spec = new PlanPhaseSpecifier(plan.getProduct().getName(), plan.getProduct().getCategory(), plan.getBillingPeriod(), priceList, phaseType); final Entitlement entitlement = killbillAPI.getEntitlementApi().createBaseEntitlement(account.getId(), spec, externalKey, now.toLocalDate(), callContext); return entitlement.getId(); }
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(); }/*www.j ava 2 s.c o m*/ return dateTime.toLocalDate().toDateTimeAtStartOfDay().toString(); }
From source file:org.kuali.kpme.core.assignment.service.AssignmentServiceImpl.java
License:Educational Community License
public List<Assignment> getAssignmentsByPayEntry(String principalId, CalendarEntry payCalendarEntry) { DateTime entryEndDate = payCalendarEntry.getEndPeriodLocalDateTime().toDateTime(); if (entryEndDate.getHourOfDay() == 0) { entryEndDate = entryEndDate.minusDays(1); }//from w w w . j a va 2s.c o m List<Assignment> beginPeriodAssign = getAssignments(principalId, payCalendarEntry.getBeginPeriodFullDateTime().toLocalDate()); List<Assignment> endPeriodAssign = getAssignments(principalId, entryEndDate.toLocalDate()); List<Assignment> assignsWithPeriod = getAssignments(principalId, payCalendarEntry.getBeginPeriodFullDateTime().toLocalDate(), entryEndDate.toLocalDate()); List<Assignment> finalAssignments = new ArrayList<Assignment>(); Map<String, Assignment> assignKeyToAssignmentMap = new HashMap<String, Assignment>(); for (Assignment assign : endPeriodAssign) { assignKeyToAssignmentMap.put( TKUtils.formatAssignmentKey(assign.getJobNumber(), assign.getWorkArea(), assign.getTask()), assign); finalAssignments.add(assign); } //Compare the begin and end and add any assignments to the end thats are not there for (Assignment assign : beginPeriodAssign) { String assignKey = TKUtils.formatAssignmentKey(assign.getJobNumber(), assign.getWorkArea(), assign.getTask()); if (!assignKeyToAssignmentMap.containsKey(assignKey)) { finalAssignments.add(assign); } } // Add the assignments within the pay period for (Assignment assign : assignsWithPeriod) { String assignKey = TKUtils.formatAssignmentKey(assign.getJobNumber(), assign.getWorkArea(), assign.getTask()); if (!assignKeyToAssignmentMap.containsKey(assignKey)) { finalAssignments.add(assign); } } return finalAssignments; }
From source file:org.kuali.kpme.core.calendar.entry.service.CalendarEntryServiceImpl.java
License:Educational Community License
@Override public CalendarEntry getCurrentCalendarDates(String principalId, DateTime currentDate) { CalendarEntry pcd = null;//from w w w . j ava2 s .c o m Calendar calendar = HrServiceLocator.getCalendarService().getCalendarByPrincipalIdAndDate(principalId, currentDate.toLocalDate(), false); if (calendar != null) { pcd = HrServiceLocator.getCalendarEntryService() .getCurrentCalendarEntryByCalendarId(calendar.getHrCalendarId(), currentDate); if (pcd != null) { pcd.setCalendarObj(calendar); } } return pcd; }
From source file:org.kuali.kpme.core.calendar.entry.service.CalendarEntryServiceImpl.java
License:Educational Community License
@Override public CalendarEntry getCurrentCalendarDates(String principalId, DateTime beginDate, DateTime endDate) { CalendarEntry pcd = null;// w w w .j a v a 2s. c o m Calendar calendar = HrServiceLocator.getCalendarService().getCalendarByPrincipalIdAndDate(principalId, beginDate.toLocalDate(), endDate.toLocalDate(), false); if (calendar != null) { pcd = HrServiceLocator.getCalendarEntryService() .getCalendarEntryByCalendarIdAndDateRange(calendar.getHrCalendarId(), beginDate, endDate); if (pcd != null) { pcd.setCalendarObj(calendar); } } return pcd; }
From source file:org.kuali.kpme.core.calendar.entry.service.CalendarEntryServiceImpl.java
License:Educational Community License
@Override public CalendarEntry getCalendarDatesByPayEndDate(String principalId, DateTime payEndDate, String calendarType) {/*from w w w . j a v a 2 s .c om*/ PrincipalHRAttributes principalCalendar = HrServiceLocator.getPrincipalHRAttributeService() .getPrincipalCalendar(principalId, payEndDate.toLocalDate()); Calendar calendar = null; if (ObjectUtils.isNull(principalCalendar)) { return null; } if (StringUtils.equalsIgnoreCase(calendarType, HrConstants.PAY_CALENDAR_TYPE)) { calendar = HrServiceLocator.getCalendarService().getCalendarByGroup(principalCalendar.getPayCalendar()); } else if (StringUtils.equalsIgnoreCase(calendarType, HrConstants.LEAVE_CALENDAR_TYPE)) { calendar = HrServiceLocator.getCalendarService() .getCalendarByGroup(principalCalendar.getLeaveCalendar()); } if (calendar == null) { return null; } CalendarEntry calendarEntry = HrServiceLocator.getCalendarEntryService() .getCalendarEntryByIdAndPeriodEndDate(calendar.getHrCalendarId(), payEndDate); if (ObjectUtils.isNotNull(calendarEntry)) { calendarEntry.setCalendarObj(calendar); } return calendarEntry; }
From source file:org.kuali.kpme.core.calendar.entry.service.CalendarEntryServiceImpl.java
License:Educational Community License
@Override public CalendarEntry getCurrentCalendarDatesForLeaveCalendar(String principalId, DateTime beginDate, DateTime endDate) {/*from w w w . java 2s . c o m*/ CalendarEntry pcd = null; Calendar calendar = HrServiceLocator.getCalendarService().getCalendarByPrincipalIdAndDate(principalId, beginDate.toLocalDate(), endDate.toLocalDate(), true); if (calendar != null) { pcd = HrServiceLocator.getCalendarEntryService() .getCalendarEntryByCalendarIdAndDateRange(calendar.getHrCalendarId(), beginDate, endDate); if (pcd != null) { pcd.setCalendarObj(calendar); } } return pcd; }
From source file:org.kuali.kpme.core.calendar.entry.service.CalendarEntryServiceImpl.java
License:Educational Community License
@Override public CalendarEntry getCurrentCalendarDatesForLeaveCalendar(String principalId, DateTime currentDate) { CalendarEntry pcd = null;//from w ww . j a v a 2s . co m Calendar calendar = HrServiceLocator.getCalendarService().getCalendarByPrincipalIdAndDate(principalId, currentDate.toLocalDate(), true); if (calendar != null) { pcd = HrServiceLocator.getCalendarEntryService() .getCurrentCalendarEntryByCalendarId(calendar.getHrCalendarId(), currentDate); if (pcd != null) { pcd.setCalendarObj(calendar); } } return pcd; }
From source file:org.kuali.kpme.core.role.proxy.service.KpmeRoleProxyDerivedRoleTypeServiceImpl.java
License:Educational Community License
@Override public List<RoleMember> getRoleMembersCached(String namespaceCode, String roleName, Map<String, String> qualification, DateTime asOfDate, boolean isActiveOnly) { // the return value List<RoleMember> roleMembers = new ArrayList<RoleMember>(); Role role = getRoleService().getRoleByNamespaceCodeAndName(namespaceCode, roleName); if (role != null) { if ((asOfDate.toLocalDate().toDateTimeAtStartOfDay().equals(LocalDate.now().toDateTimeAtStartOfDay())) && isActiveOnly) { // invoke the non-recursive helper that delegates to KIM roleMembers = getActiveRoleMembersToday(role, qualification); } else {//from w w w. java2s . c om // invoke the recursive helper roleMembers = getRoleMembers(role, qualification, asOfDate, isActiveOnly); } } else { LOG.error("Role instance for proxied role with name " + roleName + " namespace " + namespaceCode + " was null"); } return roleMembers; }
From source file:org.kuali.kpme.core.role.proxy.service.KpmeRoleProxyDerivedRoleTypeServiceImpl.java
License:Educational Community License
@Override public boolean hasDerivedRole(String principalId, List<String> groupIds, String namespaceCode, String roleName, Map<String, String> qualification) { boolean retVal = false; String proxiedRoleNamespaceCode = qualification.remove(KPME_PROXIED_ROLE_NAMESPACE_CODE); if (proxiedRoleNamespaceCode == null) { // use the hook to get the namespace proxiedRoleNamespaceCode = this.getProxiedRoleNamespaceCode(); }/*from w ww .ja v a 2 s .c o m*/ String proxiedRoleName = qualification.remove(KPME_PROXIED_ROLE_ROLE_NAME); if (proxiedRoleName == null) { // use the hook to get the role name proxiedRoleName = this.getProxiedRoleName(); } // get the as-of date and the active flag values DateTime asOfDate = LocalDate.now().toDateTimeAtStartOfDay(); String asOfDateString = qualification.remove(KPME_PROXIED_ROLE_AS_OF_DATE); if (asOfDateString != null) { asOfDate = DateTime.parse(asOfDateString); } boolean activeOnly = true; String activeOnlyString = qualification.remove(KPME_PROXIED_ROLE_IS_ACTIVE_ONLY); if (activeOnlyString != null) { activeOnly = Boolean.parseBoolean(activeOnlyString); } Role proxiedRole = getRoleService().getRoleByNamespaceCodeAndName(proxiedRoleNamespaceCode, proxiedRoleName); if (proxiedRole != null) { if ((asOfDate.toLocalDate().toDateTimeAtStartOfDay().equals(LocalDate.now().toDateTimeAtStartOfDay())) && activeOnly) { // invoke the non-recursive helper that delegates to KIM retVal = isActiveMemberOfRoleToday(principalId, groupIds, proxiedRole, qualification); } else { // invoke the recursive helper retVal = isMemberOfRole(principalId, proxiedRole, qualification, asOfDate, activeOnly); } } else { LOG.error("Role for role name " + proxiedRoleName + " with namespace code " + proxiedRoleNamespaceCode + " was null"); } return retVal; }