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.
This commit is contained in:
Susana Montes Pedreira 2010-06-30 18:52:30 +02:00 committed by Javier Moran Rua
parent 7c171c8d28
commit 6b1e19c430

View file

@ -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;
}
}