| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.contract.model.validation; |
| 17 |
|
|
| 18 |
|
import org.kuali.student.contract.model.SearchCriteria; |
| 19 |
|
import org.kuali.student.contract.model.SearchType; |
| 20 |
|
|
| 21 |
|
import java.util.ArrayList; |
| 22 |
|
import java.util.Collection; |
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
@author |
| 27 |
|
|
|
|
|
| 0% |
Uncovered Elements: 38 (38) |
Complexity: 11 |
Complexity Density: 0.55 |
|
| 28 |
|
public class SearchCriteriaValidator implements ModelValidator { |
| 29 |
|
|
| 30 |
|
private SearchCriteria criteria; |
| 31 |
|
private SearchType searchType; |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 33 |
0
|
public SearchCriteriaValidator(SearchCriteria criteria, SearchType searchType) {... |
| 34 |
0
|
this.criteria = criteria; |
| 35 |
0
|
this.searchType = searchType; |
| 36 |
|
} |
| 37 |
|
private Collection errors; |
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 39 |
0
|
@Override... |
| 40 |
|
public Collection<String> validate() { |
| 41 |
0
|
errors = new ArrayList(); |
| 42 |
0
|
basicValidation(); |
| 43 |
0
|
if (criteria.getParameters() == null) { |
| 44 |
0
|
addError("A parameter list is required even if no parameters"); |
| 45 |
|
} |
| 46 |
0
|
return errors; |
| 47 |
|
} |
| 48 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 6 |
Complexity Density: 0.6 |
|
| 49 |
0
|
private void basicValidation() {... |
| 50 |
0
|
if (criteria.getKey().equals("")) { |
| 51 |
0
|
addError("criteria key is required"); |
| 52 |
|
} |
| 53 |
0
|
if (!criteria.getType().equals("Criteria")) { |
| 54 |
0
|
addError("'Type' column in the criteria must be 'Criteria'"); |
| 55 |
|
} |
| 56 |
0
|
if (criteria.getName().equals("")) { |
| 57 |
0
|
addError("Name is required"); |
| 58 |
|
} |
| 59 |
0
|
if (criteria.getDescription().equals("")) { |
| 60 |
0
|
addError("Description is required"); |
| 61 |
|
} |
| 62 |
0
|
if (!criteria.getDataType().equals("")) { |
| 63 |
0
|
addError("Data Type should be blank"); |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 67 |
0
|
private void addError(String msg) {... |
| 68 |
0
|
String error = "Error in criteria entry: " + searchType.getKey() + "." + criteria.getKey() |
| 69 |
|
+ ": " + msg; |
| 70 |
0
|
if (!errors.contains(error)) { |
| 71 |
0
|
errors.add(error); |
| 72 |
|
} |
| 73 |
|
} |
| 74 |
|
} |