1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.util;
17
18 import org.kuali.rice.krad.uif.component.BindingInfo;
19 import org.kuali.rice.krad.uif.component.Component;
20 import org.kuali.rice.krad.uif.container.Group;
21 import org.kuali.rice.krad.uif.container.TreeGroup;
22 import org.kuali.rice.krad.uif.field.DataField;
23 import org.kuali.rice.krad.uif.util.ComponentUtils;
24 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
25 import org.kuali.rice.krad.uif.view.View;
26 import org.kuali.rice.krms.dto.AgendaEditor;
27 import org.kuali.rice.krms.service.RuleViewHelperService;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32
33
34
35 public class AgendaSection extends Group {
36
37 private String propertyName;
38 private BindingInfo bindingInfo;
39
40 private Group agendaPrototype;
41 private Group rulePrototype;
42
43 private AgendaBuilder agendaBuilder;
44
45 @Override
46 public void performInitialization(View view, Object model) {
47 setFieldBindingObjectPath(getBindingInfo().getBindingObjectPath());
48
49 super.performInitialization(view, model);
50
51 if (bindingInfo != null) {
52 bindingInfo.setDefaults(view, getPropertyName());
53 }
54
55 }
56
57 @Override
58 public void performApplyModel(View view, Object model, Component parent) {
59
60 List<Object> modelCollection = ObjectPropertyUtils.getPropertyValue(model,
61 this.getBindingInfo().getBindingPath());
62
63
64 this.getAgendaBuilder().setViewHelperService((RuleViewHelperService) view.getViewHelperService());
65
66
67 List<Component> items = new ArrayList<Component>();
68 for (int index = 0; index < modelCollection.size(); index++) {
69 AgendaEditor agenda = (AgendaEditor) modelCollection.get(index);
70 items.add(this.getAgendaBuilder().buildAgenda(agenda, index, this));
71 }
72 this.setItems(items);
73
74 super.performApplyModel(view, model, parent);
75 }
76
77 @Override
78 public List<Component> getComponentsForLifecycle() {
79 return super.getComponentsForLifecycle();
80 }
81
82 @Override
83 public List<Component> getComponentPrototypes() {
84 List<Component> components = super.getComponentPrototypes();
85 components.add(this.getAgendaPrototype());
86 components.add(this.getRulePrototype());
87
88 return components;
89 }
90
91 public AgendaBuilder getAgendaBuilder() {
92 if (this.agendaBuilder == null) {
93 this.agendaBuilder = new AgendaBuilder();
94 }
95 return this.agendaBuilder;
96 }
97
98 public String getPropertyName() {
99 return propertyName;
100 }
101
102 public void setPropertyName(String propertyName) {
103 this.propertyName = propertyName;
104 }
105
106 public BindingInfo getBindingInfo() {
107 return bindingInfo;
108 }
109
110 public void setBindingInfo(BindingInfo bindingInfo) {
111 this.bindingInfo = bindingInfo;
112 }
113
114 public Group getAgendaPrototype() {
115 return agendaPrototype;
116 }
117
118 public void setAgendaPrototype(Group agendaPrototype) {
119 this.agendaPrototype = agendaPrototype;
120 }
121
122 public Group getRulePrototype() {
123 return rulePrototype;
124 }
125
126 public void setRulePrototype(Group rulePrototype) {
127 this.rulePrototype = rulePrototype;
128 }
129 }