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.krms.impl.repository.ActionBo;
21 import org.kuali.rice.krms.impl.repository.AgendaBo;
22 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
23 import org.kuali.rice.krms.impl.repository.ContextBo;
24
25 import java.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31
32
33
34
35
36
37 public class AgendaEditor implements Serializable {
38
39 private static final long serialVersionUID = 1L;
40
41 private ContextBo context;
42 private String namespace;
43 private AgendaBo agenda;
44 private String contextName;
45 private AgendaItemBo agendaItemLine;
46 private ActionBo agendaItemLineRuleAction;
47 private String selectedAgendaItemId;
48 private String cutAgendaItemId;
49 private String selectedPropositionId;
50 private String cutPropositionId;
51 private List<String> deletedPropositionIdsFromRule = new ArrayList<>();
52 private List<String> deletedPropositionIds = new ArrayList<>();
53 private String copyRuleName;
54 private String oldContextId;
55 private String ruleEditorMessage;
56 private boolean addRuleInProgress = false;
57 private boolean disableButtons = false;
58 private Map<String, String> customAttributesMap = new HashMap<String, String>();
59 private Map<String, String> customRuleAttributesMap = new HashMap<String, String>();
60 private Map<String, String> customRuleActionAttributesMap = new HashMap<String, String>();
61
62 public AgendaEditor() {
63 agenda = new AgendaBo();
64
65 agenda.setTypeId("");
66 agendaItemLine = new AgendaItemBo();
67 agendaItemLineRuleAction = new ActionBo();
68 }
69
70 private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
71 Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
72 child.setNodeLabel(agendaItem.getRuleText());
73 child.setNodeType("agendaNode ruleNode");
74 child.setData(new AgendaTreeRuleNode(agendaItem));
75 parent.getChildren().add(child);
76
77
78 if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
79
80
81 if (agendaItem.getWhenTrue() != null) {
82 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
83 whenTrue.setNodeLabel("When TRUE");
84 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
85 whenTrue.setData(new AgendaTreeLogicNode());
86 child.getChildren().add(whenTrue);
87
88 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
89 }
90 if (agendaItem.getWhenFalse() != null) {
91 Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
92 whenFalse.setNodeLabel("When FALSE");
93 whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
94 whenFalse.setData(new AgendaTreeLogicNode());
95 child.getChildren().add(whenFalse);
96
97 addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
98 }
99 }
100
101 public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
102 Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
103
104 Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
105 agendaTree.setRootElement(rootNode);
106
107 if (agenda != null) {
108 String firstItemId = agenda.getFirstItemId();
109 List<AgendaItemBo> items = agenda.getItems();
110 AgendaItemBo firstItem = null;
111
112 if (items != null && firstItemId != null) {
113 for (AgendaItemBo item : items) {
114 if (firstItemId.equals(item.getId())) {
115 firstItem = item;
116 break;
117 }
118 }
119 }
120
121 if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
122 }
123
124 return agendaTree;
125 }
126
127
128
129
130 public AgendaItemBo getAgendaItemLine() {
131 return this.agendaItemLine;
132 }
133
134
135
136
137 public void setAgendaItemLine(AgendaItemBo agendaItemLine) {
138 this.agendaItemLine = agendaItemLine;
139 }
140
141 public ActionBo getAgendaItemLineRuleAction() {
142 return agendaItemLineRuleAction;
143 }
144
145 public void setAgendaItemLineRuleAction(ActionBo actionBo) {
146 this.agendaItemLineRuleAction = actionBo;
147 }
148
149
150
151
152 public String getSelectedAgendaItemId() {
153 return this.selectedAgendaItemId;
154 }
155
156
157
158
159 public void setSelectedAgendaItemId(String selectedAgendaItemId) {
160 this.selectedAgendaItemId = selectedAgendaItemId;
161 }
162
163
164
165
166 public String getCutAgendaItemId() {
167 return this.cutAgendaItemId;
168 }
169
170
171
172
173 public void setCutAgendaItemId(String cutAgendaItemId) {
174 this.cutAgendaItemId = cutAgendaItemId;
175 }
176
177
178
179
180 public ContextBo getContext() {
181 return this.context;
182 }
183
184
185
186
187 public void setContext(ContextBo context) {
188 this.context = context;
189 }
190
191
192
193
194 public AgendaBo getAgenda() {
195 return this.agenda;
196 }
197
198
199
200
201 public void setAgenda(AgendaBo agenda) {
202 this.agenda = agenda;
203 }
204
205 public Map<String, String> getCustomAttributesMap() {
206 return customAttributesMap;
207 }
208
209 public void setCustomAttributesMap(Map<String, String> customAttributesMap) {
210 this.customAttributesMap = customAttributesMap;
211 }
212
213 public Map<String, String> getCustomRuleAttributesMap() {
214 return customRuleAttributesMap;
215 }
216
217 public void setCustomRuleAttributesMap(Map<String, String> customRuleAttributesMap) {
218 this.customRuleAttributesMap = customRuleAttributesMap;
219 }
220
221 public Map<String, String> getCustomRuleActionAttributesMap() {
222 return customRuleActionAttributesMap;
223 }
224
225 public void setCustomRuleActionAttributesMap(Map<String, String> customRuleActionAttributesMap) {
226 this.customRuleActionAttributesMap = customRuleActionAttributesMap;
227 }
228
229
230
231
232 public void setCopyRuleName(String copyRuleName) {
233 this.copyRuleName = copyRuleName;
234 }
235
236
237
238
239 public String getCopyRuleName() {
240 return copyRuleName;
241 }
242
243
244
245
246 public void setOldContextId(String oldContextId) {
247 this.oldContextId = oldContextId;
248 }
249
250
251
252
253 public String getOldContextId() {
254 return oldContextId;
255 }
256
257
258
259
260 public String getSelectedPropositionId() {
261 return this.selectedPropositionId;
262 }
263
264
265
266
267 public void setSelectedPropositionId(String selectedPropositionId) {
268 this.selectedPropositionId = selectedPropositionId;
269 }
270
271
272
273
274
275 public String getCutPropositionId() {
276 return cutPropositionId;
277 }
278
279
280
281
282
283
284 public List<String> getDeletedPropositionIdsFromRule() {
285 return deletedPropositionIdsFromRule;
286 }
287
288
289
290
291
292
293 public void setDeletedPropositionIdsFromRule(List<String> deletedPropositionIdsFromRule) {
294 this.deletedPropositionIdsFromRule = deletedPropositionIdsFromRule;
295 }
296
297
298
299
300
301
302 public List<String> getDeletedPropositionIds() {
303 return deletedPropositionIds;
304 }
305
306
307
308
309
310
311 public void setDeletedPropositionIds(List<String> deletedPropositionIds) {
312 this.deletedPropositionIds = deletedPropositionIds;
313 }
314
315 public void addDeletedPropositionIdFromRule(String propId) {
316 getDeletedPropositionIdsFromRule().add(propId);
317 }
318
319
320
321
322
323
324
325 public void clearDeletedPropositionIdsFromRule() {
326 getDeletedPropositionIdsFromRule().clear();
327 }
328
329
330
331
332
333
334
335 public void applyDeletedPropositionIdsFromRule() {
336 getDeletedPropositionIds().addAll(getDeletedPropositionIdsFromRule());
337 clearDeletedPropositionIdsFromRule();
338 }
339
340 public String getContextName() {
341 return contextName;
342 }
343
344 public void setContextName(String contextName) {
345 this.contextName = contextName;
346 }
347
348 public String getNamespace() {
349 return namespace;
350 }
351
352 public void setNamespace(String namespace) {
353 this.namespace = namespace;
354 }
355
356 public String getRuleEditorMessage() {
357 return this.ruleEditorMessage;
358 }
359
360 public void setRuleEditorMessage(String message) {
361 this.ruleEditorMessage = message;
362 }
363
364 public boolean isAddRuleInProgress() {
365 return addRuleInProgress;
366 }
367
368 public void setAddRuleInProgress(boolean addRuleInProgress) {
369 this.addRuleInProgress = addRuleInProgress;
370 }
371
372
373
374
375
376 public boolean isDisableButtons() {
377 return disableButtons;
378 }
379
380
381
382
383
384
385 public void setDisableButtons(boolean disableButtons) {
386 this.disableButtons = disableButtons;
387 }
388
389
390
391
392 public void setCutPropositionId(String cutPropositionId) {
393 this.cutPropositionId = cutPropositionId;
394 }
395 }