/**
   * Override of InputField copy to setup properties necessary to make the field usable for
   * inputting search criteria.
   *
   * <p>Note super is not being called because we don't want to add restirctions that can cause
   * problems with the use of wildcard {@inheritDoc}
   */
  @Override
  public void copyFromAttributeDefinition(AttributeDefinition attributeDefinition) {
    // label
    if (StringUtils.isEmpty(getLabel())) {
      setLabel(attributeDefinition.getLabel());
    }

    // short label
    if (StringUtils.isEmpty(getShortLabel())) {
      setShortLabel(attributeDefinition.getShortLabel());
    }

    // security
    if ((attributeDefinition.getAttributeSecurity() != null)
        && ((getDataFieldSecurity() == null)
            || (getDataFieldSecurity().getAttributeSecurity() == null))) {
      initializeComponentSecurity();

      getDataFieldSecurity().setAttributeSecurity(attributeDefinition.getAttributeSecurity());
    }

    // options
    if (getOptionsFinder() == null) {
      setOptionsFinder(attributeDefinition.getOptionsFinder());
    }

    // use control from dictionary if not specified and convert for searching
    if (getControl() == null) {
      Control control = convertControlToLookupControl(attributeDefinition);
      setControl(control);
    }

    // overwrite maxLength to allow for wildcards and ranges; set a minimum max length unless it is
    // greater than 100
    setMaxLength(100);
    if (attributeDefinition.getMaxLength() != null && (attributeDefinition.getMaxLength() > 100)) {
      setMaxLength(attributeDefinition.getMaxLength());
    }

    // set default value for active field to true
    if (getDefaultValue() == null
        || (getDefaultValue() instanceof String
            && StringUtils.isEmpty((String) getDefaultValue()))) {
      if ((StringUtils.equals(getPropertyName(), KRADPropertyConstants.ACTIVE))) {
        setDefaultValue(KRADConstants.YES_INDICATOR_VALUE);
      }
    }
  }
 protected Control getControlInstance(
     AttributeDefinition attrDef, DataObjectAttribute dataObjectAttribute) {
   Control c = null;
   // Check for the hidden hint - if present - then use that control type
   if (dataObjectAttribute != null
       && hasHintOfType(dataObjectAttribute, UifDisplayHintType.HIDDEN)) {
     c = ComponentFactory.getHiddenControl();
   } else if (attrDef.getOptionsFinder() != null) {
     // if a values finder has been established, use a radio button group or drop-down list
     if (dataObjectAttribute != null
         && hasHintOfType(dataObjectAttribute, UifDisplayHintType.RADIO)) {
       c = ComponentFactory.getRadioGroupControl();
     } else {
       c = ComponentFactory.getSelectControl();
     }
   } else if (attrDef.getName().endsWith(".principalName") && dataObjectAttribute != null) {
     // FIXME: JHK: Yes, I know this is a *HORRIBLE* hack - but the alternative
     // would look even more "hacky" and error-prone
     c = ComponentFactory.getUserControl();
     // Need to find the relationship information
     // get the relationship ID by removing .principalName from the attribute name
     String relationshipName = StringUtils.removeEnd(attrDef.getName(), ".principalName");
     DataObjectMetadata metadata =
         dataObjectService
             .getMetadataRepository()
             .getMetadata(dataObjectAttribute.getOwningType());
     if (metadata != null) {
       DataObjectRelationship relationship = metadata.getRelationship(relationshipName);
       if (relationship != null
           && CollectionUtils.isNotEmpty(relationship.getAttributeRelationships())) {
         ((UserControl) c)
             .setPrincipalIdPropertyName(
                 relationship.getAttributeRelationships().get(0).getParentAttributeName());
         ((UserControl) c)
             .setPersonNamePropertyName(
                 relationshipName + "." + KimConstants.AttributeConstants.NAME);
         ((UserControl) c).setPersonObjectPropertyName(relationshipName);
       }
     } else {
       LOG.warn(
           "Attempt to pull relationship name: "
               + relationshipName
               + " resulted in missing metadata when looking for: "
               + dataObjectAttribute.getOwningType());
     }
   } else {
     switch (attrDef.getDataType()) {
       case STRING:
         // TODO: Determine better way to store the "200" metric below
         if (attrDef.getMaxLength() != null && attrDef.getMaxLength().intValue() > 200) {
           c = ComponentFactory.getTextAreaControl();
         } else {
           c = ComponentFactory.getTextControl();
         }
         break;
       case BOOLEAN:
         c = ComponentFactory.getCheckboxControl();
         break;
       case DATE:
       case DATETIME:
       case TRUNCATED_DATE:
         c = ComponentFactory.getDateControl();
         break;
       case CURRENCY:
       case DOUBLE:
       case FLOAT:
       case INTEGER:
       case LARGE_INTEGER:
       case LONG:
       case PRECISE_DECIMAL:
         c = ComponentFactory.getTextControl();
         break;
       case MARKUP:
         c = ComponentFactory.getTextAreaControl();
         break;
       default:
         c = ComponentFactory.getTextControl();
         break;
     }
   }
   return c;
 }