View Javadoc

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