01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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.module.labor.web.lookupable;
17:
18: import java.util.Collections;
19: import java.util.List;
20: import java.util.Map;
21:
22: import org.kuali.core.bo.BusinessObject;
23: import org.kuali.core.lookup.AbstractLookupableHelperServiceImpl;
24: import org.kuali.core.lookup.LookupUtils;
25: import org.kuali.core.util.BeanPropertyComparator;
26: import org.kuali.kfs.KFSConstants;
27: import org.kuali.kfs.KFSPropertyConstants;
28: import org.kuali.module.labor.web.inquirable.PositionDataDetailsInquirableImpl;
29: import org.kuali.module.labor.web.inquirable.PositionDataInquirableImpl;
30: import org.springframework.transaction.annotation.Transactional;
31:
32: /**
33: * The class is the front-end for all position data inquiry processing.
34: */
35: @Transactional
36: public class PositionDataLookupableHelperServiceImpl extends
37: AbstractLookupableHelperServiceImpl {
38:
39: /**
40: * @see org.kuali.core.lookup.Lookupable#getInquiryUrl(org.kuali.core.bo.BusinessObject, java.lang.String)
41: */
42: @Override
43: public String getInquiryUrl(BusinessObject businessObject,
44: String propertyName) {
45: if (KFSPropertyConstants.POSITION_NUMBER.equals(propertyName)) {
46: return (new PositionDataDetailsInquirableImpl())
47: .getInquiryUrl(businessObject, propertyName);
48: }
49: return (new PositionDataInquirableImpl()).getInquiryUrl(
50: businessObject, propertyName);
51: }
52:
53: /**
54: * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#getSearchResults(java.util.Map)
55: */
56: @Override
57: public List<? extends BusinessObject> getSearchResults(
58: Map<String, String> fieldValues) {
59: // remove hidden fields
60: LookupUtils.removeHiddenCriteriaFields(
61: getBusinessObjectClass(), fieldValues);
62:
63: setBackLocation(fieldValues.get(KFSConstants.BACK_LOCATION));
64: setDocFormKey(fieldValues.get(KFSConstants.DOC_FORM_KEY));
65: setReferencesToRefresh(fieldValues
66: .get(KFSConstants.REFERENCES_TO_REFRESH));
67:
68: List searchResults = (List) getLookupService()
69: .findCollectionBySearchHelper(getBusinessObjectClass(),
70: fieldValues, false);
71: // sort list if default sort column given
72: List defaultSortColumns = getDefaultSortColumns();
73: if (defaultSortColumns.size() > 0) {
74: Collections.sort(searchResults, new BeanPropertyComparator(
75: getDefaultSortColumns(), true));
76: }
77: return searchResults;
78: }
79:
80: }
|