001/**
002 * Copyright 2005-2016 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.kns.lookup;
017
018import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions;
019import org.kuali.rice.kns.web.struts.form.LookupForm;
020import org.kuali.rice.kns.web.ui.Column;
021import org.kuali.rice.kns.web.ui.Field;
022import org.kuali.rice.kns.web.ui.ResultRow;
023import org.kuali.rice.kns.web.ui.Row;
024import org.kuali.rice.krad.bo.BusinessObject;
025import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
026import org.kuali.rice.krad.service.DataDictionaryService;
027
028import java.io.Serializable;
029import java.util.Collection;
030import java.util.List;
031import java.util.Map;
032
033/**
034 * @deprecated Only used in KNS classes, use KRAD.
035 */
036@Deprecated
037public interface LookupableHelperService extends Serializable{
038
039    /**
040     * Initializes the lookup with a business object class.  This is set
041     * via the LookupableHelperService's consumer, namely the Lookupable
042     * implementation (or in cases of nesting a wrapping LookupableHelperService).
043     * The Lookupable in turn receives this value from the UI via
044     * LookupForm population.
045     *
046     * @param businessObjectClass
047     */
048    public void setBusinessObjectClass(Class businessObjectClass);
049
050    /**
051     * @return Returns the dataObjectClass this lookupable is representing
052     */
053    // NOTE: used in exactly one place in RuleBaseValuesLookupableHelperServiceImpl to conditionally initialize
054    // an internal lookup helper service reference; this reference should in theory be a unique instance or prototype
055    // so the check should not be necessary
056    public Class getBusinessObjectClass();
057
058    /**
059     * Initializes the lookup with the given Map of parameters.
060     *
061     * @param parameters
062     */
063    public void setParameters(Map<String, String[]> parameters);
064
065    /**
066     * @return Returns the parameters passed to this lookup
067     */
068    public Map<String, String[]> getParameters();
069
070    /**
071     * @return String url for the location to return to after the lookup
072     */
073    public String getReturnLocation();
074
075    /**
076     * @return List of Column objects used to render the result table
077     */
078    public List<Column> getColumns();
079
080    /**
081     * Validates the values filled in as search criteria, also checks for required field values.
082     *
083     * @param fieldValues - Map of property/value pairs
084     */
085    public void validateSearchParameters(Map<String, String> fieldValues);
086
087    /**
088     * Performs a search and returns result list.
089     *
090     * @param fieldValues - Map of property/value pairs
091     * @return List of business objects found by the search
092     * @throws Exception
093     */
094    public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues);
095
096    /**
097     * Similar to getSearchResults, but the number of returned rows is not bounded
098     *
099     * @param fieldValues
100     * @return
101     */
102    public List<? extends BusinessObject> getSearchResultsUnbounded(Map<String, String> fieldValues);
103
104    /**
105     * Determines if there should be more search fields rendered based on already entered search criteria.
106     *
107     * @param fieldValues - Map of property/value pairs
108     * @return boolean
109     */
110    public boolean checkForAdditionalFields(Map<String, String> fieldValues);
111
112    /**
113     * Builds the return value url.
114     *
115     * @param businessObject - Instance of a business object containing the return values
116     * @param fieldConversions - Map of conversions mapping bo names to caller field names.
117     * @param lookupImpl - Current lookup impl name
118     * @param returnKeys - Keys to return
119     * @return String url called when selecting a row from the result set
120     */
121    public HtmlData getReturnUrl(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions);
122
123    /**
124     * This method builds the return url
125     * 
126     * @param businessObject
127     * @param lookupForm
128     * @param returnKeys
129     * @return
130     */
131    public HtmlData getReturnUrl(BusinessObject businessObject, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions);
132    
133    /**
134     * Builds string of action urls that can take place for a result row
135     *
136     * @param businessObject - Instance of a business object containing the return values
137     * @param pkNames - List of primary key names
138     * @return String rendered in actions column of result set
139     */
140    public String getActionUrls(BusinessObject businessObject, List pkNames, BusinessObjectRestrictions businessObjectRestrictions);
141
142    /**
143     * 
144     * This method is a template method that allows child classes to return their own custom action html data.
145     * 
146     * @param businessObject
147     * @param pkNames
148     * @return
149     */
150    public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames);
151
152    /**
153     * Builds string an inquiry url for drill down on a result field
154     *
155     * @param businessObject - Instance of a business object containing the return values
156     * @param propertyName - Name of the property in the business object
157     * @return String url called on selection of the result field
158     */
159    public HtmlData getInquiryUrl(BusinessObject businessObject, String propertyName);
160
161    /**
162     * Sets the requested fields conversions in the lookupable
163     *
164     * @param fieldConversions
165     */
166    public void setFieldConversions(Map fieldConversions);
167
168    /**
169     * Gets the readOnlyFieldsList attribute.
170     * @return Returns the readOnlyFieldsList.
171     */
172    public List<String> getReadOnlyFieldsList();
173
174    /**
175     * Sets the requested read only fields list in the lookupable
176     *
177     * @param readOnlyFieldsList
178     */
179    public void setReadOnlyFieldsList(List<String> readOnlyFieldsList);
180
181    /**
182     * This method is public because some unit tests depend on it.
183     *
184     * @return a List of the names of fields which are marked in data dictionary as return fields.
185     */
186    public List<String> getReturnKeys();
187
188    public String getDocFormKey();
189
190    public void setDocFormKey(String docFormKey);
191
192    public String getDocNum();
193
194    public void setDocNum(String docNum);
195
196    /**
197     * 
198     * This method builds a maintenance url.
199     * 
200     * @param businessObject
201     * @param htmlData
202     * @param pkNames
203     * @return
204     */
205    public String getMaintenanceUrl(BusinessObject businessObject, HtmlData htmlData, List pkNames, BusinessObjectRestrictions businessObjectRestrictions);
206
207    /**
208     * Determines if underlying lookup bo has associated maintenance document that allows new or copy maintenance actions.
209     *
210     * @return true if bo has maint doc that allows new or copy actions
211     */
212    public boolean allowsMaintenanceNewOrCopyAction();
213
214    /**
215     * Determines if underlying lookup bo has associated document that allows new or copy maintenance actions.
216     *
217     * @return true if bo has doc that allows new or copy actions
218     */
219    public boolean allowsNewOrCopyAction(String documentTypeName);
220
221    /**
222     * Returns a list of Row objects to be used to generate the search query screen
223     *
224     * Generally, setDataObjectClass needs to be called with a non-null value for proper operation
225     * @return
226     */
227    public List<Row> getRows();
228
229    /**
230     * This method returns the DataDictionaryService used to initialize this helper service and is used by Lookupable implementations to
231     * retrieve the proper service.
232     *
233     * @return
234     */
235    public DataDictionaryService getDataDictionaryService();
236
237    /**
238     * This method returns the BusinessObjectDictionaryService used to initialize this helper service and is used by Lookupable implementations to
239     * retrieve the proper service.
240     *
241     * @return
242     */
243    public BusinessObjectDictionaryService getBusinessObjectDictionaryService();
244
245    public void setBackLocation(String backLocation);
246
247    public String getBackLocation();
248
249    /**
250     *
251     * This method performs the lookup and returns a collection of BO items
252     * @param lookupForm
253     * @param resultTable
254     * @param bounded
255     * @return the list of result BOs, possibly bounded
256     */
257    public Collection<? extends BusinessObject> performLookup(LookupForm lookupForm, Collection<ResultRow> resultTable, boolean bounded);
258
259    /**
260     * This method returns a list of the default columns used to sort the result set.  For multiple value lookups,
261     * this method does not change when different columns are sorted.
262     *
263     * @return
264     */
265    public List<String> getDefaultSortColumns();
266
267    /**
268     * This method returns whether the previously executed getSearchResults used the primary key values to search, ignoring all non key values
269     *
270     * @return
271     * @see LookupableHelperService#getPrimaryKeyFieldLabels()
272     */
273    public boolean isSearchUsingOnlyPrimaryKeyValues();
274
275    /**
276     * Returns a comma delimited list of primary key field labels, to be used on the UI to tell the user which fields were used to search
277     *
278     * @return
279     * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues()
280     */
281    public String getPrimaryKeyFieldLabels();
282
283    /**
284     * Determines whether a given BusinessObject that's returned as one of the lookup's results is considered returnable, which means that for
285     * single-value lookups, a "return value" link may be rendered, and for multiple value lookups, a checkbox is rendered.
286     *
287     * Note that this can be part of an authorization mechanism, but not the complete authorization mechanism.  The component that invoked the lookup/
288     * lookup caller (e.g. document, nesting lookup, etc.) needs to check that the object that was passed to it was returnable as well because there
289     * are ways around this method (e.g. crafting a custom return URL).
290     *
291     * @param object an object from the search result set
292     * @return
293     */
294    public boolean isResultReturnable(BusinessObject object);
295    
296    /**
297     * 
298     * This method allows for overriding the clear behavior
299     *
300     */
301    public void performClear(LookupForm lookupForm);
302    
303    public boolean shouldDisplayHeaderNonMaintActions();
304    
305    public boolean shouldDisplayLookupCriteria();
306
307        /**
308         * This method gets the supplemental lookup menu if any
309         * 
310         * @return supplemental menu bar
311         */
312        public String getSupplementalMenuBar();
313    
314    /**
315     * @return String displayed as title for the lookup
316     */
317    public String getTitle();
318    
319    /**
320     * 
321     * performs custom actions.  return true to reperform search
322     * 
323     * @param ignoreErrors
324     * @return boolean to reperform search
325     */
326    public boolean performCustomAction(boolean ignoreErrors);
327    
328    /**
329     * get an extra field
330     * @return
331     */
332    public Field getExtraField();
333    
334    public void applyFieldAuthorizationsFromNestedLookups(Field field);
335    
336    /**
337     * Performs conditional logic (based on current search values or other parameters) to
338     * override field hidden, read-only, and required attributes previously set.
339     */
340    public void applyConditionalLogicForFieldDisplay();
341}