| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 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 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 11 |
Complexity Density: 0.35 |
|
| 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 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 40 |
0
|
private MultiplicityGroupItemBinding() {};... |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@see |
| 44 |
|
|
| 45 |
|
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 7 |
Complexity Density: 0.32 |
|
| 46 |
0
|
@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 |
|
|
| 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 |
|
|
| 78 |
0
|
GWT.log("Warning: Ignoring error attempting to setValue for " + widget.getClass().getName() + " path: " + qPath, e); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
@see |
| 85 |
|
|
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 87 |
0
|
@Override... |
| 88 |
|
public void setWidgetValue(MultiplicityGroupItem multiplicityItem, DataModel model, String path) { |
| 89 |
|
|
| 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 |
|
} |