From 6b1e19c430202b0446a7518dd5e44bd0b095a63d Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Wed, 30 Jun 2010 18:52:30 +0200 Subject: [PATCH] ItEr60S04ValidacionEProbasFuncionaisItEr59S04 : Fixing bug in CostCategory Service. it adds the checkConstraintNonRepeatedHourCostCodes() method to check if there are repeated codes in the set of hours cost of a same CostCategory. --- .../business/costcategories/entities/CostCategory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/costcategories/entities/CostCategory.java b/navalplanner-business/src/main/java/org/navalplanner/business/costcategories/entities/CostCategory.java index ef57c726b..3ff7bef34 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/costcategories/entities/CostCategory.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/costcategories/entities/CostCategory.java @@ -27,6 +27,7 @@ import java.util.Set; import org.apache.commons.lang.StringUtils; import org.hibernate.validator.AssertFalse; +import org.hibernate.validator.AssertTrue; import org.hibernate.validator.NotEmpty; import org.hibernate.validator.Valid; import org.joda.time.LocalDate; @@ -204,4 +205,9 @@ public class CostCategory extends IntegrationEntity { return Registry.getCostCategoryDAO(); } + @AssertTrue(message = "The hour cost codes must be unique.") + public boolean checkConstraintNonRepeatedHourCostCodes() { + return getFirstRepeatedCode(this.hourCosts) == null; + } + }