1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.web.form;
17
18 import org.kuali.rice.krad.uif.element.BreadcrumbItem;
19 import org.kuali.rice.krad.uif.util.UrlInfo;
20
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Stack;
25
26
27
28
29
30
31
32 public class HistoryFlow implements Serializable {
33 private static final long serialVersionUID = 452587887145986691L;
34
35 protected String flowKey;
36 protected String flowReturnPoint;
37 protected String flowStartPoint;
38
39 protected Stack<UrlInfo> flowUrls = new Stack<UrlInfo>();
40
41 protected BreadcrumbItem currentViewItem;
42 protected List<BreadcrumbItem> pastItems;
43
44
45
46
47
48
49 public HistoryFlow (String flowKey) {
50 this.flowKey = flowKey;
51 }
52
53
54
55
56
57
58 public Stack<UrlInfo> getFlowUrls() {
59 return flowUrls;
60 }
61
62
63
64
65
66
67 public void setFlowUrls(Stack<UrlInfo> flowUrls) {
68 this.flowUrls = flowUrls;
69 }
70
71
72
73
74
75
76 public String getFlowReturnPoint() {
77 return flowReturnPoint;
78 }
79
80
81
82
83
84
85 public void setFlowReturnPoint(String flowReturnPoint) {
86 this.flowReturnPoint = flowReturnPoint;
87 }
88
89
90
91
92
93
94 public String getFlowStartPoint() {
95 return flowStartPoint;
96 }
97
98
99
100
101 public void setFlowStartPoint(String flowStartPoint) {
102 this.flowStartPoint = flowStartPoint;
103 }
104
105
106
107
108
109
110 public String getFlowKey() {
111 return flowKey;
112 }
113
114
115
116
117
118
119 public void setFlowKey(String flowKey) {
120 this.flowKey = flowKey;
121 }
122
123
124
125
126
127
128 public void push(String url){
129 UrlInfo urlInfo = new UrlInfo();
130 urlInfo.setHref(url);
131 flowUrls.push(urlInfo);
132 }
133
134
135
136
137
138
139 public void push(UrlInfo urlInfo){
140 flowUrls.push(urlInfo);
141 }
142
143
144
145
146
147
148 public void update(String url){
149 UrlInfo urlInfo = new UrlInfo();
150 urlInfo.setHref(url);
151
152 if(flowUrls.empty()){
153 flowUrls.push(urlInfo);
154 }
155 else{
156 flowUrls.pop();
157 flowUrls.push(urlInfo);
158 }
159 }
160
161
162
163
164
165
166 public void update(UrlInfo urlInfo){
167 if(flowUrls.empty()){
168 flowUrls.push(urlInfo);
169 }
170 else{
171 flowUrls.pop();
172 flowUrls.push(urlInfo);
173 }
174 }
175
176
177
178
179
180
181 public String getCurrentLocation(){
182 if(flowUrls != null && !flowUrls.isEmpty()){
183 return flowUrls.peek().getHref();
184 }
185
186 return null;
187 }
188
189
190
191
192 public void clear(){
193 flowUrls.clear();
194 pastItems.clear();
195 currentViewItem = null;
196 flowReturnPoint = null;
197 }
198
199
200
201
202
203
204
205
206 public void continueFlow(HistoryFlow prevFlow){
207 if(prevFlow != null){
208 flowReturnPoint = prevFlow.getCurrentLocation();
209 this.setFlowUrls(prevFlow.getFlowUrls());
210
211 if(this.getFlowUrls() != null && !this.getFlowUrls().isEmpty()){
212 flowStartPoint = this.getFlowUrls().firstElement().getHref();
213 }
214
215 pastItems = new ArrayList<BreadcrumbItem>();
216
217 if (prevFlow.getPastItems() != null){
218 pastItems.addAll(prevFlow.getPastItems());
219 }
220
221 if (prevFlow.getCurrentViewItem() != null){
222 pastItems.add(prevFlow.getCurrentViewItem());
223 }
224 }
225 }
226
227
228
229
230
231
232 public BreadcrumbItem getCurrentViewItem() {
233 return currentViewItem;
234 }
235
236
237
238
239
240
241 public void setCurrentViewItem(BreadcrumbItem currentViewItem) {
242 this.currentViewItem = currentViewItem;
243 }
244
245
246
247
248
249
250 public List<BreadcrumbItem> getPastItems() {
251 return pastItems;
252 }
253
254
255
256
257
258
259 public void setPastItems(List<BreadcrumbItem> pastItems) {
260 this.pastItems = pastItems;
261 }
262 }