View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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.krad.uif.widget;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.rice.krad.bo.DataObjectRelationship;
25  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
26  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
27  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
28  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
29  import org.kuali.rice.krad.uif.UifConstants;
30  import org.kuali.rice.krad.uif.UifParameters;
31  import org.kuali.rice.krad.uif.component.BindingInfo;
32  import org.kuali.rice.krad.uif.component.Component;
33  import org.kuali.rice.krad.uif.container.CollectionGroup;
34  import org.kuali.rice.krad.uif.element.Action;
35  import org.kuali.rice.krad.uif.field.InputField;
36  import org.kuali.rice.krad.uif.lifecycle.LifecycleEventListener;
37  import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle;
38  import org.kuali.rice.krad.uif.lifecycle.ViewPostMetadata;
39  import org.kuali.rice.krad.uif.util.LifecycleElement;
40  import org.kuali.rice.krad.uif.util.ViewModelUtils;
41  import org.kuali.rice.krad.uif.view.View;
42  import org.kuali.rice.krad.util.KRADConstants;
43  import org.kuali.rice.krad.util.KRADUtils;
44  
45  /**
46   * Widget for navigating to a lookup from a field (called a quickfinder).
47   *
48   * @author Kuali Rice Team (rice.collab@kuali.org)
49   */
50  @BeanTags({@BeanTag(name = "quickFinder-bean", parent = "Uif-QuickFinder"),
51          @BeanTag(name = "quickFinderByScript-bean", parent = "Uif-QuickFinderByScript"),
52          @BeanTag(name = "collectionQuickFinder-bean", parent = "Uif-CollectionQuickFinder")})
53  public class QuickFinder extends WidgetBase implements LifecycleEventListener {
54      private static final long serialVersionUID = 3302390972815386785L;
55  
56      // lookup configuration
57      private String baseLookupUrl;
58      private String dataObjectClassName;
59      private String viewName;
60  
61      private boolean returnByScript;
62      private String readOnlyLookupFields;
63      private String referencesToRefresh;
64      private String lookupCollectionName;
65      private String lookupCollectionId;
66  
67      private Map<String, String> fieldConversions;
68      private Map<String, String> lookupParameters;
69      private Map<String, String> additionalLookupParameters;
70  
71      private Action quickfinderAction;
72      private LightBox lightBox;
73  
74      // lookup view options
75      private Boolean renderReturnLink;
76      private Boolean renderResultActions;
77      private Boolean autoSearch;
78      private Boolean renderLookupCriteria;
79      private Boolean renderCriteriaActions;
80      private Boolean hideCriteriaOnSearch;
81      private Boolean renderMaintenanceLinks;
82      private Boolean multipleValuesSelect;
83  
84      public QuickFinder() {
85          super();
86  
87          fieldConversions = new HashMap<String, String>();
88          lookupParameters = new HashMap<String, String>();
89      }
90  
91      /**
92       * The following initialization is performed:
93       *
94       * <ul>
95       * <li>Registers an event on the quickfinder action</li>
96       * </ul>
97       *
98       * {@inheritDoc}
99       */
100     @Override
101     public void performInitialization(Object model) {
102         super.performInitialization(model);
103 
104         ViewLifecycle viewLifecycle = ViewLifecycle.getActiveLifecycle();
105         viewLifecycle.registerLifecycleCompleteListener(quickfinderAction, this);
106     }
107 
108     /**
109      * The following finalization is performed:
110      *
111      * <ul>
112      * <li>Sets up the quickfinder based on whether the parent is an input field or collection group</li>
113      * <li>Adds action parameters to the quickfinder action based on the quickfinder configuration</li>
114      * </ul>
115      *
116      * {@inheritDoc}
117      */
118     @Override
119     public void performFinalize(Object model, LifecycleElement parent) {
120         super.performFinalize(model, parent);
121 
122         if (parent instanceof Component && ((Component) parent).isReadOnly()) {
123             setRender(false);
124         }
125 
126         if (!isRender()) {
127             return;
128         }
129         
130         View view = ViewLifecycle.getActiveLifecycle().getView();
131 
132         if (parent instanceof InputField) {
133             setupForInputField(view, model, (InputField) parent);
134 
135             // add field conversions as accessible binding paths
136             if (isRender()) {
137                 for (String toField : fieldConversions.values()) {
138                     ViewLifecycle.getViewPostMetadata().addAccessibleBindingPath(toField);
139                 }
140             }
141         } else if (parent instanceof CollectionGroup) {
142             setupForCollectionGroup(view, model, (CollectionGroup) parent);
143         }
144 
145         setupQuickfinderAction(view, model, parent);
146     }
147 
148     /**
149      * If quickfinder not manually configured attempts to find a relationship to build the quickfinder on, then also
150      * adjusts the path for any configured field conversions, lookup parameters, and refresh refreshes.
151      *
152      * @param view view instance the quickfinder is associated with
153      * @param model object containing the view data
154      * @param inputField input field instance the quickfinder should apply to
155      */
156     protected void setupForInputField(View view, Object model, InputField inputField) {
157         // if quickfinder class name not specified, attempt to find a relationship to build the quickfinder from
158         if (StringUtils.isBlank(dataObjectClassName)) {
159             DataObjectRelationship relationship = getRelationshipForField(view, model, inputField);
160 
161             // if no relationship found cannot have a quickfinder
162             if (relationship == null) {
163                 setRender(false);
164 
165                 return;
166             }
167 
168             dataObjectClassName = relationship.getRelatedClass().getName();
169 
170             if ((fieldConversions == null) || fieldConversions.isEmpty()) {
171                 generateFieldConversions(relationship);
172             }
173 
174             if ((lookupParameters == null) || lookupParameters.isEmpty()) {
175                 generateLookupParameters(relationship);
176             }
177         }
178 
179         // adjust paths based on associated attribute field
180         updateFieldConversions(inputField.getBindingInfo());
181         updateLookupParameters(inputField.getBindingInfo());
182         updateReferencesToRefresh(inputField.getBindingInfo());
183 
184         // add the quickfinders action as an input field addon
185         inputField.addPostInputAddon(quickfinderAction);
186     }
187 
188     /**
189      * Retrieves any {@link org.kuali.rice.krad.bo.DataObjectRelationship} that is associated with the given
190      * field and has a configured lookup view.
191      *
192      * @param view view instance the quickfinder is associated with
193      * @param model object containing the view data
194      * @param field input field instance the quickfinder should apply to
195      * @return data object relationship for the field, or null if one could not be found
196      */
197     protected DataObjectRelationship getRelationshipForField(View view, Object model, InputField field) {
198         String propertyName = field.getBindingInfo().getBindingName();
199 
200         // get object instance and class for parent
201         Object parentObject = ViewModelUtils.getParentObjectForMetadata(view, model, field);
202         Class<?> parentObjectClass = null;
203         if (parentObject != null) {
204             parentObjectClass = parentObject.getClass();
205         }
206 
207         // get relationship from metadata service
208         return KRADServiceLocatorWeb.getLegacyDataAdapter().getDataObjectRelationship(parentObject,
209                 parentObjectClass, propertyName, "", true, true, false);
210     }
211 
212     /**
213      * Generates the lookup field conversions based on the references from the given relationship.
214      *
215      * @param relationship relationship field conversions will be generated from
216      */
217     protected void generateFieldConversions(DataObjectRelationship relationship) {
218         fieldConversions = new HashMap<String, String>();
219 
220         for (Map.Entry<String, String> entry : relationship.getParentToChildReferences().entrySet()) {
221             String fromField = entry.getValue();
222             String toField = entry.getKey();
223 
224             fieldConversions.put(fromField, toField);
225         }
226     }
227 
228     /**
229      * Generates the lookup parameters based on the references from the given relationship.
230      *
231      * @param relationship relationship lookup parameters will be generated from
232      */
233     protected void generateLookupParameters(DataObjectRelationship relationship) {
234         lookupParameters = new HashMap<String, String>();
235 
236         for (Map.Entry<String, String> entry : relationship.getParentToChildReferences().entrySet()) {
237             String fromField = entry.getKey();
238             String toField = entry.getValue();
239 
240             if (relationship.getUserVisibleIdentifierKey() == null || relationship.getUserVisibleIdentifierKey().equals(
241                     fromField)) {
242                 lookupParameters.put(fromField, toField);
243             }
244         }
245     }
246 
247     /**
248      * Adjusts the path on the field conversion to property to match the binding path prefix of the
249      * given {@link org.kuali.rice.krad.uif.component.BindingInfo}.
250      *
251      * @param bindingInfo binding info instance to copy binding path prefix from
252      */
253     protected void updateFieldConversions(BindingInfo bindingInfo) {
254         Map<String, String> adjustedFieldConversions = new HashMap<String, String>();
255         for (String fromField : fieldConversions.keySet()) {
256             String toField = fieldConversions.get(fromField);
257 
258             if (!StringUtils.startsWith(toField, bindingInfo.getBindingPathPrefix())) {
259                 String adjustedToFieldPath = bindingInfo.getPropertyAdjustedBindingPath(toField);
260                 adjustedFieldConversions.put(fromField, adjustedToFieldPath);
261             }  else {
262                 adjustedFieldConversions.put(fromField, toField);
263             }
264         }
265 
266         this.fieldConversions = adjustedFieldConversions;
267     }
268 
269     /**
270      * Adjusts the path on the lookup parameter from property to match the binding path prefix of the
271      * given {@link org.kuali.rice.krad.uif.component.BindingInfo}.
272      *
273      * @param bindingInfo binding info instance to copy binding path prefix from
274      */
275     protected void updateLookupParameters(BindingInfo bindingInfo) {
276         Map<String, String> adjustedLookupParameters = new HashMap<String, String>();
277         for (String fromField : lookupParameters.keySet()) {
278             String toField = lookupParameters.get(fromField);
279             String adjustedFromFieldPath = bindingInfo.getPropertyAdjustedBindingPath(fromField);
280 
281             adjustedLookupParameters.put(adjustedFromFieldPath, toField);
282         }
283 
284         this.lookupParameters = adjustedLookupParameters;
285     }
286 
287     /**
288      * Adjust the path on the referencesToRefresh parameter to match the binding path prefix of the
289      * given {@link org.kuali.rice.krad.uif.component.BindingInfo}.
290      *
291      * @param bindingInfo binding info instance to copy binding path prefix from
292      */
293     protected void updateReferencesToRefresh(BindingInfo bindingInfo) {
294         List<String> adjustedReferencesToRefresh = new ArrayList<String>();
295 
296         if (referencesToRefresh == null) {
297             referencesToRefresh = new String();
298         }
299 
300         for (String reference : StringUtils.split(referencesToRefresh, KRADConstants.REFERENCES_TO_REFRESH_SEPARATOR)) {
301             adjustedReferencesToRefresh.add(bindingInfo.getPropertyAdjustedBindingPath(reference));
302         }
303 
304         this.referencesToRefresh = StringUtils.join(adjustedReferencesToRefresh,
305                 KRADConstants.REFERENCES_TO_REFRESH_SEPARATOR);
306     }
307 
308     /**
309      * Configures the quickfinder for the given collection group instance by setting the data object class,
310      * field conversions, and lookup collection name (if necessary).
311      *
312      * @param view view instance the quickfinder is associated with
313      * @param model object containing the view data
314      * @param collectionGroup collection group instance to build quickfinder for
315      */
316     protected void setupForCollectionGroup(View view, Object model, CollectionGroup collectionGroup) {
317         // check to see if data object class is configured for lookup, if so we will assume it should be enabled
318         // if not and the class configured for the collection group is lookupable, use that
319         if (StringUtils.isBlank(getDataObjectClassName())) {
320             Class<?> collectionObjectClass = collectionGroup.getCollectionObjectClass();
321 
322             boolean isCollectionClassLookupable = KRADServiceLocatorWeb.getViewDictionaryService().isLookupable(
323                     collectionObjectClass);
324             if (isCollectionClassLookupable) {
325                 setDataObjectClassName(collectionObjectClass.getName());
326 
327                 // use PK fields for collection class as default field conversions
328                 if ((fieldConversions == null) || fieldConversions.isEmpty()) {
329                     List<String> collectionObjectPKFields =
330                             KRADServiceLocatorWeb.getLegacyDataAdapter().listPrimaryKeyFieldNames(
331                                     collectionObjectClass);
332 
333                     fieldConversions = new HashMap<String, String>();
334                     for (String pkField : collectionObjectPKFields) {
335                         fieldConversions.put(pkField, pkField);
336                     }
337                 }
338             } else {
339                 // no available data object class to lookup so disable quickfinder
340                 setRender(false);
341             }
342         }
343 
344         // set the lookup return collection name to this collection path
345         if (isRender() && StringUtils.isBlank(getLookupCollectionName())) {
346             setLookupCollectionName(collectionGroup.getBindingInfo().getBindingPath());
347         }
348 
349         if (isRender() && StringUtils.isBlank(getLookupCollectionId())) {
350             setLookupCollectionId(collectionGroup.getId());
351         }
352     }
353 
354     /**
355      * Adjusts the id for the quickfinder action, and then adds action parameters for passing along the
356      * quickfinder configuration to the lookup view.
357      *
358      * @param view view instance the quickfinder is associated with
359      * @param model object containing the view data
360      * @param parent component instance the quickfinder is associated with
361      */
362     protected void setupQuickfinderAction(View view, Object model, LifecycleElement parent) {
363         quickfinderAction.setId(getId() + UifConstants.IdSuffixes.ACTION);
364 
365         if ((lightBox != null) && lightBox.isRender()) {
366             String lightboxScript = UifConstants.JsFunctions.CREATE_LIGHTBOX_POST + "(\"" + quickfinderAction.getId()
367                     + "\"," + lightBox.getTemplateOptionsJSString() + "," + returnByScript + ");";
368 
369             quickfinderAction.setActionScript(lightboxScript);
370         }
371 
372         quickfinderAction.addActionParameter(UifParameters.BASE_LOOKUP_URL, baseLookupUrl);
373         quickfinderAction.addActionParameter(UifParameters.DATA_OBJECT_CLASS_NAME, dataObjectClassName);
374 
375         if (!fieldConversions.isEmpty()) {
376             quickfinderAction.addActionParameter(UifParameters.CONVERSION_FIELDS, KRADUtils.buildMapParameterString(
377                     fieldConversions));
378         }
379 
380         if (!lookupParameters.isEmpty()) {
381             quickfinderAction.addActionParameter(UifParameters.LOOKUP_PARAMETERS, KRADUtils.buildMapParameterString(
382                     lookupParameters));
383         }
384 
385         addActionParameterIfNotNull(UifParameters.VIEW_NAME, viewName);
386         addActionParameterIfNotNull(UifParameters.READ_ONLY_FIELDS, readOnlyLookupFields);
387         addActionParameterIfNotNull(UifParameters.RENDER_RETURN_LINK, renderReturnLink);
388         addActionParameterIfNotNull(UifParameters.RENDER_RESULT_ACTIONS, renderResultActions);
389         addActionParameterIfNotNull(UifParameters.REFERENCES_TO_REFRESH, referencesToRefresh);
390         addActionParameterIfNotNull(UifParameters.AUTO_SEARCH, autoSearch);
391         addActionParameterIfNotNull(UifParameters.RENDER_LOOKUP_CRITERIA, renderLookupCriteria);
392         addActionParameterIfNotNull(UifParameters.RENDER_CRITERIA_ACTIONS, renderCriteriaActions);
393         addActionParameterIfNotNull(UifParameters.HIDE_CRITERIA_ON_SEARCH, hideCriteriaOnSearch);
394         addActionParameterIfNotNull(UifParameters.RENDER_MAINTENANCE_LINKS, renderMaintenanceLinks);
395         addActionParameterIfNotNull(UifParameters.MULTIPLE_VALUES_SELECT, multipleValuesSelect);
396         addActionParameterIfNotNull(UifParameters.LOOKUP_COLLECTION_NAME, lookupCollectionName);
397         addActionParameterIfNotNull(UifParameters.LOOKUP_COLLECTION_ID, lookupCollectionId);
398         addActionParameterIfNotNull(UifParameters.QUICKFINDER_ID, getId());
399 
400         //insert additional lookup parameters.
401         if (additionalLookupParameters != null) {
402             //copy additional parameters to actionParameters
403             Map<String, String> actionParameters = quickfinderAction.getActionParameters();
404             actionParameters.putAll(additionalLookupParameters);
405             quickfinderAction.setActionParameters(actionParameters);
406         }
407     }
408 
409     /**
410      * Utility method to add an action parameter to the quickfinder action if the given parameter value
411      * is non blank.
412      *
413      * @param parameterName name of the parameter to add
414      * @param parameterValue value for the parameter to add
415      */
416     protected void addActionParameterIfNotNull(String parameterName, Object parameterValue) {
417         if ((parameterValue != null) && StringUtils.isNotBlank(parameterValue.toString())) {
418             quickfinderAction.addActionParameter(parameterName, parameterValue.toString());
419         }
420     }
421 
422     /**
423      * Adds post context data for the quickfinder so when the lookup return occurs the focus and jump point
424      * of the quickfinder action can be retrieved.
425      *
426      * {@inheritDoc}
427      */
428     @Override
429     public void processEvent(ViewLifecycle.LifecycleEvent lifecycleEvent, View view, Object model,
430             LifecycleElement eventComponent) {
431         Action finalQuickfinderAction = (Action) eventComponent;
432 
433         // add post metadata for focus point when the associated lookup returns
434         ViewLifecycle.getViewPostMetadata().addComponentPostData(this,
435                 UifConstants.PostMetadata.QUICKFINDER_FOCUS_ID, finalQuickfinderAction.getFocusOnIdAfterSubmit());
436         ViewLifecycle.getViewPostMetadata().addComponentPostData(this,
437                 UifConstants.PostMetadata.QUICKFINDER_JUMP_TO_ID, finalQuickfinderAction.getJumpToIdAfterSubmit());
438     }
439 
440     /**
441      * Returns the URL for the lookup for which parameters will be added.
442      *
443      * <p>The base URL includes the domain, context, and controller mapping for the lookup invocation. Parameters are
444      * then added based on configuration to complete the URL. This is generally defaulted to the application URL and
445      * internal KRAD servlet mapping, but can be changed to invoke another application such as the Rice standalone
446      * server</p>
447      *
448      * @return lookup base URL
449      */
450     @BeanTagAttribute(name = "baseLookupUrl")
451     public String getBaseLookupUrl() {
452         return this.baseLookupUrl;
453     }
454 
455     /**
456      * @see QuickFinder#getBaseLookupUrl()
457      */
458     public void setBaseLookupUrl(String baseLookupUrl) {
459         this.baseLookupUrl = baseLookupUrl;
460     }
461 
462     /**
463      * Full class name the lookup should be provided for.
464      *
465      * <p>This is passed on to the lookup request for the data object the lookup should be rendered for. This is then
466      * used by the lookup framework to select the lookup view (if more than one lookup view exists for the same
467      * data object class name, the {@link #getViewName()} property should be specified to select the view to
468      * render).</p>
469      *
470      * @return lookup class name
471      */
472     @BeanTagAttribute(name = "dataOjbectClassName")
473     public String getDataObjectClassName() {
474         return this.dataObjectClassName;
475     }
476 
477     /**
478      * @see QuickFinder#getDataObjectClassName()
479      */
480     public void setDataObjectClassName(String dataObjectClassName) {
481         this.dataObjectClassName = dataObjectClassName;
482     }
483 
484     /**
485      * When multiple target lookup views exists for the same data object class, the view name can be set to
486      * determine which one to use.
487      *
488      * <p>When creating multiple lookup views for the same data object class, the view name can be specified for the
489      * different versions (for example 'simple' and 'advanced'). When multiple lookup views exist the view name must
490      * be sent with the data object class for the request. Note the view id can be alternatively used to uniquely
491      * identify the lookup view</p>
492      *
493      * @return String name of lookup view
494      */
495     @BeanTagAttribute(name = "viewName")
496     public String getViewName() {
497         return this.viewName;
498     }
499 
500     /**
501      * @see QuickFinder#getViewName()
502      */
503     public void setViewName(String viewName) {
504         this.viewName = viewName;
505     }
506 
507     /**
508      * Indicates whether the lookup return should occur through script, or by refresing the page (making server
509      * request).
510      *
511      * <p>For quickfinders that do not need any additional server side action, return through script can be
512      * much faster and prevents a page refresh.</p>
513      *
514      * @return boolean true if the return should occur through script, false if not (default)
515      */
516     public boolean isReturnByScript() {
517         return returnByScript;
518     }
519 
520     /**
521      * @see QuickFinder#isReturnByScript()
522      */
523     public void setReturnByScript(boolean returnByScript) {
524         this.returnByScript = returnByScript;
525     }
526 
527     /**
528      * Comma delimited String of property names on the lookup view that should be read only.
529      *
530      * <p>When requesting a lookup view, property names for fields that are rendered as search criteria can be marked
531      * as read-only. This is usually done when a lookup parameter for that property is sent in and the user should
532      * not be allowed to change the value</p>
533      *
534      * @return property names (delimited by a comma) whose criteria fields should be read-only on the
535      *         lookup view
536      */
537     @BeanTagAttribute(name = "readOnlyLookupFields")
538     public String getReadOnlyLookupFields() {
539         return this.readOnlyLookupFields;
540     }
541 
542     /**
543      * @see QuickFinder#setReadOnlyLookupFields(java.lang.String)
544      */
545     public void setReadOnlyLookupFields(String readOnlyLookupFields) {
546         this.readOnlyLookupFields = readOnlyLookupFields;
547     }
548 
549     /**
550      * List of property names on the model that should be refreshed when the lookup returns.
551      *
552      * <p>Note this is only relevant when the return by script option is not enabled (meaning the server will be
553      * invoked
554      * on the lookup return call)</p>
555      *
556      * <p>When a lookup return call is made (to return a result value) the controller refresh method will be invoked.
557      * If
558      * refresh properties are configured, a call to refresh those references from the database will be made. This is
559      * useful if the lookup returns a foreign key field and the related record is needed.</p>
560      *
561      * @return list of property names to refresh
562      */
563     @BeanTagAttribute(name = "referencesToRefresh")
564     public String getReferencesToRefresh() {
565         return this.referencesToRefresh;
566     }
567 
568     /**
569      * @see QuickFinder#getReferencesToRefresh()
570      */
571     public void setReferencesToRefresh(String referencesToRefresh) {
572         this.referencesToRefresh = referencesToRefresh;
573     }
574 
575     /**
576      * Map that determines what properties from a result lookup row (if selected) will be returned to properties on
577      * the calling view.
578      *
579      * <p>The purpose of using the lookup is to search for a particular value and return that value to the form being
580      * completed. In order for the lookup framework to return the field back to us, we must specify the name of the
581      * field on the data object class whose value we need, and the name of the field on the calling view. Furthermore,
582      * we can choose to have the lookup return additional fields that populate other form fields or informational
583      * properties (see ‘Field Queries and Informational Properties’). These pairs of fields are known as
584      * ‘field conversions’.</p>
585      *
586      * <p>The fieldConversions property is a Map. Each entry represents a field that will be returned back from the
587      * lookup, with the entry key being the field name on the data object class, and the entry value being the field
588      * name on the calling view. It is helpful to think of this as a from-to mapping. Pulling from the data object
589      * field (map key) to the calling view field (map value).</p>
590      *
591      * @return mapping of lookup data object property names to view property names
592      */
593     @BeanTagAttribute(name = "fieldConversions", type = BeanTagAttribute.AttributeType.MAPVALUE)
594     public Map<String, String> getFieldConversions() {
595         return this.fieldConversions;
596     }
597 
598     /**
599      * @see QuickFinder#getFieldConversions()
600      */
601     public void setFieldConversions(Map<String, String> fieldConversions) {
602         this.fieldConversions = fieldConversions;
603     }
604 
605     /**
606      * Map that determines what properties from a calling view will be sent to properties on that are rendered
607      * for the lookup view's search fields (they can be hidden).
608      *
609      * <p> When invoking a lookup view, we can pre-populate search fields on the lookup view with data from the view
610      * that called the lookup. The user can then perform the search with these values, or (if edited is allowed or
611      * the fields are not hidden) change the passed in values. When the lookup is invoked, the values for the
612      * properties configured within the lookup parameters Map will be pulled and passed along as values for the
613      * lookup view properties</p>
614      *
615      * @return mapping of calling view properties to lookup view search fields
616      */
617     @BeanTagAttribute(name = "lookupParameters", type = BeanTagAttribute.AttributeType.MAPVALUE)
618     public Map<String, String> getLookupParameters() {
619         return this.lookupParameters;
620     }
621 
622     /**
623      * @see QuickFinder#getLookupParameters()
624      */
625     public void setLookupParameters(Map<String, String> lookupParameters) {
626         this.lookupParameters = lookupParameters;
627     }
628 
629     /**
630      * Indicates whether the return links for lookup results should be rendered.
631      *
632      * <p>A lookup view can be invoked to allow the user to select a value (or set of values) to return back to the
633      * calling view. For single value lookups this is done with a return link that is rendered for each row. This
634      * return link can be disabled by setting this property to false</p>
635      *
636      * @return true if the return link should not be shown, false if it should be
637      */
638     @BeanTagAttribute(name = "renderReturnLink")
639     public Boolean getRenderReturnLink() {
640         return this.renderReturnLink;
641     }
642 
643     /**
644      * @see QuickFinder#getRenderReturnLink()
645      */
646     public void setRenderReturnLink(Boolean renderReturnLink) {
647         this.renderReturnLink = renderReturnLink;
648     }
649 
650     /**
651      * Indicates whether the maintenance actions (or others) are rendered on the invoked lookup view.
652      *
653      * <p>By default a lookup view will add an actions column for the result table that display maintenance links (in
654      * addition to a new link at the top of the page) if a maintenance action is available. Custom links can also be
655      * added to the action column as necessary. This flag can be set to true to suppress the rendering of the actions
656      * for the lookup call.</p>
657      *
658      * @return true if actions should be rendered, false if not
659      */
660     @BeanTagAttribute(name = "renderResultActions")
661     public Boolean getRenderResultActions() {
662         return renderResultActions;
663     }
664 
665     /**
666      * @see QuickFinder#getRenderResultActions()
667      */
668     public void setRenderResultActions(Boolean renderResultActions) {
669         this.renderResultActions = renderResultActions;
670     }
671 
672     /**
673      * Indicates whether the search should be executed when first rendering the lookup view.
674      *
675      * <p>By default the lookup view is rendered, the user enters search values and executes the results. This flag can
676      * be set to true to indicate the search should be performed before showing the screen to the user. This is
677      * generally used when search criteria is being passed in as well</p>
678      *
679      * @return true if the search should be performed initially, false if not
680      */
681     @BeanTagAttribute(name = "autoSearch")
682     public Boolean getAutoSearch() {
683         return this.autoSearch;
684     }
685 
686     /**
687      * @see org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute#name()
688      */
689     public void setAutoSearch(Boolean autoSearch) {
690         this.autoSearch = autoSearch;
691     }
692 
693     /**
694      * Indicates whether the lookup criteria (search group) should be enabled on the invoked lookup view.
695      *
696      * <p> Setting the this to false will not display the lookup criteria but only the results. Therefore this is only
697      * useful when setting {@link #getAutoSearch()} to true and passing in criteria</p>
698      *
699      * @return true if lookup criteria should be displayed, false if not
700      */
701     @BeanTagAttribute(name = "renderLookupCriteria")
702     public Boolean getRenderLookupCriteria() {
703         return this.renderLookupCriteria;
704     }
705 
706     /**
707      * @see QuickFinder#getRenderLookupCriteria()
708      */
709     public void setRenderLookupCriteria(Boolean renderLookupCriteria) {
710         this.renderLookupCriteria = renderLookupCriteria;
711     }
712 
713     /**
714      * Indicates whether the criteria actions (footer) should be rendered on the invoked lookup view.
715      *
716      * @return boolean true if actions should be rendered (default), false if not
717      */
718     @BeanTagAttribute(name = "renderCriteriaActions")
719     public Boolean getRenderCriteriaActions() {
720         return this.renderCriteriaActions;
721     }
722 
723     /**
724      * @see QuickFinder#getRenderCriteriaActions()
725      */
726     public void setRenderCriteriaActions(Boolean renderCriteriaActions) {
727         this.renderCriteriaActions = renderCriteriaActions;
728     }
729 
730     public Boolean getHideCriteriaOnSearch() {
731         return hideCriteriaOnSearch;
732     }
733 
734     public void setHideCriteriaOnSearch(Boolean hideCriteriaOnSearch) {
735         this.hideCriteriaOnSearch = hideCriteriaOnSearch;
736     }
737 
738     /**
739      * Indicates whether the maintenance action links should be rendered for the invoked lookup view.
740      *
741      * <p>If a maintenance view exists for the data object associated with the lookup view, the framework will add
742      * links to initiate a new maintenance document. This flag can be used to disable the rendering of these links</p>
743      *
744      * <p> Note this serves similar purpose to {@link #getRenderResultActions()} but the intent is to only remove the
745      * maintenance links in this situation, not the complete actions column</p>
746      *
747      * @return true if maintenance links should be shown on the lookup view, false if not
748      */
749     @BeanTagAttribute(name = "renderMaintenanceLinks")
750     public Boolean getRenderMaintenanceLinks() {
751         return this.renderMaintenanceLinks;
752     }
753 
754     /**
755      * @see QuickFinder#getRenderMaintenanceLinks()
756      */
757     public void setRenderMaintenanceLinks(Boolean renderMaintenanceLinks) {
758         this.renderMaintenanceLinks = renderMaintenanceLinks;
759     }
760 
761     /**
762      * Action component that is used to rendered for the field for invoking the quickfinder action (bringing up the
763      * lookup).
764      *
765      * <p>Through the action configuration the image (or link, button) rendered for the quickfinder can be modified. In
766      * addition to other action component settings</p>
767      *
768      * @return Action instance rendered for quickfinder
769      */
770     @BeanTagAttribute(name = "quickfinderAction", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
771     public Action getQuickfinderAction() {
772         return this.quickfinderAction;
773     }
774 
775     /**
776      * @see QuickFinder#getQuickfinderAction()
777      */
778     public void setQuickfinderAction(Action quickfinderAction) {
779         this.quickfinderAction = quickfinderAction;
780     }
781 
782     /**
783      * Lightbox widget that will be used to view the invoked lookup view.
784      *
785      * <p>Note if the lightbox is not configured, or set to not render the lookup will be invoked based on
786      * the action alone (for example a new tab/window)</p>
787      *
788      * @return lightbox instance for viewing the lookup
789      */
790     @BeanTagAttribute(name = "lightBox", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
791     public LightBox getLightBox() {
792         return lightBox;
793     }
794 
795     /**
796      * @see QuickFinder#getLightBox()
797      */
798     public void setLightBox(LightBox lightBox) {
799         this.lightBox = lightBox;
800     }
801 
802     /**
803      * Indicates whether the invoked lookup view should allow multiple values to be selected and returned.
804      *
805      * @return true if multi-value lookup should be requested, false for normal lookup
806      */
807     @BeanTagAttribute(name = "MultipleValuesSelect")
808     public Boolean getMultipleValuesSelect() {
809         return multipleValuesSelect;
810     }
811 
812     /**
813      * @see QuickFinder#getMultipleValuesSelect()
814      */
815     public void setMultipleValuesSelect(Boolean multipleValuesSelect) {
816         this.multipleValuesSelect = multipleValuesSelect;
817     }
818 
819     /**
820      * For the case of multi-value lookup, indicates the collection that should be populated with
821      * the return results.
822      *
823      * <p>Note when the quickfinder is associated with a {@link CollectionGroup}, this property is
824      * set automatically from the collection name associated with the group</p>
825      *
826      * @return collection name (must be full binding path)
827      */
828     @BeanTagAttribute(name = "lookupCollectionName")
829     public String getLookupCollectionName() {
830         return lookupCollectionName;
831     }
832 
833     /**
834      * @see QuickFinder#getLookupCollectionName()
835      */
836     public void setLookupCollectionName(String lookupCollectionName) {
837         this.lookupCollectionName = lookupCollectionName;
838     }
839 
840     public String getLookupCollectionId() {
841         return lookupCollectionId;
842     }
843 
844     public void setLookupCollectionId(String lookupCollectionId) {
845         this.lookupCollectionId = lookupCollectionId;
846     }
847 
848     /**
849      * The additional parameters that were passed to the quickFinder.
850      *
851      * @return additionalLookupParameters - map of additional lookup parameters
852      */
853     public Map<String, String> getAdditionalLookupParameters() {
854         return additionalLookupParameters;
855     }
856 
857     /**
858      * @see QuickFinder#getAdditionalLookupParameters()
859      */
860     public void setAdditionalLookupParameters(Map<String, String> additionalLookupParameters) {
861         this.additionalLookupParameters = additionalLookupParameters;
862     }
863 }