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