Clover Coverage Report - Kuali Student 1.2.1-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Nov 2 2011 04:03:58 EST
../../../../../../../../../img/srcFileCovDistChart0.png 42% of files have more coverage
21   56   14   3.5
12   50   0.67   6
6     2.33  
1    
 
  SwapCondition       Line # 13 21 0% 14 39 0% 0.0
 
No Tests
 
1    package org.kuali.student.common.ui.client.configurable.mvc.multiplicity;
2   
3    import java.util.List;
4    import java.util.Map;
5   
6    import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
7    import org.kuali.student.common.ui.client.configurable.mvc.sections.GroupSection;
8    import org.kuali.student.common.ui.client.widgets.list.KSSelectItemWidgetAbstract;
9    import org.kuali.student.common.ui.client.widgets.search.KSPicker;
10   
11    import com.google.gwt.user.client.ui.Widget;
12   
 
13    public class SwapCondition {
14    private FieldDescriptor fd;
15    private String value;
 
16  0 toggle public FieldDescriptor getFd() {
17  0 return fd;
18    }
 
19  0 toggle public void setFd(FieldDescriptor fd) {
20  0 this.fd = fd;
21    }
 
22  0 toggle public String getValue() {
23  0 return value;
24    }
 
25  0 toggle public void setValue(String value) {
26  0 this.value = value;
27    }
 
28  0 toggle private String nvl(String inString) {
29  0 return (inString == null)? "" : inString;
30    }
 
31  0 toggle public boolean evaluate(GroupSection section, Map<String, String> helperFieldKeys) {
32  0 boolean result = false;
33  0 String widgetValue = null;
34    // could have used getField(String) method here but the getField method does
35    // not check the fields of sub sections.
36  0 List<FieldDescriptor> sectionFds = section.getFields();
37  0 Widget fieldWidget = null;
38  0 if (sectionFds != null) {
39  0 for (FieldDescriptor sectionFd : sectionFds) {
40  0 if (sectionFd.getFieldKey().equals(helperFieldKeys.get(fd.getFieldKey()))) {
41  0 fieldWidget = sectionFd.getFieldWidget();
42    }
43    }
44    }
45  0 if (fieldWidget != null && fieldWidget instanceof KSSelectItemWidgetAbstract) {
46  0 widgetValue = ((KSSelectItemWidgetAbstract)fieldWidget).getSelectedItem();
47  0 } else if (fieldWidget != null && fieldWidget instanceof KSPicker) {
48  0 Widget inputWidget = ((KSPicker)fieldWidget).getInputWidget();
49  0 widgetValue = ((KSSelectItemWidgetAbstract)inputWidget).getSelectedItem();
50    }
51  0 if (nvl(this.value).equals(widgetValue)) {
52  0 result = true;
53    }
54  0 return result;
55    }
56    }