1 /** 2 * Copyright 2005-2016 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.modifier; 17 18 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 20 import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase; 21 import org.kuali.rice.krad.uif.component.Ordered; 22 23 import java.io.Serializable; 24 25 /** 26 * Provides configuration for comparing an object with another object 27 * 28 * <p> 29 * Used with a comparison view (such as in maintenance documents edit mode) 30 * where two objects with the same properties are compared. This class 31 * configures the object paths for the objects that will be compared, and has 32 * additional configuration for the generated comparison group 33 * </p> 34 * 35 * <p> 36 * All comparison objects must have the same fields and collection rows 37 * </p> 38 * 39 * @author Kuali Rice Team (rice.collab@kuali.org) 40 * @see org.kuali.rice.krad.uif.modifier.CompareFieldCreateModifier 41 */ 42 @BeanTag(name = "compareConfig", parent = "Uif-CompareConfig") 43 public class ComparableInfo extends UifDictionaryBeanBase implements Serializable, Ordered { 44 private static final long serialVersionUID = -5926058412202550266L; 45 46 private String bindingObjectPath; 47 private String headerText; 48 private boolean readOnly; 49 50 private int order; 51 private String comparableId; 52 53 private boolean compareToForValueChange; 54 private boolean highlightValueChange; 55 56 private boolean compareToForFieldRender; 57 58 public ComparableInfo() { 59 super(); 60 61 readOnly = false; 62 compareToForValueChange = false; 63 compareToForFieldRender = false; 64 highlightValueChange = true; 65 } 66 67 /** 68 * Returns the path (from the form) for the object to compare to 69 * 70 * <p> 71 * When a comparison view is rendered, a group will be rendered for each 72 * comparison object using the fields defined on the view. This gives the 73 * path to one of the comparison objects 74 * </p> 75 * 76 * <p> 77 * e.g. For maintenance documents the compare object paths would be 78 * document.newMaintainableObject.businessObject and 79 * document.oldMaintainableObject.businessObject 80 * </p> 81 * 82 * @return path to the compare object 83 */ 84 @BeanTagAttribute 85 public String getBindingObjectPath() { 86 return this.bindingObjectPath; 87 } 88 89 /** 90 * Setter for the path to the compare object 91 * 92 * @param bindingObjectPath 93 */ 94 public void setBindingObjectPath(String bindingObjectPath) { 95 this.bindingObjectPath = bindingObjectPath; 96 } 97 98 /** 99 * Text that should display on the header for the compare group 100 * 101 * <p> 102 * In the comparison view each compare group can be labeled, this gives the 103 * text that should be used for that label. For example in the maintenance 104 * view the compare record is labeled 'Old' to indicate it is the old 105 * version of the record 106 * </p> 107 * 108 * @return header text 109 */ 110 @BeanTagAttribute 111 public String getHeaderText() { 112 return this.headerText; 113 } 114 115 /** 116 * Setter for the compare group header text 117 * 118 * @param headerText 119 */ 120 public void setHeaderText(String headerText) { 121 this.headerText = headerText; 122 } 123 124 /** 125 * Indicates whether the compare group should be read-only 126 * 127 * @return true if the group should be read-only, false if edits are 128 * allowed 129 */ 130 @BeanTagAttribute 131 public boolean isReadOnly() { 132 return this.readOnly; 133 } 134 135 /** 136 * Setter for the read-only indicator 137 * 138 * @param readOnly 139 */ 140 public void setReadOnly(boolean readOnly) { 141 this.readOnly = readOnly; 142 } 143 144 /** 145 * Sets the order value that will be used to determine where the compare 146 * group should be placed in relation to the other compare groups 147 * 148 * <p> 149 * For example if the compare groups are being rendered from left to right 150 * in columns, a lower order value would be placed to the left of a compare 151 * group with a higher order value 152 * </p> 153 * 154 * @see org.springframework.core.Ordered#getOrder() 155 */ 156 @BeanTagAttribute 157 public int getOrder() { 158 return this.order; 159 } 160 161 /** 162 * Setter for the compare object order 163 * 164 * @param order 165 */ 166 public void setOrder(int order) { 167 this.order = order; 168 } 169 170 /** 171 * Specifies an id suffix to use for the generated comparison fields 172 * 173 * <p> 174 * For the given string, all components created for the comparison group 175 * will contain the string on their id. This can be helpful for scripting. 176 * If not given, the items will receive a default id suffix 177 * </p> 178 * 179 * @return id suffix for comparison group 180 */ 181 @BeanTagAttribute 182 public String getComparableId() { 183 return this.comparableId; 184 } 185 186 /** 187 * Setter for the id prefix to use for the generated comparison components 188 * 189 * @param comparableId 190 */ 191 public void setComparableId(String comparableId) { 192 this.comparableId = comparableId; 193 } 194 195 /** 196 * Indicates whether this comparable group's field values should be compared 197 * to when highlighting changes of values between comparables (versions) 198 * 199 * @return true if this comparable group should be used for 200 * comparison, false if not 201 * @see #isHighlightValueChange 202 */ 203 @BeanTagAttribute 204 public boolean isCompareToForValueChange() { 205 return this.compareToForValueChange; 206 } 207 208 /** 209 * Setter for the use comparable group values for comparison indicator 210 * 211 * @param compareToForValueChange 212 */ 213 public void setCompareToForValueChange(boolean compareToForValueChange) { 214 this.compareToForValueChange = compareToForValueChange; 215 } 216 217 /** 218 * Indicates whether this comparable group's field values should include the 219 * {@code renderOnComparableModifier} context variable when this comparable 220 * is used to modify an existing component 221 * 222 * <p> 223 * This is especially useful when defining a {@code Uif-ActionField} that needs 224 * to appear on the new side of a maintenance document. Marking this as true 225 * on the ComparableInfo will make it push the {@code renderOnComparableModifier} 226 * context variable, holding the same value as this variable, making it easier 227 * to determine whether the field should be rendered based on whether this ComparableInfo 228 * is being applied. 229 * </p> 230 * 231 * @return true if this comparable group should be used for 232 * the {@code renderOnComparableModifier} context 233 * variable, false if not 234 */ 235 @BeanTagAttribute 236 public boolean isCompareToForFieldRender() { 237 return this.compareToForFieldRender; 238 } 239 240 /** 241 * Setter for the use comparable group values for {@code renderOnComparableModifier} 242 * context variable 243 * 244 * @param compareToForFieldRender 245 */ 246 public void setCompareToForFieldRender(boolean compareToForFieldRender) { 247 this.compareToForFieldRender = compareToForFieldRender; 248 } 249 250 /** 251 * Indicates whether the fields in this comparable group should be 252 * highlighted if their values defer from the comparable group marked for 253 * comparison 254 * 255 * @return true if the comparable fields should be highlighted, 256 * false if they should not be highlighted (no comparison will be 257 * performed) 258 * @see #isCompareToForValueChange 259 */ 260 @BeanTagAttribute 261 public boolean isHighlightValueChange() { 262 return this.highlightValueChange; 263 } 264 265 /** 266 * Setter for the highlight comparable field value changed indicator 267 * 268 * @param highlightValueChange 269 */ 270 public void setHighlightValueChange(boolean highlightValueChange) { 271 this.highlightValueChange = highlightValueChange; 272 } 273 274 }