View Javadoc

1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.docsearch;
17  
18  import org.kuali.rice.kew.util.Utilities;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  import java.util.Set;
23  
24  
25  /**
26   * This class is a holder for fields for standard document search criteria objects
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   *
30   */
31  public class StandardDocSearchCriteriaFieldContainer implements java.io.Serializable {
32  
33  	private static final long serialVersionUID = 7334865718915897486L;
34  	
35  	private String fieldKey;
36  	private String labelMessageKey;
37  	private String labelFieldWidthValue;
38  	private String labelFieldHeightValue;
39  	private String dataFieldWidthValue;
40  	private String dataFieldHeightValue;
41  	private List<StandardSearchCriteriaField> fields = new ArrayList<StandardSearchCriteriaField>();
42  	
43  	public StandardDocSearchCriteriaFieldContainer() {}
44  	
45  	public StandardDocSearchCriteriaFieldContainer(String labelKey, StandardSearchCriteriaField field) {
46  		if (!Utilities.isEmpty(labelKey)) {
47  			this.labelMessageKey = labelKey;
48  		}
49  		this.fieldKey = field.getKey();
50  		addField(field);
51  	}
52  
53  	public StandardDocSearchCriteriaFieldContainer(String fieldKey, String labelKey, List<StandardSearchCriteriaField> fields) {
54  		if (!Utilities.isEmpty(labelKey)) {
55  			this.labelMessageKey = labelKey;
56  		}
57  		if (!Utilities.isEmpty(fieldKey)) {
58  			this.fieldKey = fieldKey;
59  		}
60  		this.fields = fields;
61  	}
62  
63  	public StandardDocSearchCriteriaFieldContainer(StandardDocSearchCriteriaFieldContainer sourceContainer) {
64  		this.fieldKey = sourceContainer.getFieldKey();
65  		this.labelMessageKey = sourceContainer.getLabelMessageKey();
66  		this.labelFieldHeightValue = sourceContainer.getLabelFieldHeightValue();
67  		this.labelFieldWidthValue = sourceContainer.getLabelFieldWidthValue();
68  		this.dataFieldHeightValue = sourceContainer.getDataFieldHeightValue();
69  		this.dataFieldWidthValue = sourceContainer.getDataFieldWidthValue();
70  		this.fields = sourceContainer.getFields();
71  	}
72  
73  	public void addField(StandardSearchCriteriaField field) {
74  		fields.add(field);
75  	}
76  
77      public boolean isHidden() {
78          for (StandardSearchCriteriaField field1 : fields)
79          {
80              if (!field1.isHidden())
81              {
82                  return false;
83              }
84          }
85          return true;
86      }
87      
88      public void hideFieldsIfNecessary(Set<String> hiddenFieldKeys) {
89          for (StandardSearchCriteriaField field1 : fields)
90          {
91              if ((hiddenFieldKeys.contains(getFieldKey())) || (hiddenFieldKeys.contains(field1.getKey())))
92              {
93                  field1.setHidden(true);
94              }
95          }
96      }
97  
98  	public String getFieldKey() {
99  		return this.fieldKey;
100 	}
101 
102 	public void setFieldKey(String fieldKey) {
103 		this.fieldKey = fieldKey;
104 	}
105 
106 	public String getLabelMessageKey() {
107 		return this.labelMessageKey;
108 	}
109 
110 	public void setLabelMessageKey(String labelMessageKey) {
111 		this.labelMessageKey = labelMessageKey;
112 	}
113 
114 	public String getLabelFieldWidthValue() {
115 		return this.labelFieldWidthValue;
116 	}
117 
118 	public void setLabelFieldWidthValue(String labelFieldWidthValue) {
119 		this.labelFieldWidthValue = labelFieldWidthValue;
120 	}
121 
122 	public String getLabelFieldHeightValue() {
123 		return this.labelFieldHeightValue;
124 	}
125 
126 	public void setLabelFieldHeightValue(String labelFieldHeightValue) {
127 		this.labelFieldHeightValue = labelFieldHeightValue;
128 	}
129 
130 	public String getDataFieldWidthValue() {
131 		return this.dataFieldWidthValue;
132 	}
133 
134 	public void setDataFieldWidthValue(String dataFieldWidthValue) {
135 		this.dataFieldWidthValue = dataFieldWidthValue;
136 	}
137 
138 	public String getDataFieldHeightValue() {
139 		return this.dataFieldHeightValue;
140 	}
141 
142 	public void setDataFieldHeightValue(String dataFieldHeightValue) {
143 		this.dataFieldHeightValue = dataFieldHeightValue;
144 	}
145 
146 	public List<StandardSearchCriteriaField> getFields() {
147 		return this.fields;
148 	}
149 
150 	public void setFields(List<StandardSearchCriteriaField> fields) {
151 		this.fields = fields;
152 	}
153 	
154 }