From fedfeeaeefe0ab3cef9120d34632d43487dd4371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 20 Sep 2010 01:06:51 +0200 Subject: [PATCH] Add getCaptionForCriterionsFrom and use it wherever possible FEA: ItEr60S04ValidacionEProbasFuncionaisItEr59S04 --- .../business/resources/entities/Criterion.java | 7 +++++++ .../web/limitingresources/LimitingResourcesController.java | 5 ++--- .../web/planner/allocation/GenericAllocationRow.java | 3 ++- .../planner/limiting/allocation/LimitingAllocationRow.java | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/resources/entities/Criterion.java b/navalplanner-business/src/main/java/org/navalplanner/business/resources/entities/Criterion.java index 1208427a7..31dede2e5 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/resources/entities/Criterion.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/resources/entities/Criterion.java @@ -40,6 +40,7 @@ import org.hibernate.validator.NotNull; import org.hibernate.validator.Valid; import org.navalplanner.business.common.IntegrationEntity; import org.navalplanner.business.common.Registry; +import org.navalplanner.business.planner.entities.GenericResourceAllocation; import org.navalplanner.business.requirements.entities.CriterionRequirement; import org.navalplanner.business.resources.daos.ICriterionDAO; @@ -116,6 +117,12 @@ public class Criterion extends IntegrationEntity implements ICriterion { return getCaptionFor(ResourceEnum.WORKER, criteria); } + public static String getCaptionForCriterionsFrom( + GenericResourceAllocation allocation) { + return getCaptionFor(allocation.getResourceType(), + allocation.getCriterions()); + } + /** * Returns a string of criterion names separated by comma * @param resourceType diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/limitingresources/LimitingResourcesController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/limitingresources/LimitingResourcesController.java index 29cbd8554..e411fe675 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/limitingresources/LimitingResourcesController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/limitingresources/LimitingResourcesController.java @@ -232,9 +232,8 @@ public class LimitingResourcesController extends GenericForwardComposer { .getResource(); return (resource != null) ? resource.getName() : ""; } else if (resourceAllocation instanceof GenericResourceAllocation) { - Set criteria = ((GenericResourceAllocation) resourceAllocation) - .getCriterions(); - return Criterion.getCaptionFor(criteria); + GenericResourceAllocation genericAllocation = (GenericResourceAllocation) resourceAllocation; + return Criterion.getCaptionForCriterionsFrom(genericAllocation); } return StringUtils.EMPTY; } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java index 6748a4e70..735c44d48 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/GenericAllocationRow.java @@ -72,7 +72,8 @@ public class GenericAllocationRow extends AllocationRow { result.criterions = resourceAllocation.getCriterions(); result.resources = resourceDAO.findSatisfyingAllCriterionsAtSomePoint(result.criterions); - result.setName(Criterion.getCaptionFor(result.criterions)); + result.setName(Criterion + .getCaptionForCriterionsFrom(resourceAllocation)); return result; } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/limiting/allocation/LimitingAllocationRow.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/limiting/allocation/LimitingAllocationRow.java index 0c6b29949..4c2b87f1c 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/limiting/allocation/LimitingAllocationRow.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/limiting/allocation/LimitingAllocationRow.java @@ -138,7 +138,7 @@ public class LimitingAllocationRow { final AllocationType type = getAllocationType(); if (AllocationType.GENERIC_WORKERS.equals(type)) { final GenericResourceAllocation generic = (GenericResourceAllocation) resourceAllocation; - return Criterion.getCaptionFor(generic.getCriterions()); + return Criterion.getCaptionForCriterionsFrom(generic); } if (AllocationType.SPECIFIC.equals(type)) { return formatResources(resourceAllocation.getAssociatedResources());