| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| LookupCriteriaAttributeField | 
  | 
  | 4.0;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 |                  // security | |
| 61 | 0 |                  if (getAttributeSecurity() == null) { | 
| 62 |                          //setAttributeSecurity(attributeDefinition.getAttribute== null) { | |
| 63 | 0 |                      return; | 
| 64 | }  | |
| 65 | ||
| 66 |                  // set field size to 30 if not already set | |
| 67 | 0 |                  if ( (TextControl.class.isAssignableFrom(getControl().getClass())) && (((TextControl)getControl()).getSize() <= 0) ) { | 
| 68 | 0 |                          ((TextControl)getControl()).setSize(30); | 
| 69 | }  | |
| 70 | ||
| 71 |                  // 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 | |
| 72 | 0 |                  if ((getMaxLength() == null) && (!MultiValueControlBase.class.isAssignableFrom(getControl().getClass()))) { | 
| 73 | 0 |                          setMaxLength(100); | 
| 74 | }  | |
| 75 | ||
| 76 | 0 |                  if (StringUtils.isEmpty(getDefaultValue())) { | 
| 77 |                          // if the attrib name is "active", and BO is Inactivatable, then set the default value to Y | |
| 78 |                          // TODO delyea: this used to take into account if the class was Inactivateable: | |
| 79 |                          // Inactivateable.class.isAssignableFrom(businessObjectClass) | |
| 80 |                          // TODO delyea: check to see if the propertyName needs to be checked for instances where getPropertyName() returns "bo.active" | |
| 81 | 0 |                          if ((StringUtils.equals(getPropertyName(), KNSPropertyConstants.ACTIVE)) && (RadioGroupControl.class.isAssignableFrom(getControl().getClass()))) { | 
| 82 | 0 |                                  setDefaultValue(KNSConstants.YES_INDICATOR_VALUE); | 
| 83 | }  | |
| 84 | }  | |
| 85 | ||
| 86 |                  /* | |
| 87 |                   * TODO delyea: FieldUtils.createAndPopulateFieldsForLookup used to allow for a set of property names to be passed in via the URL  | |
| 88 |                   * parameters of the lookup url to set fields as 'read only' | |
| 89 |                   */ | |
| 90 | ||
| 91 | 0 |          } | 
| 92 | ||
| 93 | }  |