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 | 0 | 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 | 0 | Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>(); |
44 | 0 | child.setNodeLabel(agendaItem.getRuleText()); |
45 | 0 | child.setNodeType("agendaNode ruleNode"); |
46 | 0 | child.setData(new AgendaTreeRuleNode(agendaItem)); |
47 | 0 | parent.getChildren().add(child); |
48 | |
|
49 | |
|
50 | 0 | if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways()); |
51 | |
|
52 | |
|
53 | 0 | if (agendaItem.getWhenTrue() != null) { |
54 | 0 | Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>(); |
55 | 0 | whenTrue.setNodeLabel("When TRUE"); |
56 | 0 | whenTrue.setNodeType("agendaNode logicNode whenTrueNode"); |
57 | 0 | whenTrue.setData(new AgendaTreeLogicNode()); |
58 | 0 | child.getChildren().add(whenTrue); |
59 | |
|
60 | 0 | addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue()); |
61 | |
} |
62 | 0 | if (agendaItem.getWhenFalse() != null) { |
63 | 0 | Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>(); |
64 | 0 | whenFalse.setNodeLabel("When FALSE"); |
65 | 0 | whenFalse.setNodeType("agendaNode logicNode whenFalseNode"); |
66 | 0 | whenFalse.setData(new AgendaTreeLogicNode()); |
67 | 0 | child.getChildren().add(whenFalse); |
68 | |
|
69 | 0 | addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse()); |
70 | |
} |
71 | 0 | } |
72 | |
|
73 | |
public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() { |
74 | 0 | Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>(); |
75 | |
|
76 | 0 | Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>(); |
77 | 0 | agendaTree.setRootElement(rootNode); |
78 | |
|
79 | 0 | if (agenda != null) { |
80 | 0 | String firstItemId = agenda.getFirstItemId(); |
81 | 0 | List<AgendaItemBo> items = agenda.getItems(); |
82 | 0 | AgendaItemBo firstItem = null; |
83 | |
|
84 | 0 | if (items != null && firstItemId != null) { |
85 | 0 | for (AgendaItemBo item : items) { |
86 | 0 | if (firstItemId.equals(item.getId())) { |
87 | 0 | firstItem = item; |
88 | 0 | break; |
89 | |
} |
90 | |
} |
91 | |
} |
92 | |
|
93 | 0 | if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem); |
94 | |
} |
95 | |
|
96 | 0 | return agendaTree; |
97 | |
} |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
public AgendaItemBo getAgendaItemAddLine() { |
103 | 0 | return this.agendaItemAddLine; |
104 | |
} |
105 | |
|
106 | |
|
107 | |
|
108 | |
public void setAgendaItemAddLine(AgendaItemBo agendaItemAddLine) { |
109 | 0 | this.agendaItemAddLine = agendaItemAddLine; |
110 | 0 | } |
111 | |
|
112 | |
|
113 | |
|
114 | |
public ContextBo getContext() { |
115 | 0 | return this.context; |
116 | |
} |
117 | |
|
118 | |
|
119 | |
|
120 | |
public void setContext(ContextBo context) { |
121 | 0 | this.context = context; |
122 | 0 | } |
123 | |
|
124 | |
|
125 | |
|
126 | |
public AgendaBo getAgenda() { |
127 | 0 | return this.agenda; |
128 | |
} |
129 | |
|
130 | |
|
131 | |
|
132 | |
public void setAgenda(AgendaBo agenda) { |
133 | 0 | this.agenda = agenda; |
134 | 0 | } |
135 | |
|
136 | |
|
137 | |
} |