Coverage Report - org.kuali.rice.core.api.uif.RemotableQuickFinder
 
Classes in this File Line Coverage Branch Coverage Complexity
RemotableQuickFinder
77%
14/18
N/A
1.353
RemotableQuickFinder$1
N/A
N/A
1.353
RemotableQuickFinder$Builder
85%
23/27
100%
8/8
1.353
RemotableQuickFinder$Constants
0%
0/1
N/A
1.353
RemotableQuickFinder$Elements
0%
0/1
N/A
1.353
 
 1  
 package org.kuali.rice.core.api.uif;
 2  
 
 3  
 import org.apache.commons.lang.StringUtils;
 4  
 import org.kuali.rice.core.api.CoreConstants;
 5  
 import org.kuali.rice.core.api.util.jaxb.MapStringStringAdapter;
 6  
 import org.w3c.dom.Element;
 7  
 
 8  
 import javax.xml.bind.annotation.XmlAccessType;
 9  
 import javax.xml.bind.annotation.XmlAccessorType;
 10  
 import javax.xml.bind.annotation.XmlAnyElement;
 11  
 import javax.xml.bind.annotation.XmlElement;
 12  
 import javax.xml.bind.annotation.XmlRootElement;
 13  
 import javax.xml.bind.annotation.XmlType;
 14  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 15  
 import java.util.Collection;
 16  
 import java.util.Collections;
 17  
 import java.util.HashMap;
 18  
 import java.util.Map;
 19  
 
 20  
 /**
 21  
  * A quick finder widget that can be used by a TextInput, HiddenInput, Select, or MultiSelect control types.
 22  
  */
 23  
 @XmlRootElement(name = RemotableQuickFinder.Constants.ROOT_ELEMENT_NAME)
 24  
 @XmlAccessorType(XmlAccessType.NONE)
 25  
 @XmlType(name = RemotableQuickFinder.Constants.TYPE_NAME, propOrder = {
 26  
                 RemotableQuickFinder.Elements.BASE_LOOKUP_URL,
 27  
         RemotableQuickFinder.Elements.DATA_OBJECT_CLASS,
 28  
         RemotableQuickFinder.Elements.LOOKUP_PARAMETERS,
 29  
         RemotableQuickFinder.Elements.FIELD_CONVERSIONS,
 30  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS })
 31  8
 public final class RemotableQuickFinder extends RemotableAbstractWidget {
 32  
 
 33  
     @XmlElement(name = Elements.BASE_LOOKUP_URL, required = true)
 34  
     private final String baseLookupUrl;
 35  
 
 36  
     @XmlElement(name = Elements.DATA_OBJECT_CLASS, required = true)
 37  
     private final String dataObjectClass;
 38  
 
 39  
     @XmlElement(name = Elements.LOOKUP_PARAMETERS, required = false)
 40  
     @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
 41  
     private final Map<String, String> lookupParameters;
 42  
 
 43  
     @XmlElement(name = Elements.FIELD_CONVERSIONS, required = false)
 44  
     @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
 45  
     private final Map<String, String> fieldConversions;
 46  
 
 47  14
     @SuppressWarnings("unused")
 48  
     @XmlAnyElement
 49  
     private final Collection<Element> _futureElements = null;
 50  
 
 51  
     /**
 52  
      * Should only be invoked by JAXB.
 53  
      */
 54  
     @SuppressWarnings("unused")
 55  6
     private RemotableQuickFinder() {
 56  6
         baseLookupUrl = null;
 57  6
         dataObjectClass = null;
 58  6
         lookupParameters = null;
 59  6
         fieldConversions = null;
 60  6
     }
 61  
 
 62  8
     private RemotableQuickFinder(Builder b) {
 63  8
         baseLookupUrl = b.baseLookupUrl;
 64  8
         dataObjectClass = b.dataObjectClass;
 65  8
         lookupParameters = b.lookupParameters;
 66  8
         fieldConversions = b.fieldConversions;
 67  8
     }
 68  
 
 69  
     public String getBaseLookupUrl() {
 70  0
         return baseLookupUrl;
 71  
     }
 72  
 
 73  
     public String getDataObjectClass() {
 74  0
         return dataObjectClass;
 75  
     }
 76  
 
 77  
     public Map<String, String> getLookupParameters() {
 78  0
         return Collections.unmodifiableMap(lookupParameters);
 79  
     }
 80  
 
 81  
     public Map<String, String> getFieldConversions() {
 82  0
         return Collections.unmodifiableMap(fieldConversions);
 83  
     }
 84  
 
 85  40
     public static final class Builder extends RemotableAbstractWidget.Builder {
 86  
         private String baseLookupUrl;
 87  
         private String dataObjectClass;
 88  12
         private Map<String, String> lookupParameters = Collections.emptyMap();
 89  12
         private Map<String, String> fieldConversions = Collections.emptyMap();
 90  
 
 91  12
         private Builder(String baseLookupUrl, String dataObjectClass) {
 92  12
             setBaseLookupUrl(baseLookupUrl);
 93  10
             setDataObjectClass(dataObjectClass);
 94  8
         }
 95  
 
 96  
         public static Builder create(String baseLookupUrl, String dataObjectClass) {
 97  12
             return new Builder(baseLookupUrl, dataObjectClass);
 98  
         }
 99  
 
 100  
         public String getBaseLookupUrl() {
 101  0
             return baseLookupUrl;
 102  
         }
 103  
 
 104  
         public void setBaseLookupUrl(String baseLookupUrl) {
 105  12
             if (StringUtils.isBlank(baseLookupUrl)) {
 106  2
                 throw new IllegalArgumentException("baseLookupUrl is blank");
 107  
             }
 108  
 
 109  10
             this.baseLookupUrl = baseLookupUrl;
 110  10
         }
 111  
 
 112  
         public String getDataObjectClass() {
 113  0
             return dataObjectClass;
 114  
         }
 115  
 
 116  
         public void setDataObjectClass(String dataObjectClass) {
 117  10
             if (StringUtils.isBlank(dataObjectClass)) {
 118  2
                 throw new IllegalArgumentException("dataObjectClass is blank");
 119  
             }
 120  
 
 121  8
             this.dataObjectClass = dataObjectClass;
 122  8
         }
 123  
 
 124  
         public Map<String, String> getLookupParameters() {
 125  0
             return Collections.unmodifiableMap(lookupParameters);
 126  
         }
 127  
 
 128  
         public void setLookupParameters(Map<String, String> lookupParameters) {
 129  4
             if (lookupParameters != null) {
 130  3
                 this.lookupParameters = new HashMap<String, String>(lookupParameters);
 131  
             }
 132  4
         }
 133  
 
 134  
         public Map<String, String> getFieldConversions() {
 135  0
             return Collections.unmodifiableMap(fieldConversions);
 136  
         }
 137  
 
 138  
         public void setFieldConversions(Map<String, String> fieldConversions) {
 139  4
             if (fieldConversions != null) {
 140  3
                 this.fieldConversions = new HashMap<String, String>(fieldConversions);
 141  
             }
 142  4
         }
 143  
 
 144  
         @Override
 145  
         public RemotableQuickFinder build() {
 146  8
             return new RemotableQuickFinder(this);
 147  
         }
 148  
     }
 149  
 
 150  
     /**
 151  
      * Defines some internal constants used on this class.
 152  
      */
 153  0
     static final class Constants {
 154  
         static final String TYPE_NAME = "QuickFinderType";
 155  
         final static String ROOT_ELEMENT_NAME = "quickFinder";
 156  
     }
 157  
 
 158  0
     static final class Elements {
 159  
         static final String BASE_LOOKUP_URL = "baseLookupUrl";
 160  
         static final String DATA_OBJECT_CLASS = "dataObjectClass";
 161  
         static final String LOOKUP_PARAMETERS = "lookupParameters";
 162  
         static final String FIELD_CONVERSIONS = "fieldConversions";
 163  
     }
 164  
 }