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
31   105   11   10.33
14   60   0.35   3
3     3.67  
1    
 
  MultiplicityGroupItemBinding       Line # 33 31 0% 11 48 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.ui.client.configurable.mvc.binding;
17   
18    import org.kuali.student.common.assembly.data.QueryPath;
19    import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityGroupItem;
20    import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
21    import org.kuali.student.common.ui.client.configurable.mvc.sections.SectionBinding;
22    import org.kuali.student.common.ui.client.mvc.DataModel;
23   
24    import com.google.gwt.core.client.GWT;
25    import com.google.gwt.user.client.ui.Widget;
26   
27    /**
28    * This binding simply adds an index key to the multiplicity item's parent path and then calls the binding ModelWidgetBinding
29    * of the underlying multiplicity item's widget.
30    *
31    * @author Kuali Student Team
32    */
 
33    public class MultiplicityGroupItemBinding extends ModelWidgetBindingSupport<MultiplicityGroupItem> {
34    public static MultiplicityGroupItemBinding INSTANCE = new MultiplicityGroupItemBinding();
35   
36    protected static final String RT_CREATED = "_runtimeData" + QueryPath.getPathSeparator() + "created";
37    protected static final String RT_UPDATED = "_runtimeData" + QueryPath.getPathSeparator() + "updated";
38    protected static final String RT_DELETED = "_runtimeData" + QueryPath.getPathSeparator() + "deleted";
39   
 
40  0 toggle private MultiplicityGroupItemBinding() {};
41   
42    /**
43    * @see ModelWidgetBindingSupport#setModelValue(Object,
44    * org.kuali.student.common.ui.client.mvc.DataModel, String)
45    */
 
46  0 toggle @Override
47    public void setModelValue(MultiplicityGroupItem multiplicityItem, DataModel model, String path) {
48  0 String itemPath = QueryPath.concat(path, String.valueOf(multiplicityItem.getItemKey())).toString();
49  0 String itemRuntimePath = itemPath;
50  0 Widget widget = multiplicityItem.getItemWidget();
51  0 if (widget instanceof Section) {
52  0 itemPath = "";
53  0 SectionBinding.INSTANCE.setModelValue((Section) widget, model, itemPath);
54  0 } else if (widget instanceof ModelWidgetBinding) {
55  0 ((ModelWidgetBinding) widget).setModelValue(widget, model, path);
56    } else {
57  0 GWT.log(itemPath + " has no widget binding.", null);
58    }
59   
60    // Multiplicity metadata?
61  0 QueryPath qPath;
62  0 if (multiplicityItem.isCreated()) {
63  0 qPath = QueryPath.parse(itemRuntimePath + QueryPath.getPathSeparator() + RT_CREATED);
64  0 } else if (multiplicityItem.isDeleted()) {
65  0 qPath = QueryPath.parse(itemRuntimePath + QueryPath.getPathSeparator() + RT_DELETED);
66    } else {
67  0 qPath = QueryPath.parse(itemRuntimePath + QueryPath.getPathSeparator() + RT_UPDATED);
68    }
69  0 try {
70  0 Boolean oldValue = model.get(qPath);
71  0 Boolean newValue = true;
72  0 if (!nullsafeEquals(oldValue, newValue)) {
73  0 model.set(qPath, newValue);
74  0 setDirtyFlag(model, qPath);
75    }
76    } catch (IllegalArgumentException e) {
77    // model.get(qPath) will throw this exception if there is no such path
78  0 GWT.log("Warning: Ignoring error attempting to setValue for " + widget.getClass().getName() + " path: " + qPath, e);
79    }
80   
81    }
82   
83    /**
84    * @see ModelWidgetBindingSupport#setWidgetValue(Object,
85    * org.kuali.student.common.ui.client.mvc.DataModel, String)
86    */
 
87  0 toggle @Override
88    public void setWidgetValue(MultiplicityGroupItem multiplicityItem, DataModel model, String path) {
89    // String itemPath = path + QueryPath.getPathSeparator() + multiplicityItem.getItemKey();
90  0 String itemPath ="";
91  0 Widget widget = multiplicityItem.getItemWidget();
92  0 if (widget instanceof Section) {
93  0 SectionBinding.INSTANCE.setWidgetValue((Section) widget, model, itemPath);
94  0 } else if (widget instanceof ModelWidgetBinding) {
95  0 ((ModelWidgetBinding) widget).setWidgetValue(widget, model, path);
96    } else {
97  0 GWT.log(itemPath + " has no widget binding.", null);
98    }
99   
100  0 multiplicityItem.setCreated(false);
101  0 multiplicityItem.setCreated(false);
102    }
103   
104   
105    }