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.element.Link;
019import org.kuali.rice.krad.uif.field.InputField;
020import org.kuali.rice.krad.uif.service.ViewHelperService;
021
022import java.util.Collection;
023import java.util.Map;
024
025/**
026 * Provides contract for implementing a lookup within the lookup framework.
027 *
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030public interface Lookupable extends ViewHelperService, java.io.Serializable {
031
032    /**
033     * Invoked to carry out the lookup search based on the given map of key/value search values.
034     *
035     * @param form lookup form instance containing the lookup data
036     * @param searchCriteria map of criteria currently set
037     * @param bounded indicates whether the results should be limited (if necessary) to the max search
038     * result limit configured
039     * @return the list of result objects, possibly bounded with {@link CollectionIncomplete}
040     */
041     Collection<?> performSearch(LookupForm form, Map<String, String> searchCriteria, boolean bounded);
042
043    /**
044     * Invoked when the clear action is requested to reset the search fields to their initial default values.
045     *
046     * @param form lookup form instance containing the lookup data
047     * @param searchCriteria map of criteria currently set
048     * @return map of criteria with field values reset to defaults
049     */
050     Map<String, String> performClear(LookupForm form, Map<String, String> searchCriteria);
051
052    /**
053     * Returns the class for the data object the lookup is configured with.
054     *
055     * @return Class<?> data object class
056     */
057     Class<?> getDataObjectClass();
058
059    /**
060     * Sets the class for the data object the lookup will be provided on.
061     *
062     * @param dataObjectClass - data object class for lookup
063     */
064     void setDataObjectClass(Class<?> dataObjectClass);
065
066    /**
067     * Invoked to build the return URL for a result row.
068     *
069     * <p>Based on the line contained in the field context, the URL for returning the role is constructed and
070     * set as the href for the link. If a return link cannot be constructed the link should be set
071     * to not render</p>
072     *
073     * @param returnLink link that will be used to render the return URL
074     * @param model lookup form containing the data
075     */
076     void buildReturnUrlForResult(Link returnLink, Object model);
077
078    /**
079     * Invoked to build a maintenance URL for a result row.
080     *
081     * <p>Based on the line contained in the field context and the given maintenance method that should be called a
082     * URL is constructed and set as the action on the action link. If a maintenance link cannot be constructed the
083     * action link should be set to not render</p>
084     *
085     * @param actionLink link that will be used to return the maintenance URL
086     * @param model lookup form containing the data
087     * @param maintenanceMethodToCall name of the method that should be invoked in the maintenance controller
088     */
089     void buildMaintenanceActionLink(Link actionLink, Object model, String maintenanceMethodToCall);
090
091    /**
092     * Set the value for the input field control to contain the field conversion values for the line.
093     *
094     * <p>Creates and populate the value of the input field control.  This value is built according to
095     * {@link LookupForm#getFieldConversions} and allows for client side population of the returned fields without
096     * having to do an additional server call.</p>
097     *
098     * @param selectField the InputField used to mark the lookup row as selected
099     * @param model lookup form containing the model data
100     */
101     void buildMultiValueSelectField(InputField selectField, Object model);
102
103    /**
104     * Determines if given data object has associated maintenance document that allows new or copy maintenance actions.
105     *
106     * @return boolean true if the maintenance new or copy action is allowed for the data object instance, false
107     * otherwise
108     */
109    boolean allowsMaintenanceNewOrCopyAction();
110
111    /**
112     * Determines if given data object has associated maintenance document that allows edit maintenance actions.
113     *
114     * @param dataObject data object
115     * @return boolean true if the maintenance edit action is allowed for the data object instance, false otherwise
116     */
117    boolean allowsMaintenanceEditAction(Object dataObject);
118
119    /**
120     * Determines if given data object has associated maintenance document that allows delete maintenance actions.
121     *
122     * @param dataObject data object
123     * @return boolean true if the maintenance delete action is allowed for the data object instance, false otherwise
124     */
125    boolean allowsMaintenanceDeleteAction(Object dataObject);
126
127}