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