From 2d010cff12bdfaeb8f000fb660bc326cc4287442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenzo=20Tilve=20=C3=81lvaro?= Date: Sun, 11 Mar 2012 18:17:32 +0100 Subject: [PATCH] Fixed nullpointer exception when there are not elements in deviations array FEA: ItEr76S15OrganizingPerProjectDashboard --- .../org/libreplan/web/dashboard/DashboardModel.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java index 4f1a66d8e..2e53c3f5a 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java @@ -1,7 +1,7 @@ /* * This file is part of LibrePlan * - * Copyright (C) 2010-2011 Igalia, S.L. + * Copyright (C) 2010-2012 Igalia, S.L. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -45,7 +45,9 @@ import org.springframework.stereotype.Component; /** * Model for UI operations related to Order Dashboard View + * * @author Nacho Barrientos + * @author Lorenzo Tilve Álvaro */ @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) @@ -243,8 +245,13 @@ public class DashboardModel implements IDashboardModel { rootTask.acceptVisitor(visitor); List deviations = visitor.getDeviations(); - LTC_STRETCHES_MIN_VALUE = Collections.min(deviations); - LTC_STRETCHES_MAX_VALUE = Collections.max(deviations); + if (deviations.isEmpty()) { + LTC_STRETCHES_MIN_VALUE = 0; + LTC_STRETCHES_MAX_VALUE = 0; + } else { + LTC_STRETCHES_MIN_VALUE = Collections.min(deviations); + LTC_STRETCHES_MAX_VALUE = Collections.max(deviations); + } LTC_STRETCHES_STEP = (LTC_STRETCHES_MAX_VALUE - LTC_STRETCHES_MIN_VALUE) /LTC_NUMBER_OF_INTERVALS; this.lagInTaskCompletionHistogram = createHistogram(