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 java.util.List;
19
20 import org.kuali.rice.core.util.Node;
21 import org.kuali.rice.core.util.Tree;
22 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23 import org.kuali.rice.krms.impl.repository.AgendaBo;
24 import org.kuali.rice.krms.impl.repository.AgendaItemBo;
25 import org.kuali.rice.krms.impl.repository.ContextBo;
26
27
28
29
30
31
32
33
34 public class AgendaEditor extends PersistableBusinessObjectBase {
35
36 private static final long serialVersionUID = 1L;
37
38 private ContextBo context;
39 private AgendaBo agenda;
40 private AgendaItemBo agendaItemAddLine;
41
42 private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) {
43 Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>();
44 child.setNodeLabel(agendaItem.getRuleText());
45 child.setNodeType("agendaNode ruleNode");
46 child.setData(new AgendaTreeRuleNode(agendaItem));
47 parent.getChildren().add(child);
48
49
50 if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways());
51
52
53 if (agendaItem.getWhenTrue() != null) {
54 Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>();
55 whenTrue.setNodeLabel("When TRUE");
56 whenTrue.setNodeType("agendaNode logicNode whenTrueNode");
57 whenTrue.setData(new AgendaTreeLogicNode());
58 child.getChildren().add(whenTrue);
59
60 addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue());
61 }
62 if (agendaItem.getWhenFalse() != null) {
63 Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>();
64 whenFalse.setNodeLabel("When FALSE");
65 whenFalse.setNodeType("agendaNode logicNode whenFalseNode");
66 whenFalse.setData(new AgendaTreeLogicNode());
67 child.getChildren().add(whenFalse);
68
69 addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse());
70 }
71 }
72
73 public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() {
74 Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>();
75
76 Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>();
77 agendaTree.setRootElement(rootNode);
78
79 if (agenda != null) {
80 String firstItemId = agenda.getFirstItemId();
81 List<AgendaItemBo> items = agenda.getItems();
82 AgendaItemBo firstItem = null;
83
84 if (items != null && firstItemId != null) {
85 for (AgendaItemBo item : items) {
86 if (firstItemId.equals(item.getId())) {
87 firstItem = item;
88 break;
89 }
90 }
91 }
92
93 if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem);
94 }
95
96 return agendaTree;
97 }
98
99
100
101
102 public AgendaItemBo getAgendaItemAddLine() {
103 return this.agendaItemAddLine;
104 }
105
106
107
108 public void setAgendaItemAddLine(AgendaItemBo agendaItemAddLine) {
109 this.agendaItemAddLine = agendaItemAddLine;
110 }
111
112
113
114 public ContextBo getContext() {
115 return this.context;
116 }
117
118
119
120 public void setContext(ContextBo context) {
121 this.context = context;
122 }
123
124
125
126 public AgendaBo getAgenda() {
127 return this.agenda;
128 }
129
130
131
132 public void setAgenda(AgendaBo agenda) {
133 this.agenda = agenda;
134 }
135
136
137 }