01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.kuali.workflow.attribute.web;
18:
19: import java.util.ArrayList;
20: import java.util.HashMap;
21: import java.util.List;
22: import java.util.Map;
23:
24: import org.kuali.workflow.attribute.ExtensionAttribute;
25:
26: import edu.iu.uis.eden.lookupable.Field;
27: import edu.iu.uis.eden.lookupable.Row;
28:
29: /**
30: * A convienance bean for use in the web tier when collecting data from custom field extensions.
31: *
32: * @author ewestfal
33: */
34: public class WebExtensions {
35:
36: private List<List<Row>> rows = new ArrayList<List<Row>>();
37: private Map<String, String> data = new HashMap<String, String>();
38:
39: public List<List<Row>> getRows() {
40: return rows;
41: }
42:
43: public void setRows(List<List<Row>> rows) {
44: this .rows = rows;
45: }
46:
47: public Map<String, String> getData() {
48: return data;
49: }
50:
51: public void setData(Map<String, String> data) {
52: this .data = data;
53: }
54:
55: public void load(ExtensionAttribute attribute) {
56: List<Row> attributeRows = attribute.getRows();
57: rows.add(attributeRows);
58: for (Row row : attributeRows) {
59: for (Field field : row.getFields()) {
60: if (field.isInputField()
61: && !data.containsKey(field.getPropertyName())) {
62: data.put(field.getPropertyName(), field
63: .getPropertyValue());
64: }
65: }
66: }
67: }
68:
69: public void clear() {
70: clearRows();
71: data.clear();
72: }
73:
74: public void clearRows() {
75: rows.clear();
76: }
77:
78: public boolean isEmptyExtensions() {
79: return rows.isEmpty() && data.isEmpty();
80: }
81:
82: }
|