| 1 |
|
package org.kuali.student.common.ui.server.screenreport.jasper; |
| 2 |
|
|
| 3 |
|
import java.util.Collection; |
| 4 |
|
import java.util.Iterator; |
| 5 |
|
|
| 6 |
|
import net.sf.jasperreports.engine.JRException; |
| 7 |
|
import net.sf.jasperreports.engine.JRField; |
| 8 |
|
import net.sf.jasperreports.engine.data.JRAbstractBeanDataSource; |
| 9 |
|
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; |
| 10 |
|
|
| 11 |
|
import org.kuali.student.common.ui.client.util.ExportElement; |
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
@author |
| 18 |
|
|
|
|
|
| 73.6% |
Uncovered Elements: 14 (53) |
Complexity: 19 |
Complexity Density: 0.7 |
|
| 19 |
|
public class KSCollectionDataSource extends JRAbstractBeanDataSource { |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
private Collection<ExportElement> data; |
| 25 |
|
private Iterator<ExportElement> iterator; |
| 26 |
|
private ExportElement currentBean; |
| 27 |
|
private ExportElement parent; |
| 28 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 29 |
53
|
public KSCollectionDataSource(Collection<ExportElement> elements, ExportElement parent) {... |
| 30 |
53
|
super(true); |
| 31 |
|
|
| 32 |
53
|
this.parent = parent; |
| 33 |
53
|
this.data = elements; |
| 34 |
|
|
| 35 |
53
|
if (this.data != null) { |
| 36 |
16
|
this.iterator = this.data.iterator(); |
| 37 |
|
} |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 43 |
79
|
public boolean next() {... |
| 44 |
79
|
boolean hasNext = false; |
| 45 |
|
|
| 46 |
79
|
if (this.iterator != null) { |
| 47 |
79
|
hasNext = this.iterator.hasNext(); |
| 48 |
|
|
| 49 |
79
|
if (hasNext) { |
| 50 |
58
|
this.currentBean = this.iterator.next(); |
| 51 |
|
|
| 52 |
|
|
| 53 |
58
|
if (this.currentBean.isEmpty()){ |
| 54 |
5
|
return next(); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
} |
| 58 |
|
|
| 59 |
74
|
return hasNext; |
| 60 |
|
} |
| 61 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 62 |
357
|
@Override... |
| 63 |
|
public Object getFieldValue(JRField field) throws JRException { |
| 64 |
357
|
return getFieldValue(currentBean, field); |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 70 |
357
|
protected Object getFieldValue(ExportElement bean, JRField field) throws JRException {... |
| 71 |
357
|
Object object = getBeanProperty(bean, getPropertyName(field)); |
| 72 |
|
|
| 73 |
|
|
| 74 |
357
|
if ("subset".equals(field.getName())) { |
| 75 |
48
|
return new KSCollectionDataSource((Collection<ExportElement>) object, bean); |
| 76 |
|
|
| 77 |
|
|
| 78 |
309
|
} else if ("sectionName".equals(field.getName())) { |
| 79 |
48
|
if (parent != null && parent.getSectionName() != null && parent.getSectionName().equals(object)) { |
| 80 |
4
|
return null; |
| 81 |
|
} else { |
| 82 |
44
|
return object; |
| 83 |
|
} |
| 84 |
|
} |
| 85 |
261
|
return object; |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 91 |
0
|
public void moveFirst() {... |
| 92 |
0
|
if (this.data != null) { |
| 93 |
0
|
this.iterator = this.data.iterator(); |
| 94 |
|
} |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
@return |
| 101 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 102 |
0
|
public Collection getData() {... |
| 103 |
0
|
return data; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
@return |
| 110 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 111 |
0
|
public int getRecordCount() {... |
| 112 |
0
|
return data == null ? 0 : data.size(); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
@return |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 120 |
0
|
public JRBeanCollectionDataSource cloneDataSource() {... |
| 121 |
0
|
return new JRBeanCollectionDataSource(data); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
} |