Coverage Report - org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
MaintainableFieldDefinition
0%
0/76
0%
0/14
1.282
 
 1  
 /*
 2  
  * Copyright 2005-2008 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.kns.datadictionary;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.bo.BusinessObject;
 20  
 import org.kuali.rice.krad.datadictionary.DataDictionary;
 21  
 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
 22  
 import org.kuali.rice.krad.valuefinder.ValueFinder;
 23  
 
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
     The maintainableField element defines the specifications
 28  
     for one data field.
 29  
     JSTL: maintainableField is a Map accessed by the field name.
 30  
     It contains entries with the following keys:
 31  
         * field (boolean String)
 32  
         * name (String)
 33  
         * required (boolean String)
 34  
 
 35  
     * name is the name of the field
 36  
     * required is true if the field must contain a non-null value
 37  
     * readOnly is true if it cannot be updated
 38  
     * template documentation from MaintenanceUtils.java:
 39  
         Field templates are used in relation to multiple value lookups.
 40  
         When doing a MV lookup on a collection, the returned BOs
 41  
         are not necessarily of the same type as the elements of the
 42  
         collection. Therefore, a means of mapping between the fields
 43  
         for the 2 BOs are necessary. The template attribute of
 44  
         <maintainableField> contained within <maintainableCollection>
 45  
         tells us this mapping.
 46  
         Example:
 47  
         <maintainableField name="collectionAttrib" template="lookupBOAttrib">
 48  
         means that when a list of BOs are returned, the lookupBOAttrib value
 49  
         of the looked up BO will be placed into the collectionAttrib
 50  
         value of the BO added to the collection
 51  
     * webUILeaveFieldFunction is the name of a javascript function to called when
 52  
         when the user tabs out of the field.
 53  
     * webUILeaveFieldCallbackFunction
 54  
         This is the call javascript function related to the webUILeaveFieldFunction.
 55  
     * readOnlyAfterAdd
 56  
         This is used to indicate that the field is read-only after the record has been
 57  
         initially created.
 58  
  */
 59  
 @Deprecated
 60  
 public class MaintainableFieldDefinition extends MaintainableItemDefinition implements FieldDefinitionI{
 61  
     private static final long serialVersionUID = -1176087424343479963L;
 62  
     
 63  0
         protected boolean required = false;
 64  0
     protected boolean unconditionallyReadOnly = false;
 65  0
     protected boolean readOnlyAfterAdd = false;
 66  0
     protected boolean noLookup = false;
 67  0
     protected boolean lookupReadOnly = false;
 68  
     
 69  
     protected String defaultValue;
 70  
     protected String template;
 71  
     protected Class<? extends ValueFinder> defaultValueFinderClass;
 72  
 
 73  0
     protected String webUILeaveFieldFunction = "";
 74  0
     protected String webUILeaveFieldCallbackFunction = "";
 75  
     protected List<String> webUILeaveFieldFunctionParameters;
 76  
 
 77  
     protected Class<? extends BusinessObject> overrideLookupClass;
 78  
     protected String overrideFieldConversions;
 79  
     
 80  
     protected String alternateDisplayAttributeName;
 81  
     protected String additionalDisplayAttributeName;
 82  
     
 83  
     protected boolean triggerOnChange;
 84  
     
 85  0
     protected Boolean showFieldLevelHelp = null; // use default from system
 86  0
     protected String fieldLevelHelpUrl = null;
 87  
     
 88  0
     public MaintainableFieldDefinition() {}
 89  
 
 90  
     /**
 91  
      * @return true if this attribute is required
 92  
      */
 93  
     public boolean isRequired() {
 94  0
         return required;
 95  
     }
 96  
 
 97  
     /**
 98  
 required is true if the field must contain a non-null value
 99  
      */
 100  
     public void setRequired(boolean required) {
 101  0
         this.required = required;
 102  0
     }
 103  
 
 104  
     /**
 105  
      * @return Returns the defaultValue.
 106  
      */
 107  
     public String getDefaultValue() {
 108  0
         return defaultValue;
 109  
     }
 110  
 
 111  
 
 112  
     /**
 113  
      * 
 114  
                        The defaultValue element will pre-load the specified value
 115  
                        into the lookup field.
 116  
      */
 117  
     public void setDefaultValue(String defaultValue) {
 118  0
         this.defaultValue = defaultValue;
 119  0
     }
 120  
 
 121  
 
 122  
     /**
 123  
      * @return custom defaultValue class
 124  
      */
 125  
     public Class<? extends ValueFinder> getDefaultValueFinderClass() {
 126  0
         return defaultValueFinderClass;
 127  
     }
 128  
 
 129  
     /**
 130  
          * @return the unconditionallyReadOnly
 131  
          */
 132  
         public boolean isUnconditionallyReadOnly() {
 133  0
                 return this.unconditionallyReadOnly;
 134  
         }
 135  
 
 136  
         /**
 137  
          * @param unconditionallyReadOnly the unconditionallyReadOnly to set
 138  
          */
 139  
         public void setUnconditionallyReadOnly(boolean unconditionallyReadOnly) {
 140  0
                 this.unconditionallyReadOnly = unconditionallyReadOnly;
 141  0
         }
 142  
 
 143  
     /**
 144  
      * Gets the overrideFieldConversions attribute. 
 145  
      * @return Returns the overrideFieldConversions.
 146  
      */
 147  
     public String getOverrideFieldConversions() {
 148  0
         return overrideFieldConversions;
 149  
     }
 150  
 
 151  
 
 152  
     /**
 153  
      * Single value lookups expect field conversions to be passed in as a HTTP parameter when the lookups is invoked from a quickfinder icon (i.e. magnifying glass on page).
 154  
                         Field conversions are normally used to determine which fields will be returned when the "return value" link is clicked.
 155  
 
 156  
                         For example, if we're performing a quickfinder lookup and the field conversion string "a:document.someObject.a1,b:document.someObject.b1" is passed into the lookup,
 157  
                         this means that when we click on a lookup result row to be returned:
 158  
 
 159  
                         * the value of property "a" from the selected result bo will be passed as the value of the HTTP parameter named "document.someObject.a1",
 160  
                           which, in turn, populates the POJO property of the same name on the form
 161  
                         * the value of property "b" from the selected result bo will be passed as the value of the HTTP parameter named "document.someObject.b1",
 162  
                           which, in turn, populates the POJO property of the same name on the form
 163  
 
 164  
                         Normally, the field conversion string is automatically computed by the framework to return all of the primary key values of the looked up BO into the corresponding
 165  
                         foreign key values of the destination BO (i.e. document.someObject in the example above).  However, putting in this element will allow for the overriding of the
 166  
                         field conversions string.
 167  
      */
 168  
     public void setOverrideFieldConversions(String overrideFieldConversions) {
 169  0
         this.overrideFieldConversions = overrideFieldConversions;
 170  0
     }
 171  
 
 172  
 
 173  
     /**
 174  
      * Gets the overrideLookupClass attribute. 
 175  
      * @return Returns the overrideLookupClass.
 176  
      */
 177  
     public Class<? extends BusinessObject> getOverrideLookupClass() {
 178  0
         return overrideLookupClass;
 179  
     }
 180  
 
 181  
 
 182  
 
 183  
 
 184  
     /**
 185  
      * Directly validate simple fields.
 186  
      * 
 187  
      * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
 188  
      */
 189  
     public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
 190  0
         if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getName())) {
 191  0
             throw new AttributeValidationException("unable to find attribute or collection named '" + getName() + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' (" + "" + ")");
 192  
         }
 193  
 
 194  0
         if (StringUtils.isNotBlank(getAlternateDisplayAttributeName())) {
 195  0
             if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getAlternateDisplayAttributeName())) {
 196  0
                 throw new AttributeValidationException("unable to find attribute or collection named '" + getAlternateDisplayAttributeName() + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' (" + "" + ")");
 197  
             }
 198  
         }
 199  
         
 200  0
         if (StringUtils.isNotBlank(getAdditionalDisplayAttributeName())) {
 201  0
             if (!DataDictionary.isPropertyOf(rootBusinessObjectClass, getAdditionalDisplayAttributeName())) {
 202  0
                 throw new AttributeValidationException("unable to find attribute or collection named '" + getAdditionalDisplayAttributeName() + "' in rootBusinessObjectClass '" + rootBusinessObjectClass.getName() + "' (" + "" + ")");
 203  
             }
 204  
         }
 205  
 
 206  0
         if (defaultValueFinderClass != null && defaultValue != null) {
 207  0
             throw new AttributeValidationException("Both defaultValue and defaultValueFinderClass can not be specified on attribute " + getName() + " in rootBusinessObjectClass " + rootBusinessObjectClass.getName());
 208  
         }
 209  0
    }
 210  
 
 211  
     /**
 212  
      * @see java.lang.Object#toString()
 213  
      */
 214  
     public String toString() {
 215  0
         return "MaintainableFieldDefinition for field " + getName();
 216  
     }
 217  
 
 218  
 
 219  
     public String getTemplate() {
 220  0
         return template;
 221  
     }
 222  
 
 223  
 
 224  
     /**
 225  
 template documentation from MaintenanceUtils.java:
 226  
                             Field templates are used in relation to multiple value lookups.
 227  
                             When doing a MV lookup on a collection, the returned BOs
 228  
                             are not necessarily of the same type as the elements of the
 229  
                             collection. Therefore, a means of mapping between the fields
 230  
                             for the 2 BOs are necessary. The template attribute of
 231  
                             <maintainableField> contained within <maintainableCollection>
 232  
                             tells us this mapping.
 233  
                             Example:
 234  
                             <maintainableField name="collectionAttrib" template="lookupBOAttrib">
 235  
                             means that when a list of BOs are returned, the lookupBOAttrib value
 236  
                             of the looked up BO will be placed into the collectionAttrib
 237  
                             value of the BO added to the collection
 238  
  */
 239  
     public void setTemplate(String template) {
 240  0
         this.template = template;
 241  0
     }
 242  
 
 243  
 
 244  
     public String getWebUILeaveFieldCallbackFunction() {
 245  0
         return webUILeaveFieldCallbackFunction;
 246  
     }
 247  
 
 248  
 
 249  
     /**
 250  
                         * webUILeaveFieldCallbackFunction
 251  
                             This is the call javascript function related to the webUILeaveFieldFunction.
 252  
      */
 253  
     public void setWebUILeaveFieldCallbackFunction(String webUILeaveFieldCallbackFunction) {
 254  0
         this.webUILeaveFieldCallbackFunction = webUILeaveFieldCallbackFunction;
 255  0
     }
 256  
 
 257  
 
 258  
     public String getWebUILeaveFieldFunction() {
 259  0
         return webUILeaveFieldFunction;
 260  
     }
 261  
 
 262  
 
 263  
     /**
 264  
                         * webUILeaveFieldFunction is the name of a javascript function to called when
 265  
                             when the user tabs out of the field.
 266  
      */
 267  
     public void setWebUILeaveFieldFunction(String webUILeaveFieldFunction) {
 268  0
         this.webUILeaveFieldFunction = webUILeaveFieldFunction;
 269  0
     }
 270  
 
 271  
 
 272  
     public boolean isReadOnlyAfterAdd() {
 273  0
         return readOnlyAfterAdd;
 274  
     }
 275  
 
 276  
 
 277  
     /**
 278  
      * This is used to indicate that the field is read-only after the record has been
 279  
                             initially created.
 280  
      */
 281  
     public void setReadOnlyAfterAdd(boolean readOnlyAfterAdd) {
 282  0
         this.readOnlyAfterAdd = readOnlyAfterAdd;
 283  0
     }
 284  
 
 285  
 
 286  
     /**
 287  
 The defaultValueFinderClass specifies the java class that will be
 288  
                       used to determine the default value of a lookup field.  The classname
 289  
                       specified in this field must implement ValueFinder
 290  
    */
 291  
     public void setDefaultValueFinderClass(Class<? extends ValueFinder> defaultValueFinderClass) {
 292  0
         this.defaultValueFinderClass = defaultValueFinderClass;
 293  0
     }
 294  
 
 295  
 
 296  
     /**
 297  
      * The overrideLookupClass element is used to indicate the
 298  
                         class that should be used for the magnifying glass lookup.
 299  
                         The specified class must be a subclass of the business object
 300  
                         class.
 301  
      */
 302  
     public void setOverrideLookupClass(Class<? extends BusinessObject> overrideLookupClass) {
 303  0
         this.overrideLookupClass = overrideLookupClass;
 304  0
     }
 305  
     
 306  
         /**
 307  
          * @return the noLookup
 308  
          */
 309  
         public boolean isNoLookup() {
 310  0
                 return this.noLookup;
 311  
         }
 312  
 
 313  
         /**
 314  
          * @param noLookup the noLookup to set
 315  
          */
 316  
         public void setNoLookup(boolean noLookup) {
 317  0
                 this.noLookup = noLookup;
 318  0
         }
 319  
         
 320  
         public boolean isLookupReadOnly() {
 321  0
                 return lookupReadOnly;
 322  
         }
 323  
     
 324  
         public void setLookupReadOnly(boolean lookupReadOnly) {
 325  0
             this.lookupReadOnly = lookupReadOnly;
 326  0
     }
 327  
         
 328  
     public Boolean isShowFieldLevelHelp() {
 329  0
         return showFieldLevelHelp;
 330  
     }
 331  
 
 332  
     public void setShowFieldLevelHelp(Boolean showFieldLevelHelp) {
 333  0
         this.showFieldLevelHelp = showFieldLevelHelp;
 334  0
     }
 335  
 
 336  
     public String getFieldLevelHelpUrl() {
 337  0
         return fieldLevelHelpUrl;
 338  
     }
 339  
 
 340  
     public void setFieldLevelHelpUrl(String fieldLevelHelpUrl) {
 341  0
         this.fieldLevelHelpUrl = fieldLevelHelpUrl;
 342  0
     }
 343  
         
 344  
         /**
 345  
          * The alternateDisplayAttributeName is the name of the attribute whose value will be displayed instead
 346  
          * of the actual maintenance field attribute. Only applies when field is read-only.
 347  
          */
 348  
     public String getAlternateDisplayAttributeName() {
 349  0
                 return this.alternateDisplayAttributeName;
 350  
         }
 351  
 
 352  
         public void setAlternateDisplayAttributeName(String alternateDisplayAttributeName) {
 353  0
                 this.alternateDisplayAttributeName = alternateDisplayAttributeName;
 354  0
         }
 355  
 
 356  
         /**
 357  
          * The additionalDisplayAttributeName is the name of the attribute whose value will be displayed in addition
 358  
          * to the actual maintenance field attribute. Only applies when field is read-only.
 359  
          */
 360  
         public String getAdditionalDisplayAttributeName() {
 361  0
                 return this.additionalDisplayAttributeName;
 362  
         }
 363  
 
 364  
         public void setAdditionalDisplayAttributeName(String additionalDisplayAttributeName) {
 365  0
                 this.additionalDisplayAttributeName = additionalDisplayAttributeName;
 366  0
         }
 367  
         
 368  
         public boolean isTriggerOnChange() {
 369  0
                 return this.triggerOnChange;
 370  
         }
 371  
 
 372  
         public void setTriggerOnChange(boolean triggerOnChange) {
 373  0
                 this.triggerOnChange = triggerOnChange;
 374  0
         }
 375  
 
 376  
         /**
 377  
            * @return the webUILeaveFieldFunctionParameters
 378  
            */
 379  
           public List<String> getWebUILeaveFieldFunctionParameters() {
 380  0
                   return this.webUILeaveFieldFunctionParameters;
 381  
           }
 382  
 
 383  
           /**
 384  
            * @param webUILeaveFieldFunctionParameters the webUILeaveFieldFunctionParameters to set
 385  
            */
 386  
           public void setWebUILeaveFieldFunctionParameters(
 387  
                           List<String> webUILeaveFieldFunctionParameters) {
 388  0
                   this.webUILeaveFieldFunctionParameters = webUILeaveFieldFunctionParameters;
 389  0
           }
 390  
 
 391  
 }