Coverage Report - org.kuali.rice.kns.uif.widget.Suggest
 
Classes in this File Line Coverage Branch Coverage Complexity
Suggest
0%
0/15
0%
0/2
1.333
 
 1  
 /*
 2  
  * Copyright 2007 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.widget;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kns.uif.container.View;
 20  
 import org.kuali.rice.kns.uif.core.BindingInfo;
 21  
 import org.kuali.rice.kns.uif.core.Component;
 22  
 import org.kuali.rice.kns.uif.field.AttributeField;
 23  
 import org.kuali.rice.kns.uif.field.AttributeQuery;
 24  
 import org.kuali.rice.kns.uif.util.ComponentUtils;
 25  
 import org.kuali.rice.kns.uif.util.ObjectPropertyUtils;
 26  
 import org.kuali.rice.kns.util.ObjectUtils;
 27  
 
 28  
 import java.util.Map;
 29  
 
 30  
 /**
 31  
  * Widget that provides dynamic select options to the user as they
 32  
  * are entering the value (also known as auto-complete)
 33  
  *
 34  
  * <p>
 35  
  * Widget is backed by an <code>AttributeQuery</code> that provides
 36  
  * the configuration for executing a query server side that will retrieve
 37  
  * the valid option values.
 38  
  * </p>
 39  
  *
 40  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 41  
  */
 42  
 public class Suggest extends WidgetBase {
 43  
     private static final long serialVersionUID = 7373706855319347225L;
 44  
 
 45  
     private AttributeQuery suggestQuery;
 46  
     private String sourcePropertyName;
 47  
 
 48  
     public Suggest() {
 49  0
         super();
 50  0
     }
 51  
 
 52  
     /**
 53  
      * The following actions are performed:
 54  
      *
 55  
      * <ul>
 56  
      * <li>Adjusts the query field mappings on the query based on the binding configuration of the field</li>
 57  
      * <li>TODO: determine query if render is true and query is not set</li>
 58  
      * </ul>
 59  
      *
 60  
      * @see org.kuali.rice.kns.uif.core.ComponentBase#performFinalize(org.kuali.rice.kns.uif.container.View,
 61  
      *      java.lang.Object, org.kuali.rice.kns.uif.core.Component)
 62  
      */
 63  
     @Override
 64  
     public void performFinalize(View view, Object model, Component parent) {
 65  0
         super.performFinalize(view, model, parent);
 66  
 
 67  0
         if (!isRender()) {
 68  0
             return;
 69  
         }
 70  
 
 71  0
         AttributeField field = (AttributeField) parent;
 72  0
         BindingInfo bindingInfo = field.getBindingInfo();
 73  
 
 74  
         // adjust from side on query field mapping to match parent fields path
 75  0
         suggestQuery.updateQueryFieldMapping(bindingInfo);
 76  0
     }
 77  
 
 78  
     /**
 79  
      * Attribute query instance the will be executed to provide
 80  
      * the suggest options
 81  
      *
 82  
      * @return AttributeQuery
 83  
      */
 84  
     public AttributeQuery getSuggestQuery() {
 85  0
         return suggestQuery;
 86  
     }
 87  
 
 88  
     /**
 89  
      * Setter for the suggest attribute query
 90  
      *
 91  
      * @param suggestQuery
 92  
      */
 93  
     public void setSuggestQuery(AttributeQuery suggestQuery) {
 94  0
         this.suggestQuery = suggestQuery;
 95  0
     }
 96  
 
 97  
     /**
 98  
      * Name of the property on the query result object that provides
 99  
      * the options for the suggest, values from this field will be
 100  
      * collected and sent back on the result to provide as suggest options
 101  
      *
 102  
      * @return String source property name
 103  
      */
 104  
     public String getSourcePropertyName() {
 105  0
         return sourcePropertyName;
 106  
     }
 107  
 
 108  
     /**
 109  
      * Setter for the source property name
 110  
      *
 111  
      * @param sourcePropertyName
 112  
      */
 113  
     public void setSourcePropertyName(String sourcePropertyName) {
 114  0
         this.sourcePropertyName = sourcePropertyName;
 115  0
     }
 116  
 }