From c2aa16b3b1f58f202e02c80047903d4d1ea4d3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 25 Jan 2010 22:19:26 +0100 Subject: [PATCH] ItEr45S10CUAsignacionRecursosEspecificosAPlanificacionItEr44S16: Pulling up code checking if streches are empty --- .../streches/GraphicForStreches.java | 74 +++++++++++-------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java index 185a975a1..b11ce0eed 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java @@ -49,6 +49,38 @@ public abstract class GraphicForStreches implements IGraphicGenerator { } } + @Override + public XYModel getAccumulatedHoursChartData( + IStretchesFunctionModel stretchesFunctionModel) { + List stretches = stretchesFunctionModel.getStretches(); + if (stretches.isEmpty()) { + return new SimpleXYModel(); + } else { + return getAccumulatedHoursChartData(stretches, + stretchesFunctionModel.getTaskStartDate(), new BigDecimal( + stretchesFunctionModel.getTaskHours())); + } + } + + @Override + public XYModel getDedicationChart( + IStretchesFunctionModel stretchesFunctionModel) { + List stretches = stretchesFunctionModel.getStretches(); + if (stretches.isEmpty()) { + return new SimpleXYModel(); + } + return getDedicationChart(stretches, stretchesFunctionModel + .getTaskStartDate(), new BigDecimal(stretchesFunctionModel + .getTaskHours()), stretchesFunctionModel.getTaskCalendar()); + } + + protected abstract XYModel getDedicationChart(List stretches, + LocalDate startDate, BigDecimal totalHours, + BaseCalendar taskCalendar); + + protected abstract XYModel getAccumulatedHoursChartData( + List stretches, LocalDate startDate, BigDecimal taskHours); + private static class ForDefaultStreches extends GraphicForStreches { @Override @@ -57,24 +89,15 @@ public abstract class GraphicForStreches implements IGraphicGenerator { } @Override - public XYModel getAccumulatedHoursChartData( - IStretchesFunctionModel stretchesFunctionModel) { + public XYModel getAccumulatedHoursChartData(List stretches, + LocalDate startDate, BigDecimal taskHours) { XYModel xymodel = new SimpleXYModel(); - List stretches = stretchesFunctionModel.getStretches(); - if (stretches.isEmpty()) { - return xymodel; - } - String title = "percentage"; - LocalDate startDate = stretchesFunctionModel.getTaskStartDate(); xymodel.addValue(title, startDate.toDateTimeAtStartOfDay() .getMillis(), 0); - BigDecimal taskHours = new BigDecimal(stretchesFunctionModel - .getTaskHours()); - for (Stretch stretch : stretches) { BigDecimal amountWork = stretch.getAmountWorkPercentage() .multiply(taskHours); @@ -86,25 +109,14 @@ public abstract class GraphicForStreches implements IGraphicGenerator { return xymodel; } - @Override - public XYModel getDedicationChart( - IStretchesFunctionModel stretchesFunctionModel) { + protected XYModel getDedicationChart(List stretches, + LocalDate startDate, BigDecimal taskHours, + BaseCalendar calendar){ XYModel xymodel = new SimpleXYModel(); - - List stretches = stretchesFunctionModel.getStretches(); - if (stretches.isEmpty()) { - return xymodel; - } - String title = "hours"; - LocalDate previousDate = stretchesFunctionModel.getTaskStartDate(); + LocalDate previousDate = startDate; BigDecimal previousPercentage = BigDecimal.ZERO; - - BigDecimal taskHours = new BigDecimal(stretchesFunctionModel - .getTaskHours()); - BaseCalendar calendar = stretchesFunctionModel.getTaskCalendar(); - xymodel.addValue(title, previousDate.toDateTimeAtStartOfDay() .getMillis(), 0); @@ -150,17 +162,17 @@ public abstract class GraphicForStreches implements IGraphicGenerator { } @Override - public XYModel getAccumulatedHoursChartData( - IStretchesFunctionModel stretchesFunctionModel) { + protected XYModel getAccumulatedHoursChartData(List stretches, + LocalDate startDate, BigDecimal taskHours) { return new SimpleXYModel(); } @Override - public XYModel getDedicationChart( - IStretchesFunctionModel stretchesFunctionModel) { + protected XYModel getDedicationChart(List stretches, + LocalDate startDate, BigDecimal totalHours, + BaseCalendar taskCalendar) { return new SimpleXYModel(); } - } }