Clover Coverage Report - KS LUM 1.2-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Mar 3 2011 05:26:43 EST
../../../../../../../img/srcFileCovDistChart7.png 48% of files have more coverage
16   59   8   5.33
6   48   0.5   3
3     2.67  
1    
 
  ActiveDatesValidator       Line # 16 16 0% 8 9 64% 0.64
 
  (1)
 
1    package org.kuali.student.lum.course.service.utils;
2   
3    import java.util.ArrayList;
4    import java.util.List;
5    import java.util.Stack;
6   
7    import org.kuali.student.common.dictionary.dto.FieldDefinition;
8    import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
9    import org.kuali.student.common.util.MessageUtils;
10    import org.kuali.student.common.validation.dto.ValidationResultInfo;
11    import org.kuali.student.common.validator.DefaultValidatorImpl;
12    import org.kuali.student.core.atp.dto.AtpInfo;
13    import org.kuali.student.core.atp.service.AtpService;
14    import org.kuali.student.lum.course.dto.CourseInfo;
15   
 
16    public class ActiveDatesValidator extends DefaultValidatorImpl {
17    private AtpService atpService;
18   
 
19  0 toggle @Override
20    public List<ValidationResultInfo> validateObject(Object data,
21    ObjectStructureDefinition objStructure) {
22    // Custom validators are required to only override the other
23    // validateObject method
24  0 return null;
25    }
26   
 
27  7 toggle @Override
28    public List<ValidationResultInfo> validateObject(FieldDefinition field,
29    Object o, ObjectStructureDefinition objStructure,
30    Stack<String> elementStack) {
31    //Get ATPs and compare dates. If the end is <= the start, throw a validation error.
32  7 List<ValidationResultInfo> results = new ArrayList<ValidationResultInfo>();
33  7 if (o instanceof CourseInfo) {
34  7 CourseInfo course = (CourseInfo) o;
35  7 if (course.getEndTerm() != null && course.getStartTerm() != null) {
36  6 try {
37  6 AtpInfo startAtp = atpService.getAtp(course.getStartTerm());
38  6 AtpInfo endAtp = atpService.getAtp(course.getEndTerm());
39  6 if (startAtp.getStartDate()
40    .compareTo(endAtp.getStartDate()) > 0) {
41  0 ValidationResultInfo vr = new ValidationResultInfo();
42  0 vr.setElement(field.getName());
43  0 vr.setError("validation.endDateAfterStartDate");
44  0 results.add(vr);
45    }
46    } catch (Exception e) {
47  0 throw new RuntimeException("Error validating.", e);
48    }
49   
50    }
51    }
52  7 return results;
53    }
54   
 
55  1 toggle public void setAtpService(AtpService atpService) {
56  1 this.atpService = atpService;
57    }
58   
59    }