001 /** 002 * Copyright 2005-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.krad.uif.field; 017 018 import java.io.Serializable; 019 import java.util.ArrayList; 020 import java.util.HashMap; 021 import java.util.List; 022 import java.util.Map; 023 024 import org.kuali.rice.krad.datadictionary.Copyable; 025 import org.kuali.rice.krad.uif.util.CopyUtils; 026 027 /** 028 * Object that is returned for Ajax attribute queries and exposed 029 * as JSON 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033 public class AttributeQueryResult implements Serializable, Copyable { 034 private static final long serialVersionUID = -6688384365943881516L; 035 036 private String resultMessage; 037 private String resultMessageStyleClasses; 038 039 private Map<String, String> resultFieldData; 040 private List<Object> resultData; 041 042 public AttributeQueryResult() { 043 resultFieldData = new HashMap<String, String>(); 044 resultData = new ArrayList<Object>(); 045 } 046 047 /** 048 * Message text that should display (if non empty) with the results. 049 * Can be used to given messages such as data not found 050 * 051 * @return text to display with results 052 */ 053 public String getResultMessage() { 054 return resultMessage; 055 } 056 057 /** 058 * Setter for the result message text 059 * 060 * @param resultMessage 061 */ 062 public void setResultMessage(String resultMessage) { 063 this.resultMessage = resultMessage; 064 } 065 066 /** 067 * CSS Style classes that should be applied to the result message text 068 * 069 * @return CSS style classes 070 */ 071 public String getResultMessageStyleClasses() { 072 return resultMessageStyleClasses; 073 } 074 075 /** 076 * Setter for the CSS style classes to use for the return message 077 * 078 * @param resultMessageStyleClasses 079 */ 080 public void setResultMessageStyleClasses(String resultMessageStyleClasses) { 081 this.resultMessageStyleClasses = resultMessageStyleClasses; 082 } 083 084 /** 085 * Returns data for multiple fields as a Map where key is the field 086 * name and map value is the field value 087 * 088 * @return result field data 089 */ 090 public Map<String, String> getResultFieldData() { 091 return resultFieldData; 092 } 093 094 /** 095 * Setter for the map field data 096 * 097 * @param resultFieldData 098 */ 099 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 }