View Javadoc

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