List of usage examples for org.joda.time LocalDate fromDateFields
@SuppressWarnings("deprecation") public static LocalDate fromDateFields(Date date)
java.util.Date
using exactly the same field values. From source file:org.libreplan.business.workreports.entities.WorkReport.java
License:Open Source License
@AssertTrue(message = "only one timesheet line per day and task is allowed in personal timesheets") public boolean isOnlyOneWorkReportLinePerDayAndOrderElementInPersonalTimesheetConstraint() { if (!getWorkReportType().isPersonalTimesheetsType()) { return true; }// w w w. j av a2s. co m Map<OrderElement, Set<LocalDate>> map = new HashMap<>(); for (WorkReportLine line : workReportLines) { OrderElement orderElement = line.getOrderElement(); if (map.get(orderElement) == null) { map.put(orderElement, new HashSet<LocalDate>()); } LocalDate date = LocalDate.fromDateFields(line.getDate()); if (map.get(orderElement).contains(date)) { return false; } map.get(orderElement).add(date); } return true; }
From source file:org.libreplan.business.workreports.entities.WorkReport.java
License:Open Source License
@AssertTrue(message = "In personal timesheets, all timesheet lines should be in the same period") public boolean isAllWorkReportLinesInTheSamePeriodInPersonalTimesheetConstraint() { if (!getWorkReportType().isPersonalTimesheetsType()) { return true; }//w w w . j a v a 2 s . com if (workReportLines.isEmpty()) { return true; } LocalDate workReportDate = LocalDate.fromDateFields(workReportLines.iterator().next().getDate()); PersonalTimesheetsPeriodicityEnum periodicity = Registry.getConfigurationDAO() .getConfigurationWithReadOnlyTransaction().getPersonalTimesheetsPeriodicity(); LocalDate min = periodicity.getStart(workReportDate); LocalDate max = periodicity.getEnd(workReportDate); for (WorkReportLine line : workReportLines) { LocalDate date = LocalDate.fromDateFields(line.getDate()); if ((date.compareTo(min) < 0) || (date.compareTo(max) > 0)) { return false; } } return true; }
From source file:org.libreplan.business.workreports.entities.WorkReportLine.java
License:Open Source License
public LocalDate getLocalDate() { if (getDate() == null) { return null; } return LocalDate.fromDateFields(getDate()); }
From source file:org.libreplan.importers.CalendarImporterMPXJ.java
License:Open Source License
/** * Makes a {@link CalendarException} from a {@link CalendarExceptionDTO}. * * @param calendarExceptionDTO/*from w w w.ja va 2 s .co m*/ * CalendarExceptionDTO to extract data from. * @return CalendarException with the CalendarException that we want. * @throws InstanceNotFoundException */ private CalendarException toCalendarException(CalendarExceptionDTO calendarExceptionDTO) throws InstanceNotFoundException { LocalDate date = null; if (calendarExceptionDTO.date != null) { date = LocalDate.fromDateFields(calendarExceptionDTO.date); } CalendarExceptionType calendarExceptionType; if (calendarExceptionDTO.working) { calendarExceptionType = calendarExceptionTypeDAO.findUniqueByName("WORKING_DAY"); } else { calendarExceptionType = calendarExceptionTypeDAO.findUniqueByName("NOT_WORKING_DAY"); } return CalendarException.create(date, EffortDuration.hours(calendarExceptionDTO.hours) .plus(EffortDuration.minutes(calendarExceptionDTO.minutes)), calendarExceptionType); }
From source file:org.libreplan.importers.CalendarImporterMPXJ.java
License:Open Source License
/** * Makes a {@link CalendarData} from a {@link CalendarWeekDTO}. * * @param workingWeek// w w w . j av a 2s. c o m * CalendarWeekDTO to extract data from. * @param parent * BaseCalendar parent of this workingWeek * @return CalendarData with the CalendarData that we want. */ private CalendarData toCalendarData(CalendarWeekDTO workingWeek, BaseCalendar parent) { LocalDate expiringDate = null; if (workingWeek.endDate != null) { expiringDate = LocalDate.fromDateFields(workingWeek.endDate); } if (workingWeek.startDate != null) { expiringDate = LocalDate.fromDateFields(workingWeek.startDate); } CalendarData calendarData = CalendarData.create(); calendarData.setExpiringDate(expiringDate); if (parent != null) { calendarData.setParent(parent); } calendarData.setCodeAutogenerated(true); Map<Integer, Capacity> capacitiesPerDays = getCapacitiesPerDays(workingWeek.hoursPerDays); try { calendarData.updateCapacitiesPerDay(capacitiesPerDays); } catch (IllegalArgumentException e) { throw new ValidationException(e.getMessage()); } return calendarData; }
From source file:org.libreplan.importers.JiraOrderElementSynchronizer.java
License:Open Source License
/** * Synchronize progress assignment and measurement * * @param orderLine/* w w w. ja v a 2s. co m*/ * an exist orderLine * @param issue * jira's issue to synchronize with progress assignment and * measurement */ private void syncProgressMeasurement(OrderLine orderLine, IssueDTO issue, EffortDuration estimatedHours, EffortDuration loggedHours) { WorkLogDTO workLog = issue.getFields().getWorklog(); if (workLog == null) { synchronizationInfo.addFailedReason(_("No worklogs found for \"{0}\" issue", issue.getKey())); return; } List<WorkLogItemDTO> workLogItems = workLog.getWorklogs(); if (workLogItems.isEmpty()) { synchronizationInfo.addFailedReason(_("No worklog items found for \"{0}\" issue", issue.getKey())); return; } BigDecimal percentage; // if status is closed, the progress percentage is 100% regardless the // loggedHours and estimatedHours if (isIssueClosed(issue.getFields().getStatus())) { percentage = new BigDecimal(100); } else { percentage = loggedHours.dividedByAndResultAsBigDecimal(estimatedHours).multiply(new BigDecimal(100)); } LocalDate latestWorkLogDate = LocalDate.fromDateFields(getTheLatestWorkLoggedDate(workLogItems)); updateOrCreateProgressAssignmentAndMeasurement(orderLine, percentage, latestWorkLogDate); }
From source file:org.libreplan.importers.OrderImporterMPXJ.java
License:Open Source License
/** * Sets the proper constraint to and a {@link Task}. * * @param importTask//from w w w. j a v a 2s. co m * OrderElementDTO to extract data from. * @param task * Task to set data on. */ private void setPositionConstraint(Task task, OrderElementDTO importTask) { switch (importTask.constraint) { case AS_SOON_AS_POSSIBLE: task.getPositionConstraint().asSoonAsPossible(); return; case AS_LATE_AS_POSSIBLE: task.getPositionConstraint().asLateAsPossible(); return; case START_IN_FIXED_DATE: task.setIntraDayStartDate(IntraDayDate.startOfDay(LocalDate.fromDateFields(importTask.constraintDate))); Task.convertOnStartInFixedDate(task); return; case START_NOT_EARLIER_THAN: task.getPositionConstraint() .notEarlierThan(IntraDayDate.startOfDay(LocalDate.fromDateFields(importTask.constraintDate))); return; case FINISH_NOT_LATER_THAN: task.getPositionConstraint().finishNotLaterThan( IntraDayDate.startOfDay(LocalDate.fromDateFields(importTask.constraintDate))); return; default: return; } }
From source file:org.libreplan.importers.OrderImporterMPXJ.java
License:Open Source License
/** * Sets the proper constraint to and a {@link TaskMiletone} * * @param milestone/*from w ww . j a v a 2 s. c o m*/ * MilestoneDTO to extract data from. * @param taskMilestone * TaskMilestone to set data on. */ private void setPositionConstraint(TaskMilestone taskMilestone, MilestoneDTO milestone) { switch (milestone.constraint) { case AS_SOON_AS_POSSIBLE: taskMilestone.getPositionConstraint().asSoonAsPossible(); return; case AS_LATE_AS_POSSIBLE: taskMilestone.getPositionConstraint().asLateAsPossible(); return; case START_IN_FIXED_DATE: taskMilestone.getPositionConstraint() .notEarlierThan(IntraDayDate.startOfDay(LocalDate.fromDateFields(milestone.constraintDate))); return; case START_NOT_EARLIER_THAN: taskMilestone.getPositionConstraint() .notEarlierThan(IntraDayDate.startOfDay(LocalDate.fromDateFields(milestone.constraintDate))); return; case FINISH_NOT_LATER_THAN: taskMilestone.getPositionConstraint().finishNotLaterThan( IntraDayDate.startOfDay(LocalDate.fromDateFields(milestone.constraintDate))); return; default: return; } }
From source file:org.libreplan.web.calendars.BaseCalendarEditionController.java
License:Open Source License
private static LocalDate toLocalDate(Date date) { return date == null ? null : LocalDate.fromDateFields(date); }
From source file:org.libreplan.web.calendars.BaseCalendarEditionController.java
License:Open Source License
public void createException() { Combobox exceptionTypes = (Combobox) window.getFellow("exceptionTypes"); CalendarExceptionType type = exceptionTypes.getSelectedItem().getValue(); if (type == null) { throw new WrongValueException(exceptionTypes, _("Please, select type of exception")); } else {// w w w . j a v a 2 s.c o m Clients.clearWrongValue(exceptionTypes); } Datebox dateboxStartDate = (Datebox) window.getFellow("exceptionStartDate"); Date startDate = dateboxStartDate.getValue(); if (startDate == null) { throw new WrongValueException(dateboxStartDate, _("You should select a start date for the exception")); } else { Clients.clearWrongValue(dateboxStartDate); } Datebox dateboxEndDate = (Datebox) window.getFellow("exceptionEndDate"); Date endDate = dateboxEndDate.getValue(); if (endDate == null) { throw new WrongValueException(dateboxEndDate, _("Please, select an End Date for the Exception")); } else { Clients.clearWrongValue(dateboxEndDate); } if (new LocalDate(startDate).compareTo(new LocalDate(endDate)) > 0) { throw new WrongValueException(dateboxEndDate, _("Exception end date should be greater or equals than start date")); } else { Clients.clearWrongValue(dateboxEndDate); } Capacity capacity = capacityPicker.getValue(); baseCalendarModel.createException(type, LocalDate.fromDateFields(startDate), LocalDate.fromDateFields(endDate), capacity); reloadDayInformation(); }