001/** 002 * Copyright 2005-2018 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 */ 016package org.kuali.rice.krad.uif.modifier; 017 018import org.kuali.rice.krad.datadictionary.parse.BeanTag; 019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 020import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase; 021import org.kuali.rice.krad.uif.component.Ordered; 022 023import java.io.Serializable; 024 025/** 026 * Provides configuration for comparing an object with another object 027 * 028 * <p> 029 * Used with a comparison view (such as in maintenance documents edit mode) 030 * where two objects with the same properties are compared. This class 031 * configures the object paths for the objects that will be compared, and has 032 * additional configuration for the generated comparison group 033 * </p> 034 * 035 * <p> 036 * All comparison objects must have the same fields and collection rows 037 * </p> 038 * 039 * @author Kuali Rice Team (rice.collab@kuali.org) 040 * @see org.kuali.rice.krad.uif.modifier.CompareFieldCreateModifier 041 */ 042@BeanTag(name = "compareConfig", parent = "Uif-CompareConfig") 043public class ComparableInfo extends UifDictionaryBeanBase implements Serializable, Ordered { 044 private static final long serialVersionUID = -5926058412202550266L; 045 046 private String bindingObjectPath; 047 private String headerText; 048 private boolean readOnly; 049 050 private int order; 051 private String comparableId; 052 053 private boolean compareToForValueChange; 054 private boolean highlightValueChange; 055 056 private boolean compareToForFieldRender; 057 058 public ComparableInfo() { 059 super(); 060 061 readOnly = false; 062 compareToForValueChange = false; 063 compareToForFieldRender = false; 064 highlightValueChange = true; 065 } 066 067 /** 068 * Returns the path (from the form) for the object to compare to 069 * 070 * <p> 071 * When a comparison view is rendered, a group will be rendered for each 072 * comparison object using the fields defined on the view. This gives the 073 * path to one of the comparison objects 074 * </p> 075 * 076 * <p> 077 * e.g. For maintenance documents the compare object paths would be 078 * document.newMaintainableObject.businessObject and 079 * document.oldMaintainableObject.businessObject 080 * </p> 081 * 082 * @return path to the compare object 083 */ 084 @BeanTagAttribute 085 public String getBindingObjectPath() { 086 return this.bindingObjectPath; 087 } 088 089 /** 090 * Setter for the path to the compare object 091 * 092 * @param bindingObjectPath 093 */ 094 public void setBindingObjectPath(String bindingObjectPath) { 095 this.bindingObjectPath = bindingObjectPath; 096 } 097 098 /** 099 * 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}