1 package org.kuali.ole.deliver.keyvalue;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.ole.deliver.bo.OleCirculationDesk;
5 import org.kuali.ole.deliver.bo.OleCirculationDeskLocation;
6 import org.kuali.ole.deliver.form.OLEPlaceRequestForm;
7 import org.kuali.ole.describe.form.BoundwithForm;
8 import org.kuali.rice.core.api.util.ConcreteKeyValue;
9 import org.kuali.rice.core.api.util.KeyValue;
10 import org.kuali.rice.krad.service.BusinessObjectService;
11 import org.kuali.rice.krad.service.KRADServiceLocator;
12 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
13 import org.kuali.rice.krad.uif.view.ViewModel;
14
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.List;
18
19
20
21
22 public class OlePlaceRequestCirculationDeskKeyValue extends UifKeyValuesFinderBase {
23
24 private BusinessObjectService businessObjectService;
25
26 public BusinessObjectService getBusinessObjectService() {
27 if(businessObjectService == null){
28 this.businessObjectService = KRADServiceLocator.getBusinessObjectService();
29 }
30 return businessObjectService;
31 }
32
33 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
34 this.businessObjectService = businessObjectService;
35 }
36
37 @Override
38 public List<KeyValue> getKeyValues(ViewModel viewModel) {
39 OLEPlaceRequestForm olePlaceRequestForm = (OLEPlaceRequestForm) viewModel;
40 HashMap<String,String> circulationDeskMap = new HashMap<String,String>();
41 circulationDeskMap.put("circulationPickUpDeskLocation",olePlaceRequestForm.getItemLocation());
42 List<OleCirculationDeskLocation> oleCirculationDeskLocations = (List<OleCirculationDeskLocation>)getBusinessObjectService().findMatching(OleCirculationDeskLocation.class,circulationDeskMap);
43 List<KeyValue> options = new ArrayList<KeyValue>();
44
45 if(oleCirculationDeskLocations!=null && oleCirculationDeskLocations.size()>0){
46
47 for(OleCirculationDeskLocation oleCirculationDeskLocation : oleCirculationDeskLocations){
48 options.add(new ConcreteKeyValue(oleCirculationDeskLocation.getCirculationDeskId(),oleCirculationDeskLocation.getOleCirculationDesk().getCirculationDeskCode()));
49 }
50 }
51 return options;
52 }
53 }