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 String ruleEditorMessage;
53 private boolean addRuleInProgress = false;
54 private Map<String, String> customAttributesMap = new HashMap<String, String>();
55 private Map<String, String> customRuleAttributesMap = new HashMap<String, String>();
56 private Map<String, String> customRuleActionAttributesMap = new HashMap<String, String>();
57
58 public AgendaEditor() {
59 agenda = new AgendaBo();
60
61 agenda.setTypeId("");
62 agendaItemLine = new AgendaItemBo();
63 agendaItemLineRuleAction = new ActionBo();
64 }
65
66 private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
67 Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
68 child.setNodeLabel(agendaItem.getRuleText());
69 child.setNodeType("agendaNode ruleNode");
70 child.setData(new AgendaTreeRuleNode(agendaItem));
71 parent.getChildren().add(child);
72
73
74 if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
75
76
77 if (agendaItem.getWhenTrue() != null) {
78 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
79 whenTrue.setNodeLabel("When TRUE");
80 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
81 whenTrue.setData(new AgendaTreeLogicNode());
82 child.getChildren().add(whenTrue);
83
84 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
85 }
86 if (agendaItem.getWhenFalse() != null) {
87 Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
88 whenFalse.setNodeLabel("When FALSE");
89 whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
90 whenFalse.setData(new AgendaTreeLogicNode());
91 child.getChildren().add(whenFalse);
92
93 addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
94 }
95 }
96
97 public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
98 Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
99
100 Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
101 agendaTree.setRootElement(rootNode);
102
103 if (agenda != null) {
104 String firstItemId = agenda.getFirstItemId();
105 List<AgendaItemBo> items = agenda.getItems();
106 AgendaItemBo firstItem = null;
107
108 if (items != null && firstItemId != null) {
109 for (AgendaItemBo item : items) {
110 if (firstItemId.equals(item.getId())) {
111 firstItem = item;
112 break;
113 }
114 }
115 }
116
117 if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
118 }
119
120 return agendaTree;
121 }
122
123
124
125
126 public AgendaItemBo getAgendaItemLine() {
127 return this.agendaItemLine;
128 }
129
130
131
132
133 public void setAgendaItemLine(AgendaItemBo agendaItemLine) {
134 this.agendaItemLine = agendaItemLine;
135 }
136
137 public ActionBo getAgendaItemLineRuleAction() {
138 return agendaItemLineRuleAction;
139 }
140
141 public void setAgendaItemLineRuleAction(ActionBo actionBo) {
142 this.agendaItemLineRuleAction = actionBo;
143 }
144
145
146
147
148 public String getSelectedAgendaItemId() {
149 return this.selectedAgendaItemId;
150 }
151
152
153
154
155 public void setSelectedAgendaItemId(String selectedAgendaItemId) {
156 this.selectedAgendaItemId = selectedAgendaItemId;
157 }
158
159
160
161
162 public String getCutAgendaItemId() {
163 return this.cutAgendaItemId;
164 }
165
166
167
168
169 public void setCutAgendaItemId(String cutAgendaItemId) {
170 this.cutAgendaItemId = cutAgendaItemId;
171 }
172
173
174
175
176 public ContextBo getContext() {
177 return this.context;
178 }
179
180
181
182
183 public void setContext(ContextBo context) {
184 this.context = context;
185 }
186
187
188
189
190 public AgendaBo getAgenda() {
191 return this.agenda;
192 }
193
194
195
196
197 public void setAgenda(AgendaBo agenda) {
198 this.agenda = agenda;
199 }
200
201 public Map<String, String> getCustomAttributesMap() {
202 return customAttributesMap;
203 }
204
205 public void setCustomAttributesMap(Map<String, String> customAttributesMap) {
206 this.customAttributesMap = customAttributesMap;
207 }
208
209 public Map<String, String> getCustomRuleAttributesMap() {
210 return customRuleAttributesMap;
211 }
212
213 public void setCustomRuleAttributesMap(Map<String, String> customRuleAttributesMap) {
214 this.customRuleAttributesMap = customRuleAttributesMap;
215 }
216
217 public Map<String, String> getCustomRuleActionAttributesMap() {
218 return customRuleActionAttributesMap;
219 }
220
221 public void setCustomRuleActionAttributesMap(Map<String, String> customRuleActionAttributesMap) {
222 this.customRuleActionAttributesMap = customRuleActionAttributesMap;
223 }
224
225
226
227
228 public void setCopyRuleName(String copyRuleName) {
229 this.copyRuleName = copyRuleName;
230 }
231
232
233
234
235 public String getCopyRuleName() {
236 return copyRuleName;
237 }
238
239
240
241
242 public void setOldContextId(String oldContextId) {
243 this.oldContextId = oldContextId;
244 }
245
246
247
248
249 public String getOldContextId() {
250 return oldContextId;
251 }
252
253
254
255
256 public String getSelectedPropositionId() {
257 return this.selectedPropositionId;
258 }
259
260
261
262
263 public void setSelectedPropositionId(String selectedPropositionId) {
264 this.selectedPropositionId = selectedPropositionId;
265 }
266
267
268
269
270
271 public String getCutPropositionId() {
272 return cutPropositionId;
273 }
274
275 public String getContextName() {
276 return contextName;
277 }
278
279 public void setContextName(String contextName) {
280 this.contextName = contextName;
281 }
282
283 public String getNamespace() {
284 return namespace;
285 }
286
287 public void setNamespace(String namespace) {
288 this.namespace = namespace;
289 }
290
291 public String getRuleEditorMessage() {
292 return this.ruleEditorMessage;
293 }
294
295 public void setRuleEditorMessage(String message) {
296 this.ruleEditorMessage = message;
297 }
298
299 public boolean isAddRuleInProgress() {
300 return addRuleInProgress;
301 }
302
303 public void setAddRuleInProgress(boolean addRuleInProgress) {
304 this.addRuleInProgress = addRuleInProgress;
305 }
306
307
308
309
310 public void setCutPropositionId(String cutPropositionId) {
311 this.cutPropositionId = cutPropositionId;
312 }
313
314
315 @Override
316 public void refreshNonUpdateableReferences() {
317 getPersistenceService().refreshAllNonUpdatingReferences(this.getAgenda());
318 }
319
320 }