1 /**
2 * Copyright 2005-2014 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.Set;
20
21 import org.kuali.rice.core.api.criteria.PredicateFactory;
22 import org.kuali.rice.core.api.criteria.QueryByCriteria;
23 import org.kuali.rice.krad.bo.BusinessObject;
24 import org.kuali.rice.krad.bo.DataObjectBase;
25 import org.kuali.rice.krad.data.KradDataServiceLocator;
26 import org.kuali.rice.krad.util.KRADPropertyConstants;
27
28 /**
29 * The LookupResultsSupportStrategyService implementation which supports DataObjectBase objects, 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 DataObjectBaseLookupResultsSupportStrategyImpl
37 implements LookupResultsSupportStrategyService {
38
39 /**
40 * Returns the object id
41 *
42 * @see org.kuali.rice.kns.lookup.LookupResultsSupportStrategyService#getLookupIdForBusinessObject(org.kuali.rice.krad.bo.BusinessObject)
43 */
44 @Override
45 public String getLookupIdForBusinessObject(BusinessObject businessObject) {
46 DataObjectBase pbo = (DataObjectBase)businessObject;
47 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 @Override
56 public <T extends BusinessObject> Collection<T> retrieveSelectedResultBOs(Class<T> boClass, Set<String> lookupIds)
57 throws Exception {
58
59 return KradDataServiceLocator.getDataObjectService().findMatching(
60 boClass,
61 QueryByCriteria.Builder.fromPredicates( PredicateFactory.in(KRADPropertyConstants.OBJECT_ID, lookupIds) )).getResults();
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 @Override
70 public boolean qualifiesForStrategy(Class<? extends BusinessObject> boClass) {
71 return DataObjectBase.class.isAssignableFrom(boClass);
72 }
73
74 }