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.web.calendars.BaseCalendarEditionController.java
License:Open Source License
private static LocalDate getLocalDateFrom(Datebox datebox) { Date value = datebox.getValue(); return value == null ? null : LocalDate.fromDateFields(value); }
From source file:org.libreplan.web.calendars.BaseCalendarEditionController.java
License:Open Source License
public void updateException() { Combobox exceptionTypes = (Combobox) window.getFellow("exceptionTypes"); CalendarExceptionType type = exceptionTypes.getSelectedItem().getValue(); 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 {//from w w w .j a v a2 s . com 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 (startDate.compareTo(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.updateException(type, LocalDate.fromDateFields(startDate), LocalDate.fromDateFields(endDate), capacity); reloadDayInformation(); }
From source file:org.libreplan.web.calendars.BaseCalendarModel.java
License:Open Source License
public CalendarData getCurrentVersion() { return getBaseCalendar().getCalendarData(LocalDate.fromDateFields(new Date())); }
From source file:org.libreplan.web.calendars.BaseCalendarModel.java
License:Open Source License
@Override public void checkAndChangeStartDate(CalendarData version, Date date) throws ValidationException { if (date == null) { if (version.equals(getBaseCalendar().getFirstCalendarData())) { return; } else {// w w w . j a v a 2 s . c om throw new ValidationException(_("This date cannot be empty")); } } LocalDate newStartDate = LocalDate.fromDateFields(date); CalendarData prevVersion = getBaseCalendar().getPrevious(version); if ((newStartDate != null) && (prevVersion != null)) { if (getBaseCalendar().getPrevious(prevVersion) == null) { return; } LocalDate prevStartDate = getBaseCalendar().getPrevious(prevVersion).getExpiringDate(); if ((prevStartDate == null) || ((newStartDate.compareTo(prevStartDate) > 0))) { prevVersion.setExpiringDate(newStartDate); return; } } throw new ValidationException(_("This date can not include the whole previous work week")); }
From source file:org.libreplan.web.calendars.BaseCalendarModel.java
License:Open Source License
@Override public void checkChangeExpiringDate(CalendarData version, Date date) { Integer index = getBaseCalendar().getCalendarDataVersions().indexOf(version); if (date == null) { if (version.equals(getBaseCalendar().getLastCalendarData())) { return; } else {//from www. ja v a2 s . c o m throw new ValidationException(_("This date cannot be empty")); } } LocalDate newExpiringDate = LocalDate.fromDateFields(date); if ((index < getBaseCalendar().getCalendarDataVersions().size() - 1)) { LocalDate nextExpiringDate = getBaseCalendar().getCalendarDataVersions().get(index + 1) .getExpiringDate(); if ((nextExpiringDate == null) || (newExpiringDate.compareTo(nextExpiringDate) < 0)) { return; } } throw new ValidationException(_("Date cannot include the entire next work week")); }
From source file:org.libreplan.web.calendars.BaseCalendarsTreeModel.java
License:Open Source License
private static Map<BaseCalendar, List<BaseCalendar>> createRelationParentChildren( List<BaseCalendar> rootCalendars, List<BaseCalendar> derivedCalendars) { Map<BaseCalendar, List<BaseCalendar>> result = new HashMap<>(); for (BaseCalendar root : rootCalendars) { result.put(root, new ArrayList<>()); }// ww w .j a v a2 s . c o m for (BaseCalendar derived : derivedCalendars) { BaseCalendar parent = derived.getCalendarData(LocalDate.fromDateFields(new Date())).getParent(); List<BaseCalendar> siblings = result.get(parent); if (siblings == null) { siblings = new ArrayList<>(); siblings.add(derived); result.put(parent, siblings); } else { siblings.add(derived); } } return result; }
From source file:org.libreplan.web.common.TemplateModel.java
License:Open Source License
private LocalDate asLocalDate(Date date) { return date != null ? LocalDate.fromDateFields(date) : null; }
From source file:org.libreplan.web.dashboard.CostStatusController.java
License:Open Source License
public void render() { LocalDate today = LocalDate.fromDateFields(new Date()); BigDecimal actualCost = costStatusModel.getActualCostWorkPerformedAt(today); setHoursLabel(lblACWP, actualCost);//from w ww.ja va2s.c om BigDecimal budgetedCost = costStatusModel.getBudgetedCostWorkPerformedAt(today); BigDecimal costVariance = costStatusModel.getCostVariance(budgetedCost, actualCost); setHoursLabel(lblCV, costVariance); BigDecimal costPerformanceIndex = costStatusModel.getCostPerformanceIndex(budgetedCost, actualCost); setPercentageLabel(lblCPI, costPerformanceIndex); BigDecimal budgetAtCompletion = costStatusModel.getBudgetAtCompletion(); setHoursLabel(lblBAC, budgetAtCompletion); BigDecimal estimateAtCompletion = costStatusModel.getEstimateAtCompletion(budgetAtCompletion, costPerformanceIndex); setHoursLabel(lblEAC, estimateAtCompletion); BigDecimal varianceAtCompletion = costStatusModel.getVarianceAtCompletion(budgetAtCompletion, estimateAtCompletion); setHoursLabel(lblVAC, varianceAtCompletion); BigDecimal estimateToComplete = costStatusModel.getEstimateToComplete(estimateAtCompletion, actualCost); setHoursLabel(lblETC, estimateToComplete); }
From source file:org.libreplan.web.dashboard.DashboardModel.java
License:Open Source License
private void calculateMarginWithDeadLine() { if (this.getRootTask() == null) { throw new RuntimeException("Root task is null"); }//from w w w. j av a 2s . c o m if (this.currentOrder.getDeadline() == null) { this.marginWithDeadLine = null; return; } TaskGroup rootTask = getRootTask(); LocalDate endDate = TaskElement.maxDate(rootTask.getChildren()).asExclusiveEnd(); Days orderDuration = Days.daysBetween(TaskElement.minDate(rootTask.getChildren()).getDate(), endDate); LocalDate deadLineAsLocalDate = LocalDate.fromDateFields(currentOrder.getDeadline()); Days deadlineOffset = Days.daysBetween(endDate, deadLineAsLocalDate.plusDays(1)); BigDecimal outcome = new BigDecimal(deadlineOffset.getDays(), MathContext.DECIMAL32); this.marginWithDeadLine = orderDuration.getDays() != 0 ? outcome.divide(new BigDecimal(orderDuration.getDays()), 8, BigDecimal.ROUND_HALF_EVEN) : new BigDecimal(Days.daysBetween(rootTask.getStartAsLocalDate(), deadLineAsLocalDate.plusDays(1)) .getDays()); }
From source file:org.libreplan.web.dashboard.DashboardModel.java
License:Open Source License
private void calculateAbsoluteMarginWithDeadLine() { TaskElement rootTask = getRootTask(); Date deadline = currentOrder.getDeadline(); if (rootTask == null) { throw new RuntimeException("Root task is null"); }/*from w w w. j a v a 2s . co m*/ if (deadline == null) { this.absoluteMarginWithDeadLine = null; return; } absoluteMarginWithDeadLine = daysBetween(TaskElement.maxDate(rootTask.getChildren()).asExclusiveEnd(), LocalDate.fromDateFields(deadline).plusDays(1)); }