| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
package org.kuali.student.contract.model.util; |
| 6 |
|
|
| 7 |
|
import java.io.PrintStream; |
| 8 |
|
import java.util.Stack; |
| 9 |
|
|
| 10 |
|
import org.kuali.student.contract.model.MessageStructure; |
| 11 |
|
import org.kuali.student.contract.model.ServiceContractModel; |
| 12 |
|
import org.kuali.student.contract.model.XmlType; |
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
@author |
| 17 |
|
|
|
|
|
| 0% |
Uncovered Elements: 97 (97) |
Complexity: 14 |
Complexity Density: 0.17 |
|
| 18 |
|
public class MessageStructureHierarchyDumper |
| 19 |
|
{ |
| 20 |
|
|
| 21 |
|
private ServiceContractModel model; |
| 22 |
|
private ModelFinder finder; |
| 23 |
|
private PrintStream out; |
| 24 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 25 |
0
|
public MessageStructureHierarchyDumper (PrintStream out,... |
| 26 |
|
ServiceContractModel model) |
| 27 |
|
{ |
| 28 |
0
|
this.out = out; |
| 29 |
0
|
this.model = model; |
| 30 |
0
|
this.finder = new ModelFinder (model); |
| 31 |
|
} |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
|
| 33 |
0
|
public void writeTabbedHeader ()... |
| 34 |
|
{ |
| 35 |
0
|
out.print ("id"); |
| 36 |
0
|
out.print ("\t"); |
| 37 |
0
|
out.print ("Action"); |
| 38 |
0
|
out.print ("\t"); |
| 39 |
0
|
out.print ("xmlObject"); |
| 40 |
0
|
out.print ("\t"); |
| 41 |
0
|
out.print ("ShortName"); |
| 42 |
0
|
out.print ("\t"); |
| 43 |
0
|
out.print ("Name"); |
| 44 |
0
|
out.print ("\t"); |
| 45 |
0
|
out.print ("Type"); |
| 46 |
0
|
out.print ("\t"); |
| 47 |
0
|
out.print ("Description"); |
| 48 |
0
|
out.print ("\t"); |
| 49 |
0
|
out.print ("Required"); |
| 50 |
0
|
out.print ("\t"); |
| 51 |
0
|
out.print ("Cardinality"); |
| 52 |
0
|
out.print ("\t"); |
| 53 |
0
|
out.print ("XMLAttribute"); |
| 54 |
0
|
out.print ("\t"); |
| 55 |
0
|
out.print ("Status"); |
| 56 |
0
|
out.print ("\t"); |
| 57 |
0
|
out.print ("Feedback"); |
| 58 |
0
|
out.println (""); |
| 59 |
|
} |
| 60 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 6 |
Complexity Density: 0.43 |
|
| 61 |
0
|
private String clean (String str)... |
| 62 |
|
{ |
| 63 |
0
|
int len = str.length (); |
| 64 |
0
|
StringBuffer buffer = new StringBuffer (len); |
| 65 |
0
|
for (int i = 0; i < len; i ++) |
| 66 |
|
{ |
| 67 |
0
|
char c = str.charAt (i); |
| 68 |
|
|
| 69 |
0
|
switch (c) |
| 70 |
|
{ |
| 71 |
0
|
case '\n': |
| 72 |
0
|
case '\r': |
| 73 |
0
|
if (i + 1 < len && str.charAt (i + 1) == '\n') |
| 74 |
|
{ |
| 75 |
0
|
i ++; |
| 76 |
|
} |
| 77 |
|
|
| 78 |
0
|
buffer.append (" "); |
| 79 |
0
|
break; |
| 80 |
0
|
default: |
| 81 |
0
|
buffer.append (c); |
| 82 |
|
} |
| 83 |
|
} |
| 84 |
0
|
return buffer.toString (); |
| 85 |
|
} |
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
| 87 |
0
|
public String calcId (MessageStructure ms, Stack<String> parents)... |
| 88 |
|
{ |
| 89 |
0
|
StringBuilder bldr = new StringBuilder (); |
| 90 |
|
{ |
| 91 |
0
|
for (String parent : parents) |
| 92 |
|
{ |
| 93 |
0
|
bldr.append (parent); |
| 94 |
0
|
bldr.append ("."); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
0
|
bldr.append (ms.getShortName ()); |
| 98 |
0
|
return bldr.toString (); |
| 99 |
|
} |
| 100 |
|
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 3 |
Complexity Density: 0.1 |
|
| 101 |
0
|
public void writeTabbedData (MessageStructure ms, Stack<String> parents)... |
| 102 |
|
{ |
| 103 |
0
|
out.print (calcId (ms, parents)); |
| 104 |
0
|
out.print ("\t"); |
| 105 |
0
|
out.print (""); |
| 106 |
0
|
out.print ("\t"); |
| 107 |
0
|
out.print (ms.getXmlObject ()); |
| 108 |
0
|
out.print ("\t"); |
| 109 |
0
|
out.print (ms.getShortName ()); |
| 110 |
0
|
out.print ("\t"); |
| 111 |
0
|
out.print (ms.getName ()); |
| 112 |
0
|
out.print ("\t"); |
| 113 |
0
|
out.print (ms.getType ()); |
| 114 |
0
|
out.print ("\t"); |
| 115 |
0
|
out.print (clean (ms.getDescription ())); |
| 116 |
0
|
out.print ("\t"); |
| 117 |
0
|
out.print (ms.getRequired ()); |
| 118 |
0
|
out.print ("\t"); |
| 119 |
0
|
out.print (ms.getCardinality ()); |
| 120 |
0
|
out.print ("\t"); |
| 121 |
0
|
out.print (ms.getXmlAttribute ()); |
| 122 |
0
|
out.print ("\t"); |
| 123 |
0
|
out.print (ms.getStatus ()); |
| 124 |
0
|
out.print ("\t"); |
| 125 |
0
|
out.print (ms.getFeedback ()); |
| 126 |
0
|
out.println (""); |
| 127 |
0
|
XmlType st = finder.findXmlType (stripList (ms.getType ())); |
| 128 |
0
|
if (st.getPrimitive ().equalsIgnoreCase (XmlType.COMPLEX)) |
| 129 |
|
{ |
| 130 |
0
|
if ( ! parents.contains (st.getName ())) |
| 131 |
|
{ |
| 132 |
0
|
parents.push (st.getName ()); |
| 133 |
0
|
for (MessageStructure childMs : finder.findMessageStructures (st.getName ())) |
| 134 |
|
{ |
| 135 |
0
|
this.writeTabbedData (childMs, parents); |
| 136 |
|
} |
| 137 |
0
|
parents.pop (); |
| 138 |
|
} |
| 139 |
|
} |
| 140 |
|
} |
| 141 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 142 |
0
|
private String stripList (String type)... |
| 143 |
|
{ |
| 144 |
0
|
if (type.endsWith ("List")) |
| 145 |
|
{ |
| 146 |
0
|
return type.substring (0, type.length () - "List".length ()); |
| 147 |
|
} |
| 148 |
0
|
return type; |
| 149 |
|
} |
| 150 |
|
} |