| 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.util.MessageUtils; |
| 8 |
|
import org.kuali.student.common.validator.DefaultValidatorImpl; |
| 9 |
|
import org.kuali.student.core.atp.dto.AtpInfo; |
| 10 |
|
import org.kuali.student.core.atp.service.AtpService; |
| 11 |
|
import org.kuali.student.core.dictionary.dto.FieldDefinition; |
| 12 |
|
import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition; |
| 13 |
|
import org.kuali.student.core.validation.dto.ValidationResultInfo; |
| 14 |
|
import org.kuali.student.lum.course.dto.CourseInfo; |
| 15 |
|
|
|
|
|
| 64% |
Uncovered Elements: 9 (25) |
Complexity: 8 |
Complexity Density: 0.5 |
|
| 16 |
|
public class ActiveDatesValidator extends DefaultValidatorImpl { |
| 17 |
|
private AtpService atpService; |
| 18 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 19 |
0
|
@Override... |
| 20 |
|
public List<ValidationResultInfo> validateObject(Object data, |
| 21 |
|
ObjectStructureDefinition objStructure) { |
| 22 |
|
|
| 23 |
|
|
| 24 |
0
|
return null; |
| 25 |
|
} |
| 26 |
|
|
|
|
|
| 65% |
Uncovered Elements: 7 (20) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 27 |
7
|
@Override... |
| 28 |
|
public List<ValidationResultInfo> validateObject(FieldDefinition field, |
| 29 |
|
Object o, ObjectStructureDefinition objStructure, |
| 30 |
|
Stack<String> elementStack) { |
| 31 |
|
|
| 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 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
1
|
public void setAtpService(AtpService atpService) {... |
| 56 |
1
|
this.atpService = atpService; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
} |