1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.ui;
17
18 import org.kuali.rice.core.api.util.tree.Node;
19 import org.kuali.rice.core.api.util.tree.Tree;
20 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21 import org.kuali.rice.krms.impl.repository.ActionBo;
22 import org.kuali.rice.krms.impl.repository.AgendaBo;
23 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
24 import org.kuali.rice.krms.impl.repository.ContextBo;
25
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29
30
31
32
33
34
35
36 public class AgendaEditor extends PersistableBusinessObjectBase {
37
38 private static final long serialVersionUID = 1L;
39
40 private ContextBo context;
41 private String namespace;
42 private AgendaBo agenda;
43 private String contextName;
44 private AgendaItemBo agendaItemLine;
45 private ActionBo agendaItemLineRuleAction;
46 private String selectedAgendaItemId;
47 private String cutAgendaItemId;
48 private String selectedPropositionId;
49 private String cutPropositionId;
50 private String copyRuleName;
51 private String oldContextId;
52 private Map<String, String> customAttributesMap = new HashMap<String, String>();
53 private Map<String, String> customRuleAttributesMap = new HashMap<String, String>();
54 private Map<String, String> customRuleActionAttributesMap = new HashMap<String, String>();
55
56 public AgendaEditor() {
57 agenda = new AgendaBo();
58
59 agenda.setTypeId("");
60 agendaItemLine = new AgendaItemBo();
61 agendaItemLineRuleAction = new ActionBo();
62 }
63
64 private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
65 Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
66 child.setNodeLabel(agendaItem.getRuleText());
67 child.setNodeType("agendaNode ruleNode");
68 child.setData(new AgendaTreeRuleNode(agendaItem));
69 parent.getChildren().add(child);
70
71
72 if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
73
74
75 if (agendaItem.getWhenTrue() != null) {
76 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
77 whenTrue.setNodeLabel("When TRUE");
78 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
79 whenTrue.setData(new AgendaTreeLogicNode());
80 child.getChildren().add(whenTrue);
81
82 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
83 }
84 if (agendaItem.getWhenFalse() != null) {
85 Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
86 whenFalse.setNodeLabel("When FALSE");
87 whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
88 whenFalse.setData(new AgendaTreeLogicNode());
89 child.getChildren().add(whenFalse);
90
91 addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
92 }
93 }
94
95 public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
96 Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
97
98 Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
99 agendaTree.setRootElement(rootNode);
100
101 if (agenda != null) {
102 String firstItemId = agenda.getFirstItemId();
103 List<AgendaItemBo> items = agenda.getItems();
104 AgendaItemBo firstItem = null;
105
106 if (items != null && firstItemId != null) {
107 for (AgendaItemBo item : items) {
108 if (firstItemId.equals(item.getId())) {
109 firstItem = item;
110 break;
111 }
112 }
113 }
114
115 if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
116 }
117
118 return agendaTree;
119 }
120
121
122
123
124 public AgendaItemBo getAgendaItemLine() {
125 return this.agendaItemLine;
126 }
127
128
129
130
131 public void setAgendaItemLine(AgendaItemBo agendaItemLine) {
132 this.agendaItemLine = agendaItemLine;
133 }
134
135 public ActionBo getAgendaItemLineRuleAction() {
136 return agendaItemLineRuleAction;
137 }
138
139 public void setAgendaItemLineRuleAction(ActionBo actionBo) {
140 this.agendaItemLineRuleAction = actionBo;
141 }
142
143
144
145
146 public String getSelectedAgendaItemId() {
147 return this.selectedAgendaItemId;
148 }
149
150
151
152
153 public void setSelectedAgendaItemId(String selectedAgendaItemId) {
154 this.selectedAgendaItemId = selectedAgendaItemId;
155 }
156
157
158
159
160 public String getCutAgendaItemId() {
161 return this.cutAgendaItemId;
162 }
163
164
165
166
167 public void setCutAgendaItemId(String cutAgendaItemId) {
168 this.cutAgendaItemId = cutAgendaItemId;
169 }
170
171
172
173
174 public ContextBo getContext() {
175 return this.context;
176 }
177
178
179
180
181 public void setContext(ContextBo context) {
182 this.context = context;
183 }
184
185
186
187
188 public AgendaBo getAgenda() {
189 return this.agenda;
190 }
191
192
193
194
195 public void setAgenda(AgendaBo agenda) {
196 this.agenda = agenda;
197 }
198
199 public Map<String, String> getCustomAttributesMap() {
200 return customAttributesMap;
201 }
202
203 public void setCustomAttributesMap(Map<String, String> customAttributesMap) {
204 this.customAttributesMap = customAttributesMap;
205 }
206
207 public Map<String, String> getCustomRuleAttributesMap() {
208 return customRuleAttributesMap;
209 }
210
211 public void setCustomRuleAttributesMap(Map<String, String> customRuleAttributesMap) {
212 this.customRuleAttributesMap = customRuleAttributesMap;
213 }
214
215 public Map<String, String> getCustomRuleActionAttributesMap() {
216 return customRuleActionAttributesMap;
217 }
218
219 public void setCustomRuleActionAttributesMap(Map<String, String> customRuleActionAttributesMap) {
220 this.customRuleActionAttributesMap = customRuleActionAttributesMap;
221 }
222
223
224
225
226 public void setCopyRuleName(String copyRuleName) {
227 this.copyRuleName = copyRuleName;
228 }
229
230
231
232
233 public String getCopyRuleName() {
234 return copyRuleName;
235 }
236
237
238
239
240 public void setOldContextId(String oldContextId) {
241 this.oldContextId = oldContextId;
242 }
243
244
245
246
247 public String getOldContextId() {
248 return oldContextId;
249 }
250
251
252
253
254 public String getSelectedPropositionId() {
255 return this.selectedPropositionId;
256 }
257
258
259
260
261 public void setSelectedPropositionId(String selectedPropositionId) {
262 this.selectedPropositionId = selectedPropositionId;
263 }
264
265
266
267
268
269 public String getCutPropositionId() {
270 return cutPropositionId;
271 }
272
273 public String getContextName() {
274 return contextName;
275 }
276
277 public void setContextName(String contextName) {
278 this.contextName = contextName;
279 }
280
281 public String getNamespace() {
282 return namespace;
283 }
284
285 public void setNamespace(String namespace) {
286 this.namespace = namespace;
287 }
288
289
290
291
292 public void setCutPropositionId(String cutPropositionId) {
293 this.cutPropositionId = cutPropositionId;
294 }
295
296
297 @Override
298 public void refreshNonUpdateableReferences() {
299 getPersistenceService().refreshAllNonUpdatingReferences(this.getAgenda());
300 }
301
302 }