List of usage examples for org.joda.time DateTimeConstants WEDNESDAY
int WEDNESDAY
To view the source code for org.joda.time DateTimeConstants WEDNESDAY.
Click Source Link
From source file:com.axelor.apps.base.service.scheduler.SchedulerService.java
License:Open Source License
/** * Mthode qui dtermine la prochaine date d'xcution d'un planificateur pour un rythme hebdomadaire * * @param scheduler//from ww w . j a v a2s . c o m * Instance de planificateur * @param date * Derniere date d'xcution thorique * * @return LocalDate * Prochaine date d'xcution */ private LocalDate getWeeklyComputeDate(Scheduler scheduler, LocalDate date) { int weekDay = 0; if (scheduler.getMonday()) weekDay = DateTimeConstants.MONDAY; else if (scheduler.getTuesday()) weekDay = DateTimeConstants.TUESDAY; else if (scheduler.getWednesday()) weekDay = DateTimeConstants.WEDNESDAY; else if (scheduler.getThursday()) weekDay = DateTimeConstants.THURSDAY; else if (scheduler.getFriday()) weekDay = DateTimeConstants.FRIDAY; else if (scheduler.getSaturday()) weekDay = DateTimeConstants.SATURDAY; else if (scheduler.getSunday()) weekDay = DateTimeConstants.SUNDAY; if (weekDay == 0) weekDay = 1; return date.plusWeeks(scheduler.getWeekWeekly()).withDayOfWeek(weekDay); }
From source file:com.axelor.apps.crm.web.EventController.java
License:Open Source License
@Transactional public void generateRecurrentEvents(ActionRequest request, ActionResponse response) throws AxelorException { Long eventId = new Long(request.getContext().get("_idEvent").toString()); Event event = eventRepo.find(eventId); RecurrenceConfiguration conf = request.getContext().asType(RecurrenceConfiguration.class); RecurrenceConfigurationRepository confRepo = Beans.get(RecurrenceConfigurationRepository.class); conf = confRepo.save(conf);//from w w w . jav a 2 s . co m event.setRecurrenceConfiguration(conf); event = eventRepo.save(event); if (request.getContext().get("recurrenceType") == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_RECURRENCE_TYPE)), IException.CONFIGURATION_ERROR); } int recurrenceType = new Integer(request.getContext().get("recurrenceType").toString()); if (request.getContext().get("periodicity") == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_PERIODICITY)), IException.CONFIGURATION_ERROR); } int periodicity = new Integer(request.getContext().get("periodicity").toString()); if (periodicity < 1) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_PERIODICITY)), IException.CONFIGURATION_ERROR); } boolean monday = (boolean) request.getContext().get("monday"); boolean tuesday = (boolean) request.getContext().get("tuesday"); boolean wednesday = (boolean) request.getContext().get("wednesday"); boolean thursday = (boolean) request.getContext().get("thursday"); boolean friday = (boolean) request.getContext().get("friday"); boolean saturday = (boolean) request.getContext().get("saturday"); boolean sunday = (boolean) request.getContext().get("sunday"); Map<Integer, Boolean> daysMap = new HashMap<Integer, Boolean>(); Map<Integer, Boolean> daysCheckedMap = new HashMap<Integer, Boolean>(); if (recurrenceType == 2) { daysMap.put(DateTimeConstants.MONDAY, monday); daysMap.put(DateTimeConstants.TUESDAY, tuesday); daysMap.put(DateTimeConstants.WEDNESDAY, wednesday); daysMap.put(DateTimeConstants.THURSDAY, thursday); daysMap.put(DateTimeConstants.FRIDAY, friday); daysMap.put(DateTimeConstants.SATURDAY, saturday); daysMap.put(DateTimeConstants.SUNDAY, sunday); for (Integer day : daysMap.keySet()) { if (daysMap.get(day)) { daysCheckedMap.put(day, daysMap.get(day)); } } if (daysMap.isEmpty()) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_DAYS_CHECKED)), IException.CONFIGURATION_ERROR); } } int monthRepeatType = new Integer(request.getContext().get("monthRepeatType").toString()); int endType = new Integer(request.getContext().get("endType").toString()); int repetitionsNumber = 0; if (endType == 1) { if (request.getContext().get("repetitionsNumber") == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_REPETITION_NUMBER)), IException.CONFIGURATION_ERROR); } repetitionsNumber = new Integer(request.getContext().get("repetitionsNumber").toString()); if (repetitionsNumber < 1) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_REPETITION_NUMBER)), IException.CONFIGURATION_ERROR); } } LocalDate endDate = new LocalDate(); if (endType == 2) { if (request.getContext().get("endDate") == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_END_DATE)), IException.CONFIGURATION_ERROR); } endDate = new LocalDate(request.getContext().get("endDate").toString()); if (endDate.isBefore(event.getStartDateTime()) && endDate.isEqual(event.getStartDateTime())) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_END_DATE)), IException.CONFIGURATION_ERROR); } } switch (recurrenceType) { case 1: eventService.addRecurrentEventsByDays(event, periodicity, endType, repetitionsNumber, endDate); break; case 2: eventService.addRecurrentEventsByWeeks(event, periodicity, endType, repetitionsNumber, endDate, daysCheckedMap); break; case 3: eventService.addRecurrentEventsByMonths(event, periodicity, endType, repetitionsNumber, endDate, monthRepeatType); break; case 4: eventService.addRecurrentEventsByYears(event, periodicity, endType, repetitionsNumber, endDate); break; default: break; } response.setCanClose(true); response.setReload(true); }
From source file:com.axelor.apps.crm.web.EventController.java
License:Open Source License
@Transactional public void changeAll(ActionRequest request, ActionResponse response) throws AxelorException { Long eventId = new Long(request.getContext().get("_idEvent").toString()); Event event = eventRepo.find(eventId); Event child = eventRepo.all().filter("self.parentEvent.id = ?1", event.getId()).fetchOne(); Event parent = event.getParentEvent(); child.setParentEvent(null);// w w w . j a va 2s.c o m Event eventDeleted = child; child = eventRepo.all().filter("self.parentEvent.id = ?1", eventDeleted.getId()).fetchOne(); while (child != null) { child.setParentEvent(null); eventRepo.remove(eventDeleted); eventDeleted = child; child = eventRepo.all().filter("self.parentEvent.id = ?1", eventDeleted.getId()).fetchOne(); } while (parent != null) { Event nextParent = parent.getParentEvent(); eventRepo.remove(parent); parent = nextParent; } RecurrenceConfiguration conf = request.getContext().asType(RecurrenceConfiguration.class); RecurrenceConfigurationRepository confRepo = Beans.get(RecurrenceConfigurationRepository.class); conf = confRepo.save(conf); event.setRecurrenceConfiguration(conf); event = eventRepo.save(event); if (conf.getRecurrenceType() == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_RECURRENCE_TYPE)), IException.CONFIGURATION_ERROR); } int recurrenceType = conf.getRecurrenceType(); if (conf.getPeriodicity() == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_PERIODICITY)), IException.CONFIGURATION_ERROR); } int periodicity = conf.getPeriodicity(); if (periodicity < 1) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_PERIODICITY)), IException.CONFIGURATION_ERROR); } boolean monday = conf.getMonday(); boolean tuesday = conf.getTuesday(); boolean wednesday = conf.getWednesday(); boolean thursday = conf.getThursday(); boolean friday = conf.getFriday(); boolean saturday = conf.getSaturday(); boolean sunday = conf.getSunday(); Map<Integer, Boolean> daysMap = new HashMap<Integer, Boolean>(); Map<Integer, Boolean> daysCheckedMap = new HashMap<Integer, Boolean>(); if (recurrenceType == 2) { daysMap.put(DateTimeConstants.MONDAY, monday); daysMap.put(DateTimeConstants.TUESDAY, tuesday); daysMap.put(DateTimeConstants.WEDNESDAY, wednesday); daysMap.put(DateTimeConstants.THURSDAY, thursday); daysMap.put(DateTimeConstants.FRIDAY, friday); daysMap.put(DateTimeConstants.SATURDAY, saturday); daysMap.put(DateTimeConstants.SUNDAY, sunday); for (Integer day : daysMap.keySet()) { if (daysMap.get(day)) { daysCheckedMap.put(day, daysMap.get(day)); } } if (daysMap.isEmpty()) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_DAYS_CHECKED)), IException.CONFIGURATION_ERROR); } } int monthRepeatType = conf.getMonthRepeatType(); int endType = conf.getEndType(); int repetitionsNumber = 0; if (endType == 1) { if (conf.getRepetitionsNumber() == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_REPETITION_NUMBER)), IException.CONFIGURATION_ERROR); } repetitionsNumber = conf.getRepetitionsNumber(); if (repetitionsNumber < 1) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_REPETITION_NUMBER)), IException.CONFIGURATION_ERROR); } } LocalDate endDate = new LocalDate(); if (endType == 2) { if (conf.getEndDate() == null) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_END_DATE)), IException.CONFIGURATION_ERROR); } endDate = new LocalDate(conf.getEndDate()); if (endDate.isBefore(event.getStartDateTime()) && endDate.isEqual(event.getStartDateTime())) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.RECURRENCE_END_DATE)), IException.CONFIGURATION_ERROR); } } switch (recurrenceType) { case 1: eventService.addRecurrentEventsByDays(event, periodicity, endType, repetitionsNumber, endDate); break; case 2: eventService.addRecurrentEventsByWeeks(event, periodicity, endType, repetitionsNumber, endDate, daysCheckedMap); break; case 3: eventService.addRecurrentEventsByMonths(event, periodicity, endType, repetitionsNumber, endDate, monthRepeatType); break; case 4: eventService.addRecurrentEventsByYears(event, periodicity, endType, repetitionsNumber, endDate); break; default: break; } response.setCanClose(true); response.setReload(true); }
From source file:com.axelor.apps.project.service.ProjectPlanningService.java
License:Open Source License
public void getTasksForUser(ActionRequest request, ActionResponse response) { List<Map<String, String>> dataList = new ArrayList<Map<String, String>>(); try {//from ww w . jav a 2 s . c o m LocalDate todayDate = Beans.get(GeneralService.class).getTodayDate(); List<ProjectPlanningLine> linesList = Beans.get(ProjectPlanningLineRepository.class).all() .filter("self.user.id = ?1 AND self.year >= ?2 AND self.week >= ?3", AuthUtils.getUser().getId(), todayDate.getYear(), todayDate.getWeekOfWeekyear()) .fetch(); for (ProjectPlanningLine line : linesList) { if (line.getMonday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.MONDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getMonday().toString()); dataList.add(map); } } if (line.getTuesday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.TUESDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getTuesday().toString()); dataList.add(map); } } if (line.getWednesday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.WEDNESDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getWednesday().toString()); dataList.add(map); } } if (line.getThursday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.THURSDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getThursday().toString()); dataList.add(map); } } if (line.getFriday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.FRIDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getFriday().toString()); dataList.add(map); } } if (line.getSaturday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.SATURDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getSaturday().toString()); dataList.add(map); } } if (line.getSunday().compareTo(BigDecimal.ZERO) != 0) { LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek()) .withDayOfWeek(DateTimeConstants.SUNDAY); if (date.isAfter(todayDate) || date.isEqual(todayDate)) { Map<String, String> map = new HashMap<String, String>(); map.put("taskId", line.getProjectTask().getId().toString()); map.put("name", line.getProjectTask().getFullName()); if (line.getProjectTask().getProject() != null) { map.put("projectName", line.getProjectTask().getProject().getFullName()); } else { map.put("projectName", ""); } map.put("date", date.toString()); map.put("duration", line.getSunday().toString()); dataList.add(map); } } } response.setData(dataList); } catch (Exception e) { response.setStatus(-1); response.setError(e.getMessage()); } }
From source file:com.battlelancer.seriesguide.util.TimeTools.java
License:Apache License
/** * Converts US week day string to {@link org.joda.time.DateTimeConstants} day. * * <p> Returns -1 if no conversion is possible and 0 if it is "Daily". *//*from w w w. j a v a 2 s.co m*/ public static int parseShowReleaseWeekDay(String day) { if (day == null || day.length() == 0) { return -1; } // catch Monday through Sunday switch (day) { case "Monday": return DateTimeConstants.MONDAY; case "Tuesday": return DateTimeConstants.TUESDAY; case "Wednesday": return DateTimeConstants.WEDNESDAY; case "Thursday": return DateTimeConstants.THURSDAY; case "Friday": return DateTimeConstants.FRIDAY; case "Saturday": return DateTimeConstants.SATURDAY; case "Sunday": return DateTimeConstants.SUNDAY; case "Daily": return 0; } // no match return -1; }
From source file:com.effektif.workflow.api.model.NextRelativeTime.java
License:Apache License
public static String dayOfWeekToString(Integer dayOfWeek) { if (dayOfWeek == null) return "unspecified day"; else if (dayOfWeek == DateTimeConstants.MONDAY) return "Monday"; // 1 else if (dayOfWeek == DateTimeConstants.TUESDAY) return "Tuesday"; // 2 else if (dayOfWeek == DateTimeConstants.WEDNESDAY) return "Wednesday"; // 3 else if (dayOfWeek == DateTimeConstants.THURSDAY) return "Thursday"; // 4 else if (dayOfWeek == DateTimeConstants.FRIDAY) return "Friday"; // 5 else if (dayOfWeek == DateTimeConstants.SATURDAY) return "Saturday"; // 6 else if (dayOfWeek == DateTimeConstants.SUNDAY) return "Sunday"; // 7 return "invalid day of the week " + dayOfWeek; }
From source file:com.helger.bootstrap3.datetimepicker.EDateTimePickerDayOfWeek.java
License:Apache License
@Nullable public static EDateTimePickerDayOfWeek getFromJodaValueOrNull(final int nJodaValue) { switch (nJodaValue) { case DateTimeConstants.MONDAY: return MONDAY; case DateTimeConstants.TUESDAY: return TUESDAY; case DateTimeConstants.WEDNESDAY: return WEDNESDAY; case DateTimeConstants.THURSDAY: return THURSDAY; case DateTimeConstants.FRIDAY: return FRIDAY; case DateTimeConstants.SATURDAY: return SATURDAY; case DateTimeConstants.SUNDAY: return SUNDAY; }/*from w w w. j a va2s. co m*/ return null; }
From source file:com.helger.datetime.holiday.mgr.XMLUtil.java
License:Apache License
/** * Returns the {@link DateTimeConstants} value for the given weekday. * //w w w . j a v a 2 s. c om * @param eWeekday * Day of week to convert * @return {@link DateTimeConstants} value. */ @Nonnegative public static int getWeekday(@Nonnull final Weekday eWeekday) { switch (eWeekday) { case MONDAY: return DateTimeConstants.MONDAY; case TUESDAY: return DateTimeConstants.TUESDAY; case WEDNESDAY: return DateTimeConstants.WEDNESDAY; case THURSDAY: return DateTimeConstants.THURSDAY; case FRIDAY: return DateTimeConstants.FRIDAY; case SATURDAY: return DateTimeConstants.SATURDAY; case SUNDAY: return DateTimeConstants.SUNDAY; default: throw new IllegalArgumentException("Unknown weekday " + eWeekday); } }
From source file:com.jjlharrison.jollyday.util.XMLUtil.java
License:Apache License
/** * Returns the <code>DateTimeConstants</code> value for the given weekday. * * @param weekday/*w w w .ja v a 2s . c o m*/ * a {@link com.jjlharrison.config.Weekday} object. * @return DateTimeConstants value. */ public final int getWeekday(Weekday weekday) { switch (weekday) { case MONDAY: return DateTimeConstants.MONDAY; case TUESDAY: return DateTimeConstants.TUESDAY; case WEDNESDAY: return DateTimeConstants.WEDNESDAY; case THURSDAY: return DateTimeConstants.THURSDAY; case FRIDAY: return DateTimeConstants.FRIDAY; case SATURDAY: return DateTimeConstants.SATURDAY; case SUNDAY: return DateTimeConstants.SUNDAY; default: throw new IllegalArgumentException("Unknown weekday " + weekday); } }
From source file:com.marand.thinkmed.medications.business.impl.MedicationsEhrUtils.java
License:Open Source License
public static DayOfWeek dayOfWeekToEhrEnum(final DateTime dateTime) { if (dateTime.getDayOfWeek() == DateTimeConstants.MONDAY) { return DayOfWeek.MONDAY; }// ww w.java 2 s. co m if (dateTime.getDayOfWeek() == DateTimeConstants.TUESDAY) { return DayOfWeek.TUESDAY; } if (dateTime.getDayOfWeek() == DateTimeConstants.WEDNESDAY) { return DayOfWeek.WEDNESDAY; } if (dateTime.getDayOfWeek() == DateTimeConstants.THURSDAY) { return DayOfWeek.THURSDAY; } if (dateTime.getDayOfWeek() == DateTimeConstants.FRIDAY) { return DayOfWeek.FRIDAY; } if (dateTime.getDayOfWeek() == DateTimeConstants.SATURDAY) { return DayOfWeek.SATURDAY; } if (dateTime.getDayOfWeek() == DateTimeConstants.SUNDAY) { return DayOfWeek.SUNDAY; } throw new IllegalArgumentException("Day of week conversion error"); }