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.util.ObjectUtils;
19 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
20 import org.kuali.rice.krms.dto.AgendaEditor;
21 import org.kuali.rice.krms.dto.RuleEditor;
22 import org.kuali.rice.krms.dto.RuleManagementWrapper;
23
24
25
26
27 public class AgendaUtilities {
28
29 public static RuleEditor retrieveSelectedRuleEditor(MaintenanceDocumentForm document) {
30
31 RuleManagementWrapper ruleWrapper = getRuleWrapper(document);
32 RuleEditor ruleEditor = getSelectedRuleEditor(ruleWrapper, getRuleKey(document));
33 ruleWrapper.setRuleEditor((RuleEditor) ObjectUtils.deepCopy(ruleEditor));
34
35 return ruleWrapper.getRuleEditor();
36 }
37
38 public static RuleEditor getSelectedRuleEditor(MaintenanceDocumentForm document) {
39 return AgendaUtilities.getSelectedRuleEditor(getRuleWrapper(document), getRuleKey(document));
40 }
41
42 public static RuleEditor getSelectedRuleEditor(RuleManagementWrapper wrapper, String ruleKey) {
43
44 AgendaEditor agendaEditor = getSelectedAgendaEditor(wrapper, ruleKey);
45 if (agendaEditor != null) {
46 return agendaEditor.getRuleEditors().get(ruleKey);
47 }
48
49 return null;
50 }
51
52 public static AgendaEditor getSelectedAgendaEditor(MaintenanceDocumentForm document) {
53 return AgendaUtilities.getSelectedAgendaEditor(getRuleWrapper(document), getRuleKey(document));
54 }
55
56 public static AgendaEditor getSelectedAgendaEditor(RuleManagementWrapper wrapper, String ruleKey) {
57
58 for (AgendaEditor agendaEditor : wrapper.getAgendas()) {
59 if (agendaEditor.getRuleEditors().containsKey(ruleKey)) {
60 return agendaEditor;
61 }
62 }
63
64 return null;
65 }
66
67 public static String getRuleKey(MaintenanceDocumentForm document) {
68 return document.getActionParamaterValue("ruleKey");
69 }
70
71 public static RuleManagementWrapper getRuleWrapper(MaintenanceDocumentForm document) {
72 return (RuleManagementWrapper) document.getDocument().getNewMaintainableObject().getDataObject();
73 }
74
75 }