1 |
|
package org.kuali.student.common.ui.server.screenreport.jasper; |
2 |
|
|
3 |
|
import java.text.DateFormat; |
4 |
|
import java.text.SimpleDateFormat; |
5 |
|
import java.util.Date; |
6 |
|
import java.util.Iterator; |
7 |
|
import java.util.NoSuchElementException; |
8 |
|
|
9 |
|
import net.sf.jasperreports.engine.JRDataSource; |
10 |
|
import net.sf.jasperreports.engine.JRException; |
11 |
|
import net.sf.jasperreports.engine.JRField; |
12 |
|
|
13 |
|
import org.kuali.student.common.assembly.data.Data; |
14 |
|
import org.kuali.student.common.assembly.data.Data.Property; |
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
@author |
20 |
|
|
|
|
| 0% |
Uncovered Elements: 54 (54) |
Complexity: 17 |
Complexity Density: 0.59 |
|
21 |
|
public class KSCustomDataSource implements JRDataSource { |
22 |
|
|
23 |
|
private Iterator<Property> iterator; |
24 |
|
|
25 |
|
private Property property; |
26 |
|
|
27 |
|
private DateFormat format; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
32 |
0
|
public KSCustomDataSource(final Iterator<Property> source) {... |
33 |
0
|
this.iterator = source; |
34 |
0
|
this.format = new SimpleDateFormat("yyyy-MM-dd"); |
35 |
|
} |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 5 |
Complexity Density: 0.83 |
|
40 |
0
|
public boolean next() throws JRException {... |
41 |
0
|
try { |
42 |
0
|
property = (Property) iterator.next(); |
43 |
0
|
if (("metaInfo".equals(property.getKey().toString())) || ("id".equals(property.getKey().toString())) || ("_runtimeData".equals(property.getKey().toString()))) { |
44 |
0
|
return this.next(); |
45 |
|
} |
46 |
|
} catch (NoSuchElementException e) { |
47 |
0
|
return false; |
48 |
|
} |
49 |
0
|
return true; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
|
|
| 0% |
Uncovered Elements: 41 (41) |
Complexity: 11 |
Complexity Density: 0.52 |
|
55 |
0
|
public Object getFieldValue(JRField field) throws JRException {... |
56 |
0
|
Object value = null; |
57 |
|
|
58 |
0
|
String fieldName = field.getName(); |
59 |
0
|
if ("key".equals(fieldName)) { |
60 |
0
|
value = property.getKey().toString(); |
61 |
|
} else { |
62 |
0
|
if (property.getValueType().equals(Data.class)) { |
63 |
0
|
if ("sub".equals(fieldName)) { |
64 |
0
|
value = new Boolean(true); |
65 |
0
|
} else if ("value".equals(fieldName)) { |
66 |
0
|
value = null; |
67 |
0
|
} else if ("subset".equals(fieldName)) { |
68 |
0
|
value = new KSCustomDataSource(((Data) property.getValue()).iterator()); |
69 |
|
} |
70 |
|
} else { |
71 |
0
|
if ("sub".equals(fieldName)) { |
72 |
0
|
value = new Boolean(false); |
73 |
0
|
} else if ("value".equals(fieldName)) { |
74 |
0
|
if (property.getValue() instanceof Date) { |
75 |
0
|
value = format.format((Date) property.getValue()); |
76 |
|
} else { |
77 |
0
|
if (property.getValue() != null) { |
78 |
0
|
value = property.getValue().toString(); |
79 |
|
} |
80 |
|
} |
81 |
0
|
} else if ("subset".equals(fieldName)) { |
82 |
0
|
value = null; |
83 |
|
} |
84 |
|
} |
85 |
|
} |
86 |
0
|
return value; |
87 |
|
} |
88 |
|
|
89 |
|
} |