1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.docsearch;
17
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21
22
23
24
25
26
27
28
29 public class StandardDocSearchCriteriaManager implements java.io.Serializable {
30
31 private static final long serialVersionUID = -1898076444679158722L;
32
33 private List<List<StandardDocSearchCriteriaFieldContainer>> columnsPreSearchAttributes = new ArrayList<List<StandardDocSearchCriteriaFieldContainer>>();
34 private List<List<StandardDocSearchCriteriaFieldContainer>> columnsPostSearchAttributes = new ArrayList<List<StandardDocSearchCriteriaFieldContainer>>();
35
36 public StandardDocSearchCriteriaManager(int preSearchAttributeColumns, int postSearchAttributeColumns, boolean searchCriteriaDisplayed, boolean headerBarDisplayed) {
37 setupColumns(preSearchAttributeColumns,postSearchAttributeColumns);
38 }
39
40 private void setupColumns(int preSearchAttributeColumns, int postSearchAttributeColumns) {
41 for (int i = 0; i < preSearchAttributeColumns; i++) {
42 columnsPreSearchAttributes.add(new ArrayList<StandardDocSearchCriteriaFieldContainer>());
43 }
44 for (int i = 0; i < postSearchAttributeColumns; i++) {
45 columnsPostSearchAttributes.add(new ArrayList<StandardDocSearchCriteriaFieldContainer>());
46 }
47 }
48
49 public List<StandardDocSearchCriteriaFieldContainer> getPreSearchAttributeMaxRows() {
50 return getMaxRowsForList(columnsPreSearchAttributes);
51 }
52
53 public List<StandardDocSearchCriteriaFieldContainer> getPostSearchAttributeMaxRows() {
54 return getMaxRowsForList(columnsPostSearchAttributes);
55 }
56
57 @SuppressWarnings("unchecked")
58 private List<StandardDocSearchCriteriaFieldContainer> getMaxRowsForList(List<List<StandardDocSearchCriteriaFieldContainer>> columns) {
59 List<StandardDocSearchCriteriaFieldContainer> biggestFieldContainerList = null;
60 for (Iterator iter = columns.iterator(); iter.hasNext();) {
61 List<StandardDocSearchCriteriaFieldContainer> fieldContainerList = (List<StandardDocSearchCriteriaFieldContainer>) iter.next();
62 if (biggestFieldContainerList == null) {
63 biggestFieldContainerList = fieldContainerList;
64 } else {
65 if (fieldContainerList.size() > biggestFieldContainerList.size()) {
66 biggestFieldContainerList = fieldContainerList;
67 }
68 }
69 }
70 return biggestFieldContainerList;
71 }
72
73 public int getMaxColumnCount() {
74 return Math.max(columnsPreSearchAttributes.size(), columnsPostSearchAttributes.size());
75 }
76
77 public List<List<StandardDocSearchCriteriaFieldContainer>> getColumnsPreSearchAttributes() {
78 return this.columnsPreSearchAttributes;
79 }
80
81 public void setColumnsPreSearchAttributes(List<List<StandardDocSearchCriteriaFieldContainer>> columnsPreSearchAttributes) {
82 this.columnsPreSearchAttributes = columnsPreSearchAttributes;
83 }
84
85 public List<List<StandardDocSearchCriteriaFieldContainer>> getColumnsPostSearchAttributes() {
86 return this.columnsPostSearchAttributes;
87 }
88
89 public void setColumnsPostSearchAttributes(List<List<StandardDocSearchCriteriaFieldContainer>> columnsPostSearchAttributes) {
90 this.columnsPostSearchAttributes = columnsPostSearchAttributes;
91 }
92
93 }