public void validate(Object obj, Errors errors) {
DefectVarity defectVarity = (DefectVarity) obj;
//checking defect parameters
List parameterList = defectVarity.getParameters();
for (int i = 0; i < parameterList.size(); i++) {
Parameter parameter = (Parameter) parameterList.get(i);
if (parameter.getParameterId().equals(new Long(-1))) {
errors.rejectValue("parameters[" + i + "]", "defectVarity.noParameter");
}
}
//checking defect material
if(defectVarity.getMaterial().getMaterialId().equals(new Long(-1))){
errors.rejectValue("material", "defectVarity.noMaterial");
}
if (!defectVarityManager.isUniqueVarity(defectVarity)) {
errors.rejectValue("varityId", "defectVarity.notUnique");