| 1 |
|
package org.kuali.student.lum.course.service.impl; |
| 2 |
|
|
| 3 |
|
import java.beans.IntrospectionException; |
| 4 |
|
import java.util.ArrayList; |
| 5 |
|
import java.util.List; |
| 6 |
|
|
| 7 |
|
import org.kuali.student.common.dictionary.dto.FieldDefinition; |
| 8 |
|
import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition; |
| 9 |
|
|
|
|
|
| 0% |
Uncovered Elements: 53 (53) |
Complexity: 13 |
Complexity Density: 0.39 |
|
| 10 |
|
public class Dictionary2DictionaryComparer |
| 11 |
|
{ |
| 12 |
|
|
| 13 |
|
private ObjectStructureDefinition os1; |
| 14 |
|
private ObjectStructureDefinition os2; |
| 15 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 16 |
0
|
public Dictionary2DictionaryComparer (ObjectStructureDefinition os1,... |
| 17 |
|
ObjectStructureDefinition os2) |
| 18 |
|
{ |
| 19 |
0
|
this.os1 = os1; |
| 20 |
0
|
this.os2 = os2; |
| 21 |
|
} |
| 22 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 23 |
0
|
public List<String> compare ()... |
| 24 |
|
{ |
| 25 |
0
|
return compare (os1, os2); |
| 26 |
|
|
| 27 |
|
} |
| 28 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
| 29 |
0
|
private List<String> compare (ObjectStructureDefinition os1,... |
| 30 |
|
ObjectStructureDefinition os2) |
| 31 |
|
{ |
| 32 |
0
|
List<String> discrepancies = new ArrayList (); |
| 33 |
0
|
compare (discrepancies, "Java Object Name", os2.getName (), |
| 34 |
|
os1.getName ()); |
| 35 |
0
|
compare (discrepancies, "hasMetaData", os2.isHasMetaData (), |
| 36 |
|
os1.isHasMetaData ()); |
| 37 |
0
|
compare (discrepancies, "BusinessObjectClass", |
| 38 |
|
os2.getBusinessObjectClass (), |
| 39 |
|
os1.getBusinessObjectClass ()); |
| 40 |
0
|
for (FieldDefinition fdDict : os1.getAttributes ()) |
| 41 |
|
{ |
| 42 |
0
|
FieldDefinition fdBean = findField (fdDict.getName (), os2); |
| 43 |
0
|
if (fdBean == null) |
| 44 |
|
{ |
| 45 |
0
|
discrepancies.add ("Field " + fdDict.getName () |
| 46 |
|
+ " is missing from the 1st structure"); |
| 47 |
|
} |
| 48 |
0
|
compare (discrepancies, fdDict.getName () + " dataType", |
| 49 |
|
fdDict.getDataType (), fdBean.getDataType ()); |
| 50 |
0
|
compare (discrepancies, fdDict.getName () + " minOccurs", |
| 51 |
|
fdDict.getMinOccurs (), fdBean.getMinOccurs ()); |
| 52 |
0
|
compare (discrepancies, fdDict.getName () + " maxOccurs", |
| 53 |
|
fdDict.getMaxOccurs (), fdBean.getMaxOccurs ()); |
| 54 |
|
} |
| 55 |
0
|
for (FieldDefinition fdBean : os2.getAttributes ()) |
| 56 |
|
{ |
| 57 |
0
|
FieldDefinition fdDict = findField (fdBean.getName (), os1); |
| 58 |
0
|
if (fdDict == null) |
| 59 |
|
{ |
| 60 |
0
|
discrepancies.add ("Field " + fdBean.getName () |
| 61 |
|
+ " missing from the 2nd structure"); |
| 62 |
0
|
continue; |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
0
|
return discrepancies; |
| 66 |
|
} |
| 67 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 68 |
0
|
private FieldDefinition findField (String name, ObjectStructureDefinition os)... |
| 69 |
|
{ |
| 70 |
0
|
for (FieldDefinition fd : os.getAttributes ()) |
| 71 |
|
{ |
| 72 |
0
|
if (name.equals (fd.getName ())) |
| 73 |
|
{ |
| 74 |
0
|
return fd; |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
0
|
return null; |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 80 |
0
|
private void compare (List<String> discrepancies,... |
| 81 |
|
String field, |
| 82 |
|
Object value1, |
| 83 |
|
Object value2) |
| 84 |
|
{ |
| 85 |
0
|
String discrep = compare (field, value1, value2); |
| 86 |
0
|
if (discrep != null) |
| 87 |
|
{ |
| 88 |
0
|
discrepancies.add (discrep); |
| 89 |
|
} |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 92 |
0
|
private String compare (String field, Object value1, Object value2)... |
| 93 |
|
{ |
| 94 |
0
|
if (value1 == null) |
| 95 |
|
{ |
| 96 |
0
|
if (value2 == null) |
| 97 |
|
{ |
| 98 |
0
|
return null; |
| 99 |
|
} |
| 100 |
|
} |
| 101 |
|
else |
| 102 |
|
{ |
| 103 |
0
|
if (value1.equals (value2)) |
| 104 |
|
{ |
| 105 |
0
|
return null; |
| 106 |
|
} |
| 107 |
|
} |
| 108 |
0
|
return field + " inconsistent: os1=[" + value1 + "], os2=[" + value2 + "]"; |
| 109 |
|
} |
| 110 |
|
} |