ItEr33S08ValidacionEProbasFuncionaisItEr32S09: Not forcing ValidationException because save method already takes care of that
This commit is contained in:
parent
fd3b521f44
commit
c68e1463c0
15 changed files with 15 additions and 203 deletions
|
|
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||
import java.util.Set;
|
||||
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.hibernate.validator.NotNull;
|
||||
|
||||
/**
|
||||
* This class models a worker.
|
||||
|
|
@ -44,6 +45,7 @@ public class Worker extends Resource {
|
|||
return worker;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String firstName;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.hibernate.validator.Valid;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
||||
/**
|
||||
|
|
@ -61,6 +62,7 @@ public class WorkReport extends BaseEntity {
|
|||
|
||||
private WorkReportType workReportType;
|
||||
|
||||
@Valid
|
||||
private Set<WorkReportLine> workReportLines = new HashSet<WorkReportLine>();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,10 +56,9 @@ public class WorkReportLine extends BaseEntity {
|
|||
|
||||
private Integer numHours;
|
||||
|
||||
@NotNull
|
||||
|
||||
private Resource resource;
|
||||
|
||||
@NotNull
|
||||
private OrderElement orderElement;
|
||||
|
||||
private WorkReport workReport;
|
||||
|
|
@ -89,6 +88,7 @@ public class WorkReportLine extends BaseEntity {
|
|||
this.numHours = numHours;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Resource getResource() {
|
||||
return resource;
|
||||
}
|
||||
|
|
@ -97,6 +97,7 @@ public class WorkReportLine extends BaseEntity {
|
|||
this.resource = resource;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OrderElement getOrderElement() {
|
||||
return orderElement;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import static org.junit.Assert.assertTrue;
|
|||
import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
|
||||
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -37,8 +36,6 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.Before;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.IDataBootstrap;
|
||||
|
|
@ -164,12 +161,6 @@ public class TaskElementDAOTest {
|
|||
@Test
|
||||
public void canSaveMilestone() {
|
||||
TaskMilestone milestone = createValidTaskMilestone();
|
||||
ClassValidator<TaskMilestone> validator = new ClassValidator<TaskMilestone>(
|
||||
TaskMilestone.class);
|
||||
InvalidValue[] invalidValues = validator.getInvalidValues(milestone);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new RuntimeException(Arrays.toString(invalidValues));
|
||||
}
|
||||
taskElementDAO.save(milestone);
|
||||
flushAndEvict(milestone);
|
||||
TaskElement fromDB;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ import java.math.BigDecimal;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.advance.daos.IAdvanceTypeDAO;
|
||||
import org.navalplanner.business.advance.entities.AdvanceType;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
|
|
@ -49,9 +47,6 @@ public class AdvanceTypeModel implements IAdvanceTypeModel {
|
|||
|
||||
private AdvanceType advanceType;
|
||||
|
||||
private ClassValidator<AdvanceType> advanceTypeValidator = new ClassValidator<AdvanceType>(
|
||||
AdvanceType.class);
|
||||
|
||||
@Autowired
|
||||
private IAdvanceTypeDAO advanceTypeDAO;
|
||||
|
||||
|
|
@ -104,11 +99,6 @@ public class AdvanceTypeModel implements IAdvanceTypeModel {
|
|||
@Override
|
||||
@Transactional
|
||||
public void save() throws ValidationException {
|
||||
InvalidValue[] invalidValues = advanceTypeValidator
|
||||
.getInvalidValues(advanceType);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
advanceTypeDAO.save(advanceType);
|
||||
checkCanBeModified(advanceType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
|
|
@ -64,9 +63,6 @@ public class BaseCalendarModel implements IBaseCalendarModel {
|
|||
|
||||
protected boolean editing = false;
|
||||
|
||||
private ClassValidator<BaseCalendar> baseCalendarValidator = new ClassValidator<BaseCalendar>(
|
||||
BaseCalendar.class);
|
||||
|
||||
@Autowired
|
||||
private IBaseCalendarDAO baseCalendarDAO;
|
||||
|
||||
|
|
@ -430,12 +426,6 @@ public class BaseCalendarModel implements IBaseCalendarModel {
|
|||
@Override
|
||||
public void checkInvalidValuesCalendar(BaseCalendar entity)
|
||||
throws ValidationException {
|
||||
InvalidValue[] invalidValues = baseCalendarValidator
|
||||
.getInvalidValues(entity);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
|
||||
if (baseCalendarDAO.thereIsOtherWithSameName(entity)) {
|
||||
InvalidValue[] invalidValues2 = { new InvalidValue(_(
|
||||
"{0} already exists", entity.getName()),
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ package org.navalplanner.web.labels;
|
|||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
|
|
@ -53,12 +51,6 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
|
||||
private LabelType labelType;
|
||||
|
||||
private ClassValidator<LabelType> validatorLabelType = new ClassValidator<LabelType>(
|
||||
LabelType.class);
|
||||
|
||||
private ClassValidator<Label> validatorLabel = new ClassValidator<Label>(
|
||||
Label.class);
|
||||
|
||||
public LabelTypeModel() {
|
||||
|
||||
}
|
||||
|
|
@ -92,64 +84,16 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
@Override
|
||||
@Transactional
|
||||
public void confirmSave() throws ValidationException {
|
||||
ArrayList<InvalidValue> invalidValues = new ArrayList<InvalidValue>();
|
||||
|
||||
// Check properties
|
||||
invalidValues.addAll(checkLabelTypeProperties());
|
||||
invalidValues.addAll(checkLabelsProperties());
|
||||
if (invalidValues.size() > 0) {
|
||||
throw new ValidationException(invalidValues
|
||||
.toArray(new InvalidValue[0]));
|
||||
}
|
||||
|
||||
// Check elements are unique
|
||||
invalidValues.addAll(checkLabelTypeUnique());
|
||||
invalidValues.addAll(checkLabelsUnique());
|
||||
if (invalidValues.size() > 0) {
|
||||
throw new ValidationException(invalidValues
|
||||
.toArray(new InvalidValue[0]));
|
||||
}
|
||||
checkLabelTypeUnique();
|
||||
checkLabelsUnique();
|
||||
|
||||
labelTypeDAO.save(labelType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check errors in {@link LabelType}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<InvalidValue> checkLabelTypeProperties() {
|
||||
List<InvalidValue> result = new ArrayList<InvalidValue>();
|
||||
result.addAll(Arrays.asList(validatorLabelType
|
||||
.getInvalidValues(labelType)));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check errors in {@link Label}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<InvalidValue> checkLabelsProperties() {
|
||||
List<InvalidValue> result = new ArrayList<InvalidValue>();
|
||||
for (Label label : labelType.getLabels()) {
|
||||
result.addAll(Arrays.asList(validatorLabel
|
||||
.getInvalidValues(label)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check {@link LabelType} name is unique
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<InvalidValue> checkLabelTypeUnique() {
|
||||
List<InvalidValue> result = new ArrayList<InvalidValue>();
|
||||
private void checkLabelTypeUnique() {
|
||||
if (!labelTypeDAO.isUnique(labelType)) {
|
||||
result.add(createInvalidValue(labelType));
|
||||
throw new ValidationException(createInvalidValue(labelType));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private InvalidValue createInvalidValue(LabelType labelType) {
|
||||
|
|
@ -164,9 +108,8 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
* @return
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private List<InvalidValue> checkLabelsUnique() throws ValidationException {
|
||||
private void checkLabelsUnique() throws ValidationException {
|
||||
List<InvalidValue> result = new ArrayList<InvalidValue>();
|
||||
|
||||
List<Label> labels = new ArrayList<Label>(labelType.getLabels());
|
||||
for (int i = 0; i < labels.size(); i++) {
|
||||
for (int j = i + 1; j < labels.size(); j++) {
|
||||
|
|
@ -175,7 +118,9 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
if (!result.isEmpty()) {
|
||||
throw new ValidationException(result.toArray(new InvalidValue[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private InvalidValue createInvalidValue(Label label) {
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.advance.entities.AdvanceMeasurement;
|
||||
import org.navalplanner.business.advance.entities.DirectAdvanceAssignment;
|
||||
import org.navalplanner.business.advance.entities.IndirectAdvanceAssignment;
|
||||
|
|
@ -83,9 +81,6 @@ public class OrderModel implements IOrderModel {
|
|||
|
||||
private Order order;
|
||||
|
||||
private ClassValidator<Order> orderValidator = new ClassValidator<Order>(
|
||||
Order.class);
|
||||
|
||||
private OrderElementTreeModel orderElementTreeModel;
|
||||
|
||||
@Autowired
|
||||
|
|
@ -218,11 +213,6 @@ public class OrderModel implements IOrderModel {
|
|||
@Transactional
|
||||
public void save() throws ValidationException {
|
||||
reattachCriterions();
|
||||
InvalidValue[] invalidValues = orderValidator.getInvalidValues(order);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
|
||||
order.checkValid();
|
||||
this.orderDAO.save(order);
|
||||
deleteOrderElementNotParent();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import java.util.List;
|
|||
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.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
|
|
@ -58,9 +57,6 @@ public class CriterionsModel implements ICriterionsModel {
|
|||
|
||||
private static final Log log = LogFactory.getLog(CriterionsModel.class);
|
||||
|
||||
private ClassValidator<Criterion> criterionValidator = new ClassValidator<Criterion>(
|
||||
Criterion.class);
|
||||
|
||||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
|
|
@ -120,11 +116,6 @@ public class CriterionsModel implements ICriterionsModel {
|
|||
@Override
|
||||
@Transactional
|
||||
public void saveCriterion() throws ValidationException {
|
||||
InvalidValue[] invalidValues = criterionValidator
|
||||
.getInvalidValues(criterion);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
try {
|
||||
save(criterion);
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ import java.util.List;
|
|||
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.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionDAO;
|
||||
|
|
@ -57,9 +55,6 @@ public class CriterionsModel_V2 implements ICriterionsModel_V2 {
|
|||
|
||||
private static final Log log = LogFactory.getLog(CriterionsModel.class);
|
||||
|
||||
private ClassValidator<CriterionType> criterionTypeValidator = new ClassValidator<CriterionType>(
|
||||
CriterionType.class);
|
||||
|
||||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
|
|
@ -161,11 +156,6 @@ public class CriterionsModel_V2 implements ICriterionsModel_V2 {
|
|||
@Override
|
||||
@Transactional
|
||||
public void saveCriterionType() throws ValidationException {
|
||||
InvalidValue[] invalidValues = criterionTypeValidator
|
||||
.getInvalidValues(criterionType);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
criterionTreeModel.saveCriterions(criterionType);
|
||||
criterionTypeDAO.save(criterionType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionTypeDAO;
|
||||
|
|
@ -39,12 +38,6 @@ import org.zkoss.zk.ui.WrongValueException;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class AssignedMachineCriterionsModel implements IAssignedMachineCriterionsModel {
|
||||
|
||||
private ClassValidator<CriterionSatisfactionDTO> satisfactionDTOValidator = new ClassValidator<CriterionSatisfactionDTO>(
|
||||
CriterionSatisfactionDTO.class);
|
||||
|
||||
private ClassValidator<CriterionSatisfactionDTO> satisfactionValidator = new ClassValidator<CriterionSatisfactionDTO>(
|
||||
CriterionSatisfactionDTO.class);
|
||||
|
||||
@Autowired
|
||||
private IResourceDAO resourceDAO;
|
||||
|
||||
|
|
@ -300,13 +293,7 @@ public class AssignedMachineCriterionsModel implements IAssignedMachineCriterion
|
|||
}
|
||||
|
||||
public void save() throws ValidationException {
|
||||
InvalidValue[] invalidValues;
|
||||
for (CriterionSatisfactionDTO satisfactionDTO : this.criterionSatisfactionDTOs) {
|
||||
invalidValues = satisfactionValidator
|
||||
.getInvalidValues(satisfactionDTO);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
save(satisfactionDTO);
|
||||
}
|
||||
}
|
||||
|
|
@ -361,12 +348,6 @@ public class AssignedMachineCriterionsModel implements IAssignedMachineCriterion
|
|||
Set<CriterionSatisfactionDTO> listDTOs = new HashSet<CriterionSatisfactionDTO>(
|
||||
criterionSatisfactionDTOs);
|
||||
for (CriterionSatisfactionDTO satisfactionDTO : listDTOs) {
|
||||
InvalidValue[] invalidValues;
|
||||
invalidValues = satisfactionDTOValidator
|
||||
.getInvalidValues(satisfactionDTO);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
Criterion criterion = satisfactionDTO.getCriterionWithItsType()
|
||||
.getCriterion();
|
||||
if (checkSameCriterionAndSameInterval(satisfactionDTO)) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.ResourceCalendar;
|
||||
|
|
@ -62,8 +60,6 @@ public class MachineModel implements IMachineModel {
|
|||
|
||||
private Machine machine;
|
||||
|
||||
private ClassValidator<Machine> validator = new ClassValidator<Machine>(Machine.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("subclass")
|
||||
private IBaseCalendarModel baseCalendarModel;
|
||||
|
|
@ -90,10 +86,6 @@ public class MachineModel implements IMachineModel {
|
|||
if (machine.getCalendar() != null) {
|
||||
baseCalendarModel.checkInvalidValuesCalendar(machine.getCalendar());
|
||||
}
|
||||
InvalidValue[] invalidValues = validator.getInvalidValues(getMachine());
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
resourceDAO.save(machine);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,9 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionTypeDAO;
|
||||
import org.navalplanner.business.resources.daos.IResourceDAO;
|
||||
import org.navalplanner.business.resources.daos.IWorkerDAO;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.CriterionSatisfaction;
|
||||
import org.navalplanner.business.resources.entities.CriterionType;
|
||||
|
|
@ -41,18 +38,9 @@ import org.zkoss.zk.ui.WrongValueException;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class AssignedCriterionsModel implements IAssignedCriterionsModel {
|
||||
|
||||
private ClassValidator<CriterionSatisfactionDTO> satisfactionDTOValidator = new ClassValidator<CriterionSatisfactionDTO>(
|
||||
CriterionSatisfactionDTO.class);
|
||||
|
||||
private ClassValidator<CriterionSatisfaction> satisfactionValidator = new ClassValidator<CriterionSatisfaction>(
|
||||
CriterionSatisfaction.class);
|
||||
|
||||
@Autowired
|
||||
private IResourceDAO resourceDAO;
|
||||
|
||||
@Autowired
|
||||
private IWorkerDAO workerDAO;
|
||||
|
||||
@Autowired
|
||||
private ICriterionTypeDAO criterionTypeDAO;
|
||||
|
||||
|
|
@ -310,12 +298,6 @@ public class AssignedCriterionsModel implements IAssignedCriterionsModel {
|
|||
Set<CriterionSatisfactionDTO> listDTOs = new HashSet<CriterionSatisfactionDTO>(
|
||||
criterionSatisfactionDTOs);
|
||||
for (CriterionSatisfactionDTO satisfactionDTO : listDTOs) {
|
||||
InvalidValue[] invalidValues;
|
||||
invalidValues = satisfactionDTOValidator
|
||||
.getInvalidValues(satisfactionDTO);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
Criterion criterion = satisfactionDTO.getCriterionWithItsType()
|
||||
.getCriterion();
|
||||
if (checkSameCriterionAndSameInterval(satisfactionDTO)) {
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.orders.daos.IOrderElementDAO;
|
||||
|
|
@ -65,12 +63,6 @@ public class WorkReportModel implements IWorkReportModel {
|
|||
|
||||
private WorkReport workReport;
|
||||
|
||||
private ClassValidator<WorkReport> workReportValidator = new ClassValidator<WorkReport>(
|
||||
WorkReport.class);
|
||||
|
||||
private ClassValidator<WorkReportLine> workReportLineValidator = new ClassValidator<WorkReportLine>(
|
||||
WorkReportLine.class);
|
||||
|
||||
private boolean editing = false;
|
||||
|
||||
@Override
|
||||
|
|
@ -145,22 +137,6 @@ public class WorkReportModel implements IWorkReportModel {
|
|||
@Override
|
||||
@Transactional
|
||||
public void save() throws ValidationException {
|
||||
InvalidValue[] invalidValues = workReportValidator
|
||||
.getInvalidValues(workReport);
|
||||
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
|
||||
// Check WorkReportLines
|
||||
for (WorkReportLine workReportLine : workReport.getWorkReportLines()) {
|
||||
invalidValues = workReportLineValidator
|
||||
.getInvalidValues(workReportLine);
|
||||
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
}
|
||||
workReportDAO.save(workReport);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.ClassValidator;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionTypeDAO;
|
||||
|
|
@ -57,9 +55,6 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
|
|||
|
||||
private WorkReportType workReportType;
|
||||
|
||||
private ClassValidator<WorkReportType> workReportTypeValidator = new ClassValidator<WorkReportType>(
|
||||
WorkReportType.class);
|
||||
|
||||
private boolean editing = false;
|
||||
|
||||
@Override
|
||||
|
|
@ -117,12 +112,6 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
|
|||
@Override
|
||||
@Transactional
|
||||
public void save() throws ValidationException {
|
||||
InvalidValue[] invalidValues = workReportTypeValidator
|
||||
.getInvalidValues(workReportType);
|
||||
if (invalidValues.length > 0) {
|
||||
throw new ValidationException(invalidValues);
|
||||
}
|
||||
|
||||
workReportTypeDAO.save(workReportType);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue