1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.inquiry;
17
18 import edu.sampleu.travel.dataobject.TravelCompany;
19 import org.kuali.rice.core.api.criteria.QueryByCriteria;
20 import org.kuali.rice.core.api.criteria.QueryResults;
21 import org.kuali.rice.krad.data.KradDataServiceLocator;
22 import org.kuali.rice.krad.inquiry.Inquirable;
23 import org.kuali.rice.krad.inquiry.InquirableImpl;
24 import org.kuali.rice.krad.uif.widget.Inquiry;
25
26 import java.util.Collections;
27 import java.util.Map;
28
29
30
31
32
33
34
35 public class TravelCompanyCategoryInquirable extends InquirableImpl implements Inquirable {
36
37 @Override
38 public void setDataObjectClass(Class<?> dataObjectClass) {
39 if (!TravelCompanyCategory.class.equals(dataObjectClass)) {
40 throw new IllegalArgumentException("This Inquirable is only good for class TravelCompaniesCategory");
41 }
42 }
43
44 @Override
45 public Object retrieveDataObject(Map<String, String> fieldValues) {
46 TravelCompanyCategory tcc = new TravelCompanyCategory();
47
48 tcc.setName("Preferred Providers");
49
50 QueryResults<TravelCompany> travelCompanies =
51 KradDataServiceLocator.getDataObjectService().findMatching(TravelCompany.class,
52 QueryByCriteria.Builder.create().build());
53 tcc.setCompanies(travelCompanies.getResults());
54
55 return tcc;
56 }
57
58 @Override
59 public void buildInquirableLink(Object dataObject, String propertyName, Inquiry inquiry) {
60 inquiry.buildInquiryLink(dataObject, propertyName, TravelCompanyCategory.class,
61 Collections.<String,String>emptyMap());
62 }
63 }