View Javadoc

1   /**
2    * Copyright 2005-2012 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.kns.lookup;
17  
18  import org.kuali.rice.kns.document.authorization.BusinessObjectRestrictions;
19  import org.kuali.rice.kns.web.struts.form.LookupForm;
20  import org.kuali.rice.kns.web.ui.Field;
21  import org.kuali.rice.kns.web.ui.Row;
22  import org.kuali.rice.krad.bo.BusinessObject;
23  import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
24  import org.kuali.rice.krad.service.DataDictionaryService;
25  
26  import java.io.Serializable;
27  import java.util.Collection;
28  import java.util.List;
29  import java.util.Map;
30  
31  public interface LookupableHelperService extends Serializable{
32  
33      /**
34       * Initializes the lookup with a business object class.  This is set
35       * via the LookupableHelperService's consumer, namely the Lookupable
36       * implementation (or in cases of nesting a wrapping LookupableHelperService).
37       * The Lookupable in turn receives this value from the UI via
38       * LookupForm population.
39       *
40       * @param businessObjectClass
41       */
42      public void setBusinessObjectClass(Class businessObjectClass);
43  
44      /**
45       * @return Returns the dataObjectClass this lookupable is representing
46       */
47      // NOTE: used in exactly one place in RuleBaseValuesLookupableHelperServiceImpl to conditionally initialize
48      // an internal lookup helper service reference; this reference should in theory be a unique instance or prototype
49      // so the check should not be necessary
50      public Class getBusinessObjectClass();
51  
52      /**
53       * Initializes the lookup with the given Map of parameters.
54       *
55       * @param parameters
56       */
57      public void setParameters(Map<String, String[]> parameters);
58  
59      /**
60       * @return Returns the parameters passed to this lookup
61       */
62      public Map<String, String[]> getParameters();
63  
64      /**
65       * @return String url for the location to return to after the lookup
66       */
67      public String getReturnLocation();
68  
69      /**
70       * @return List of Column objects used to render the result table
71       */
72      public List getColumns();
73  
74      /**
75       * Validates the values filled in as search criteria, also checks for required field values.
76       *
77       * @param fieldValues - Map of property/value pairs
78       */
79      public void validateSearchParameters(Map fieldValues);
80  
81      /**
82       * Performs a search and returns result list.
83       *
84       * @param fieldValues - Map of property/value pairs
85       * @return List of business objects found by the search
86       * @throws Exception
87       */
88      public List getSearchResults(Map<String, String> fieldValues);
89  
90      /**
91       * Similar to getSearchResults, but the number of returned rows is not bounded
92       *
93       * @param fieldValues
94       * @return
95       */
96      public List getSearchResultsUnbounded(Map<String, String> fieldValues);
97  
98      /**
99       * Determines if there should be more search fields rendered based on already entered search criteria.
100      *
101      * @param fieldValues - Map of property/value pairs
102      * @return boolean
103      */
104     public boolean checkForAdditionalFields(Map fieldValues);
105 
106     /**
107      * Builds the return value url.
108      *
109      * @param businessObject - Instance of a business object containing the return values
110      * @param fieldConversions - Map of conversions mapping bo names to caller field names.
111      * @param lookupImpl - Current lookup impl name
112      * @param returnKeys - Keys to return
113      * @return String url called when selecting a row from the result set
114      */
115     public HtmlData getReturnUrl(BusinessObject businessObject, Map fieldConversions, String lookupImpl, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions);
116 
117     /**
118      * This method builds the return url
119      * 
120      * @param businessObject
121      * @param lookupForm
122      * @param returnKeys
123      * @return
124      */
125     public HtmlData getReturnUrl(BusinessObject businessObject, LookupForm lookupForm, List returnKeys, BusinessObjectRestrictions businessObjectRestrictions);
126     
127     /**
128      * Builds string of action urls that can take place for a result row
129      *
130      * @param businessObject - Instance of a business object containing the return values
131      * @param pkNames - List of primary key names
132      * @return String rendered in actions column of result set
133      */
134     public String getActionUrls(BusinessObject businessObject, List pkNames, BusinessObjectRestrictions businessObjectRestrictions);
135 
136     /**
137      * 
138      * This method is a template method that allows child classes to return their own custom action html data.
139      * 
140      * @param businessObject
141      * @param pkNames
142      * @return
143      */
144     public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames);
145 
146     /**
147      * Builds string an inquiry url for drill down on a result field
148      *
149      * @param businessObject - Instance of a business object containing the return values
150      * @param propertyName - Name of the property in the business object
151      * @return String url called on selection of the result field
152      */
153     public HtmlData getInquiryUrl(BusinessObject businessObject, String propertyName);
154 
155     /**
156      * Sets the requested fields conversions in the lookupable
157      *
158      * @param fieldConversions
159      */
160     public void setFieldConversions(Map fieldConversions);
161 
162     /**
163      * Gets the readOnlyFieldsList attribute.
164      * @return Returns the readOnlyFieldsList.
165      */
166     public List<String> getReadOnlyFieldsList();
167 
168     /**
169      * Sets the requested read only fields list in the lookupable
170      *
171      * @param readOnlyFieldsList
172      */
173     public void setReadOnlyFieldsList(List<String> readOnlyFieldsList);
174 
175     /**
176      * This method is public because some unit tests depend on it.
177      *
178      * @return a List of the names of fields which are marked in data dictionary as return fields.
179      */
180     public List getReturnKeys();
181 
182     public String getDocFormKey();
183 
184     public void setDocFormKey(String docFormKey);
185 
186     public String getDocNum();
187 
188     public void setDocNum(String docNum);
189 
190     /**
191      * 
192      * This method builds a maintenance url.
193      * 
194      * @param businessObject
195      * @param htmlData
196      * @param pkNames
197      * @return
198      */
199     public String getMaintenanceUrl(BusinessObject businessObject, HtmlData htmlData, List pkNames, BusinessObjectRestrictions businessObjectRestrictions);
200 
201     /**
202      * Determines if underlying lookup bo has associated maintenance document that allows new or copy maintenance actions.
203      *
204      * @return true if bo has maint doc that allows new or copy actions
205      */
206     public boolean allowsMaintenanceNewOrCopyAction();
207 
208     /**
209      * Determines if underlying lookup bo has associated document that allows new or copy maintenance actions.
210      *
211      * @return true if bo has doc that allows new or copy actions
212      */
213     public boolean allowsNewOrCopyAction(String documentTypeName);
214 
215     /**
216      * Returns a list of Row objects to be used to generate the search query screen
217      *
218      * Generally, setDataObjectClass needs to be called with a non-null value for proper operation
219      * @return
220      */
221     public List<Row> getRows();
222 
223     /**
224      * This method returns the DataDictionaryService used to initialize this helper service and is used by Lookupable implementations to
225      * retrieve the proper service.
226      *
227      * @return
228      */
229     public DataDictionaryService getDataDictionaryService();
230 
231     /**
232      * This method returns the BusinessObjectDictionaryService used to initialize this helper service and is used by Lookupable implementations to
233      * retrieve the proper service.
234      *
235      * @return
236      */
237     public BusinessObjectDictionaryService getBusinessObjectDictionaryService();
238 
239     public void setBackLocation(String backLocation);
240 
241     public String getBackLocation();
242 
243     /**
244      *
245      * This method performs the lookup and returns a collection of BO items
246      * @param lookupForm
247      * @param resultTable
248      * @param bounded
249      * @return the list of result BOs, possibly bounded
250      */
251     public Collection performLookup(LookupForm lookupForm, Collection resultTable, boolean bounded);
252 
253     /**
254      * This method returns a list of the default columns used to sort the result set.  For multiple value lookups,
255      * this method does not change when different columns are sorted.
256      *
257      * @return
258      */
259     public List getDefaultSortColumns();
260 
261     /**
262      * This method returns whether the previously executed getSearchResults used the primary key values to search, ignoring all non key values
263      *
264      * @return
265      * @see LookupableHelperService#getPrimaryKeyFieldLabels()
266      */
267     public boolean isSearchUsingOnlyPrimaryKeyValues();
268 
269     /**
270      * 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
271      *
272      * @return
273      * @see LookupableHelperService#isSearchUsingOnlyPrimaryKeyValues()
274      */
275     public String getPrimaryKeyFieldLabels();
276 
277     /**
278      * Determines whether a given BusinessObject that's returned as one of the lookup's results is considered returnable, which means that for
279      * single-value lookups, a "return value" link may be rendered, and for multiple value lookups, a checkbox is rendered.
280      *
281      * Note that this can be part of an authorization mechanism, but not the complete authorization mechanism.  The component that invoked the lookup/
282      * 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
283      * are ways around this method (e.g. crafting a custom return URL).
284      *
285      * @param object an object from the search result set
286      * @return
287      */
288     public boolean isResultReturnable(BusinessObject object);
289     
290     /**
291      * 
292      * This method allows for overriding the clear behavior
293      *
294      */
295     public void performClear(LookupForm lookupForm);
296     
297     public boolean shouldDisplayHeaderNonMaintActions();
298     
299     public boolean shouldDisplayLookupCriteria();
300 
301 	/**
302 	 * This method gets the supplemental lookup menu if any
303 	 * 
304 	 * @return supplemental menu bar
305 	 */
306 	public String getSupplementalMenuBar();
307     
308     /**
309      * @return String displayed as title for the lookup
310      */
311     public String getTitle();
312     
313     /**
314      * 
315      * performs custom actions.  return true to reperform search
316      * 
317      * @param ignoreErrors
318      * @return boolean to reperform search
319      */
320     public boolean performCustomAction(boolean ignoreErrors);
321     
322     /**
323      * get an extra field
324      * @return
325      */
326     public Field getExtraField();
327     
328     public void applyFieldAuthorizationsFromNestedLookups(Field field);
329     
330     /**
331      * Performs conditional logic (based on current search values or other parameters) to
332      * override field hidden, read-only, and required attributes previously set.
333      */
334     public void applyConditionalLogicForFieldDisplay();
335 }