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