diff --git a/ganttzk/pom.xml b/ganttzk/pom.xml
index e7503dd20..cbdb8e63b 100644
--- a/ganttzk/pom.xml
+++ b/ganttzk/pom.xml
@@ -113,11 +113,11 @@
commons-lang
commons-lang
-
-
- commons-collections
- commons-collections
-
+
+ commons-collections
+ commons-collections
+
+
org.zkoss.zk
diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/timetracker/zoom/TimeTrackerState.java b/ganttzk/src/main/java/org/zkoss/ganttz/timetracker/zoom/TimeTrackerState.java
index 36f3106c1..7a5fb8765 100644
--- a/ganttzk/src/main/java/org/zkoss/ganttz/timetracker/zoom/TimeTrackerState.java
+++ b/ganttzk/src/main/java/org/zkoss/ganttz/timetracker/zoom/TimeTrackerState.java
@@ -21,9 +21,12 @@
package org.zkoss.ganttz.timetracker.zoom;
+import static java.util.Arrays.asList;
+
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -266,20 +269,15 @@ public abstract class TimeTrackerState {
protected abstract Period getMinimumPeriod();
- private Interval calculateIntervalWithMinimum(Interval interval) {
- Period minimumPeriod = getMinimumPeriod();
- BaseSingleFieldPeriod intervalAsPeriod = minimumPeriod
- .asPeriod(interval);
- if (intervalAsPeriod.compareTo(minimumPeriod.toPeriod()) >= 0) {
- return interval;
- }
- LocalDate newEnd = new LocalDate(interval.getStart())
- .plus(minimumPeriod.toPeriod());
- return new Interval(interval.getStart(), newEnd);
+ private Interval ensureMinimumInterval(Interval interval) {
+ LocalDate newEnd = interval.getStart().plus(
+ getMinimumPeriod().toPeriod());
+ return new Interval(interval.getStart(), Collections.max(asList(newEnd,
+ interval.getFinish())));
}
public Interval getRealIntervalFor(Interval testInterval) {
- return calculateForAtLeastMinimum(calculateIntervalWithMinimum(testInterval));
+ return calculateForAtLeastMinimum(ensureMinimumInterval(testInterval));
}
private Interval calculateForAtLeastMinimum(Interval atLeastMinimum) {
diff --git a/libreplan-business/pom.xml b/libreplan-business/pom.xml
index 29e6196d6..1080622c9 100644
--- a/libreplan-business/pom.xml
+++ b/libreplan-business/pom.xml
@@ -30,24 +30,29 @@
org.hibernate
hibernate-annotations
+
+ org.hibernate
+ hibernate-ehcache
+
org.hibernate
hibernate-validator
- joda-time
- joda-time-hibernate
+ org.jadira.usertype
+ usertype.core
${jdbcDriver.groupId}
${jdbcDriver.artifactId}
+ test
- org.apache.geronimo.specs
- geronimo-jta_1.0.1B_spec
+ org.jboss.spec.javax.transaction
+ jboss-transaction-api_1.1_spec
@@ -55,18 +60,11 @@
org.springframework
spring-context-support
-
- org.aspectj
- aspectjrt
-
+
org.aspectj
aspectjweaver
-
- javassist
- javassist
-
@@ -102,19 +100,11 @@
jdk15
-
- commons-lang
- commons-lang
-
commons-math
commons-math
-
- commons-logging
- commons-logging
-
org.slf4j
slf4j-log4j12
@@ -129,10 +119,6 @@
org.dbunit
dbunit
-
- net.sf.ehcache
- ehcache
-
org.liquibase
liquibase-core
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignment.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignment.java
index a4d3e21be..5e26122d4 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignment.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignment.java
@@ -21,7 +21,7 @@
package org.libreplan.business.advance.entities;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.NotNull;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.orders.entities.OrderLineGroup;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignmentTemplate.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignmentTemplate.java
index 41423ac46..983c7c971 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignmentTemplate.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceAssignmentTemplate.java
@@ -23,7 +23,7 @@ package org.libreplan.business.advance.entities;
import java.math.BigDecimal;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.NotNull;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.templates.entities.OrderElementTemplate;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceMeasurement.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceMeasurement.java
index ae25d27e3..00afe9d8f 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceMeasurement.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceMeasurement.java
@@ -26,9 +26,9 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotNull;
-import org.hibernate.validator.Valid;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.NotNull;
+import javax.validation.Valid;
import org.joda.time.LocalDate;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.orders.entities.OrderElement;
@@ -153,7 +153,7 @@ public class AdvanceMeasurement extends BaseEntity {
}
@AssertTrue(message = "The current value must be less than the max value.")
- public boolean checkConstraintValueIsLessThanMaxValue() {
+ public boolean isValueIsLessThanMaxValueConstraint() {
if ((this.value == null) || (this.advanceAssignment == null)){
return true;
}
@@ -167,7 +167,7 @@ public class AdvanceMeasurement extends BaseEntity {
}
@AssertTrue(message = "The current value must be less than the max value.")
- public boolean checkConstraintValidPrecision() {
+ public boolean isValidPrecisionConstraint() {
if ((this.value == null) || (this.advanceAssignment == null)
|| (this.advanceAssignment.getAdvanceType() == null)) {
return true;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceType.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceType.java
index bbbb320c9..54cb5cb31 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceType.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/AdvanceType.java
@@ -27,9 +27,9 @@ import java.math.BigDecimal;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.AssertTrue;
+import org.hibernate.validator.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
import org.libreplan.business.advance.daos.IAdvanceTypeDAO;
import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.common.IHumanIdentifiable;
@@ -219,7 +219,7 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
}
@AssertTrue(message = "progress type marked as quality form but is updatable")
- public boolean checkConstraintIfIsQualityFormIsNotUpdatable() {
+ public boolean isIfIsQualityFormIsNotUpdatableConstraint() {
if (isQualityForm()) {
if (isUpdatable()) {
return false;
@@ -229,7 +229,7 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
}
@AssertTrue(message = "default maximum value of percentage progress type must be 100")
- public boolean checkConstraintDefaultMaxValueMustBe100ForPercentage() {
+ public boolean isDefaultMaxValueMustBe100ForPercentageConstraint() {
if (percentage) {
if (defaultMaxValue.compareTo(new BigDecimal(100)) != 0) {
return false;
@@ -244,7 +244,7 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
}
@AssertTrue(message = "progress type name is already in use")
- public boolean checkConstraintUniqueName() {
+ public boolean isUniqueNameConstraint() {
if (StringUtils.isBlank(unitName)) {
return true;
}
@@ -266,7 +266,7 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
}
@AssertTrue(message = "default maximum value must be greater than precision value")
- public boolean checkDefaultMaxValueGreaterThanPrecision() {
+ public boolean isDefaultMaxValueGreaterThanPrecisionConstraint() {
if (defaultMaxValue.compareTo(unitPrecision) == -1) {
return false;
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/DirectAdvanceAssignment.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/DirectAdvanceAssignment.java
index b44c06c30..41eb4cd44 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/DirectAdvanceAssignment.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/DirectAdvanceAssignment.java
@@ -30,9 +30,9 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotNull;
-import org.hibernate.validator.Valid;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.NotNull;
+import javax.validation.Valid;
import org.joda.time.LocalDate;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.planner.entities.consolidations.NonCalculatedConsolidation;
@@ -193,7 +193,7 @@ public class DirectAdvanceAssignment extends AdvanceAssignment {
}
@AssertTrue(message = "Progress measurements must have a value lower than their following progress measurements.")
- public boolean checkConstraintValidAdvanceMeasurements() {
+ public boolean isValidAdvanceMeasurementsConstraint() {
if (advanceMeasurements.isEmpty()) {
return true;
}
@@ -224,7 +224,7 @@ public class DirectAdvanceAssignment extends AdvanceAssignment {
}
@AssertTrue(message = "maxixum value of percentage progress type must be 100")
- public boolean checkConstraintMaxValueMustBe100ForPercentage() {
+ public boolean isMaxValueMustBe100ForPercentageConstraint() {
AdvanceType advanceType = getAdvanceType();
if ((advanceType != null) && (advanceType.getPercentage())) {
if (maxValue.compareTo(new BigDecimal(100)) != 0) {
@@ -235,7 +235,7 @@ public class DirectAdvanceAssignment extends AdvanceAssignment {
}
@AssertTrue(message = "maximum value must be greater than zero")
- public boolean checkConstraintMaxValueMustBeGreaterThanZero() {
+ public boolean isMaxValueMustBeGreaterThanZeroConstraint() {
return maxValue.compareTo(BigDecimal.ZERO) > 0;
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/IndirectAdvanceAssignment.java b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/IndirectAdvanceAssignment.java
index d064a297b..ddaec5b5d 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/advance/entities/IndirectAdvanceAssignment.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/advance/entities/IndirectAdvanceAssignment.java
@@ -24,7 +24,7 @@ package org.libreplan.business.advance.entities;
import java.util.HashSet;
import java.util.Set;
-import org.hibernate.validator.Valid;
+import javax.validation.Valid;
import org.libreplan.business.orders.entities.OrderLineGroup;
import org.libreplan.business.planner.entities.consolidations.CalculatedConsolidation;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/daos/BaseCalendarDAO.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/daos/BaseCalendarDAO.java
index 33bb44b7c..93f0458b1 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/daos/BaseCalendarDAO.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/daos/BaseCalendarDAO.java
@@ -154,7 +154,7 @@ public class BaseCalendarDAO extends IntegrationEntityDAO
.add(Restrictions.eq("calendarData.parent", calendar)).list();
if (!calendars.isEmpty()) {
throw ValidationException
- .invalidValue(
+ .invalidValueException(
"Cannot delete calendar. It is being used at this moment by some resources.",
calendar);
}
@@ -165,7 +165,7 @@ public class BaseCalendarDAO extends IntegrationEntityDAO
.add(Restrictions.eq("calendar", calendar)).list();
if (!orders.isEmpty()) {
throw ValidationException
- .invalidValue(
+ .invalidValueException(
"Cannot delete calendar. It is being used at this moment by some orders.",
calendar);
}
@@ -176,7 +176,7 @@ public class BaseCalendarDAO extends IntegrationEntityDAO
.add(Restrictions.eq("calendar", calendar)).list();
if (!tasks.isEmpty()) {
throw ValidationException
- .invalidValue(
+ .invalidValueException(
"Cannot delete calendar. It is being used at this moment by some tasks.",
calendar);
}
@@ -187,7 +187,7 @@ public class BaseCalendarDAO extends IntegrationEntityDAO
.add(Restrictions.eq("calendar", calendar)).list();
if (!templates.isEmpty()) {
throw ValidationException
- .invalidValue(
+ .invalidValueException(
"Cannot delete calendar. It is being used at this moment by some templates.",
calendar);
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/BaseCalendar.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/BaseCalendar.java
index 444c531a6..97e39cb96 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/BaseCalendar.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/BaseCalendar.java
@@ -30,10 +30,10 @@ import java.util.Set;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
-import org.hibernate.validator.Valid;
+import javax.validation.constraints.AssertTrue;
+import org.hibernate.validator.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import javax.validation.Valid;
import org.joda.time.LocalDate;
import org.libreplan.business.calendars.daos.IBaseCalendarDAO;
import org.libreplan.business.calendars.entities.AvailabilityTimeLine.IVetoer;
@@ -1104,7 +1104,7 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar,
@SuppressWarnings("unused")
@AssertTrue(message = "dates must be sorted and cannot overlap")
- public boolean checkConstraintDateCouldNotOverlap() {
+ public boolean isDateCouldNotOverlapConstraint() {
if (calendarDataVersions == null || calendarDataVersions.isEmpty()) {
return true;
@@ -1216,7 +1216,7 @@ public class BaseCalendar extends IntegrationEntity implements ICalendar,
}
@AssertTrue(message = "calendars with zero hours are not allowed")
- public boolean checkConstraintZeroHours() {
+ public boolean isZeroHoursConstraint() {
if ((calendarDataVersions != null) && (!calendarDataVersions.isEmpty())) {
for (CalendarData each : calendarDataVersions) {
if (!each.isEmpty()) {
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarAvailability.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarAvailability.java
index a9cf1c403..77fc814a1 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarAvailability.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarAvailability.java
@@ -24,7 +24,7 @@ package org.libreplan.business.calendars.entities;
import java.util.Comparator;
import java.util.Date;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.NotNull;
import org.joda.time.Interval;
import org.joda.time.LocalDate;
import org.libreplan.business.calendars.daos.ICalendarAvailabilityDAO;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarException.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarException.java
index e6e0e6067..a0d06f09f 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarException.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarException.java
@@ -22,7 +22,7 @@
package org.libreplan.business.calendars.entities;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.NotNull;
import org.joda.time.LocalDate;
import org.libreplan.business.calendars.daos.ICalendarExceptionDAO;
import org.libreplan.business.common.IntegrationEntity;
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarExceptionType.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarExceptionType.java
index f7e81bd40..4f4534984 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarExceptionType.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/CalendarExceptionType.java
@@ -29,9 +29,9 @@ import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.hibernate.NonUniqueResultException;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotEmpty;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.AssertTrue;
+import org.hibernate.validator.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
import org.libreplan.business.calendars.daos.ICalendarExceptionTypeDAO;
import org.libreplan.business.common.IHumanIdentifiable;
import org.libreplan.business.common.IntegrationEntity;
@@ -39,7 +39,7 @@ import org.libreplan.business.common.Registry;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.workingday.EffortDuration;
import org.libreplan.business.workingday.EffortDuration.Granularity;
-import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
+import org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException;
/**
* Type of an exception day.
@@ -180,7 +180,7 @@ public class CalendarExceptionType extends IntegrationEntity implements
}
@AssertTrue(message = "name is already used")
- public boolean checkConstraintUniqueName() {
+ public boolean isUniqueNameConstraint() {
if (StringUtils.isBlank(name)) {
return true;
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/ResourceCalendar.java b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/ResourceCalendar.java
index 57b3ad2ae..1090b5011 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/ResourceCalendar.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/calendars/entities/ResourceCalendar.java
@@ -21,8 +21,8 @@
package org.libreplan.business.calendars.entities;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.AssertTrue;
+import javax.validation.constraints.NotNull;
import org.joda.time.LocalDate;
import org.libreplan.business.resources.entities.Resource;
@@ -71,7 +71,7 @@ public class ResourceCalendar extends BaseCalendar {
}
@AssertTrue(message = "Capacity must be a positive integer number")
- public boolean checkCapacityPositiveIntegerNumber() {
+ public boolean isCapacityPositiveIntegerNumberConstraint() {
return (capacity >= 1);
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/BaseEntity.java b/libreplan-business/src/main/java/org/libreplan/business/common/BaseEntity.java
index cf2b3650a..1f011b597 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/common/BaseEntity.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/common/BaseEntity.java
@@ -27,9 +27,13 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.INewObject;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.util.deepcopy.AfterCopy;
@@ -67,6 +71,11 @@ public abstract class BaseEntity implements INewObject {
private static final Log LOG = LogFactory.getLog(BaseEntity.class);
+ private static final ValidatorFactory validatorFactory = Validation
+ .buildDefaultValidatorFactory();
+
+ private static final Validator validator = validatorFactory.getValidator();
+
@OnCopy(Strategy.IGNORE)
private Long id;
@@ -125,10 +134,10 @@ public abstract class BaseEntity implements INewObject {
@SuppressWarnings("unchecked")
public void validate() throws ValidationException {
- LibrePlanClassValidator classValidator = new LibrePlanClassValidator(this.getClass());
- InvalidValue[] invalidValues = classValidator.getInvalidValues(this);
- if (invalidValues.length > 0) {
- throw new ValidationException(invalidValues);
+ Set> violations = validator
+ .validate(this);
+ if (!violations.isEmpty()) {
+ throw new ValidationException(violations);
}
}
diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/IntegrationEntity.java b/libreplan-business/src/main/java/org/libreplan/business/common/IntegrationEntity.java
index 915762aff..6a573170d 100644
--- a/libreplan-business/src/main/java/org/libreplan/business/common/IntegrationEntity.java
+++ b/libreplan-business/src/main/java/org/libreplan/business/common/IntegrationEntity.java
@@ -26,8 +26,8 @@ import java.util.Set;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
-import org.hibernate.validator.AssertTrue;
-import org.hibernate.validator.NotEmpty;
+import javax.validation.constraints.AssertTrue;
+import org.hibernate.validator.constraints.NotEmpty;
import org.libreplan.business.common.daos.IIntegrationEntityDAO;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
@@ -107,7 +107,7 @@ public abstract class IntegrationEntity extends BaseEntity {
* calls on the abstract method getIntegrationEntityDAO().
*/
@AssertTrue(message="code is already used")
- public boolean checkConstraintUniqueCode() {
+ public boolean isUniqueCodeConstraint() {
/* Check if it makes sense to check the constraint .*/
if (!iCodeSpecified()) {
diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/LibrePlanClassValidator.java b/libreplan-business/src/main/java/org/libreplan/business/common/LibrePlanClassValidator.java
deleted file mode 100644
index e8fc3c959..000000000
--- a/libreplan-business/src/main/java/org/libreplan/business/common/LibrePlanClassValidator.java
+++ /dev/null
@@ -1,799 +0,0 @@
-/*
- * This file is part of LibrePlan
- *
- * Copyright (C) 2010-2011 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
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package org.libreplan.business.common;
-
-import java.beans.Introspector;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.AssertionFailure;
-import org.hibernate.Hibernate;
-import org.hibernate.MappingException;
-import org.hibernate.annotations.common.reflection.Filter;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XMember;
-import org.hibernate.annotations.common.reflection.XMethod;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
-import org.hibernate.mapping.Component;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.util.IdentitySet;
-import org.hibernate.validator.InvalidStateException;
-import org.hibernate.validator.InvalidValue;
-import org.hibernate.validator.MessageInterpolator;
-import org.hibernate.validator.PersistentClassConstraint;
-import org.hibernate.validator.PropertyConstraint;
-import org.hibernate.validator.Valid;
-import org.hibernate.validator.Validator;
-import org.hibernate.validator.ValidatorClass;
-import org.hibernate.validator.Version;
-import org.hibernate.validator.interpolator.DefaultMessageInterpolatorAggregator;
-
-
-/**
- * This class is copy-cat of HibernateValidator.ClassValidator
- *
- * Adds extra functionality to cache extra ClassValidators created for validating children elements (see getClassValidator)
- *
- * The function createChildValidator creates ClassValidators for getters and members marked for Validation, but it doesn't create
- * ClassValidators for members that return Collections or ArrayList of entities. These ClassValidators are created later in getClasValidator
- * but are not cached.
- *
- * Original code: http://anonsvn.jboss.org/repos/hibernate/validator/trunk/hibernate-validator-legacy/src/main/java/org/hibernate/validator/ClassValidator.java
- *
- * @author Diego Pino
- */
-public class LibrePlanClassValidator implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static Log log = LogFactory.getLog( LibrePlanClassValidator.class );
- private static final InvalidValue[] EMPTY_INVALID_VALUE_ARRAY = new InvalidValue[]{};
- private static final String DEFAULT_VALIDATOR_MESSAGE = "org.hibernate.validator.resources.DefaultValidatorMessages";
- private static final String VALIDATOR_MESSAGE = "ValidatorMessages";
- private static final Set INDEXABLE_CLASS = new HashSet();
-
- static {
- INDEXABLE_CLASS.add( Integer.class );
- INDEXABLE_CLASS.add( Long.class );
- INDEXABLE_CLASS.add( String.class );
- }
-
- static {
- Version.touch(); //touch version
- }
-
- private final Class beanClass;
- private transient ResourceBundle messageBundle;
- private transient ResourceBundle defaultMessageBundle;
- private transient boolean isUserProvidedResourceBundle;
- private transient ReflectionManager reflectionManager;
-
- private final transient Map childClassValidators;
- private final transient Map extraClassValidators;
- private transient List beanValidators;
- private transient List memberValidators;
- private transient List memberGetters;
- private transient List childGetters;
- private transient DefaultMessageInterpolatorAggregator defaultInterpolator;
- private transient MessageInterpolator userInterpolator;
- private static final Filter GET_ALL_FILTER = new Filter() {
- public boolean returnStatic() {
- return true;
- }
-
- public boolean returnTransient() {
- return true;
- }
- };
-
- /**
- * create the validator engine for this bean type
- */
- public LibrePlanClassValidator(Class beanClass) {
- this( beanClass, (ResourceBundle) null );
- }
-
- /**
- * create the validator engine for a particular bean class, using a resource bundle
- * for message rendering on violation
- */
- public LibrePlanClassValidator(Class beanClass, ResourceBundle resourceBundle) {
- this( beanClass, resourceBundle, null, new HashMap(), null );
- }
-
- /**
- * create the validator engine for a particular bean class, using a custom message interpolator
- * for message rendering on violation
- */
- public LibrePlanClassValidator(Class beanClass, MessageInterpolator interpolator) {
- this( beanClass, null, interpolator, new HashMap(), null );
- }
-
- /**
- * Not a public API
- */
- public LibrePlanClassValidator(
- Class beanClass, ResourceBundle resourceBundle, MessageInterpolator interpolator,
- Map childClassValidators, ReflectionManager reflectionManager
- ) {
- this.reflectionManager = reflectionManager != null ? reflectionManager : new JavaReflectionManager();
- XClass beanXClass = this.reflectionManager.toXClass( beanClass );
- this.beanClass = beanClass;
- this.messageBundle = resourceBundle == null ?
- getDefaultResourceBundle() :
- resourceBundle;
- this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
- this.userInterpolator = interpolator;
- this.childClassValidators = childClassValidators != null ?
- childClassValidators :
- new HashMap();
- this.extraClassValidators = new HashMap();
- initValidator( beanXClass, this.childClassValidators );
- }
-
- @SuppressWarnings("unchecked")
- protected LibrePlanClassValidator(
- XClass beanXClass, ResourceBundle resourceBundle, MessageInterpolator userInterpolator,
- Map childClassValidators, ReflectionManager reflectionManager
- ) {
- this.reflectionManager = reflectionManager;
- this.beanClass = reflectionManager.toClass( beanXClass );
- this.messageBundle = resourceBundle == null ?
- getDefaultResourceBundle() :
- resourceBundle;
- this.defaultMessageBundle = ResourceBundle.getBundle( DEFAULT_VALIDATOR_MESSAGE );
- this.userInterpolator = userInterpolator;
- this.childClassValidators = childClassValidators;
- this.extraClassValidators = new HashMap();
- initValidator( beanXClass, childClassValidators );
- }
-
- private ResourceBundle getDefaultResourceBundle() {
- ResourceBundle rb;
- try {
- //use context class loader as a first citizen
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- if ( contextClassLoader == null ) {
- throw new MissingResourceException( "No context classloader", null, VALIDATOR_MESSAGE );
- }
- rb = ResourceBundle.getBundle(
- VALIDATOR_MESSAGE,
- Locale.getDefault(),
- contextClassLoader
- );
- }
- catch (MissingResourceException e) {
- log.trace( "ResourceBundle " + VALIDATOR_MESSAGE + " not found in thread context classloader" );
- //then use the Validator Framework classloader
- try {
- rb = ResourceBundle.getBundle(
- VALIDATOR_MESSAGE,
- Locale.getDefault(),
- this.getClass().getClassLoader()
- );
- }
- catch (MissingResourceException ee) {
- log.debug(
- "ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to " + DEFAULT_VALIDATOR_MESSAGE
- );
- //the user did not override the default ValidatorMessages
- rb = null;
- }
- }
- isUserProvidedResourceBundle = true;
- return rb;
- }
-
- private void initValidator(
- XClass xClass, Map childClassValidators
- ) {
- beanValidators = new ArrayList();
- memberValidators = new ArrayList();
- memberGetters = new ArrayList();
- childGetters = new ArrayList();
- defaultInterpolator = new DefaultMessageInterpolatorAggregator();
- defaultInterpolator.initialize( messageBundle, defaultMessageBundle );
-
- //build the class hierarchy to look for members in
- childClassValidators.put( xClass, this );
- Collection classes = new HashSet();
- addSuperClassesAndInterfaces( xClass, classes );
- for ( XClass currentClass : classes ) {
- Annotation[] classAnnotations = currentClass.getAnnotations();
- for ( int i = 0; i < classAnnotations.length ; i++ ) {
- Annotation classAnnotation = classAnnotations[i];
- Validator beanValidator = createValidator( classAnnotation );
- if ( beanValidator != null ) beanValidators.add( beanValidator );
- handleAggregateAnnotations(classAnnotation, null);
- }
- }
-
- //Check on all selected classes
- for ( XClass currClass : classes ) {
- List methods = currClass.getDeclaredMethods();
- for ( XMethod method : methods ) {
- createMemberValidator( method );
- createChildValidator( method );
- }
-
- List fields = currClass.getDeclaredProperties(
- "field", GET_ALL_FILTER
- );
- for ( XProperty field : fields ) {
- createMemberValidator( field );
- createChildValidator( field );
- }
- }
- }
-
- private void addSuperClassesAndInterfaces(XClass clazz, Collection classes) {
- for ( XClass currClass = clazz; currClass != null ; currClass = currClass.getSuperclass() ) {
- if ( ! classes.add( currClass ) ) return;
- XClass[] interfaces = currClass.getInterfaces();
- for ( XClass interf : interfaces ) {
- addSuperClassesAndInterfaces( interf, classes );
- }
- }
- }
-
- private boolean handleAggregateAnnotations(Annotation annotation, XMember member) {
- Object[] values;
- try {
- Method valueMethod = annotation.getClass().getMethod( "value" );
- if ( valueMethod.getReturnType().isArray() ) {
- values = (Object[]) valueMethod.invoke( annotation );
- }
- else {
- return false;
- }
- }
- catch (NoSuchMethodException e) {
- return false;
- }
- catch (Exception e) {
- throw new IllegalStateException( e );
- }
-
- boolean validatorPresent = false;
- for ( Object value : values ) {
- if ( value instanceof Annotation ) {
- annotation = (Annotation) value;
- Validator validator = createValidator( annotation );
- if ( validator != null ) {
- if ( member != null ) {
- //member
- memberValidators.add( validator );
- setAccessible( member );
- memberGetters.add( member );
- }
- else {
- //bean
- beanValidators.add( validator );
- }
- validatorPresent = true;
- }
- }
- }
- return validatorPresent;
- }
-
- @SuppressWarnings("unchecked")
- private void createChildValidator( XMember member) {
- if ( member.isAnnotationPresent( Valid.class ) ) {
- setAccessible( member );
- childGetters.add( member );
- XClass clazz;
- if ( member.isCollection() || member.isArray() ) {
- clazz = member.getElementClass();
- }
- else {
- clazz = member.getType();
- }
- if ( !childClassValidators.containsKey( clazz ) ) {
- //ClassValidator added by side effect (added to childClassValidators during CV construction)
- new LibrePlanClassValidator( clazz, messageBundle, userInterpolator, childClassValidators, reflectionManager );
- }
- }
- }
-
- private void createMemberValidator(XMember member) {
- boolean validatorPresent = false;
- Annotation[] memberAnnotations = member.getAnnotations();
- for ( Annotation methodAnnotation : memberAnnotations ) {
- Validator propertyValidator = createValidator( methodAnnotation );
- if ( propertyValidator != null ) {
- memberValidators.add( propertyValidator );
- setAccessible( member );
- memberGetters.add( member );
- validatorPresent = true;
- }
- boolean agrValidPresent = handleAggregateAnnotations( methodAnnotation, member );
- validatorPresent = validatorPresent || agrValidPresent;
- }
- if ( validatorPresent && !member.isTypeResolved() ) {
- log.warn( "Original type of property " + member + " is unbound and has been approximated." );
- }
- }
-
- private static void setAccessible(XMember member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- member.setAccessible( true );
- }
- }
-
- @SuppressWarnings("unchecked")
- private Validator createValidator(Annotation annotation) {
- try {
- ValidatorClass validatorClass = annotation.annotationType().getAnnotation( ValidatorClass.class );
- if ( validatorClass == null ) {
- return null;
- }
- Validator beanValidator = validatorClass.value().newInstance();
- beanValidator.initialize( annotation );
- defaultInterpolator.addInterpolator( annotation, beanValidator );
- return beanValidator;
- }
- catch (Exception e) {
- throw new IllegalArgumentException( "could not instantiate LibrePlanClassValidator", e );
- }
- }
-
- public boolean hasValidationRules() {
- return beanValidators.size() != 0 || memberValidators.size() != 0;
- }
-
- /**
- * apply constraints on a bean instance and return all the failures.
- * if bean is null, an empty array is returned
- */
- public InvalidValue[] getInvalidValues(T bean) {
- return this.getInvalidValues( bean, new IdentitySet() );
- }
-
- /**
- * apply constraints on a bean instance and return all the failures.
- * if bean is null, an empty array is returned
- */
- @SuppressWarnings("unchecked")
- protected InvalidValue[] getInvalidValues(T bean, Set
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
index d66751bc9..d0a09f150 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Configuration.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Connector.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Connector.hbm.xml
index 9ee20be34..a67d8046c 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Connector.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Connector.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/EntitySequence.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/EntitySequence.hbm.xml
index 6b47f4b12..d191d7939 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/EntitySequence.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/EntitySequence.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/JobSchedulerConfiguration.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/JobSchedulerConfiguration.hbm.xml
index 822636ef6..5dc7f41b2 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/JobSchedulerConfiguration.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/JobSchedulerConfiguration.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/costcategories/entities/CostCategories.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/costcategories/entities/CostCategories.hbm.xml
index 9626274cb..29158c774 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/costcategories/entities/CostCategories.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/costcategories/entities/CostCategories.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -38,11 +38,9 @@
-
+
-
+
@@ -88,11 +86,9 @@
-
+
-
+
-
+
@@ -17,8 +17,7 @@
-
+
@@ -47,11 +46,9 @@
-
+
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/externalcompanies/entities/ExternalCompanies.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/externalcompanies/entities/ExternalCompanies.hbm.xml
index 618413ca8..eadfb94fb 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/externalcompanies/entities/ExternalCompanies.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/externalcompanies/entities/ExternalCompanies.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/labels/entities/Labels.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/labels/entities/Labels.hbm.xml
index 3936baba4..d21418b8e 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/labels/entities/Labels.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/labels/entities/Labels.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/materials/entities/Materials.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/materials/entities/Materials.hbm.xml
index bb11141c9..6db254935 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/materials/entities/Materials.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/materials/entities/Materials.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
index 6e45c0c11..5d1172ce4 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml
index 4daa5ec54..60f52479c 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -11,12 +11,12 @@
-
+
-
+
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/ResourceAllocations.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/ResourceAllocations.hbm.xml
index c7419c0d4..dfc29c267 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/ResourceAllocations.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/ResourceAllocations.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -99,15 +99,15 @@
-
+
+
-
+
+
@@ -134,15 +134,15 @@
-
+
+
-
+
+
@@ -194,12 +194,12 @@
-
+
-
+
@@ -273,7 +273,7 @@
-
+
@@ -307,7 +307,7 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorCommunication.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorCommunication.hbm.xml
index 8ae7336de..33662e79c 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorCommunication.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorCommunication.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/Tasks.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/Tasks.hbm.xml
index a370b9024..2b57a4c16 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/Tasks.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/Tasks.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -13,18 +13,18 @@
-
+
+
-
+
+
-
+
-
+
+
@@ -127,8 +127,8 @@
-
+
+
@@ -175,8 +175,8 @@
cascade="all"
name="queueDependency"
column="queue_dependency"
- unique="false"
- />
+ unique="false" />
+
org.libreplan.business.planner.entities.Dependency$Type
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/qualityforms/entities/QualityForms.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/qualityforms/entities/QualityForms.hbm.xml
index ad6c66d8b..cb94285cb 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/qualityforms/entities/QualityForms.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/qualityforms/entities/QualityForms.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/requirements/entities/Requirements.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/requirements/entities/Requirements.hbm.xml
index 085d4a98a..1908c54e7 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/requirements/entities/Requirements.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/requirements/entities/Requirements.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -18,16 +18,16 @@
+ index="idx_criterion_requirement_on_hours_group" />
+
+ index="idx_criterion_requirement_on_order_element" />
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/resources/entities/Resources.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/resources/entities/Resources.hbm.xml
index f701410f1..85eb2b513 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/resources/entities/Resources.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/resources/entities/Resources.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -155,10 +155,10 @@
-
-
+
+
+
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/scenarios/entities/Scenarios.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/scenarios/entities/Scenarios.hbm.xml
index 79a1d61c3..efe317a4e 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/scenarios/entities/Scenarios.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/scenarios/entities/Scenarios.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -15,7 +15,6 @@
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/templates/entities/Templates.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/templates/entities/Templates.hbm.xml
index f64091ca5..16025d827 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/templates/entities/Templates.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/templates/entities/Templates.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/users/entities/Users.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/users/entities/Users.hbm.xml
index 0fd927182..9393b945f 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/users/entities/Users.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/users/entities/Users.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/main/resources/org/libreplan/business/workreports/entities/WorkReports.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/workreports/entities/WorkReports.hbm.xml
index 6ff0c4a85..72cdd1b13 100644
--- a/libreplan-business/src/main/resources/org/libreplan/business/workreports/entities/WorkReports.hbm.xml
+++ b/libreplan-business/src/main/resources/org/libreplan/business/workreports/entities/WorkReports.hbm.xml
@@ -1,5 +1,5 @@
-
+
@@ -121,10 +121,13 @@
-
-
+
+
+
orderElementValidator =
- new ClassValidator(OrderElement.class);
+ private Validator orderElementValidator = Validation
+ .buildDefaultValidatorFactory().getValidator();
private static OrderLine givenOrderLine(String name, String code,
Integer hours) {
@@ -255,15 +255,10 @@ public class OrderElementTest {
public void checkValidPropagation()throws ValidationException{
OrderElement orderElement = givenOrderLineGroupWithTwoOrderLines(1000,
2000);
- try {
- InvalidValue[] invalidValues =
- orderElementValidator.getInvalidValues(orderElement);
- if (invalidValues.length > 0) {
- throw new ValidationException(invalidValues);
- }
- } catch (ValidationException e) {
- fail("It not should throw an exception");
- }
+ Set> invalidValues = orderElementValidator
+ .validate(orderElement);
+ assertTrue(invalidValues.isEmpty());
+
CriterionType type = CriterionType.create("", "");
type.setResource(ResourceEnum.WORKER);
Criterion criterion = Criterion.create(type);
@@ -271,15 +266,9 @@ public class OrderElementTest {
.create(criterion);
requirement.setOrderElement(orderElement);
orderElement.addDirectCriterionRequirement(requirement);
- try {
- InvalidValue[] invalidValues =
- orderElementValidator.getInvalidValues(orderElement);
- if (invalidValues.length > 0) {
- throw new ValidationException(invalidValues);
- }
- } catch (ValidationException e) {
- fail("It no should throw an exception");
- }
+
+ invalidValues = orderElementValidator.validate(orderElement);
+ assertTrue(invalidValues.isEmpty());
}
@Test
diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/StretchesFunctionTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/StretchesFunctionTest.java
index 5d6fa2bac..eef6adcaa 100644
--- a/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/StretchesFunctionTest.java
+++ b/libreplan-business/src/test/java/org/libreplan/business/test/planner/entities/StretchesFunctionTest.java
@@ -102,40 +102,40 @@ public class StretchesFunctionTest {
@Test
public void stretchesFunctionCheckNoEmpty1() {
givenStretchesFunction();
- assertFalse(stretchesFunction.checkNoEmpty());
+ assertFalse(stretchesFunction.isNoEmptyConstraint());
}
@Test
public void stretchesFunctionCheckNoEmpty2() {
givenStretchesFunction();
givenStretchAsChild();
- assertTrue(stretchesFunction.checkNoEmpty());
+ assertTrue(stretchesFunction.isNoEmptyConstraint());
}
@Test
public void stretchesFunctionCheckOneHundredPercent1() {
givenStretchesFunction();
- assertTrue(stretchesFunction.checkOneHundredPercent());
+ assertTrue(stretchesFunction.isOneHundredPercentConstraint());
}
@Test
public void stretchesFunctionCheckOneHundredPercent2() {
givenStretchesFunction();
givenStretchAsChild();
- assertTrue(stretchesFunction.checkOneHundredPercent());
+ assertTrue(stretchesFunction.isOneHundredPercentConstraint());
}
@Test
public void stretchesFunctionCheckStretchesOrder1() {
givenStretchesFunction();
- assertTrue(stretchesFunction.checkStretchesOrder());
+ assertTrue(stretchesFunction.isStretchesOrderConstraint());
}
@Test
public void stretchesFunctionCheckStretchesOrder2() {
givenStretchesFunction();
givenStretchAsChild();
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
@@ -143,7 +143,7 @@ public class StretchesFunctionTest {
givenStretchesFunction();
givenStretchAsChild();
givenStretchAsChild();
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
@@ -151,7 +151,7 @@ public class StretchesFunctionTest {
givenStretchesFunction();
givenStretchAsChild();
givenStretchAsChild(BigDecimal.ONE, BigDecimal.ONE);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
@@ -159,7 +159,7 @@ public class StretchesFunctionTest {
givenStretchesFunction();
givenStretchAsChild();
givenStretchAsChild(BigDecimal.ZERO, BigDecimal.ZERO);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
@@ -167,7 +167,7 @@ public class StretchesFunctionTest {
givenStretchesFunction();
givenStretchAsChild();
givenStretchAsChild(BigDecimal.ONE, BigDecimal.ONE);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
@@ -175,21 +175,21 @@ public class StretchesFunctionTest {
givenStretchesFunction();
givenStretchAsChild();
givenStretchAsChild(BigDecimal.ONE, BigDecimal.ONE);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
public void stretchesFunctionCheckStretchesOrder8() {
givenStretchesFunction();
givenStretchAsChild(BigDecimal.ONE, BigDecimal.ONE);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
public void stretchesFunctionCheckStretchesOrder9() {
givenStretchesFunction();
givenStretchAsChild(BigDecimal.ZERO, BigDecimal.ZERO);
- assertFalse(stretchesFunction.checkStretchesOrder());
+ assertFalse(stretchesFunction.isStretchesOrderConstraint());
}
@Test
diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionDAOTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionDAOTest.java
index 0fb79e63b..0f1549266 100644
--- a/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionDAOTest.java
+++ b/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionDAOTest.java
@@ -47,6 +47,7 @@ import org.libreplan.business.resources.entities.ICriterionType;
import org.libreplan.business.resources.entities.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.test.annotation.NotTransactional;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -103,7 +104,7 @@ public class CriterionDAOTest {
}
- @Test(expected = DataIntegrityViolationException.class)
+ @Test(expected = InvalidDataAccessApiUsageException.class)
public void aCriterionRelatedToATransientTypeCannotBeSaved() {
givenACriterionWithATransientCriterionType();
criterionDAO.save(criterion);
diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionSatisfactionDAOTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionSatisfactionDAOTest.java
index 729a89ed0..aaacf2bd3 100644
--- a/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionSatisfactionDAOTest.java
+++ b/libreplan-business/src/test/java/org/libreplan/business/test/resources/daos/CriterionSatisfactionDAOTest.java
@@ -43,7 +43,7 @@ import org.libreplan.business.resources.entities.CriterionSatisfaction;
import org.libreplan.business.resources.entities.CriterionType;
import org.libreplan.business.resources.entities.Worker;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@@ -109,7 +109,7 @@ public class CriterionSatisfactionDAOTest {
criterion.setType(criterionType);
}
- @Test(expected = DataIntegrityViolationException.class)
+ @Test(expected = InvalidDataAccessApiUsageException.class)
public void testNotSaveWithTransientCriterionAndWorker() {
Criterion criterion = CriterionDAOTest.createValidCriterion();
saveCriterionType(criterion);
diff --git a/libreplan-business/src/test/resources/TestEntities.hbm.xml b/libreplan-business/src/test/resources/TestEntities.hbm.xml
index f4766069b..5358e662d 100644
--- a/libreplan-business/src/test/resources/TestEntities.hbm.xml
+++ b/libreplan-business/src/test/resources/TestEntities.hbm.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml b/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml
index 2591e648f..e1676e312 100644
--- a/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml
+++ b/libreplan-business/src/test/resources/libreplan-business-hibernate-test.cfg.xml
@@ -1,6 +1,6 @@
+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
${hibernate.dialect}
@@ -9,8 +9,18 @@
true
create-drop
+ none
+
+ none
+
+ true
+ jvm
+ jvm
+
- net.sf.ehcache.hibernate.EhCacheProvider
+ org.hibernate.cache.ehcache.EhCacheRegionFactory
false
false
classpath:ehcache.xml
diff --git a/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml b/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml
index a0d0ca70d..c7c2e6073 100644
--- a/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml
+++ b/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml
@@ -21,7 +21,7 @@
diff --git a/libreplan-webapp/pom.xml b/libreplan-webapp/pom.xml
index 6069bcb73..3c5232534 100644
--- a/libreplan-webapp/pom.xml
+++ b/libreplan-webapp/pom.xml
@@ -382,10 +382,26 @@
junit
junit
+
+
+
+ com.jolbox
+ bonecp
+ test
+
+
+
+
+ ${jdbcDriver.groupId}
+ ${jdbcDriver.artifactId}
+ test
+
+
org.springframework
spring-test
+
org.easymock
easymock
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/calendars/BaseCalendarModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/calendars/BaseCalendarModel.java
index 5e6348113..10e861780 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/calendars/BaseCalendarModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/calendars/BaseCalendarModel.java
@@ -21,6 +21,7 @@
package org.libreplan.web.calendars;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.util.Date;
@@ -29,7 +30,6 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.InvalidValue;
import org.joda.time.LocalDate;
import org.libreplan.business.calendars.daos.IBaseCalendarDAO;
import org.libreplan.business.calendars.daos.ICalendarExceptionTypeDAO;
@@ -599,11 +599,9 @@ public class BaseCalendarModel extends IntegrationEntityModel implements
public void checkInvalidValuesCalendar(BaseCalendar entity)
throws ValidationException {
if (baseCalendarDAO.thereIsOtherWithSameName(entity)) {
- InvalidValue[] invalidValues2 = { new InvalidValue(_(
- "{0} already exists", entity.getName()),
- BaseCalendar.class, "name", entity.getName(), entity) };
- throw new ValidationException(invalidValues2,
- _("Could not save the new calendar"));
+ throw new ValidationException(_("Could not save the new calendar"),
+ invalidValue(_("{0} already exists", entity.getName()),
+ "name", entity.getName(), entity));
}
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
index c6b0fee6e..4d7bd2cc1 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/ConfigurationModel.java
@@ -556,8 +556,8 @@ public class ConfigurationModel implements IConfigurationModel {
}
public boolean checkFrefixFormat(EntitySequence sequence) {
- return (sequence.checkConstraintWithoutLowBar() && sequence
- .checkConstraintPrefixWithoutWhiteSpaces());
+ return (sequence.isWithoutLowBarConstraint() && sequence
+ .isPrefixWithoutWhiteSpacesConstraint());
}
@Override
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/IMessagesForUser.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/IMessagesForUser.java
index 0b417c34c..07037df7b 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/IMessagesForUser.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/IMessagesForUser.java
@@ -21,8 +21,8 @@
package org.libreplan.web.common;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.zkoss.zk.ui.Component;
/**
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/MessagesForUser.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/MessagesForUser.java
index d85f6f970..0b31b3702 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/common/MessagesForUser.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/MessagesForUser.java
@@ -32,8 +32,8 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.CheckEvent;
import org.zkoss.zk.ui.event.Event;
@@ -227,8 +227,8 @@ public class MessagesForUser extends GenericForwardComposer implements
invalidValue(invalidValue, customLabelCreator);
}
if (!StringUtils.isEmpty(e.getMessage())
- && e.getInvalidValues().length == 0) {
- showMessage(Level.WARNING, e.getMessage());
+ && e.getInvalidValues().isEmpty()) {
+ showMessage(Level.WARNING, e.getMessage());
}
LOG.warn(e.getMessage());
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/costcategories/CostCategoryCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/costcategories/CostCategoryCRUDController.java
index 06b13404c..2fafab387 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/costcategories/CostCategoryCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/costcategories/CostCategoryCRUDController.java
@@ -128,7 +128,7 @@ public class CostCategoryCRUDController extends BaseCRUDController
}
private void showInvalidValues(ValidationException e) {
- Object value = e.getInvalidValue().getBean();
+ Object value = e.getInvalidValue().getRootBean();
if (value instanceof HourCost) {
showInvalidValue((HourCost) value);
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java
index cd7abfe3b..9c7ed2f02 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java
@@ -515,7 +515,8 @@ public class ExpenseSheetCRUDController extends
} else {
String oldCode = line.getCode();
line.setCode(code);
- if (!getExpenseSheet().checkConstraintNonRepeatedExpenseSheetLinesCodes()) {
+ if (!getExpenseSheet()
+ .isNonRepeatedExpenseSheetLinesCodesConstraint()) {
line.setCode(oldCode);
throw new WrongValueException(comp, _("The code must be unique."));
}
@@ -534,7 +535,7 @@ public class ExpenseSheetCRUDController extends
if (code == null || code.isEmpty()) {
throw new WrongValueException(comp,
_("The code cannot be empty and it must be unique."));
- } else if (!getExpenseSheet().checkConstraintUniqueCode()) {
+ } else if (!getExpenseSheet().isUniqueCodeConstraint()) {
throw new WrongValueException(comp,
_("it already exists another expense sheet with the same code."));
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/labels/LabelTypeModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/labels/LabelTypeModel.java
index 2fd00fb4a..39c74fb15 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/labels/LabelTypeModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/labels/LabelTypeModel.java
@@ -21,6 +21,7 @@
package org.libreplan.web.labels;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.util.ArrayList;
@@ -29,12 +30,12 @@ import java.util.List;
import java.util.Set;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.IntegrationEntity;
import org.libreplan.business.common.daos.IConfigurationDAO;
import org.libreplan.business.common.entities.EntityNameEnum;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.labels.daos.ILabelDAO;
import org.libreplan.business.labels.daos.ILabelTypeDAO;
import org.libreplan.business.labels.entities.Label;
@@ -150,9 +151,8 @@ public class LabelTypeModel extends IntegrationEntityModel implements
}
private InvalidValue createInvalidValue(LabelType labelType) {
- return new InvalidValue(_(
- "{0} already exists", labelType.getName()),
- LabelType.class, "name", labelType.getName(), labelType);
+ return invalidValue(_("{0} already exists", labelType.getName()),
+ "name", labelType.getName(), labelType);
}
/**
@@ -172,15 +172,13 @@ public class LabelTypeModel extends IntegrationEntityModel implements
}
}
if (!result.isEmpty()) {
- throw new ValidationException(
- result.toArray(new InvalidValue[result.size()]));
+ throw new ValidationException(result);
}
}
private InvalidValue createInvalidValue(Label label) {
- return new InvalidValue(_(
- "{0} already exists", label.getName()),
- LabelType.class, "name", label.getName(), label);
+ return invalidValue(_("{0} already exists", label.getName()), "name",
+ label.getName(), label);
}
@Override
@@ -265,10 +263,10 @@ public class LabelTypeModel extends IntegrationEntityModel implements
throws ValidationException {
for (Label label : labelType.getLabels()) {
if (name.equals(label.getName())) {
- InvalidValue[] invalidValues = { new InvalidValue(
- _("Already exists other " + "label with the same name"),
- LabelType.class, "name", name, getLabelType()) };
- throw new ValidationException(invalidValues);
+ throw new ValidationException(
+ invalidValue(_("Already exists other "
+ + "label with the same name"), "name", name,
+ getLabelType()));
}
}
}
@@ -276,10 +274,9 @@ public class LabelTypeModel extends IntegrationEntityModel implements
@Override
public void validateNameNotEmpty(String name) throws ValidationException {
if (name.isEmpty()) {
- InvalidValue[] invalidValues = { new InvalidValue(
- _("The name of the label is empty."), LabelType.class,
- "name", "", getLabelType()) };
- throw new ValidationException(invalidValues);
+ throw new ValidationException(invalidValue(
+ _("The name of the label is empty."),
+ "name", "", getLabelType()));
}
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsController.java b/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsController.java
index b892d78b4..440ee15d1 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsController.java
@@ -28,10 +28,11 @@ import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.materials.entities.Material;
import org.libreplan.business.materials.entities.MaterialCategory;
import org.libreplan.business.materials.entities.UnitType;
@@ -321,7 +322,7 @@ public class MaterialsController extends
reloadCategoriesTree(treeitem);
} catch (ValidationException e) {
for (InvalidValue invalidValue : e.getInvalidValues()) {
- Object value = invalidValue.getBean();
+ Object value = invalidValue.getRootBean();
if (value instanceof MaterialCategory) {
MaterialCategory materialCategory = (MaterialCategory) value;
Component comp = findInMaterialCategoryTree(materialCategory);
@@ -404,9 +405,10 @@ public class MaterialsController extends
}
private void showInvalidValues(ValidationException validationException) {
- final InvalidValue[] invalidValues = validationException.getInvalidValues();
+ final Set extends InvalidValue> invalidValues = validationException
+ .getInvalidValues();
for (InvalidValue each: invalidValues) {
- final Object bean = each.getBean();
+ final Object bean = each.getRootBean();
// Errors related with contraints in Material (not null, etc)
if (bean instanceof Material) {
final Material material = (Material) bean;
@@ -417,12 +419,12 @@ public class MaterialsController extends
final MaterialCategory materialCategory = (MaterialCategory) bean;
final Treeitem treeitem = findTreeItemByMaterialCategory(categoriesTree, materialCategory);
if (treeitem != null) {
- if(each.getPropertyName().equals("name")) {
+ if(each.getPropertyPath().equals("name")) {
throw new WrongValueException(
getCategoryTextbox(treeitem),
_(each.getMessage()));
}
- if(each.getPropertyName().equals("code")) {
+ if(each.getPropertyPath().equals("code")) {
throw new WrongValueException(
getCategoryCodeTextbox(treeitem),
_(each.getMessage()));
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsModel.java
index 847ec1c47..1c86ffe07 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/materials/MaterialsModel.java
@@ -21,6 +21,7 @@
package org.libreplan.web.materials;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.util.ArrayList;
@@ -34,7 +35,6 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.IntegrationEntity;
import org.libreplan.business.common.daos.IConfigurationDAO;
import org.libreplan.business.common.entities.EntityNameEnum;
@@ -170,9 +170,9 @@ public class MaterialsModel extends IntegrationEntityModel implements
final MaterialCategory materialCategory = findMaterialCategory(child);
if (materialCategory != null) {
- final InvalidValue invalidValue = new InvalidValue(_("{0} already exists", materialCategory.getName()),
- MaterialCategory.class, "name", materialCategory.getName(), materialCategory);
- throw new ValidationException(invalidValue);
+ throw new ValidationException(invalidValue(
+ _("{0} already exists", materialCategory.getName()),
+ "name", materialCategory.getName(), materialCategory));
}
child.setParent(parent);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementController.java
index 38cf1c540..e457e6fc9 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementController.java
@@ -27,10 +27,10 @@ import java.util.Date;
import java.util.List;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.advance.exceptions.DuplicateAdvanceAssignmentForOrderElementException;
import org.libreplan.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.qualityforms.entities.QualityForm;
import org.libreplan.business.qualityforms.entities.TaskQualityForm;
@@ -515,7 +515,7 @@ public class AssignedTaskQualityFormsToOrderElementController extends
item.setDate((Date) value);
if (((Date) value == null)
- && (!item.checkConstraintIfDateCanBeNull())) {
+ && (!item.isIfDateCanBeNullConstraint())) {
item.setDate(null);
throw new WrongValueException(comp,
_("date not specified"));
@@ -584,7 +584,7 @@ public class AssignedTaskQualityFormsToOrderElementController extends
*/
private void showInvalidValues(ValidationException e) {
for (InvalidValue invalidValue : e.getInvalidValues()) {
- Object value = invalidValue.getBean();
+ Object value = invalidValue.getRootBean();
if (value instanceof TaskQualityForm) {
showInvalidValue(invalidValue, (TaskQualityForm) value);
}
@@ -598,9 +598,9 @@ public class AssignedTaskQualityFormsToOrderElementController extends
Row row = findRowOfTaskQualityForm(assignedTaskQualityForms
.getRows().getChildren(), taskQualityForm);
- if (row != null) {
- String itemName = (String) invalidValue.getValue();
- String propertyName = invalidValue.getPropertyName();
+ if (row != null && invalidValue.getInvalidValue() instanceof String) {
+ String itemName = (String) invalidValue.getInvalidValue();
+ String propertyName = invalidValue.getPropertyPath();
Row rowItem = findRowOfTaskQualityFormItem(row, itemName);
if (rowItem != null) {
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementModel.java
index 3598500b5..77dd23f3c 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/AssignedTaskQualityFormsToOrderElementModel.java
@@ -21,6 +21,7 @@
package org.libreplan.web.orders;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.math.BigDecimal;
@@ -28,7 +29,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.hibernate.validator.InvalidValue;
import org.joda.time.LocalDate;
import org.libreplan.business.advance.daos.IAdvanceTypeDAO;
import org.libreplan.business.advance.entities.AdvanceAssignment;
@@ -262,23 +262,22 @@ public class AssignedTaskQualityFormsToOrderElementModel implements
if ((!taskQualityForm.isByItems())
&& (!taskQualityForm.isCorrectConsecutivePassed(item))) {
- throw new ValidationException(new InvalidValue(
+ throw new ValidationException(
+ invalidValue(
_("cannot be checked until the previous item is checked before"),
- TaskQualityForm.class,
"passed", item.getName(), taskQualityForm));
}
if ((!taskQualityForm.isByItems())
&& (!taskQualityForm.isCorrectConsecutiveDate(item))) {
- throw new ValidationException(new InvalidValue(
+ throw new ValidationException(invalidValue(
_("must be after the previous date"),
- TaskQualityForm.class,
"date", item.getName(), taskQualityForm));
}
- if (!item.checkConstraintIfDateCanBeNull()) {
- throw new ValidationException(new InvalidValue(
- _("date not specified"), TaskQualityForm.class, "date",
+ if (!item.isIfDateCanBeNullConstraint()) {
+ throw new ValidationException(invalidValue(
+ _("date not specified"), "date",
item.getName(), taskQualityForm));
}
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/ManageOrderElementAdvancesModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/ManageOrderElementAdvancesModel.java
index 553864c29..aa7da83c4 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/ManageOrderElementAdvancesModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/ManageOrderElementAdvancesModel.java
@@ -529,7 +529,7 @@ public class ManageOrderElementAdvancesModel implements
public boolean isPrecisionValid(AdvanceMeasurement advanceMeasurement) {
if ((this.advanceAssignment != null)
&& (this.advanceAssignment.getAdvanceType() != null)) {
- return advanceMeasurement.checkConstraintValidPrecision();
+ return advanceMeasurement.isValidPrecisionConstraint();
}
return true;
}
@@ -540,7 +540,7 @@ public class ManageOrderElementAdvancesModel implements
|| this.advanceAssignment.getMaxValue() == null) {
return false;
}
- return !(advanceMeasurement.checkConstraintValueIsLessThanMaxValue());
+ return !(advanceMeasurement.isValueIsLessThanMaxValueConstraint());
}
@Override
@@ -548,8 +548,7 @@ public class ManageOrderElementAdvancesModel implements
if (this.advanceAssignment == null) {
return false;
}
- return !(this.advanceAssignment
- .checkConstraintValidAdvanceMeasurements());
+ return !(this.advanceAssignment.isValidAdvanceMeasurementsConstraint());
}
@Override
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/streches/StretchesFunctionModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/streches/StretchesFunctionModel.java
index 74996b28b..a8285ff3e 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/streches/StretchesFunctionModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/allocation/streches/StretchesFunctionModel.java
@@ -163,16 +163,16 @@ public class StretchesFunctionModel implements IStretchesFunctionModel {
@Override
public void confirm() throws ValidationException {
if (stretchesFunction != null) {
- if (!stretchesFunction.checkNoEmpty()) {
+ if (!stretchesFunction.isNoEmptyConstraint()) {
throw new ValidationException(
_("At least one stretch is needed"));
}
- if (!stretchesFunction.checkStretchesOrder()) {
+ if (!stretchesFunction.isStretchesOrderConstraint()) {
throw new ValidationException(
_("Some stretch has higher or equal values than the "
+ "previous stretch"));
}
- if (!stretchesFunction.checkOneHundredPercent()) {
+ if (!stretchesFunction.isOneHundredPercentConstraint()) {
throw new ValidationException(
_("Last stretch should have 100% for length and amount of work"));
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/SaveCommandBuilder.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/SaveCommandBuilder.java
index 3a10854c0..d97288e35 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/SaveCommandBuilder.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/SaveCommandBuilder.java
@@ -32,7 +32,6 @@ import java.util.SortedSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.joda.time.LocalDate;
import org.libreplan.business.advance.bootstrap.PredefinedAdvancedTypes;
import org.libreplan.business.advance.entities.AdvanceMeasurement;
@@ -48,6 +47,7 @@ import org.libreplan.business.common.daos.IEntitySequenceDAO;
import org.libreplan.business.common.entities.EntityNameEnum;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.orders.daos.IOrderDAO;
import org.libreplan.business.orders.daos.IOrderElementDAO;
import org.libreplan.business.orders.entities.HoursGroup;
@@ -333,7 +333,7 @@ public class SaveCommandBuilder {
.getValue() + "\n";
}
- if (validationException.getInvalidValues().length == 0) {
+ if (validationException.getInvalidValues().isEmpty()) {
message += validationException.getMessage();
}
@@ -1055,23 +1055,24 @@ public class SaveCommandBuilder {
@Override
public org.zkoss.zk.ui.Component createLabelFor(
InvalidValue invalidValue) {
- if (invalidValue.getBean() instanceof OrderElement) {
+ if (invalidValue.getRootBean() instanceof OrderElement) {
Label result = new Label();
String orderElementName;
- if (invalidValue.getBean() instanceof Order) {
+ if (invalidValue.getRootBean() instanceof Order) {
orderElementName = _("Project");
} else {
orderElementName = _("Task {0}",
- ((OrderElement) invalidValue.getBean()).getName());
+ ((OrderElement) invalidValue.getRootBean())
+ .getName());
}
result.setValue(orderElementName + ": "
+ _(invalidValue.getMessage()));
return result;
- } else if (invalidValue.getBean() instanceof HoursGroup) {
+ } else if (invalidValue.getRootBean() instanceof HoursGroup) {
Label result = new Label();
- HoursGroup hoursGroup = (HoursGroup) invalidValue.getBean();
+ HoursGroup hoursGroup = (HoursGroup) invalidValue.getRootBean();
result.setValue(_("Hours Group at {0}",
getParentName(hoursGroup))
+ ": "
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/qualityforms/QualityFormModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/qualityforms/QualityFormModel.java
index 234e3d91e..ea0c81c3c 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/qualityforms/QualityFormModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/qualityforms/QualityFormModel.java
@@ -31,7 +31,6 @@ import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.qualityforms.daos.IQualityFormDAO;
import org.libreplan.business.qualityforms.entities.QualityForm;
import org.libreplan.business.qualityforms.entities.QualityFormItem;
-import org.libreplan.business.users.entities.Profile;
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -156,7 +155,7 @@ public class QualityFormModel implements IQualityFormModel {
@Override
public boolean checkConstraintUniqueQualityFormItemName() {
if (getQualityForm() != null) {
- return getQualityForm().checkConstraintUniqueQualityFormItemsName();
+ return getQualityForm().isUniqueQualityFormItemsNameConstraint();
}
return true;
}
@@ -164,7 +163,7 @@ public class QualityFormModel implements IQualityFormModel {
@Override
public boolean checkConstraintUniqueQualityFormName() {
if (getQualityForm() != null) {
- return getQualityForm().checkConstraintUniqueQualityFormName();
+ return getQualityForm().isUniqueQualityFormNameConstraint();
}
return true;
}
@@ -173,7 +172,7 @@ public class QualityFormModel implements IQualityFormModel {
public boolean checkConstraintOutOfRangeQualityFormItemPercentage(
QualityFormItem item) {
if ((getQualityForm() != null) && (item != null)) {
- return (!item.checkConstraintQualityFormItemPercentage());
+ return (!item.isQualityFormItemPercentageConstraint());
}
return true;
}
@@ -182,7 +181,7 @@ public class QualityFormModel implements IQualityFormModel {
public boolean checkConstraintUniqueQualityFormItemPercentage() {
if (getQualityForm() != null) {
return getQualityForm()
- .checkConstraintDuplicatesQualityFormItemPercentage();
+ .isDuplicatesQualityFormItemPercentageConstraint();
}
return true;
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeController.java
index d1ac860c0..e17f9e698 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeController.java
@@ -27,10 +27,9 @@ import java.util.Iterator;
import java.util.Set;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.costcategories.entities.CostCategory;
-import org.libreplan.business.costcategories.entities.ResourcesCostCategoryAssignment;
import org.libreplan.web.common.IMessagesForUser;
import org.libreplan.web.common.Level;
import org.libreplan.web.common.MessagesForUser;
@@ -45,7 +44,6 @@ import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Checkbox;
import org.zkoss.zul.Comboitem;
-import org.zkoss.zul.Row;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.Treecell;
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeModel.java
index beca8380b..ff81c4889 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/criterion/CriterionTreeModel.java
@@ -26,6 +26,7 @@
package org.libreplan.web.resources.criterion;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.util.ArrayList;
@@ -34,7 +35,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.resources.entities.Criterion;
import org.libreplan.business.resources.entities.CriterionType;
@@ -326,12 +326,10 @@ public class CriterionTreeModel implements ICriterionTreeModel {
throws ValidationException{
for(CriterionDTO criterion : criterions){
if(criterion.getName().equals(name)){
- InvalidValue[] invalidValues = {
- new InvalidValue(_("Already exists another " +
- "criterion with the same name"),
- Criterion.class, "name",
- criterion.getName(), criterion)};
- throw new ValidationException(invalidValues);
+ throw new ValidationException(invalidValue(
+ _("Already exists another "
+ + "criterion with the same name"), "name",
+ criterion.getName(), criterion));
}
thereIsOtherWithSameNameAndType(name,criterion.getChildren());
}
@@ -340,11 +338,9 @@ public class CriterionTreeModel implements ICriterionTreeModel {
public void validateNameNotEmpty(String name)
throws ValidationException{
if(name.isEmpty()){
- InvalidValue[] invalidValues = {
- new InvalidValue(_("Name of criterion is empty."),
- CriterionType.class, "name",
- "",criterionType)};
- throw new ValidationException(invalidValues);
+ throw new ValidationException(
+ invalidValue(_("Name of criterion is empty."), "name",
+ "",criterionType));
}
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineModel.java
index 533834393..3f83b5855 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/machine/MachineModel.java
@@ -32,7 +32,6 @@ import java.util.Set;
import org.apache.commons.lang.Validate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.ClassValidator;
import org.libreplan.business.calendars.daos.IBaseCalendarDAO;
import org.libreplan.business.calendars.entities.BaseCalendar;
import org.libreplan.business.calendars.entities.CalendarData;
@@ -117,9 +116,6 @@ public class MachineModel extends IntegrationEntityModel implements
@Autowired
private IScenarioManager scenarioManager;
- private ClassValidator validator = new ClassValidator(
- Machine.class);
-
private void reattachCriterionsCache() {
for (Criterion each: criterions.values()) {
criterionDAO.reattachUnmodifiedEntity(each);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionSatisfactionDTO.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionSatisfactionDTO.java
index 8a6e6c919..a642f336e 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionSatisfactionDTO.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionSatisfactionDTO.java
@@ -30,7 +30,7 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
-import org.hibernate.validator.NotNull;
+import javax.validation.constraints.NotNull;
import org.joda.time.LocalDate;
import org.libreplan.business.INewObject;
import org.libreplan.business.resources.entities.Criterion;
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsController.java
index 88845d51a..ffdef2a54 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsController.java
@@ -32,8 +32,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.resources.entities.Criterion;
import org.libreplan.business.resources.entities.CriterionSatisfaction;
import org.libreplan.business.resources.entities.CriterionWithItsType;
@@ -310,7 +310,7 @@ public class CriterionsController extends GenericForwardComposer {
*/
private void showInvalidValues(ValidationException e) {
for (InvalidValue invalidValue : e.getInvalidValues()) {
- Object value = invalidValue.getBean();
+ Object value = invalidValue.getRootBean();
if(value instanceof CriterionSatisfactionDTO){
validateCriterionSatisfactionDTO(invalidValue,
(CriterionSatisfactionDTO)value);
@@ -332,7 +332,7 @@ public class CriterionsController extends GenericForwardComposer {
satisfactionDTO);
if (row != null) {
- String propertyName = invalidValue.getPropertyName();
+ String propertyName = invalidValue.getPropertyPath();
if (CriterionSatisfactionDTO.START_DATE.equals(propertyName)) {
// Locate TextboxResource
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsMachineController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsMachineController.java
index 28ccdfeae..bcba58b8f 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsMachineController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/CriterionsMachineController.java
@@ -32,8 +32,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.resources.entities.CriterionSatisfaction;
import org.libreplan.business.resources.entities.CriterionWithItsType;
import org.libreplan.business.resources.entities.Machine;
@@ -315,7 +315,7 @@ public class CriterionsMachineController extends GenericForwardComposer {
*/
private void showInvalidValues(ValidationException e) {
for (InvalidValue invalidValue : e.getInvalidValues()) {
- Object value = invalidValue.getBean();
+ Object value = invalidValue.getRootBean();
if (value instanceof CriterionSatisfactionDTO) {
validateCriterionSatisfactionDTO(invalidValue,
(CriterionSatisfactionDTO) value);
@@ -337,7 +337,7 @@ public class CriterionsMachineController extends GenericForwardComposer {
.getRows(), satisfactionDTO);
if (row != null) {
- String propertyName = invalidValue.getPropertyName();
+ String propertyName = invalidValue.getPropertyPath();
if (CriterionSatisfactionDTO.START_DATE.equals(propertyName)) {
// Locate TextboxResource
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/scenarios/ScenarioModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/scenarios/ScenarioModel.java
index 40454bc9c..a1d21d61d 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/scenarios/ScenarioModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/scenarios/ScenarioModel.java
@@ -21,14 +21,13 @@
package org.libreplan.web.scenarios;
+import static org.libreplan.business.common.exceptions.ValidationException.invalidValue;
import static org.libreplan.web.I18nHelper._;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.Validate;
-import org.hibernate.validator.InvalidValue;
-import org.libreplan.business.calendars.entities.BaseCalendar;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.orders.daos.IOrderDAO;
@@ -217,11 +216,9 @@ public class ScenarioModel implements IScenarioModel {
@Transactional
public void confirmSave() throws ValidationException {
if (scenarioDAO.thereIsOtherWithSameName(scenario)) {
- InvalidValue[] invalidValues = { new InvalidValue(_(
- "{0} already exists", scenario.getName()),
- BaseCalendar.class, "name", scenario.getName(), scenario) };
- throw new ValidationException(invalidValues,
- _("Could not save the scenario"));
+ throw new ValidationException(_("Could not save the scenario"),
+ invalidValue(_("{0} already exists", scenario.getName()),
+ "name", scenario.getName(), scenario));
}
scenarioDAO.save(scenario);
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/templates/OrderTemplatesModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/templates/OrderTemplatesModel.java
index 5c3016be9..4abfb3931 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/templates/OrderTemplatesModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/templates/OrderTemplatesModel.java
@@ -312,7 +312,7 @@ public class OrderTemplatesModel implements IOrderTemplatesModel {
}
getTemplate().setName(name);
- if (!getTemplate().checkConstraintUniqueRootTemplateName()) {
+ if (!getTemplate().isUniqueRootTemplateNameConstraint()) {
throw new IllegalArgumentException(
_("Already exists another template with the same name"));
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/templates/TemplatesTreeController.java b/libreplan-webapp/src/main/java/org/libreplan/web/templates/TemplatesTreeController.java
index 04893ddde..af9fe3082 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/templates/TemplatesTreeController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/templates/TemplatesTreeController.java
@@ -25,7 +25,6 @@ import static org.libreplan.web.I18nHelper._;
import java.math.BigDecimal;
import org.apache.commons.lang.StringUtils;
-import org.hibernate.validator.ClassValidator;
import org.libreplan.business.orders.entities.SchedulingState;
import org.libreplan.business.templates.entities.OrderElementTemplate;
import org.libreplan.business.templates.entities.OrderLineTemplate;
@@ -63,9 +62,6 @@ public class TemplatesTreeController extends
final class TemplatesTreeRenderer extends Renderer {
- private final ClassValidator validator = new ClassValidator(
- OrderElementTemplate.class);
-
@Override
protected void addOperationsCell(Treeitem item,
OrderElementTemplate currentElement) {
@@ -129,7 +125,8 @@ public class TemplatesTreeController extends
@Override
public void set(Integer value) {
- checkInvalidValues(validator, "startAsDaysFromBeginning",
+ checkInvalidValues(OrderElementTemplate.class,
+ "startAsDaysFromBeginning",
value, intbox);
currentElement.setStartAsDaysFromBeginning(value);
}
@@ -149,7 +146,7 @@ public class TemplatesTreeController extends
@Override
public void set(Integer value) {
- checkInvalidValues(validator,
+ checkInvalidValues(OrderElementTemplate.class,
"deadlineAsDaysFromBeginning", value, intbox);
currentElement.setDeadlineAsDaysFromBeginning(value);
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/tree/TreeController.java b/libreplan-webapp/src/main/java/org/libreplan/web/tree/TreeController.java
index dd62d911c..f554ef93b 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/tree/TreeController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/tree/TreeController.java
@@ -32,15 +32,17 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.ClassValidator;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.orders.entities.SchedulingState;
import org.libreplan.business.orders.entities.SchedulingState.ITypeChangedListener;
import org.libreplan.business.orders.entities.SchedulingState.Type;
-import org.libreplan.business.templates.entities.OrderElementTemplate;
import org.libreplan.business.trees.ITreeNode;
import org.libreplan.web.common.IMessagesForUser;
import org.libreplan.web.common.Level;
@@ -77,6 +79,7 @@ import org.zkoss.zul.Treerow;
import org.zkoss.zul.api.Hbox;
import org.zkoss.zul.impl.api.InputElement;
+
/**
* Tree controller for project WBS structures
*
@@ -88,6 +91,11 @@ import org.zkoss.zul.impl.api.InputElement;
public abstract class TreeController> extends
GenericForwardComposer {
+ private static final ValidatorFactory validatorFactory = Validation
+ .buildDefaultValidatorFactory();
+
+ private static final Validator validator = validatorFactory.getValidator();
+
private static final Log LOG = LogFactory.getLog(TreeController.class);
private IMessagesForUser messagesForUser;
@@ -736,14 +744,12 @@ public abstract class TreeController> extends
onDropMoveFromDraggedToTarget();
}
- protected void checkInvalidValues(
- ClassValidator validator,
+ protected void checkInvalidValues(Class> beanType,
String property, Integer value, final Intbox component) {
- InvalidValue[] invalidValues = validator.getPotentialInvalidValues(
- property, value);
- if (invalidValues.length > 0) {
+ Set> violations = validator.validateValue(type, property, value);
+ if (!violations.isEmpty()) {
throw new WrongValueException(component,
- _(invalidValues[0].getMessage()));
+ _(violations.iterator().next().getMessage()));
}
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/util/ValidationExceptionPrinter.java b/libreplan-webapp/src/main/java/org/libreplan/web/util/ValidationExceptionPrinter.java
index cda03d6de..98ee8a329 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/util/ValidationExceptionPrinter.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/util/ValidationExceptionPrinter.java
@@ -21,8 +21,8 @@ package org.libreplan.web.util;
import static org.libreplan.web.I18nHelper._;
-import org.hibernate.validator.InvalidValue;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.zkoss.ganttz.util.ComponentsFinder;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
@@ -53,7 +53,8 @@ public class ValidationExceptionPrinter {
}
private static void showAt(Grid comp, InvalidValue invalidValue) {
- Row row = ComponentsFinder.findRowByValue(comp, invalidValue.getValue());
+ Row row = ComponentsFinder.findRowByValue(comp,
+ invalidValue.getInvalidValue());
if (row != null) {
throw new WrongValueException(row, _(invalidValue.getMessage()));
}
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportCRUDController.java
index 381161b04..68a1f8b38 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportCRUDController.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportCRUDController.java
@@ -32,9 +32,9 @@ import java.util.regex.Pattern;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.validator.InvalidValue;
import org.joda.time.LocalDate;
import org.libreplan.business.common.exceptions.ValidationException;
+import org.libreplan.business.common.exceptions.ValidationException.InvalidValue;
import org.libreplan.business.costcategories.entities.TypeOfWorkHours;
import org.libreplan.business.labels.entities.Label;
import org.libreplan.business.labels.entities.LabelType;
@@ -275,14 +275,14 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
*/
private void showInvalidValues(ValidationException e) {
for (InvalidValue invalidValue : e.getInvalidValues()) {
- Object value = invalidValue.getBean();
+ Object value = invalidValue.getRootBean();
if (value instanceof WorkReport) {
if (validateWorkReport()) {
messagesForUser.showInvalidValues(e);
}
}
if (value instanceof WorkReportLine) {
- WorkReportLine workReportLine = (WorkReportLine) invalidValue.getBean();
+ WorkReportLine workReportLine = (WorkReportLine) invalidValue.getRootBean();
Row row = ComponentsFinder.findRowByValue(listWorkReportLines, workReportLine);
if (row == null) {
messagesForUser.showInvalidValues(e);
@@ -315,21 +315,21 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
private boolean validateWorkReport() {
if (!getWorkReport()
- .checkConstraintDateMustBeNotNullIfIsSharedByLines()) {
+.isDateMustBeNotNullIfIsSharedByLinesConstraint()) {
Datebox datebox = (Datebox) createWindow.getFellowIfAny("date");
showInvalidMessage(datebox, _("cannot be empty"));
return false;
}
if (!getWorkReport()
- .checkConstraintResourceMustBeNotNullIfIsSharedByLines()) {
+ .isResourceMustBeNotNullIfIsSharedByLinesConstraint()) {
showInvalidMessage(autocompleteResource,
_("cannot be empty"));
return false;
}
if (!getWorkReport()
- .checkConstraintOrderElementMustBeNotNullIfIsSharedByLines()) {
+ .isOrderElementMustBeNotNullIfIsSharedByLinesConstraint()) {
showInvalidMessage(bandboxSelectOrderElementInHead,
_("cannot be empty"));
return false;
@@ -395,7 +395,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
}
if (!workReportLine
- .checkConstraintClockStartMustBeNotNullIfIsCalculatedByClock()) {
+ .isClockStartMustBeNotNullIfIsCalculatedByClockConstraint()) {
Timebox timeStart = getTimeboxStart(row);
if (timeStart != null) {
String message = _("cannot be empty");
@@ -405,7 +405,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
}
if (!workReportLine
- .checkConstraintClockFinishMustBeNotNullIfIsCalculatedByClock()) {
+ .isClockFinishMustBeNotNullIfIsCalculatedByClockConstraint()) {
Timebox timeFinish = getTimeboxFinish(row);
if (timeFinish != null) {
String message = _("cannot be empty");
@@ -428,7 +428,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
return false;
}
- if (!workReportLine.checkConstraintHoursCalculatedByClock()) {
+ if (!workReportLine.isHoursCalculatedByClockConstraint()) {
Textbox effort = getEffort(row);
if (effort != null) {
String message = _("effort is not properly calculated based on clock");
@@ -460,7 +460,8 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
return false;
}
- if (!workReportLine.checkConstraintOrderElementFinishedInAnotherWorkReport()) {
+ if (!workReportLine
+ .isOrderElementFinishedInAnotherWorkReportConstraint()) {
Checkbox checkboxFinished = getFinished(row);
if (checkboxFinished != null) {
String message = _("task is already marked as finished in another timesheet");
diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java
index e39981e5a..b8e1dbb71 100644
--- a/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java
+++ b/libreplan-webapp/src/main/java/org/libreplan/web/workreports/WorkReportTypeModel.java
@@ -409,7 +409,7 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
}
getWorkReportType().setName(name);
- if (!getWorkReportType().checkConstraintUniqueWorkReportTypeName()) {
+ if (!getWorkReportType().isUniqueWorkReportTypeNameConstraint()) {
throw new IllegalArgumentException(
_("There is another timesheet template with the same name"));
}
@@ -428,7 +428,7 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
}
getWorkReportType().setCode(code);
- if (!getWorkReportType().checkConstraintUniqueCode()) {
+ if (!getWorkReportType().isUniqueCodeConstraint()) {
throw new IllegalArgumentException(
_("There is another timesheet template with the same code"));
}
@@ -477,8 +477,9 @@ public class WorkReportTypeModel extends IntegrationEntityModel implements
/* Operations to calculated the index position of the fields into workReport */
public boolean validateTheIndexFieldsAndLabels() {
- return ((getWorkReportType().checkConstraintTheIndexHeadingFieldsAndLabelMustBeUniqueAndConsecutive()) && (getWorkReportType()
- .checkConstraintTheIndexLineFieldsAndLabelMustBeUniqueAndConsecutive()));
+ return ((getWorkReportType()
+ .isTheIndexHeadingFieldsAndLabelMustBeUniqueAndConsecutiveConstraint()) && (getWorkReportType()
+ .isTheIndexLineFieldsAndLabelMustBeUniqueAndConsecutiveConstraint()));
}
public List
- org.apache.geronimo.specs
- geronimo-jta_1.0.1B_spec
- 1.1.1
+ org.jboss.spec.javax.transaction
+ jboss-transaction-api_1.1_spec
+ 1.0.1.Final
+ compile
+
+
+ xml-apis
+ xml-apis
+
+
org.springframework
spring-web
- 3.0.7.RELEASE
+ 3.2.8.RELEASE
-
- org.aspectj
- aspectjrt
- 1.6.11
-
org.aspectj
aspectjweaver
- 1.6.11
+ 1.7.4
-
- javassist
- javassist
- 3.4.GA
-
-
-
org.springframework.security
spring-security-web
- 3.0.8.RELEASE
+ 3.2.3.RELEASE
org.springframework.security
spring-security-config
- 3.0.8.RELEASE
+ 3.2.3.RELEASE
org.springframework.security
spring-security-acl
- 3.0.8.RELEASE
+ 3.2.3.RELEASE
org.springframework.security
spring-security-ldap
- 3.0.8.RELEASE
+ 3.2.3.RELEASE
@@ -354,7 +347,7 @@
org.springframework
spring-test
- 3.0.7.RELEASE
+ 3.2.8.RELEASE
test
@@ -379,17 +372,18 @@
2.2.3
jdk15
-
- commons-collections
- commons-collections
- 3.2
-
+
+ commons-collections
+ commons-collections
+ 3.2
+
+
net.sf.ezmorph
ezmorph
1.0.6
-
+
commons-lang
commons-lang
@@ -405,12 +399,17 @@
commons-logging
commons-logging
- 1.0.4
+ 1.1.3
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.7
org.slf4j
slf4j-log4j12
- 1.7.2
+ 1.7.7
@@ -469,7 +468,7 @@
joda-time
joda-time
- 1.6
+ 2.3
@@ -572,11 +571,7 @@
-
- net.sf.ehcache
- ehcache
- 1.6.2
-
+
org.liquibase