1 package org.kuali.ole.location.keyvalue;
2
3 import org.kuali.ole.location.bo.OleLocation;
4 import org.kuali.rice.core.api.util.ConcreteKeyValue;
5 import org.kuali.rice.core.api.util.KeyValue;
6 import org.kuali.rice.krad.service.KRADServiceLocator;
7 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
8 import org.kuali.rice.krad.uif.view.ViewModel;
9 import org.kuali.rice.krad.web.form.MaintenanceForm;
10
11 import java.util.*;
12
13
14
15
16
17 public class LocationKeyValuesFinder extends UifKeyValuesFinderBase {
18
19
20
21
22
23
24 @Override
25 public List<KeyValue> getKeyValues(ViewModel model) {
26 MaintenanceForm testForm = (MaintenanceForm) model;
27 List<KeyValue> options = new ArrayList<KeyValue>();
28 String levelId = ((OleLocation)testForm.getDocument().getNewMaintainableObject().getDataObject()).getLevelId();
29 Collection<OleLocation> oleLocations = KRADServiceLocator.getBusinessObjectService().findAll(OleLocation.class);
30 for (OleLocation location : oleLocations) {
31 if(location.getLevelId() != null && !location.getLevelId().equalsIgnoreCase("") && levelId != null && !levelId.equalsIgnoreCase("")) {
32 if(Integer.parseInt(location.getLevelId()) < Integer.parseInt(levelId)){
33 options.add(new ConcreteKeyValue(location.getLocationId(),location.getLocationName()+" ["+location.getLocationCode()+"]"));
34 }
35 }
36 }
37 return options;
38 }
39
40 }