Clover Coverage Report - Kuali Student 1.3.0-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Apr 28 2011 05:03:32 EDT
../../../../../../../../img/srcFileCovDistChart0.png 2% of files have more coverage
29   89   17   9.67
22   63   0.59   3
3     5.67  
1    
 
  KSCustomDataSource       Line # 21 29 0% 17 54 0% 0.0
 
No Tests
 
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    * This is a custom data source class to convert a datamodel to a Jasper report data source object.
18    *
19    * @author Kuali Rice Team (kuali-rice@googlegroups.com)
20    */
 
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    */
 
32  0 toggle 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    */
 
40  0 toggle 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    */
 
55  0 toggle 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    }