001/**
002 * Copyright 2005-2015 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.lookup;
017
018import org.kuali.rice.krad.uif.field.InputField;
019import org.kuali.rice.krad.uif.field.LinkField;
020import org.kuali.rice.krad.uif.service.ViewHelperService;
021import org.kuali.rice.krad.web.form.LookupForm;
022
023import java.util.Collection;
024import java.util.List;
025import java.util.Map;
026
027/**
028 * Provides contract for implementing a lookup within the lookup framework
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public interface Lookupable extends ViewHelperService, java.io.Serializable {
033
034    /**
035     * Initialize the suppressAction indicator on the LookupForm.
036     *
037     * <p>
038     * The suppress action is set to true if the user is not authorized to initiate these documents.  The indicator
039     * is then used to hide irrelevant actions such as creating a new document or editing existing ones.
040     * </p>
041     *
042     * @param lookupForm on which to initialize the suppressAction indicator
043     */
044    public void initSuppressAction(LookupForm lookupForm);
045
046    /**
047     * Invoked to carry out the lookup search based on the given map of key/value search
048     * values
049     *
050     * @param form - lookup form instance containing the lookup data
051     * @param searchCriteria - map of criteria currently set
052     * @param bounded - indicates whether the results should be limited (if necessary) to the max search
053     * result limit configured
054     * @return the list of result objects, possibly bounded
055     */
056    public Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded);
057
058    /**
059     * Invoked when the clear action is requested to result the search fields to
060     * their initial default values
061     *
062     * @param form - lookup form instance containing the lookup data
063     * @param searchCriteria - map of criteria currently set
064     * @return map of criteria with field values reset to defaults
065     */
066    public Map<String, String> performClear(LookupForm form, Map<String, String> searchCriteria);
067
068    /**
069     * Invoked to perform validation on the search criteria before the search is performed
070     *
071     * @param form - lookup form instance containing the lookup data
072     * @param searchCriteria - map of criteria where key is search property name and value is
073     * search value (which can include wildcards)
074     * @return  boolean true if validation was successful, false if there were errors and the search
075     * should not be performed
076     */
077    public boolean validateSearchParameters(LookupForm form, Map<String, String> searchCriteria);
078
079    /**
080     * Sets the class for the data object the lookup will be provided on
081     *
082     * @param dataObjectClass - data object class for lookup
083     */
084    public void setDataObjectClass(Class<?> dataObjectClass);
085
086    /**
087     * Returns the class for the data object the lookup is configured with
088     *
089     * @return Class<?> data object class
090     */
091    public Class<?> getDataObjectClass();
092
093    /**
094     * Sets the field conversion map on the lookupable
095     *
096     * <p>
097     * The field conversions map specifies the mappings for return fields. When the
098     * user selects a row to return, for each configured field conversion the corresponding value
099     * from the result row will be sent back as the value for the field on the calling field.
100     * </p>
101     *
102     * @param fieldConversions - map of field conversions where key is name of the property on result
103     * data object to get value for, and map value is the name of the field to send the value back as (name
104     * of the field on the calling view)
105     */
106    public void setFieldConversions(Map<String, String> fieldConversions);
107
108    /**
109     * Sets List of fields on the lookupable that should be made read only in the search
110     * criteria group
111     *
112     * @param readOnlyFieldsList - list of read only fields
113     */
114    public void setReadOnlyFieldsList(List<String> readOnlyFieldsList);
115
116    /**
117     * Invoked to build the return URL for a result row
118     *
119     * <p>
120     * Based on the line contained in the field context, the URL for returning the role is constructed and
121     * set as the href for the link field. If a return link cannot be constructed the field should be set
122     * to not render
123     * </p>
124     *
125     * @param returnLinkField - link field that will be used to render the return URL
126     * @param model - lookup form containing the data
127     */
128    public void getReturnUrlForResults(LinkField returnLinkField, Object model);
129
130    /**
131     * Invoked to build a maintenance URL for a result row
132     *
133     * <p>
134     * Based on the line contained in the field context and the given maintenance method that should be called a
135     * URL is constructed and set as the href on the link field. If a maintenance link cannot be constructed the
136     * field should be set to not render
137     * </p>
138     *
139     * @param actionLinkField - link field that will be used to return the maintenance URL
140     * @param model - lookup form containing the data
141     * @param maintenanceMethodToCall - name of the method that should be invoked in the maintenance controller
142     */
143    public void getMaintenanceActionLink(LinkField actionLinkField, Object model, String maintenanceMethodToCall);
144
145    public void setMultiValueLookupSelect(InputField selectField, Object model);
146}