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