View Javadoc
1   package org.kuali.ole.deliver.keyvalue.drools;
2   
3   import org.apache.commons.collections.CollectionUtils;
4   import org.kuali.ole.deliver.util.ItemInfoUtil;
5   import org.kuali.ole.describe.bo.OleLocation;
6   import org.kuali.rice.core.api.util.ConcreteKeyValue;
7   import org.kuali.rice.core.api.util.KeyValue;
8   import org.kuali.rice.krad.keyvalues.KeyValuesBase;
9   import org.kuali.rice.krad.service.KRADServiceLocator;
10  
11  import java.util.ArrayList;
12  import java.util.Collection;
13  import java.util.Collections;
14  import java.util.List;
15  
16  /**
17   * Created by sheiksalahudeenm on 7/14/15.
18   */
19  public class ShelvingLocationKeyValueFinder extends KeyValuesBase {
20      @Override
21      public List getKeyValues() {
22          List<KeyValue> keyValues = new ArrayList<KeyValue>();
23          List<ConcreteKeyValue> concreteKeyValues = new ArrayList<ConcreteKeyValue>();
24          Collection<OleLocation> oleLocations = KRADServiceLocator.getBusinessObjectService().findAll(OleLocation.class);
25          if (CollectionUtils.isNotEmpty(oleLocations)) {
26              for (OleLocation oleLocation : oleLocations) {
27                  if(oleLocation.getLevelId().equalsIgnoreCase(String.valueOf(ItemInfoUtil.LEVEL_CODES.SHELVING.getId()))){
28                      concreteKeyValues.add(new ConcreteKeyValue(oleLocation.getLocationCode(), oleLocation.getLocationCode()));
29                  }
30              }
31          }
32          Collections.sort(concreteKeyValues);
33          keyValues.addAll(concreteKeyValues);
34          return keyValues;
35      }
36  }