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