1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
package net.smartlab.web; |
24 |
|
|
25 |
|
import java.beans.Introspector; |
26 |
|
import java.beans.PropertyDescriptor; |
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.List; |
29 |
|
import javax.servlet.ServletRequest; |
30 |
|
import javax.servlet.http.HttpServletRequest; |
31 |
|
import javax.servlet.http.HttpServletResponse; |
32 |
|
import net.smartlab.web.DataAccessObject.SearchInfo; |
33 |
|
import org.apache.struts.action.ActionForm; |
34 |
|
import org.apache.struts.action.ActionMapping; |
35 |
|
import org.apache.struts.action.DynaActionForm; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@author |
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 0% |
Uncovered Elements: 52 (52) |
Complexity: 16 |
Complexity Density: 0,55 |
|
47 |
|
public abstract class AbstractArchiveAction extends DynaAction { |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
public final static String SELECTION = "selection"; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
@param |
61 |
|
@param |
62 |
|
@param |
63 |
|
@return |
64 |
|
@throws |
65 |
|
|
66 |
|
|
67 |
|
public abstract String search(ActionForm form, HttpServletRequest request, HttpServletResponse response, |
68 |
|
ActionMapping mapping) throws Exception; |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@param |
74 |
|
@param |
75 |
|
@param |
76 |
|
@param |
77 |
|
@return |
78 |
|
@throws |
79 |
|
|
80 |
|
|
81 |
|
public abstract String select(ActionForm form, HttpServletRequest request, HttpServletResponse response, |
82 |
|
ActionMapping mapping) throws Exception; |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
@param |
89 |
|
@param |
90 |
|
@param |
91 |
|
@return |
92 |
|
@throws |
93 |
|
|
94 |
|
|
95 |
|
public abstract String update(ActionForm form, HttpServletRequest request, HttpServletResponse response, |
96 |
|
ActionMapping mapping) throws Exception; |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
@param |
102 |
|
@param |
103 |
|
@param |
104 |
|
@param |
105 |
|
@return |
106 |
|
@throws |
107 |
|
|
108 |
|
|
109 |
|
public abstract String remove(ActionForm form, HttpServletRequest request, HttpServletResponse response, |
110 |
|
ActionMapping mapping) throws Exception; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@param |
117 |
|
@param |
118 |
|
@param |
119 |
|
@param |
120 |
|
@return |
121 |
|
@throws |
122 |
|
|
123 |
|
|
124 |
|
public abstract String removeAll(ActionForm form, HttpServletRequest request, HttpServletResponse response, |
125 |
|
ActionMapping mapping) throws Exception; |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
@param |
131 |
|
@return |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0
|
public String[] getListSelection(ServletRequest request) {... |
134 |
0
|
return request.getParameterValues("selection"); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@param |
141 |
|
@param |
142 |
|
@param |
143 |
|
@return |
144 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 10 |
Complexity Density: 0,59 |
|
145 |
0
|
public String[] getSelection(ActionForm form, String name) {... |
146 |
0
|
String[] values = null; |
147 |
0
|
if (form instanceof DynaActionForm) { |
148 |
0
|
values = (String[])((DynaActionForm)form).get(name); |
149 |
|
} else { |
150 |
0
|
try { |
151 |
0
|
PropertyDescriptor[] descriptors = Introspector.getBeanInfo(form.getClass()).getPropertyDescriptors(); |
152 |
0
|
for (int i = 0; i < descriptors.length; i++) { |
153 |
0
|
if (descriptors[i].getName().equals(name)) { |
154 |
0
|
values = (String[])descriptors[i].getReadMethod().invoke(form, null); |
155 |
|
} |
156 |
|
} |
157 |
|
} catch (Exception e) { |
158 |
|
|
159 |
|
logger.warn(e); |
160 |
|
} |
161 |
|
} |
162 |
0
|
if (values.length == 0) { |
163 |
0
|
return null; |
164 |
0
|
} else if (values.length == 1 && EmptyMarkerTag.EMPTY_MARKER.equals(values[0])) { |
165 |
0
|
return new String[0]; |
166 |
|
} else { |
167 |
0
|
List selection = new ArrayList(); |
168 |
0
|
for (int i = 0; i < values.length; i++) { |
169 |
0
|
if (!EmptyMarkerTag.EMPTY_MARKER.equals(values[i])) { |
170 |
0
|
selection.add(values[i]); |
171 |
|
} |
172 |
|
} |
173 |
0
|
return (String[])selection.toArray(new String[selection.size()]); |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
@param |
181 |
|
@param |
182 |
|
@param |
183 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
184 |
0
|
public void setSelection(ActionForm form, String name, String[] values) {... |
185 |
0
|
if (form instanceof DynaActionForm) { |
186 |
0
|
((DynaActionForm)form).set(name, values); |
187 |
|
} else { |
188 |
|
|
189 |
0
|
throw new ClassCastException(); |
190 |
|
} |
191 |
|
} |
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
@param |
197 |
|
@param |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
199 |
0
|
public void resetSelection(ActionForm form, String name) {... |
200 |
0
|
if (form instanceof DynaActionForm) { |
201 |
0
|
((DynaActionForm)form).set(name, new String[0]); |
202 |
|
} else { |
203 |
|
|
204 |
0
|
throw new ClassCastException(); |
205 |
|
} |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
@param |
213 |
|
@return |
214 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
|
215 |
0
|
public SearchInfo getSearchInfo(ServletRequest request) {... |
216 |
0
|
SearchInfo info = new SearchInfo(); |
217 |
0
|
info.setFilters(request.getParameterValues("filter")); |
218 |
0
|
info.setUnion(request.getParameter("union")); |
219 |
0
|
info.setOrder(request.getParameter("order")); |
220 |
0
|
return info; |
221 |
|
} |
222 |
|
} |