Coverage Report - org.kuali.rice.kns.uif.field.LookupCriteriaAttributeField
 
Classes in this File Line Coverage Branch Coverage Complexity
LookupCriteriaAttributeField
0%
0/16
0%
0/16
4
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.uif.field;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kns.datadictionary.AttributeDefinition;
 20  
 import org.kuali.rice.kns.uif.control.MultiValueControlBase;
 21  
 import org.kuali.rice.kns.uif.control.RadioGroupControl;
 22  
 import org.kuali.rice.kns.uif.control.TextControl;
 23  
 import org.kuali.rice.kns.uif.util.LookupInquiryUtils;
 24  
 import org.kuali.rice.kns.util.KNSConstants;
 25  
 import org.kuali.rice.kns.util.KNSPropertyConstants;
 26  
 
 27  
 /**
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 30  
  */
 31  0
 public class LookupCriteriaAttributeField extends AttributeField {
 32  
 
 33  0
         protected boolean treatWildcardsAndOperatorsAsLiteral = false;
 34  
 
 35  
         /**
 36  
      * @return the treatWildcardsAndOperatorsAsLiteral
 37  
      */
 38  
     public boolean isTreatWildcardsAndOperatorsAsLiteral() {
 39  0
             return this.treatWildcardsAndOperatorsAsLiteral;
 40  
     }
 41  
 
 42  
         /**
 43  
      * @param treatWildcardsAndOperatorsAsLiteral the treatWildcardsAndOperatorsAsLiteral to set
 44  
      */
 45  
     public void setTreatWildcardsAndOperatorsAsLiteral(boolean treatWildcardsAndOperatorsAsLiteral) {
 46  0
             this.treatWildcardsAndOperatorsAsLiteral = treatWildcardsAndOperatorsAsLiteral;
 47  0
     }
 48  
 
 49  
         /**
 50  
          * Defaults the properties of the <code>AttributeField</code> to the corresponding properties of its <code>AttributeDefinition</code> retrieved from the dictionary (if such an entry exists). If
 51  
          * the field already contains a value for a property, the definitions value is not used.
 52  
          * 
 53  
          * @param attributeDefinition
 54  
          *            - AttributeDefinition instance the property values should be copied from
 55  
          */
 56  
         @Override
 57  
         public void copyFromAttributeDefinition(AttributeDefinition attributeDefinition) {
 58  0
                 LookupInquiryUtils.initializeAttributeFieldFromAttributeDefinition(this, attributeDefinition);
 59  
                 
 60  0
                 if (getControl() == null) {
 61  0
                     return;
 62  
                 }
 63  
 
 64  
                 // set field size to 30 if not already set
 65  0
                 if ( (TextControl.class.isAssignableFrom(getControl().getClass())) && (((TextControl)getControl()).getSize() <= 0) ) {
 66  0
                         ((TextControl)getControl()).setSize(30);
 67  
                 }
 68  
 
 69  
                 // overwrite maxLength to allow for wildcards and ranges in the select, but only if it's not a mulitselect box, because maxLength determines the # of entries
 70  0
                 if ((getMaxLength() == null) && (!MultiValueControlBase.class.isAssignableFrom(getControl().getClass()))) {
 71  0
                         setMaxLength(100);
 72  
                 }
 73  
 
 74  0
                 if (StringUtils.isEmpty(getDefaultValue())) {
 75  
                         // if the attrib name is "active", and BO is Inactivatable, then set the default value to Y
 76  
                         // TODO delyea: this used to take into account if the class was Inactivateable:
 77  
                         // Inactivateable.class.isAssignableFrom(businessObjectClass)
 78  
                         // TODO delyea: check to see if the propertyName needs to be checked for instances where getPropertyName() returns "bo.active"
 79  0
                         if ((StringUtils.equals(getPropertyName(), KNSPropertyConstants.ACTIVE)) && (RadioGroupControl.class.isAssignableFrom(getControl().getClass()))) {
 80  0
                                 setDefaultValue(KNSConstants.YES_INDICATOR_VALUE);
 81  
                         }
 82  
                 }
 83  
 
 84  
                 /*
 85  
                  * TODO delyea: FieldUtils.createAndPopulateFieldsForLookup used to allow for a set of property names to be passed in via the URL 
 86  
                  * parameters of the lookup url to set fields as 'read only'
 87  
                  */
 88  
 
 89  0
         }
 90  
 
 91  
 }