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