View Javadoc
1   /**
2    * Copyright 2005-2015 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 java.util.Collection;
19  import java.util.HashMap;
20  import java.util.Map;
21  import java.util.Set;
22  
23  import org.kuali.rice.krad.bo.BusinessObject;
24  import org.kuali.rice.krad.bo.PersistableBusinessObject;
25  import org.kuali.rice.krad.service.BusinessObjectService;
26  import org.kuali.rice.krad.util.KRADPropertyConstants;
27  
28  /**
29   * The LookupResultsSupportStrategyService implementation which supports PersistableBusinessObjects, simply enough 
30   * 
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   *
33   * @deprecated Only used by KNS classes, use KRAD.
34   */
35  @Deprecated
36  public class PersistableBusinessObjectLookupResultsSupportStrategyImpl
37  		implements LookupResultsSupportStrategyService {
38  	
39  	private BusinessObjectService businessObjectService;
40  
41  	/**
42  	 * Returns the object id
43  	 * 
44  	 * @see org.kuali.rice.kns.lookup.LookupResultsSupportStrategyService#getLookupIdForBusinessObject(org.kuali.rice.krad.bo.BusinessObject)
45  	 */
46  	public String getLookupIdForBusinessObject(BusinessObject businessObject) {
47  		PersistableBusinessObject pbo = (PersistableBusinessObject)businessObject;
48  		return pbo.getObjectId(); 
49  	}
50  
51  	/**
52  	 * Uses the BusinessObjectService to retrieve a collection of PersistableBusinessObjects
53  	 * 
54  	 * @see org.kuali.rice.kns.lookup.LookupResultsSupportStrategyService#retrieveSelectedResultBOs(java.lang.String, java.lang.Class, java.lang.String)
55  	 */
56  	public <T extends BusinessObject> Collection<T> retrieveSelectedResultBOs(Class<T> boClass, Set<String> lookupIds)
57  			throws Exception {
58  		
59          Map<String, Collection<String>> queryCriteria = new HashMap<String, Collection<String>>();
60          queryCriteria.put(KRADPropertyConstants.OBJECT_ID, lookupIds);
61          return getBusinessObjectService().findMatching(boClass, queryCriteria);
62  	}
63  	
64  
65  	/**
66  	 * Sees if the class implements the PersistableBusinessObject interface; if so, then yes, the BO qualifies!
67  	 * @see org.kuali.rice.kns.lookup.LookupResultsSupportStrategyService#qualifiesForStrategy(java.lang.Class)
68  	 */
69  	public boolean qualifiesForStrategy(Class<? extends BusinessObject> boClass) {
70  		return PersistableBusinessObject.class.isAssignableFrom(boClass);
71  	}
72  
73  	/**
74  	 * @return the businessObjectService
75  	 */
76  	public BusinessObjectService getBusinessObjectService() {
77  		return this.businessObjectService;
78  	}
79  
80  	/**
81  	 * @param businessObjectService the businessObjectService to set
82  	 */
83  	public void setBusinessObjectService(BusinessObjectService businessObjectService) {
84  		this.businessObjectService = businessObjectService;
85  	}
86  }