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