1 /**
2 * Copyright 2005-2014 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.krad.uif.field;
17
18 import java.io.Serializable;
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.rice.krad.datadictionary.Copyable;
25 import org.kuali.rice.krad.uif.util.CopyUtils;
26
27 /**
28 * Object that is returned for Ajax attribute queries and exposed
29 * as JSON
30 *
31 * @author Kuali Rice Team (rice.collab@kuali.org)
32 */
33 public class AttributeQueryResult implements Serializable, Copyable {
34 private static final long serialVersionUID = -6688384365943881516L;
35
36 private String resultMessage;
37 private String resultMessageStyleClasses;
38
39 private Map<String, String> resultFieldData;
40 private List<Object> resultData;
41
42 public AttributeQueryResult() {
43 resultFieldData = new HashMap<String, String>();
44 resultData = new ArrayList<Object>();
45 }
46
47 /**
48 * Message text that should display (if non empty) with the results.
49 * Can be used to given messages such as data not found
50 *
51 * @return text to display with results
52 */
53 public String getResultMessage() {
54 return resultMessage;
55 }
56
57 /**
58 * Setter for the result message text
59 *
60 * @param resultMessage
61 */
62 public void setResultMessage(String resultMessage) {
63 this.resultMessage = resultMessage;
64 }
65
66 /**
67 * CSS Style classes that should be applied to the result message text
68 *
69 * @return CSS style classes
70 */
71 public String getResultMessageStyleClasses() {
72 return resultMessageStyleClasses;
73 }
74
75 /**
76 * Setter for the CSS style classes to use for the return message
77 *
78 * @param resultMessageStyleClasses
79 */
80 public void setResultMessageStyleClasses(String resultMessageStyleClasses) {
81 this.resultMessageStyleClasses = resultMessageStyleClasses;
82 }
83
84 /**
85 * Returns data for multiple fields as a Map where key is the field
86 * name and map value is the field value
87 *
88 * @return result field data
89 */
90 public Map<String, String> getResultFieldData() {
91 return resultFieldData;
92 }
93
94 /**
95 * Setter for the map field data
96 *
97 * @param resultFieldData
98 */
99 public void setResultFieldData(Map<String, String> resultFieldData) {
100 this.resultFieldData = resultFieldData;
101 }
102
103 /**
104 * Result of an attribute query that will be sent back to the client
105 *
106 * @return result data
107 */
108 public List<Object> getResultData() {
109 return resultData;
110 }
111
112 /**
113 * Setter for the attribute query result data
114 *
115 * @param resultData
116 */
117 public void setResultData(List<Object> resultData) {
118 this.resultData = resultData;
119 }
120
121 /**
122 * @see Copyable#clone()
123 */
124 @Override
125 public AttributeQueryResult clone() throws CloneNotSupportedException {
126 return (AttributeQueryResult) super.clone();
127 }
128
129 /**
130 * Modification is not controlled at this level.
131 *
132 * @see Copyable#preventModification()
133 */
134 @Override
135 public void preventModification() {}
136
137 /**
138 * @see Copyable#copy()
139 * @see CopyUtils#copy(Copyable)
140 */
141 public final <T> T copy() {
142 return CopyUtils.copy(this);
143 }
144
145 /**
146 * {@inheritDoc}
147 */
148 @Override
149 public Copyable unwrap() {
150 return this;
151 }
152 }