1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.docsearch; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.HashMap; |
21 | |
import java.util.HashSet; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.List; |
24 | |
import java.util.Map; |
25 | |
import java.util.Set; |
26 | |
|
27 | |
import org.apache.commons.lang.StringUtils; |
28 | |
import org.kuali.rice.core.config.ConfigContext; |
29 | |
import org.kuali.rice.core.exception.RiceRuntimeException; |
30 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
31 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
32 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
33 | |
import org.kuali.rice.kew.util.KEWConstants; |
34 | |
import org.kuali.rice.kew.util.KEWPropertyConstants; |
35 | |
import org.kuali.rice.kew.util.Utilities; |
36 | |
import org.kuali.rice.kew.web.KeyValueSort; |
37 | |
import org.kuali.rice.kns.util.KNSConstants; |
38 | |
import org.kuali.rice.kns.web.format.Formatter; |
39 | |
import org.kuali.rice.kns.web.ui.Column; |
40 | |
import org.kuali.rice.kns.web.ui.Field; |
41 | |
import org.kuali.rice.kns.web.ui.Row; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | 0 | public class StandardDocumentSearchResultProcessor implements |
48 | |
DocumentSearchResultProcessor { |
49 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger |
50 | |
.getLogger(StandardDocumentSearchResultProcessor.class); |
51 | |
|
52 | 0 | private Map<String, Boolean> sortableByKey = new HashMap<String, Boolean>(); |
53 | 0 | private Map<String, String> labelsByKey = new HashMap<String, String>(); |
54 | |
private DocSearchCriteriaDTO searchCriteria; |
55 | |
private String searchingUser; |
56 | 0 | private boolean processFinalResults = true; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
public DocSearchCriteriaDTO getSearchCriteria() { |
62 | 0 | return searchCriteria; |
63 | |
} |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
public void setSearchCriteria(DocSearchCriteriaDTO searchCriteria) { |
70 | 0 | this.searchCriteria = searchCriteria; |
71 | 0 | } |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
public String getSearchingUser() { |
77 | 0 | return searchingUser; |
78 | |
} |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
public void setSearchingUser(String searchingUser) { |
85 | 0 | this.searchingUser = searchingUser; |
86 | 0 | } |
87 | |
|
88 | |
public List<Column> getCustomDisplayColumns() { |
89 | 0 | return new ArrayList<Column>(); |
90 | |
} |
91 | |
|
92 | |
public List<Column> setUpCustomDisplayColumns( |
93 | |
DocSearchCriteriaDTO criteria, List<Column> columns) { |
94 | 0 | for (Column column : columns) { |
95 | 0 | if (column instanceof Column) { |
96 | 0 | Column dsColumn = (Column) column; |
97 | 0 | for (org.kuali.rice.kns.web.ui.Field field : getFields(criteria)) { |
98 | 0 | if (field instanceof Field) { |
99 | 0 | Field dsField = (Field) field; |
100 | 0 | dsColumn.setFormatter((Formatter)dsField.getFormatter()); |
101 | 0 | } else { |
102 | 0 | throw new RiceRuntimeException( |
103 | |
"field must be of type org.kuali.rice.kew.docsearch.Field"); |
104 | |
} |
105 | |
} |
106 | 0 | } else { |
107 | 0 | throw new RiceRuntimeException( |
108 | |
"column must be of type org.kuali.rice.kew.docsearch.DocumentSearchColumn"); |
109 | |
} |
110 | |
} |
111 | 0 | return columns; |
112 | |
} |
113 | |
|
114 | |
public List<Column> getAndSetUpCustomDisplayColumns( |
115 | |
DocSearchCriteriaDTO criteria) { |
116 | 0 | List<Column> columns = getCustomDisplayColumns(); |
117 | 0 | return setUpCustomDisplayColumns(criteria, columns); |
118 | |
} |
119 | |
|
120 | |
public boolean getShowAllStandardFields() { |
121 | 0 | return true; |
122 | |
} |
123 | |
|
124 | |
public boolean getOverrideSearchableAttributes() { |
125 | 0 | return false; |
126 | |
} |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public SearchAttributeCriteriaComponent getSearchableAttributeByFieldName( |
137 | |
String name) { |
138 | 0 | if (StringUtils.isBlank(name)) { |
139 | 0 | throw new IllegalArgumentException( |
140 | |
"Attempted to find Searchable Attribute with blank Field name '" |
141 | |
+ name + "'"); |
142 | |
} |
143 | 0 | for (Iterator iter = getSearchCriteria().getSearchableAttributes() |
144 | 0 | .iterator(); iter.hasNext();) { |
145 | 0 | SearchAttributeCriteriaComponent critComponent = (SearchAttributeCriteriaComponent) iter |
146 | |
.next(); |
147 | 0 | if (name.equals(critComponent.getFormKey())) { |
148 | 0 | return critComponent; |
149 | |
} |
150 | 0 | } |
151 | 0 | return null; |
152 | |
} |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public DocumentSearchResultComponents processIntoFinalResults( |
163 | |
List<DocSearchDTO> docSearchResultRows, |
164 | |
DocSearchCriteriaDTO criteria, String principalId) { |
165 | 0 | this.setSearchCriteria(criteria); |
166 | 0 | this.setSearchingUser(principalId); |
167 | 0 | List columns = constructColumnList(criteria, docSearchResultRows); |
168 | |
|
169 | 0 | List<DocumentSearchResult> documentSearchResults = new ArrayList<DocumentSearchResult>(); |
170 | 0 | for (Iterator iter = docSearchResultRows.iterator(); iter.hasNext();) { |
171 | 0 | DocSearchDTO docCriteriaDTO = (DocSearchDTO) iter.next(); |
172 | 0 | DocumentSearchResult docSearchResult = this.generateSearchResult( |
173 | |
docCriteriaDTO, columns); |
174 | 0 | if (docSearchResult != null) { |
175 | 0 | documentSearchResults.add(docSearchResult); |
176 | |
} |
177 | 0 | } |
178 | 0 | return new DocumentSearchResultComponents(columns, |
179 | |
documentSearchResults); |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
public List<Column> constructColumnList( |
190 | |
DocSearchCriteriaDTO criteria, List<DocSearchDTO> docSearchResultRows) { |
191 | 0 | List<Column> tempColumns = new ArrayList<Column>(); |
192 | 0 | List<Column> customDisplayColumnNames = getAndSetUpCustomDisplayColumns(criteria); |
193 | 0 | if ((!getShowAllStandardFields()) |
194 | |
&& (getOverrideSearchableAttributes())) { |
195 | |
|
196 | 0 | this.addAllCustomColumns(tempColumns, criteria, |
197 | |
customDisplayColumnNames); |
198 | 0 | } else if (getShowAllStandardFields() |
199 | |
&& (getOverrideSearchableAttributes())) { |
200 | |
|
201 | |
|
202 | 0 | this.addStandardSearchColumns(tempColumns, docSearchResultRows); |
203 | 0 | this.addAllCustomColumns(tempColumns, criteria, |
204 | |
customDisplayColumnNames); |
205 | 0 | } else if ((!getShowAllStandardFields()) |
206 | |
&& (!getOverrideSearchableAttributes())) { |
207 | |
|
208 | 0 | this.addCustomStandardCriteriaColumns(tempColumns, criteria, |
209 | |
customDisplayColumnNames); |
210 | 0 | this |
211 | |
.addSearchableAttributeColumnsNoOverrides(tempColumns, |
212 | |
criteria); |
213 | |
} |
214 | 0 | if (tempColumns.isEmpty()) { |
215 | |
|
216 | 0 | this.addStandardSearchColumns(tempColumns, docSearchResultRows); |
217 | 0 | this.addSearchableAttributeColumnsNoOverrides(tempColumns, |
218 | |
criteria); |
219 | |
} |
220 | |
|
221 | 0 | List<Column> columns = new ArrayList<Column>(); |
222 | 0 | this.addRouteHeaderIdColumn(columns); |
223 | 0 | columns.addAll(tempColumns); |
224 | 0 | this.addRouteLogColumn(columns); |
225 | 0 | return columns; |
226 | |
} |
227 | |
|
228 | |
public void addStandardSearchColumns(List<Column> columns, List<DocSearchDTO> docSearchResultRows) { |
229 | 0 | this.addColumnUsingKey( |
230 | |
columns, |
231 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_TYPE_LABEL); |
232 | 0 | this.addColumnUsingKey( |
233 | |
columns, |
234 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOCUMENT_TITLE); |
235 | 0 | this.addColumnUsingKey( |
236 | |
columns, |
237 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_STATUS_DESC); |
238 | 0 | addDocStatusColumn(columns, docSearchResultRows); |
239 | 0 | this.addColumnUsingKey(columns, |
240 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR); |
241 | 0 | this.addColumnUsingKey( |
242 | |
columns, |
243 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DATE_CREATED); |
244 | 0 | } |
245 | |
|
246 | |
public void addRouteHeaderIdColumn(List<Column> columns) { |
247 | 0 | this |
248 | |
.addColumnUsingKey( |
249 | |
columns, |
250 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_HEADER_ID); |
251 | 0 | } |
252 | |
|
253 | |
public void addRouteLogColumn(List<Column> columns) { |
254 | 0 | this.addColumnUsingKey(columns, |
255 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_LOG); |
256 | 0 | } |
257 | |
|
258 | |
public void addDocStatusColumn(List<Column> columns, List<DocSearchDTO> docSearchResultRows) { |
259 | |
|
260 | 0 | for (DocSearchDTO myDTO : docSearchResultRows) { |
261 | 0 | DocumentType docType = KEWServiceLocator.getDocumentTypeService().findByName(myDTO.getDocTypeName()); |
262 | 0 | if (docType.isAppDocStatusInUse()){ |
263 | 0 | this.addColumnUsingKey(columns, |
264 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_STATUS); |
265 | 0 | break; |
266 | |
} |
267 | 0 | } |
268 | 0 | return; |
269 | |
} |
270 | |
|
271 | |
public void addSearchableAttributeColumnsNoOverrides( |
272 | |
List<Column> columns, DocSearchCriteriaDTO criteria) { |
273 | 0 | this |
274 | |
.addSearchableAttributeColumnsBasedOnFields(columns, criteria, |
275 | |
null); |
276 | 0 | } |
277 | |
|
278 | |
public void addSearchableAttributeColumnsBasedOnFields( |
279 | |
List<Column> columns, DocSearchCriteriaDTO criteria, |
280 | |
List<String> searchAttributeFieldNames) { |
281 | 0 | Set<String> alreadyProcessedFieldKeys = new HashSet<String>(); |
282 | 0 | List<Field> fields = this |
283 | |
.getFields(criteria, searchAttributeFieldNames); |
284 | 0 | for (Field field : fields) { |
285 | 0 | if (field instanceof Field) { |
286 | 0 | Field dsField = (Field) field; |
287 | 0 | if ((dsField.getPropertyName() == null) |
288 | |
|| (!alreadyProcessedFieldKeys.contains(dsField |
289 | |
.getPropertyName()))) { |
290 | 0 | if (dsField.isColumnVisible()) { |
291 | 0 | if (Field.SEARCH_RESULT_DISPLAYABLE_FIELD_TYPES |
292 | |
.contains(dsField.getFieldType())) { |
293 | 0 | String resultFieldLabel = dsField.getFieldLabel(); |
294 | 0 | if (dsField.isMemberOfRange()) { |
295 | 0 | resultFieldLabel = dsField.getMainFieldLabel(); |
296 | |
} |
297 | 0 | this.addSearchableAttributeColumnUsingKey(columns, |
298 | |
dsField.getFormatter(), dsField.getPropertyName(), |
299 | |
resultFieldLabel, Boolean.TRUE, |
300 | |
Boolean.TRUE); |
301 | 0 | if (dsField.getPropertyName() != null) { |
302 | 0 | alreadyProcessedFieldKeys.add(dsField |
303 | |
.getPropertyName()); |
304 | |
} |
305 | |
|
306 | |
} |
307 | |
} |
308 | |
} |
309 | 0 | } else { |
310 | 0 | throw new RiceRuntimeException( |
311 | |
"Fields must be of type org.kuali.rice.kew.docsearch.Field"); |
312 | |
} |
313 | |
} |
314 | 0 | } |
315 | |
|
316 | |
public void addAllCustomColumns(List<Column> columns, |
317 | |
DocSearchCriteriaDTO criteria, |
318 | |
List<Column> customDisplayColumns) { |
319 | 0 | for (Column customColumn : customDisplayColumns) { |
320 | 0 | this.addCustomColumn(columns, customColumn); |
321 | |
} |
322 | 0 | } |
323 | |
|
324 | |
public void addCustomStandardCriteriaColumns( |
325 | |
List<Column> columns, DocSearchCriteriaDTO criteria, |
326 | |
List<Column> customDisplayColumns) { |
327 | 0 | for (Column customColumn : customDisplayColumns) { |
328 | 0 | if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_SET |
329 | |
.contains(customColumn.getPropertyName())) { |
330 | 0 | this.addCustomColumn(columns, customColumn); |
331 | |
} |
332 | |
} |
333 | 0 | } |
334 | |
|
335 | |
public void addCustomColumn(List<Column> columns, |
336 | |
Column customColumn) { |
337 | |
|
338 | 0 | addColumnUsingKey(columns, |
339 | |
customColumn.getPropertyName(), customColumn.getColumnTitle(), new Boolean(customColumn.getSortable())); |
340 | 0 | } |
341 | |
|
342 | |
public List<Field> getFields(DocSearchCriteriaDTO criteria) { |
343 | 0 | return getFields(criteria, null); |
344 | |
} |
345 | |
|
346 | |
public DocumentType getDocumentType(String documentTypeName) { |
347 | 0 | DocumentType documentType = null; |
348 | 0 | if (StringUtils.isNotBlank(documentTypeName)) { |
349 | 0 | documentType = ((DocumentTypeService) KEWServiceLocator |
350 | |
.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE)) |
351 | |
.findByName(documentTypeName); |
352 | |
} |
353 | 0 | return documentType; |
354 | |
} |
355 | |
|
356 | |
public List<Field> getFields(DocSearchCriteriaDTO criteria, |
357 | |
List<String> searchAttributeFieldNames) { |
358 | 0 | List<Field> returnFields = new ArrayList<Field>(); |
359 | 0 | DocumentType documentType = getDocumentType(criteria |
360 | |
.getDocTypeFullName()); |
361 | 0 | if (documentType != null) { |
362 | 0 | List<Field> allFields = new ArrayList<Field>(); |
363 | 0 | for (SearchableAttribute searchableAttribute : documentType |
364 | |
.getSearchableAttributes()) { |
365 | 0 | List<Row> searchRows = searchableAttribute |
366 | |
.getSearchingRows(DocSearchUtils |
367 | |
.getDocumentSearchContext("", documentType |
368 | |
.getName(), "")); |
369 | 0 | if (searchRows == null) { |
370 | 0 | continue; |
371 | |
} |
372 | 0 | for (Row row : searchRows) { |
373 | 0 | allFields.addAll(row.getFields()); |
374 | |
} |
375 | 0 | } |
376 | 0 | if (searchAttributeFieldNames == null) { |
377 | 0 | returnFields = allFields; |
378 | |
} else { |
379 | 0 | for (String searchAttributeName : searchAttributeFieldNames) { |
380 | 0 | for (Field field : allFields) { |
381 | 0 | Field dsField = (Field) field; |
382 | 0 | if (field instanceof Field) { |
383 | 0 | if (searchAttributeName.equals(dsField |
384 | |
.getPropertyName())) { |
385 | 0 | returnFields.add(field); |
386 | |
} |
387 | |
} else { |
388 | 0 | throw new RiceRuntimeException( |
389 | |
"Fields must be of type org.kuali.rice.kns.Field"); |
390 | |
} |
391 | 0 | } |
392 | |
} |
393 | |
} |
394 | |
} |
395 | 0 | return returnFields; |
396 | |
} |
397 | |
|
398 | |
public DocumentSearchResult generateSearchResult( |
399 | |
DocSearchDTO docCriteriaDTO, List<Column> columns) { |
400 | 0 | Map<String, Object> alternateSortValues = getSortValuesMap(docCriteriaDTO); |
401 | 0 | DocumentSearchResult docSearchResult = null; |
402 | 0 | for (Iterator iterator = columns.iterator(); iterator.hasNext();) { |
403 | 0 | Column currentColumn = (Column) iterator |
404 | |
.next(); |
405 | 0 | KeyValueSort kvs = generateSearchResult(docCriteriaDTO, |
406 | |
currentColumn, alternateSortValues); |
407 | 0 | if (kvs != null) { |
408 | 0 | if (docSearchResult == null) { |
409 | 0 | docSearchResult = new DocumentSearchResult(); |
410 | |
} |
411 | 0 | docSearchResult.addResultContainer(kvs); |
412 | |
} |
413 | 0 | } |
414 | 0 | return docSearchResult; |
415 | |
} |
416 | |
|
417 | 0 | public class DisplayValues { |
418 | |
public String htmlValue; |
419 | |
public String userDisplayValue; |
420 | |
} |
421 | |
|
422 | |
public KeyValueSort generateSearchResult(DocSearchDTO docCriteriaDTO, |
423 | |
Column column, |
424 | |
Map<String, Object> sortValuesByColumnKey) { |
425 | 0 | KeyValueSort returnValue = null; |
426 | 0 | DisplayValues fieldValue = null; |
427 | 0 | Object sortFieldValue = null; |
428 | 0 | String columnKeyName = column.getPropertyName(); |
429 | 0 | SearchableAttributeValue attributeValue = null; |
430 | |
|
431 | 0 | if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_HEADER_ID |
432 | |
.equals(columnKeyName)) { |
433 | 0 | fieldValue = this.getRouteHeaderIdFieldDisplayValue(docCriteriaDTO |
434 | |
.getRouteHeaderId().toString(), docCriteriaDTO |
435 | |
.isUsingSuperUserSearch(), docCriteriaDTO.getDocTypeName()); |
436 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
437 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_LOG |
438 | |
.equals(columnKeyName)) { |
439 | 0 | fieldValue = this.getRouteLogFieldDisplayValue(docCriteriaDTO |
440 | |
.getRouteHeaderId().toString()); |
441 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
442 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DATE_CREATED |
443 | |
.equals(columnKeyName)) { |
444 | 0 | fieldValue = new DisplayValues(); |
445 | 0 | fieldValue.htmlValue = DocSearchUtils |
446 | |
.getDisplayValueWithDateTime(docCriteriaDTO |
447 | |
.getDateCreated()); |
448 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
449 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_TYPE_LABEL |
450 | |
.equals(columnKeyName)) { |
451 | 0 | fieldValue = new DisplayValues(); |
452 | 0 | fieldValue.htmlValue = docCriteriaDTO.getDocTypeLabel(); |
453 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
454 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOCUMENT_TITLE |
455 | |
.equals(columnKeyName)) { |
456 | 0 | fieldValue = new DisplayValues(); |
457 | 0 | fieldValue.htmlValue = docCriteriaDTO.getDocumentTitle(); |
458 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
459 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR |
460 | |
.equals(columnKeyName)) { |
461 | 0 | fieldValue = this.getInitiatorFieldDisplayValue(docCriteriaDTO |
462 | |
.getInitiatorTransposedName(), docCriteriaDTO |
463 | |
.getInitiatorWorkflowId()); |
464 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
465 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_STATUS_DESC |
466 | |
.equals(columnKeyName)) { |
467 | 0 | fieldValue = new DisplayValues(); |
468 | 0 | fieldValue.htmlValue = docCriteriaDTO.getDocRouteStatusCodeDesc(); |
469 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
470 | 0 | } else if (KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_STATUS |
471 | |
.equals(columnKeyName)) { |
472 | 0 | fieldValue = new DisplayValues(); |
473 | 0 | fieldValue.htmlValue = docCriteriaDTO.getAppDocStatus(); |
474 | 0 | sortFieldValue = sortValuesByColumnKey.get(columnKeyName); |
475 | |
} else { |
476 | |
|
477 | 0 | for (Iterator iter = docCriteriaDTO.getSearchableAttributes() |
478 | 0 | .iterator(); iter.hasNext();) { |
479 | 0 | KeyValueSort searchAttribute = (KeyValueSort) iter.next(); |
480 | 0 | if (searchAttribute.getKey().equals(columnKeyName)) { |
481 | 0 | Object sortValue = sortValuesByColumnKey.get(columnKeyName); |
482 | 0 | sortFieldValue = (sortValue != null) ? sortValue |
483 | |
: searchAttribute.getSortValue(); |
484 | 0 | attributeValue = searchAttribute.getSearchableAttributeValue(); |
485 | 0 | fieldValue = new DisplayValues(); |
486 | 0 | fieldValue.htmlValue = searchAttribute.getValue(); |
487 | 0 | break; |
488 | |
} |
489 | 0 | } |
490 | |
} |
491 | 0 | if (fieldValue != null) { |
492 | 0 | String userDisplaySortValue = fieldValue.userDisplayValue; |
493 | 0 | if (StringUtils.isBlank(userDisplaySortValue)) { |
494 | 0 | userDisplaySortValue = fieldValue.htmlValue; |
495 | |
} |
496 | 0 | returnValue = new KeyValueSort(columnKeyName, fieldValue.htmlValue, |
497 | |
fieldValue.userDisplayValue, |
498 | |
(sortFieldValue != null) ? sortFieldValue |
499 | |
: userDisplaySortValue, attributeValue); |
500 | |
} |
501 | 0 | return returnValue; |
502 | |
} |
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | |
public DisplayValues getRouteLogFieldDisplayValue(String routeHeaderId) { |
510 | 0 | DisplayValues dv = new DisplayValues(); |
511 | 0 | String linkPopup = ""; |
512 | 0 | if (this.isRouteLogPopup()) { |
513 | 0 | linkPopup = " target=\"_new\""; |
514 | |
} |
515 | 0 | String imageSource = "<img alt=\"Route Log for Document\" src=\"images/my_route_log.gif\"/>"; |
516 | 0 | dv.htmlValue = "<a href=\"RouteLog.do?routeHeaderId=" + routeHeaderId |
517 | |
+ "\"" + linkPopup + ">" + imageSource + "</a>"; |
518 | 0 | dv.userDisplayValue = imageSource; |
519 | 0 | return dv; |
520 | |
} |
521 | |
|
522 | |
public DisplayValues getRouteHeaderIdFieldDisplayValue( |
523 | |
String routeHeaderId, boolean isSuperUserSearch, |
524 | |
String documentTypeName) { |
525 | 0 | return this.getValueEncodedWithDocHandlerUrl(routeHeaderId, |
526 | |
routeHeaderId, isSuperUserSearch, documentTypeName); |
527 | |
} |
528 | |
|
529 | |
public DisplayValues getInitiatorFieldDisplayValue( |
530 | |
String fieldLinkTextValue, String initiatorWorkflowId) { |
531 | 0 | DisplayValues dv = new DisplayValues(); |
532 | |
|
533 | 0 | dv.htmlValue = "<a href=\""+ ConfigContext.getCurrentContextConfig().getKRBaseURL() + |
534 | |
"/inquiry.do?businessObjectClassName=org.kuali.rice.kim.bo.impl.PersonImpl&" + |
535 | |
"methodToCall=continueWithInquiry&principalId="+ initiatorWorkflowId |
536 | |
+ "\" target=\"_blank\">" |
537 | |
+ fieldLinkTextValue + "</a>"; |
538 | 0 | dv.userDisplayValue = fieldLinkTextValue; |
539 | 0 | return dv; |
540 | |
} |
541 | |
|
542 | |
|
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
|
558 | |
public DisplayValues getValueEncodedWithDocHandlerUrl(String value, |
559 | |
String routeHeaderId, boolean isSuperUserSearch, |
560 | |
String documentTypeName) { |
561 | 0 | DisplayValues dv = new DisplayValues(); |
562 | 0 | dv.htmlValue = getDocHandlerUrlPrefix(routeHeaderId, isSuperUserSearch, |
563 | |
documentTypeName) |
564 | |
+ value + getDocHandlerUrlSuffix(isSuperUserSearch); |
565 | 0 | dv.userDisplayValue = value; |
566 | 0 | return dv; |
567 | |
} |
568 | |
|
569 | |
public Map<String, Object> getSortValuesMap(DocSearchDTO docCriteriaDTO) { |
570 | 0 | Map<String, Object> alternateSort = new HashMap<String, Object>(); |
571 | 0 | alternateSort |
572 | |
.put( |
573 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_HEADER_ID, |
574 | |
docCriteriaDTO.getRouteHeaderId()); |
575 | 0 | if (StringUtils.isNotBlank(docCriteriaDTO.getInitiatorTransposedName())) { |
576 | 0 | alternateSort.put( |
577 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR, |
578 | |
docCriteriaDTO.getInitiatorTransposedName()); |
579 | |
} |
580 | |
else { |
581 | 0 | alternateSort.put( |
582 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR, |
583 | |
docCriteriaDTO.getInitiatorWorkflowId()); |
584 | |
} |
585 | 0 | alternateSort |
586 | |
.put( |
587 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DATE_CREATED, |
588 | |
docCriteriaDTO.getDateCreated()); |
589 | 0 | return alternateSort; |
590 | |
} |
591 | |
|
592 | |
public Map<String, Boolean> getSortableByKey() { |
593 | 0 | if (sortableByKey.isEmpty()) { |
594 | 0 | sortableByKey = constructSortableByKey(); |
595 | |
} |
596 | 0 | return sortableByKey; |
597 | |
} |
598 | |
|
599 | |
public Map<String, Boolean> constructSortableColumnByKey() { |
600 | 0 | Map<String, Boolean> sortable = new HashMap<String, Boolean>(); |
601 | 0 | sortable |
602 | |
.put( |
603 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_HEADER_ID, |
604 | |
Boolean.TRUE); |
605 | 0 | sortable |
606 | |
.put( |
607 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_TYPE_LABEL, |
608 | |
Boolean.TRUE); |
609 | 0 | sortable |
610 | |
.put( |
611 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOCUMENT_TITLE, |
612 | |
Boolean.TRUE); |
613 | 0 | sortable |
614 | |
.put( |
615 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_STATUS_DESC, |
616 | |
Boolean.TRUE); |
617 | 0 | sortable |
618 | |
.put( |
619 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_STATUS, |
620 | |
Boolean.TRUE); |
621 | 0 | sortable.put( |
622 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR, |
623 | |
Boolean.TRUE); |
624 | 0 | sortable |
625 | |
.put( |
626 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DATE_CREATED, |
627 | |
Boolean.TRUE); |
628 | 0 | sortable.put( |
629 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_LOG, |
630 | |
Boolean.FALSE); |
631 | 0 | return sortable; |
632 | |
} |
633 | |
|
634 | |
public Map<String, Boolean> getSortableColumnByKey() { |
635 | 0 | if (sortableByKey.isEmpty()) { |
636 | 0 | sortableByKey = constructSortableByKey(); |
637 | |
} |
638 | 0 | return sortableByKey; |
639 | |
} |
640 | |
|
641 | |
public Map<String, Boolean> constructSortableByKey() { |
642 | 0 | Map<String, Boolean> sortable = new HashMap<String, Boolean>(); |
643 | 0 | sortable |
644 | |
.put( |
645 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_HEADER_ID, |
646 | |
Boolean.TRUE); |
647 | 0 | sortable |
648 | |
.put( |
649 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_TYPE_LABEL, |
650 | |
Boolean.TRUE); |
651 | 0 | sortable |
652 | |
.put( |
653 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOCUMENT_TITLE, |
654 | |
Boolean.TRUE); |
655 | 0 | sortable |
656 | |
.put( |
657 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_STATUS_DESC, |
658 | |
Boolean.TRUE); |
659 | 0 | sortable.put( |
660 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DOC_STATUS, |
661 | |
Boolean.TRUE); |
662 | 0 | sortable.put( |
663 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_INITIATOR, |
664 | |
Boolean.TRUE); |
665 | 0 | sortable |
666 | |
.put( |
667 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_DATE_CREATED, |
668 | |
Boolean.TRUE); |
669 | 0 | sortable.put( |
670 | |
KEWPropertyConstants.DOC_SEARCH_RESULT_PROPERTY_NAME_ROUTE_LOG, |
671 | |
Boolean.FALSE); |
672 | 0 | return sortable; |
673 | |
} |
674 | |
|
675 | |
public Map<String, String> getLabelsByKey() { |
676 | 0 | if (labelsByKey.isEmpty()) { |
677 | 0 | labelsByKey = constructLabelsByKey(); |
678 | |
} |
679 | 0 | return labelsByKey; |
680 | |
} |
681 | |
|
682 | |
public Map<String, String> constructLabelsByKey() { |
683 | 0 | return new HashMap<String, String>(); |
684 | |
} |
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
public void addColumnUsingKey(List<Column> columns, String key) { |
691 | 0 | this.addColumnUsingKey(columns, key, |
692 | |
null, null); |
693 | 0 | } |
694 | |
|
695 | |
public void addColumnUsingKey(List<Column> columns, String key, String label) { |
696 | 0 | this.addColumnUsingKey(columns, key, label, null); |
697 | 0 | } |
698 | |
|
699 | |
public void addColumnUsingKey(List<Column> columns, String key, Boolean sortable) { |
700 | 0 | this.addColumnUsingKey(columns, key, null, sortable); |
701 | 0 | } |
702 | |
|
703 | |
public void addColumnUsingKey(List<Column> columns, String key, String label, |
704 | |
Boolean sortable) { |
705 | 0 | columns.add(this.constructColumnUsingKey(key, label, |
706 | |
sortable)); |
707 | 0 | } |
708 | |
|
709 | |
public void addSearchableAttributeColumnUsingKey( |
710 | |
List<Column> columns, |
711 | |
String key, String label, |
712 | |
Boolean sortableOverride, Boolean defaultSortable) { |
713 | 0 | columns.add(this |
714 | |
.constructColumnUsingKey(key, label, |
715 | |
(sortableOverride != null) ? sortableOverride |
716 | |
: defaultSortable)); |
717 | 0 | } |
718 | |
|
719 | |
public void addSearchableAttributeColumnUsingKey( |
720 | |
List<Column> columns, |
721 | |
Formatter formatter, String key, String label, |
722 | |
Boolean sortableOverride, Boolean defaultSortable) { |
723 | 0 | Column column = this.constructColumnUsingKey(key, label, |
724 | |
(sortableOverride != null) ? sortableOverride |
725 | |
: defaultSortable); |
726 | |
|
727 | 0 | column.setFormatter(formatter); |
728 | |
|
729 | 0 | columns.add(column); |
730 | 0 | } |
731 | |
|
732 | |
|
733 | |
|
734 | |
|
735 | |
|
736 | |
|
737 | |
|
738 | |
public Column constructColumnUsingKey(String key, String label, |
739 | |
Boolean sortable) { |
740 | 0 | if (sortable == null) { |
741 | 0 | sortable = getSortableByKey().get(key); |
742 | |
} |
743 | 0 | if (label == null) { |
744 | 0 | label = getLabelsByKey().get(key); |
745 | |
} |
746 | 0 | Column c = new Column( |
747 | |
label,key); |
748 | 0 | return c; |
749 | |
} |
750 | |
|
751 | |
public boolean isDocumentHandlerPopup() { |
752 | 0 | return Utilities.getKNSParameterBooleanValue( |
753 | |
KEWConstants.KEW_NAMESPACE, |
754 | |
KNSConstants.DetailTypes.DOCUMENT_SEARCH_DETAIL_TYPE, |
755 | |
KEWConstants.DOCUMENT_SEARCH_DOCUMENT_POPUP_IND); |
756 | |
} |
757 | |
|
758 | |
public boolean isRouteLogPopup() { |
759 | 0 | return Utilities.getKNSParameterBooleanValue( |
760 | |
KEWConstants.KEW_NAMESPACE, |
761 | |
KNSConstants.DetailTypes.DOCUMENT_SEARCH_DETAIL_TYPE, |
762 | |
KEWConstants.DOCUMENT_SEARCH_ROUTE_LOG_POPUP_IND); |
763 | |
} |
764 | |
|
765 | |
public String getDocHandlerUrlPrefix(String routeHeaderId, |
766 | |
boolean superUserSearch, String documentTypeName) { |
767 | 0 | String linkPopup = ""; |
768 | 0 | if (this.isDocumentHandlerPopup()) { |
769 | 0 | linkPopup = " target=\"_blank\""; |
770 | |
} |
771 | 0 | if (superUserSearch) { |
772 | 0 | String url = "<a href=\"SuperUser.do?methodToCall=displaySuperUserDocument&routeHeaderId=" |
773 | |
+ routeHeaderId + "\"" + linkPopup + " >"; |
774 | 0 | if (!getDocumentType(documentTypeName) |
775 | |
.getUseWorkflowSuperUserDocHandlerUrl().getPolicyValue() |
776 | |
.booleanValue()) { |
777 | 0 | url = "<a href=\"" + KEWConstants.DOC_HANDLER_REDIRECT_PAGE |
778 | |
+ "?" + KEWConstants.COMMAND_PARAMETER + "=" |
779 | |
+ KEWConstants.SUPERUSER_COMMAND + "&" |
780 | |
+ KEWConstants.ROUTEHEADER_ID_PARAMETER + "=" |
781 | |
+ routeHeaderId + "\"" + linkPopup + ">"; |
782 | |
} |
783 | 0 | return url; |
784 | |
} else { |
785 | 0 | return "<a href=\"" + KEWConstants.DOC_HANDLER_REDIRECT_PAGE + "?" |
786 | |
+ KEWConstants.COMMAND_PARAMETER + "=" |
787 | |
+ KEWConstants.DOCSEARCH_COMMAND + "&" |
788 | |
+ KEWConstants.ROUTEHEADER_ID_PARAMETER + "=" |
789 | |
+ routeHeaderId + "\"" + linkPopup + ">"; |
790 | |
} |
791 | |
} |
792 | |
|
793 | |
public String getDocHandlerUrlSuffix(boolean superUserSearch) { |
794 | 0 | if (superUserSearch) { |
795 | 0 | return "</a>"; |
796 | |
} else { |
797 | 0 | return "</a>"; |
798 | |
} |
799 | |
} |
800 | |
|
801 | |
|
802 | |
|
803 | |
|
804 | |
|
805 | |
|
806 | |
public void setProcessFinalResults(boolean isProcessFinalResults) { |
807 | 0 | this.processFinalResults = isProcessFinalResults; |
808 | 0 | } |
809 | |
|
810 | |
|
811 | |
|
812 | |
|
813 | |
|
814 | |
|
815 | |
public boolean isProcessFinalResults() { |
816 | 0 | return this.processFinalResults; |
817 | |
} |
818 | |
} |