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